Project

General

Profile

Actions

Feature #645

closed

Create a prototype app for monitoring devices

Added by Hammel over 6 years ago. Updated about 6 years ago.

Status:
Closed
Priority:
Immediate
Assignee:
Category:
Software
Target version:
Start date:
17 Jul 2018
Due date:
% Done:

100%

Estimated time:
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 crashesClosedHammel25 Sep 2018

Actions
Actions #1

Updated by Hammel over 6 years ago

  • Severity changed from 05 - Very Low to 02 - High
Actions #2

Updated by Hammel over 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.

Actions #3

Updated by Hammel over 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.

Actions #4

Updated by Hammel about 6 years 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
Actions #5

Updated by Hammel about 6 years 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.
Actions #6

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.

Actions #7

Updated by Hammel about 6 years ago

  • Severity changed from 02 - High to 01 - Critical
Actions #8

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.

Actions #9

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.

Actions

Also available in: Atom PDF