Feature #624

Add support for requesting a device list from Jarvis.

Added by Hammel 5 months ago. Updated about 1 month ago.

Status:ClosedStart date:08 May 2018
Priority:ImmediateDue date:
Assignee:Hammel% Done:

100%

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

Description

This is partially implemented and should happen on a repeating basis so that Jarvis always has an up to date list of IoT devices for each registered monitor.

Associated revisions

Revision 7fc8c6c3
Added by Hammel 5 months ago

RM #624: Stub support for getting a device list.

Revision f4b14d2e
Added by Hammel about 1 month ago

RM #624: Fix write of JSON registration data to be proper JSON and use it as JSON when reading it back in.

Revision 6d243071
Added by Hammel about 1 month ago

RM #624: Make sure we're using stored data correctly when retrieving keys. Change the API for GET /device to POST /devices so we can use the encryption key for validating the sender.

Revision 669c3eba
Added by Hammel about 1 month ago

RM #624: Implement a polling getDevices command run via a TimerTask().

Revision a970d354
Added by Hammel about 1 month ago

RM #624: Cleanup to provide device list support in imrest.
Changed crypto.encrypt() to return json object instead of parseable string.
Moved retrieval of UUIDs to function in new utils class.
Moved retrieval of monitor descriptor to function in new utils class.
Implemented retrieval of device configurations in device list API.
Simplified the monitor get API code considerably.

Revision f556b023
Added by Hammel about 1 month ago

RM #624: Cleanup to provide device list support in Jarvis.
Allow Imwww:send() to collect responses from all monitors it sends to.
Fix JarvisCmd:getDevices() to properly retrieve and hold responses from monitors (still encoded/encrypted, however).
Add support for returning the number of messages a Message object is holding.
Fix register to work with changed context where Imwww:send() now returns a Message object even if no messages were
returned and each message is hashed by the monitors IP address.

Revision dc546091
Added by Hammel about 1 month ago

RM #624: Add decrypt() method to Message and use it with registration (to get monitor description) and in getDevices() (to view device list JSON returned from each monitor).

Revision 99a8af7d
Added by Hammel about 1 month ago

RM #624: Add missing utils class.

Revision b975eb38
Added by Hammel about 1 month ago

RM #624: Move code from pair class to utils class that "stringifies" a JSON object correctly, that is, with quotes around the name and field. Then make pair and device classes use it properly.

History

#1 Updated by Hammel 5 months ago

  • Project changed from Iron Man to Jarvis
  • Category deleted (Jarvis)

#2 Updated by Hammel 2 months ago

  • Status changed from New to In Progress
  • Priority changed from Urgent to Immediate
  • % Done changed from 0 to 10
  • Severity changed from 03 - Medium to 01 - Critical

This needs to be done before state can be retrieved. Jarvis needs to poll for registered devices so when a request comes for "office" it will know which monitor to query.

Jarvis must run this poll in a thread so that it has an up to date list of devices all the time.

#3 Updated by Hammel about 1 month ago

  • % Done changed from 10 to 20

There are a number of updates required for this. I've started with a TimerTask() to poll monitors for device lists. There were some minor bugs in the handling of the keys for encryption that needed to be fixed, but that's done now. The poll properly triggers the correct method in imrest.

The next problem is also a side-bar: the Imwww:send() method is iterating over all monitors but sending back individual responses for each one. These need to be collected into a list and the list needs to be returned. The caller will have to iterate over the list to get the data it wants.

Once I've fixed that (there are existing calls to send() that need to be fixed first) I can then work on the code in imrest:device.js:list() that returns the list of registered nodes. This is just a matter of iterating all sensor registration files stored and grabbing their JSON content which should include all device names and states. These have to be placed into a JSON array in order to be properly managed on both ends.

I also need to associate the list data with the monitor so I need to include the monitor descriptor with the array of sensor registration/state data before returning it to Jarvis.

#4 Updated by Hammel about 1 month ago

  • % Done changed from 20 to 50
All of the previous work is now done but there is more to do.
  1. Data returned from the monitor is encoded/encrypted. It's needs to be decoded/decrypted when it's used (re: displayed).
  2. The list of devices is not displayed anywhere yet. It doesn't actually need to be in Jarvis but it does for debugging purposes.

#5 Updated by Hammel about 1 month ago

  • % Done changed from 50 to 80

Decryption is now implemented as a method in Message which makes it easy to process them. Tested in test environment.

Now I need to deploy the updated imrest to real hardware. Then I need to register a lightsw device with it and then run Jarvis to see if it retrieves it. Just powering on Jarvis should do that.

If that works, I'm one step closer to making the request to "turn on the light"! (But that's a different issue to track.)

#6 Updated by Hammel about 1 month ago

  • Status changed from In Progress to Closed
  • % Done changed from 80 to 100

Verified working on hardware. There are other problems, like phantom registrations from devices that are no longer around. I'll make issues to track fixing those separately.

All code has been pushed.
This issue can be closed.

Also available in: Atom PDF