Create a prototype app for monitoring devices
Added by Hammel over 4 years ago.
Updated over 4 years ago.
This needs to watch the ironman directories with inotify. When changes occur (basically registrations), update the list of devices with device type and description and state information.
This is just like a real simple version of videofe since it's only purpose is to show devices. I could get clever and use icons matched to device types, if I have time.
- Severity changed from 05 - Very Low to 02 - High
- Status changed from New to In Progress
- % Done changed from 0 to 10
This will be called pisensors. The first version will show all sensors as icons with the current state and offer a widget for changing the state along with a button for dropping the pairing/registration.
- % Done changed from 10 to 40
Pisensors has a working UI now. It shows three sensors per page with three columns per sensor (device type, state and remove button) using flat icons. There are two nav buttons at the bottom. This has been tested with fake IoT registration data on the desktop but has not been tried on the monitor.
Next I need to add the code that runs inotify to reread the database. Since inotify can know which file has changed it simply needs to read that file, then find the match in the existing db and update it or, if not found, append the entry to the database. If the notification is "delete" then the matching db entry needs to be removed. NOTE: this means the filename (aka IP address) needs to be added to the db entries when it's read the first time!!!
Then I need to extend the callbacks for state toggling and removing the sensor. Both will call imrest APIs using a simple wget call (like the cron job). The latter is a new API and should be handled just like the getDevices() function in imrest's device.js - it can only be called from the localhost. The former is just a state change request like the one Jarvis makes. Neither returns any data (not that pisensors cares about). pisensors can make a getDevices() call too and then the inotify handler will pick up the update and reload the database.
I added the watcher thread to pisensors. Now I need to
- Add a mutext to db.c
- Add functions that use the mutex
- dbGetEntry (which already exists but isn't using a mutex yet)
The first three will then be called by the watcher. The mutext allows me to make db updates synchronous to the UI threads read of the db.
Before this can work, however, I need to update dbLoad to add the filename to the json it reads from each file. This means:
- Read a file as a string
- convert the string to json
- add the filename to the json
- convert back to a string
- save the updated string
- % Done changed from 40 to 60
Okay, everything is ready in pisensors. The UI appears fully functioning (and I cleaned up the icons). It makes the wget calls to the new APIs in imrest. So now I need to implement two new APIs in imrest:
- PUT /set/device: pass an updated status for a given device, just like Jarvis does but via the PUT method. I may want to check this and simply use the same API Jarvis is using.
- DELETE /set/device: delete the registration for the specified device. This just removes the registration file. The device will need to re-pair with the monitor after that.
- % Done changed from 60 to 70
I decided to use the existing API for update, and then added the delete API. Code is written and ready for testing on real hardware.
- Severity changed from 02 - High to 01 - Critical
Some crashes (see RM #680) need to be fixed.
Also, touchscreen support is not implemented. I need to remap the 9 table cells properly, and that may mean a change to the piboxlib touchscreen support.
And I also need a STOP button in the nav bar, which needs it's own touchscreen support.
I may be able to use the touchscreen library by getting the drawing screen offsets and calculating which cell (sensors or nav) has the event.
- Status changed from In Progress to Closed
- % Done changed from 70 to 100
Done. The touchscreen support was easier than I thought using the ABS coordinates and the crashes were easy fixes too. I added a square stop button too. And I've fixed a few small problems with the way I was sending messages to the imrest server. But all that is done and now the console app - pisensors - works with the touchscreen (and, BTW, on my desktop using a mouse).
Very cool. Now the monitor UI is ready for MakerFaire with both the sensor app and the webcam.
All changes committed and pushed (there were changes to pisensors, imrest and the imlightsw).
Also available in: Atom