Feature #645
closedCreate a prototype app for monitoring devices
100%
Description
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.
Related issues
Updated by Hammel about 6 years ago
- Severity changed from 05 - Very Low to 02 - High
Updated by Hammel about 6 years ago
- 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.
Updated by Hammel about 6 years ago
- % 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.
Updated by Hammel about 6 years ago
- Add a mutext to db.c
- Add functions that use the mutex
- dbAddEntry
- dbDeleteEntry
- dbModifyEntry
- 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
Updated by Hammel about 6 years ago
- % Done changed from 40 to 60
- 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.
Updated by Hammel about 6 years ago
- % 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.
Updated by Hammel about 6 years ago
- Severity changed from 02 - High to 01 - Critical
Updated by Hammel about 6 years ago
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.
Updated by Hammel about 6 years ago
- 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).
Closing issue.