Feature #645

Create a prototype app for monitoring devices

Added by Hammel about 1 year ago. Updated 10 months ago.

Status:ClosedStart date:17 Jul 2018
Priority:ImmediateDue date:
Assignee:Hammel% Done:

100%

Category:Software
Target version:Iron Man - 002 - MVP
Severity:01 - Critical

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

Related to Monitor - Bug #680: pisensor crashes Closed 25 Sep 2018

Associated revisions

Revision 62621ae9
Added by Hammel 10 months ago

RM #645: Replace media player launcher with new Ironman launcher.

Revision c2877916
Added by Hammel 10 months ago

RM #645: Add support for nav buttons. Add button click handling for testing on the desktop. Rebuild icons as flat, grayscale icons. Add blind icon and a test sensor that uses it.

Revision 78121e06
Added by Hammel 10 months ago

RM #645: Add watcher thread on IoT directory. Add mutex on db so watcher can do update without affecting UI thread.

Revision ee618add
Added by Hammel 10 months ago

RM #645: Add support for deleting a sensor, toggling the state of a sensor and handling updates to sensor data by the watcher.

Revision e2959025
Added by Hammel 10 months ago

RM #645: Allow watcher to properly update display when on-disk changes are made to IoT files.

Revision 63bf9924
Added by Hammel 10 months ago

RM #645: Fixup REST API calls for modify and delete operations.

Revision d74a62d9
Added by Hammel 10 months ago

RM #645: Fix up packaging.

Revision 98c93adb
Added by Hammel 10 months ago

RM #645: Fix packaging for root crontab.

Revision 98c93adb
Added by Hammel 10 months ago

RM #645: Fix packaging for root crontab.

Revision bea45325
Added by Hammel 10 months ago

RM #645: Allow updates from localhost without encryption. Add delete API.

Revision bea45325
Added by Hammel 10 months ago

RM #645: Allow updates from localhost without encryption. Add delete API.

Revision 0d62ac1a
Added by Hammel 10 months ago

RM #645: HTTP DELETE method is referneced as http_server.del() in Restify.

Revision 0d62ac1a
Added by Hammel 10 months ago

RM #645: HTTP DELETE method is referneced as http_server.del() in Restify.

Revision e998b9d3
Added by Hammel 10 months ago

RM #645: Add missing /etc/pisensor directory to packaging so icons are available at runtime.

Revision 5c0f4562
Added by Hammel 10 months ago

RM #645: Add picam, mjpg-streamer and pisensors to Ironman package list. Make sure sensors and launcher use the top/opkg directory to retrieve the generated opk archive.

Revision 4e197cf5
Added by Hammel 10 months ago

RM #645: Stubbed out touchscreen support by calculating which cell I was in using ABS coordinates.

Revision 26d4c9a7
Added by Hammel 10 months ago

RM #645: Touchscreen callbacks implemented. Stop button icon added.

Revision 331788c3
Added by Hammel 10 months ago

RM #645: Add -O option to wget to avoid generating disk output from the getDevices request.

Revision 331788c3
Added by Hammel 10 months ago

RM #645: Add -O option to wget to avoid generating disk output from the getDevices request.

Revision bc67c1d9
Added by Hammel 10 months ago

RM #645: Fix buffer sizes after adding in port and version strings to wget commands. Fix double free crashes by changing to proper handling of json objects.

Revision 1ebc29a1
Added by Hammel 10 months ago

RM #645: Use rawBody when retrieving JSON string from pisensors on localhost.

Revision 1ebc29a1
Added by Hammel 10 months ago

RM #645: Use rawBody when retrieving JSON string from pisensors on localhost.

History

#1 Updated by Hammel 10 months ago

  • Severity changed from 05 - Very Low to 02 - High

#2 Updated by Hammel 10 months 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.

#3 Updated by Hammel 10 months 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.

#4 Updated by Hammel 10 months ago

I added the watcher thread to pisensors. Now I need to
  1. Add a mutext to db.c
  2. Add functions that use the mutex
    1. dbAddEntry
    2. dbDeleteEntry
    3. dbModifyEntry
    4. 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:
  1. Read a file as a string
  2. convert the string to json
  3. add the filename to the json
  4. convert back to a string
  5. save the updated string

#5 Updated by Hammel 10 months ago

  • % 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:
  1. 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.
  2. 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.

#6 Updated by Hammel 10 months 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.

#7 Updated by Hammel 10 months ago

  • Severity changed from 02 - High to 01 - Critical

#8 Updated by Hammel 10 months 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.

#9 Updated by Hammel 10 months 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.

Also available in: Atom PDF