Project

General

Profile

Device Protocol » History » Revision 6

Revision 5 (Hammel, 04 Apr 2016 11:49) → Revision 6/9 (Hammel, 04 Apr 2016 14:04)

h1. Device Protocol 

 The device protocol defines the messaging that occurs between an IoT device and the PiBox server.   

 h2. Registration 

 Registration is initiated by the IoT device.    It sends a multicast packet to the PiBox server.    The packet does not need to contain any information.    It's purpose is to advertise the IP address of the IoT device.   

 The server captures the message and then queries the device for type, features and configuration which is stored in the piboxd daemon and to file as needed. 

 h2. Queries 

 A query is made from the server to the IoT device using a web URL.    The URL is of the format 

 <pre> 
   http://<ipaddress>/im/<version>/<command> 
 </pre> 

 POST variables are used for arguments to the command. 

 Some commands are common to all devices. 

 <pre> 
   get: arguments include config, registration 
   set: arguments include config 
 </pre> 

 Other commands are specific to the device and can be identified in the config response. 

 h2. Query Response 

 A query response is provided as JSON text in the body of the page returned to the caller.    For a registration request the device returns it's identity and feature list.    For a config request the device returns its current settings associated with the features it supports. 

 h3. Identify 

 The identity is the device name.    This is free format and is used to identify the device to the server. 

 h3. Features 

 A device can specify a collection of features.    The feature is a set of names and associated data types and values.    The data type for the feature and is one of num, text, range, or set which is specified as the value for the feature name.    If a feature is of type of range then the range is specified as name-range.    If the type is set then the set is specified as name-set. A feature can have a display name separate from the feature name, which is represented as name-display.    The feature name cannot have the "-" character.    All other names prefixed with that name are associated with that feature. 

 <pre> 
 { 
     "identity": "abcd",  
     "features": { 
         "damper":               "set",  
         "damper-display":       "Vent Damper",  
         "damper-set":           "0,25,50,75,100",  
         "damper-value":         "25",  
     } 
 } 
 </pre> 

 Features are the way a device specifies how it can be configured and what data it provides.    The server can use this to dynamically build a UI for the device. 

 h3. Config 

 The config response contains the current settings for the named features.   

 h2. Control 

 Control of a device is through a config object.    The configuration is changed by a UI application and forwarded to the IoT device.    The device attempts to apply the configuration changes, which may or may not succeed.    Success is not specified on a configuration change.    The only way to know if the change was applied is to query the current configuration and compare it to the change request.