Skip to content

Instantly share code, notes, and snippets.

@Sushisugre
Last active April 11, 2017 05:02
Show Gist options
  • Save Sushisugre/091234702887f4b65396e92f2341c444 to your computer and use it in GitHub Desktop.
Save Sushisugre/091234702887f4b65396e92f2341c444 to your computer and use it in GitHub Desktop.

API to Application Layer

For application layer to send configuration message to device fleet, different from the configuration API exposed to front end.

Endpoint: http://52.35.217.241:1880/configuration

Parameters

  • app_id - required
    • AppEUI, fixed value for the traffic calming project
  • device_ids - required
    • List of devEUI
  • config_id - required
    • Identifier of the configuration, equals to the incrementalId in
  • schedules - required
    • lists of configuration changes and their effective time
    • start_from: required
      • represent in unixtime, 0 or a time in the past means to execute the configuration ASAP
    • params: required
      • one or more parameters to change device behavior, refer to parameters
    • duration - required
      • in seconds
    • repeat_interval: optional
      • if not specified, the configuration expires after its duration

Example:

{
    "app_id": 1,                
    "device_ids": [1,2,3],          
    "config_id": 00001,
    "schedules": [
        {	// morning rush hours
            "start_from": 1491894000,               // 04/11/2017T07:00:00
            "duration": 10800,                      // 3 hrs
            "repeat_interval": 86400,               // 1 days
            "params": {     
                "min_report_interval": 3600,        // 1 hrs
                "bucket_size": 300,                 // 5 min
                "device_mode": 1,                   // 1: normal, 2: passive
            }
        },
        {	// normal
            "start_from": 1491904800,               // 04/11/2017T10:00:00
            "duration": 21600,                      // 6 hrs
            "repeat_interval": 86400,               // 1 days
            "params": {     
                "min_report_interval": 43200,       // 3 hrs
                "bucket_size": 900,                 // 15min
            }
        },
        {	// afternoon rush hours
            "start_from": 1491904800,               // 04/16/2017T10:00:00
            "duration": 10800,                      // 3 hrs
            "repeat_interval": 86400                // 1 days
            "params": {     
                "min_report_interval": 3600,        // 1 hrs
                "bucket_size": 300,                 // 5 min
            }
        },
    ]
}

Device View

The behavior of a devices is defined by 2 layers of configurations:

  • Default setting of the device
  • Scheduled configuration: run for certain period of time, maybe periodically
    • When there's no configuration scheduled for current moment, the device runs under the default setting
    • The /configuration API updates this layer

//TODO: add graph

  • Device only executes the new configuration after a data packet is formed
  • When device sending uplink packet, the CONF_ACK field represents the current running configuration and the default setting. (xor)

More information:

Downlink Flow

https://gist.github.com/Sushisugre/fe429cdaf90e78e4bcf826a5ebf7ac56

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment