The Chain of Command
In order to make the kindle interacts with your home automation system, you have to :
- guess what both globally and precisely user is going to do
- imagine a way to transmit user's precise choice to an underlying piece of software
- trigger command when user's precise choice corresponds to a home automation instruction.
Obviously, Kindle already has a web navigator which could be used to command your home automation.
Obviously it's not what I'm aiming.
I want Kindle interacts - as a controller or as a sensor - with home automation smoothly, discretely.
Detection of user movement
Prepare the kindle
For the moment Kindle must be jailbreaked, the easiest way to do what we have to is through wifi and ssh. You can also use usb network and ssh, but keep in mind the Kindle have to be connected to your home automation a priori via wifi.
Getting kindle status
Kindle underlying system is a Linux distribution. You can see by yourselves that id, uname, df, dh, cp and bash are available.
The first think to do is looking inside logs. dmesg gives a lot of interesting stuff but nothing seems to help us guessing what user is actually doing.
If dmesg is our first shot, the second shot is spying in /var/log. So we run tail -f /var/log/* and observe this :
[root@kindle root]# tail -f /var/log/* ==> /var/log/udhcpc.log <== Sending discover... Offer from server xxx.xxx.1.1 received Sending select for xxx.xxx.1.110... Lease of xxx.xxx.1.110 obtained, lease time 43200 ==> /var/log/wpa_supplicant <== ==> /var/log/wtmp <== ttymxc0mxcLOGIN���U~~~reboot2.6.31- (…) snip (…) ��U���0pts/0ts/0root192.168.1.203���U[T ==> /var/log/messages <== 150807:032805 powerd: I def:suspenddelta:sec=1890, cap=-1, mAh=-1, volt=-16, bp=-16:Suspend delta 150807:032805 syslog-ng: new configuration initialized ==> /var/log/messages <== 150807:032809 powerd: I lipc:evts:name=battLevelChanged, origin=com.lab126.powerd, fparam=59:Event sent
Still no usable information… But, we have not physically interact with kindle !
Observing user interactions
The command tail -f writes to your screen all the content of all files in /var/log in continue.
At this level I advise you to reset the terminal of ssh to only show what is new to logs file.
With your kindle in hand do regular things you always do. Like opening an ebook, a PDF, return to home screen, call parameters et cætera.
And now magic happened :
[root@kindle root]# tail -f /var/log/* ==> /var/log/messages <== 150807:034115 cvm: I FrameworkKeyEventDispatcher:USER_HARDKEY_PRESS:KeyPressed=Home:User pressed Home button 150807:034115 cvm: I BookletManager:SwitchingBooklets:from=Bookworm,to=Home: 150807:034115 cvm: I WebServicesImpl:UploadAnnotations::first journal empty 150807:034115 cvm: I Reader:SYNC LPR:position=374292:Send LPR to server 150807:034115 cvm: I HTMLBookViewer:Information::HTMLBookViewer closeBook save last read position 374292 150807:034115 webreader: I def:commandHandlerFunc:Received command: /command/close_uri, msg=0x298a58 : 150807:034115 webreader: I def:processCommandHandler:Response sent for this request, msg=0x298a58, time=1.863037 : 150807:034115 cvm: I HTMLBookViewer:Information::Request to close 9dabdc03-04c7-4ba7-b361-e64526ddd7f5 is processed successfully 150807:034115 cvm: I lipc:gsp:prop=orientation, source=com.lab126.system:Get string property 150807:034115 cvm: W SystemBarImpl:SPIN:spinCount=0:count <=0 when stopSpinner() called 150807:034115 cvm: I MainView:Information::The WiFi dialog has been previously shown. 150807:034116 cvm: I HTMLJsonSidecarFile:Information::Delayed Write to sidecar file 150807:034118 cvm: I GUIManager:HomeViewSwitch:view=CollectionView: 150807:034119 cvm: I FrameworkKeyEventDispatcher:USER_HARDKEY_PRESS:KeyPressed=Home:User pressed Home button 150807:034119 cvm: I BookletManager:SwitchingBooklets:...Read more »