DIO Device Operation Flow

The IAP Device resource is a collection of objects in the request and feedback channels. Each set of IAP device objects represents one physical device and its interface with data points, properties and so on. This example going to perform various operations on DIO device. The example explains the essential operations for DIO device as listed below.

  1. DIO device creation [Request and Response]
  2. DIO device provision [Request and Response]
  3. DIO device send data for relay on interface 1 [Request]
  4. IOX sends response on feedback channel for relay data on the same interface to Apollo. [Response]
  5. DIO device deprovision [Request and Response]

DIO Device Creation

The topic for creating DIO device will be glp/0/SID/rq/dev/IOX_HANDLE/dio/do and the action object from the message should be create .

Request

DIO Device Creation
glp/0/1401/rq/dev/iox.409eb1/dio/do {
"action":"create",
"args": {
"type":"dio",
"unid":"256"
}
}


This will create the DIO device and publishes its status and configuration objects on the feedback channel also leaves the device in the unprovisioned state.

Response

Create DIO Device will respond on the feedback channel and there corresponding status and configuration message publishes on the below topic:

 glp/0/SID/fb/dev/IOX_HANDLE/dio/cfg  and  glp/0/SID/fb/dev/IOX_HANDLE/dio/sts     


Response for DIO CREATE DEVICE
glp/0/1401/fb/dev/iox.409eb1/dio/cfg {
"name": "dio",
"desc": "IOX Digital IO Device",
"motion_zone": 0,
"motion_radius": 0,
"motion_timeout": 0,
"loc": {
"desc": "",
"lat": 0,
"lng": 0
}
}
glp/0/1401/fb/dev/iox.409eb1/dio/sts {
"state": "unprovisioned",
"unid": "256",
"health": "normal",
"cat": "i/o",
"type": "dio",
"interfaceType": "static",
"usage": "mixed",
"version": "1.0.0"
}
glp/0/1401/fb/res/type/iox-datapoints-0/level {
"id": "level",
"unit": "do-level-ctrl-unit",
"class": "datapoint",
"type": {
"type": "boolean",
"base": "int32"
}
}
glp/0/1401/fb/res/type/iox-datapoints-0/pulse {
"id": "pulse",
"unit": "ms",
"class": "datapoint",
"type": {
"type": "scalar",
"min": 0,
"max": 2592000000.0000,
"base": "uint32",
"scaling": {
"a": 1,
"b": 0,
"c": 0,
"s": 1
}
}
}
glp/0/1401/fb/res/type/iox-datapoints-0/frequency {
"id": "frequency",
"unit": "Hz",
"class": "datapoint",
"type": {
"type": "scalar",
"min": 1,
"max": 20000,
"base": "uint32",
"scaling": {
"a": 1,
"b": 0,
"c": 0,
"s": 1
}
}
}
glp/0/1401/fb/res/type/iox-datapoints-0/pwm {
"id": "pwm",
"unit": "pwm-ctrl-unit",
"class": "datapoint",
"type": {
"cat": "struct",
"type": "aggregate",
"members": [{
"id": "frequency",
"unit": "Hz",
"type": {
"type": "scalar",
"min": 1,
"max": 20000,
"base": "uint32",
"scaling": {
"a": 1,
"b": 0,
"c": 0,
"s": 1
}
}
}, {
"id": "duty-cycle",
"unit": "%",
"type": {
"type": "scalar",
"min": 0,
"max": 100,
"base": "uint32",
"scaling": {
"a": 1,
"b": 0,
"c": 0,
"s": 1
}
}
}]
}
}
glp/0/1401/fb/res/type/iox-datapoints-0/do-val {
"id": "do-val",
"unit": "do-val-ctrl-unit",
"class": "datapoint",
"type": {
"cat": "struct",
"type": "aggregate",
"members": [{
"id": "type",
"unit": "do-type-ctrl-unit",
"type": {
"enum": ["none", "level", "pulse", "frequency", "pwm"]
}
}, {
"id": "level",
"type": {
"type": "reference",
"reference": "iox-datapoints-0/level"
}
}, {
"id": "pulse",
"type": {
"type": "reference",
"reference": "iox-datapoints-0/pulse"
}
}, {
"id": "frequency",
"type": {
"type": "reference",
"reference": "iox-datapoints-0/frequency"
}
}, {
"id": "pwm",
"type": {
"type": "reference",
"reference": "iox-datapoints-0/pwm"
}
}]
}
}
glp/0/1401/fb/res/type/iox-profiles-0/do {
"id": "do",
"name": "DigitalOutput",
"class": "profile",
"datapoints": {
"do-val": {
"id": "do-val",
"mandatory": true,
"type": "iox-datapoints-0/do-val",
"dir": "input"
}
}
}
glp/0/1401/fb/dev/iox.409eb1/dio/if/do/1 {
"desc": "Digital output with level, frequency, oneshot and PWM output modes",
"type": "iox-profiles-0/do",
"do-val": {
"desc": "Digital output control value",
"type": "iox-datapoints-0/do-val",
"property": false,
"cat": "in",
"value": {
"type": "none",
"level": false,
"frequency": 0,
"pulse": 0,
"pwm": {
"frequency": 0,
"duty-cycle": 0
}
}
}
}
glp/0/1401/fb/dev/iox.409eb1/dio/if/do/2 {
"desc": "Digital output with level, frequency, oneshot and PWM output modes",
"type": "iox-profiles-0/do",
"do-val": {
"desc": "Digital output control value",
"type": "iox-datapoints-0/do-val",
"property": false,
"cat": "in",
"value": {
"type": "none",
"level": false,
"frequency": 0,
"pulse": 0,
"pwm": {
"frequency": 0,
"duty-cycle": 0
}
}
}
}
glp/0/1401/fb/dev/iox.409eb1/dio/if/do/3 {
"desc": "Digital output with level, frequency, oneshot and PWM output modes",
"type": "iox-profiles-0/do",
"do-val": {
"desc": "Digital output control value",
"type": "iox-datapoints-0/do-val",
"property": false,
"cat": "in",
"value": {
"type": "none",
"level": false,
"frequency": 0,
"pulse": 0,
"pwm": {
"frequency": 0,
"duty-cycle": 0
}
}
}
}
glp/0/1401/fb/dev/iox.409eb1/dio/if/do/4 {
"desc": "Digital output with level, frequency, oneshot and PWM output modes",
"type": "iox-profiles-0/do",
"do-val": {
"desc": "Digital output control value",
"type": "iox-datapoints-0/do-val",
"property": false,
"cat": "in",
"value": {
"type": "none",
"level": false,
"frequency": 0,
"pulse": 0,
"pwm": {
"frequency": 0,
"duty-cycle": 0
}
}
}
}
glp/0/1401/fb/dev/iox.409eb1/dio/if/do/5 {
"desc": "Digital output with level, frequency, oneshot and PWM output modes",
"type": "iox-profiles-0/do",
"do-val": {
"desc": "Digital output control value",
"type": "iox-datapoints-0/do-val",
"property": false,
"cat": "in",
"value": {
"type": "none",
"level": false,
"frequency": 0,
"pulse": 0,
"pwm": {
"frequency": 0,
"duty-cycle": 0
}
}
}
}
glp/0/1401/fb/dev/iox.409eb1/dio/if/do/6 {
"desc": "Digital output with level, frequency, oneshot and PWM output modes",
"type": "iox-profiles-0/do",
"do-val": {
"desc": "Digital output control value",
"type": "iox-datapoints-0/do-val",
"property": false,
"cat": "in",
"value": {
"type": "none",
"level": false,
"frequency": 0,
"pulse": 0,
"pwm": {
"frequency": 0,
"duty-cycle": 0
}
}
}
}
glp/0/1401/fb/res/type/iox-datapoints-0/relay-val {
"id": "relay-val",
"unit": "relay-val-ctrl-unit",
"class": "datapoint",
"type": {
"cat": "struct",
"type": "aggregate",
"members": [{
"id": "level",
"type": {
"type": "reference",
"reference": "iox-datapoints-0/level"
}
}]
}
}
glp/0/1401/fb/res/type/iox-profiles-0/relay {
"id": "relay",
"name": "RelayOutput",
"class": "profile",
"datapoints": {
"relay-val": {
"id": "relay-val",
"mandatory": true,
"type": "iox-datapoints-0/relay-val",
"dir": "input"
}
}
}
glp/0/1401/fb/dev/iox.409eb1/dio/if/relay/1 {
"desc": "Relay output",
"type": "iox-profiles-0/relay",
"relay-val": {
"desc": "iox-relay",
"type": "iox-datapoints-0/relay-val",
"property": false,
"cat": "in",
"value": {
"level": false
}
}
}
glp/0/1401/fb/dev/iox.409eb1/dio/if/relay/2 {
"desc": "Relay output",
"type": "iox-profiles-0/relay",
"relay-val": {
"desc": "iox-relay",
"type": "iox-datapoints-0/relay-val",
"property": false,
"cat": "in",
"value": {
"level": false
}
}
}
glp/0/1401/fb/res/type/iox-datapoints-0/di-level {
"id": "di-level",
"unit": "di-level-ctrl-unit",
"class": "datapoint",
"type": {
"cat": "struct",
"type": "aggregate",
"members": [{
"id": "detect-level",
"unit": "detect-level-ctrl-unit",
"type": {
"type": "scalar",
"min": 0,
"max": 4,
"base": "uint32",
"scaling": {
"a": 1,
"b": 0,
"c": 0,
"s": 1
}
}
}, {
"id": "report-dur",
"unit": "s",
"type": {
"type": "scalar",
"min": 1,
"max": 2592000,
"base": "uint32",
"scaling": {
"a": 1,
"b": 0,
"c": 0,
"s": 1
}
}
}, {
"id": "pullup-cfg",
"unit": "pullup-ctrl-unit",
"type": {
"type": "boolean",
"base": "int32"
}
}, {
"id": "level",
"unit": "di-level-state-unit",
"type": {
"type": "boolean",
"base": "int32"
}
}]
}
}
glp/0/1401/fb/res/type/iox-datapoints-0/di-frequency {
"id": "di-frequency",
"unit": "di-freq-ctrl-unit",
"class": "datapoint",
"type": {
"cat": "struct",
"type": "aggregate",
"members": [{
"id": "detect-level",
"unit": "detect-level-ctrl-unit",
"type": {
"type": "scalar",
"min": 0,
"max": 4,
"base": "uint32",
"scaling": {
"a": 1,
"b": 0,
"c": 0,
"s": 1
}
}
}, {
"id": "report-dur",
"unit": "s",
"type": {
"type": "scalar",
"min": 1,
"max": 2592000,
"base": "uint32",
"scaling": {
"a": 1,
"b": 0,
"c": 0,
"s": 1
}
}
}, {
"id": "pullup-cfg",
"unit": "pullup-ctrl-unit",
"type": {
"type": "boolean",
"base": "int32"
}
}, {
"id": "frequency",
"unit": "Hz",
"type": {
"type": "scalar",
"min": 1,
"max": 20000,
"base": "uint32",
"scaling": {
"a": 1,
"b": 0,
"c": 0,
"s": 1
}
}
}]
}
}
glp/0/1401/fb/res/type/iox-datapoints-0/di-pulse {
"id": "di-pulse",
"unit": "di-pulse-ctrl-unit",
"class": "datapoint",
"type": {
"cat": "struct",
"type": "aggregate",
"members": [{
"id": "detect-level",
"unit": "detect-level-ctrl-unit",
"type": {
"type": "scalar",
"min": 0,
"max": 4,
"base": "uint32",
"scaling": {
"a": 1,
"b": 0,
"c": 0,
"s": 1
}
}
}, {
"id": "report-dur",
"unit": "s",
"type": {
"type": "scalar",
"min": 1,
"max": 2592000,
"base": "uint32",
"scaling": {
"a": 1,
"b": 0,
"c": 0,
"s": 1
}
}
}, {
"id": "pullup-cfg",
"unit": "pullup-ctrl-unit",
"type": {
"type": "boolean",
"base": "int32"
}
}, {
"id": "pulse",
"unit": "count",
"type": {
"type": "scalar",
"min": 0,
"max": 2592000,
"base": "uint32",
"scaling": {
"a": 1,
"b": 0,
"c": 0,
"s": 1
}
}
}]
}
}
glp/0/1401/fb/res/type/iox-datapoints-0/di-val {
"id": "di-val",
"unit": "di-val-ctrl-unit",
"class": "datapoint",
"type": {
"cat": "struct",
"type": "aggregate",
"members": [{
"id": "type",
"unit": "di-type-ctrl-unit",
"type": {
"enum": ["none", "level", "pulse", "frequency"]
}
}, {
"id": "di-level",
"type": {
"type": "reference",
"reference": "iox-datapoints-0/di-level"
}
}, {
"id": "di-pulse",
"type": {
"type": "reference",
"reference": "iox-datapoints-0/di-pulse"
}
}, {
"id": "di-frequency",
"type": {
"type": "reference",
"reference": "iox-datapoints-0/di-frequency"
}
}]
}
}
glp/0/1401/fb/res/type/iox-profiles-0/di {
"id": "di",
"name": "DigitalInput",
"class": "profile",
"datapoints": {
"di-val": {
"id": "di-val",
"mandatory": true,
"type": "iox-datapoints-0/di-val",
"dir": "output"
}
}
}
glp/0/1401/fb/dev/iox.409eb1/dio/if/di/1 {
"desc": "Digital input with level, pulse and frequency inputs",
"type": "iox-profiles-0/di",
"di-val": {
"desc": "Digital input control value",
"type": "iox-datapoints-0/di-val",
"property": false,
"cat": "out",
"monitor": {
"rate": 0,
"cat": "data",
"inFeedback": false,
"report": "any",
"throttle": 0,
"threshold": 0
},
"value": {
"type": "none",
"di-level": {
"detect-level": 0,
"report-dur": 0,
"pullup-cfg": false,
"level": false
},
"di-pulse": {
"detect-level": 0,
"report-dur": 0,
"pullup-cfg": false,
"pulse": 0
},
"di-frequency": {
"detect-level": 0,
"report-dur": 0,
"pullup-cfg": false,
"frequency": 0
}
},
"mru": "2018-07-12 12:06:45.830 UTC"
}
}
glp/0/1401/fb/dev/iox.409eb1/dio/if/di/2 {
"desc": "Digital input with level, pulse and frequency inputs",
"type": "iox-profiles-0/di",
"di-val": {
"desc": "Digital input control value",
"type": "iox-datapoints-0/di-val",
"property": false,
"cat": "out",
"monitor": {
"rate": 0,
"cat": "data",
"inFeedback": false,
"report": "any",
"throttle": 0,
"threshold": 0
},
"value": {
"type": "none",
"di-level": {
"detect-level": 0,
"report-dur": 0,
"pullup-cfg": false,
"level": false
},
"di-pulse": {
"detect-level": 0,
"report-dur": 0,
"pullup-cfg": false,
"pulse": 0
},
"di-frequency": {
"detect-level": 0,
"report-dur": 0,
"pullup-cfg": false,
"frequency": 0
}
},
"mru": "2018-07-12 12:06:46.70 UTC"
}
}
glp/0/1401/fb/dev/iox.409eb1/dio/if/di/3 {
"desc": "Digital input with level, pulse and frequency inputs",
"type": "iox-profiles-0/di",
"di-val": {
"desc": "Digital input control value",
"type": "iox-datapoints-0/di-val",
"property": false,
"cat": "out",
"monitor": {
"rate": 0,
"cat": "data",
"inFeedback": false,
"report": "any",
"throttle": 0,
"threshold": 0
},
"value": {
"type": "none",
"di-level": {
"detect-level": 0,
"report-dur": 0,
"pullup-cfg": false,
"level": false
},
"di-pulse": {
"detect-level": 0,
"report-dur": 0,
"pullup-cfg": false,
"pulse": 0
},
"di-frequency": {
"detect-level": 0,
"report-dur": 0,
"pullup-cfg": false,
"frequency": 0
}
},
"mru": "2018-07-12 12:06:46.390 UTC"
}
}
glp/0/1401/fb/dev/iox.409eb1/dio/if/di/4 {
"desc": "Digital input with level, pulse and frequency inputs",
"type": "iox-profiles-0/di",
"di-val": {
"desc": "Digital input control value",
"type": "iox-datapoints-0/di-val",
"property": false,
"cat": "out",
"monitor": {
"rate": 0,
"cat": "data",
"inFeedback": false,
"report": "any",
"throttle": 0,
"threshold": 0
},
"value": {
"type": "none",
"di-level": {
"detect-level": 0,
"report-dur": 0,
"pullup-cfg": false,
"level": false
},
"di-pulse": {
"detect-level": 0,
"report-dur": 0,
"pullup-cfg": false,
"pulse": 0
},
"di-frequency": {
"detect-level": 0,
"report-dur": 0,
"pullup-cfg": false,
"frequency": 0
}
},
"mru": "2018-07-12 12:06:46.720 UTC"
}
}
glp/0/1401/fb/dev/iox.409eb1/dio/if/di/5 {
"desc": "Digital input with level, pulse and frequency inputs",
"type": "iox-profiles-0/di",
"di-val": {
"desc": "Digital input control value",
"type": "iox-datapoints-0/di-val",
"property": false,
"cat": "out",
"monitor": {
"rate": 0,
"cat": "data",
"inFeedback": false,
"report": "any",
"throttle": 0,
"threshold": 0
},
"value": {
"type": "none",
"di-level": {
"detect-level": 0,
"report-dur": 0,
"pullup-cfg": false,
"level": false
},
"di-pulse": {
"detect-level": 0,
"report-dur": 0,
"pullup-cfg": false,
"pulse": 0
},
"di-frequency": {
"detect-level": 0,
"report-dur": 0,
"pullup-cfg": false,
"frequency": 0
}
},
"mru": "2018-07-12 12:06:47.60 UTC"
}
}
glp/0/1401/fb/dev/iox.409eb1/dio/if/di/6 {
"desc": "Digital input with level, pulse and frequency inputs",
"type": "iox-profiles-0/di",
"di-val": {
"desc": "Digital input control value",
"type": "iox-datapoints-0/di-val",
"property": false,
"cat": "out",
"monitor": {
"rate": 0,
"cat": "data",
"inFeedback": false,
"report": "any",
"throttle": 0,
"threshold": 0
},
"value": {
"type": "none",
"di-level": {
"detect-level": 0,
"report-dur": 0,
"pullup-cfg": false,
"level": false
},
"di-pulse": {
"detect-level": 0,
"report-dur": 0,
"pullup-cfg": false,
"pulse": 0
},
"di-frequency": {
"detect-level": 0,
"report-dur": 0,
"pullup-cfg": false,
"frequency": 0
}
},
"mru": "2018-07-12 12:06:47.490 UTC"
}
}
glp/0/1401/fb/dev/iox.409eb1/dio/if/di/7 {
"desc": "Digital input with level, pulse and frequency inputs",
"type": "iox-profiles-0/di",
"di-val": {
"desc": "Digital input control value",
"type": "iox-datapoints-0/di-val",
"property": false,
"cat": "out",
"monitor": {
"rate": 0,
"cat": "data",
"inFeedback": false,
"report": "any",
"throttle": 0,
"threshold": 0
},
"value": {
"type": "none",
"di-level": {
"detect-level": 0,
"report-dur": 0,
"pullup-cfg": false,
"level": false
},
"di-pulse": {
"detect-level": 0,
"report-dur": 0,
"pullup-cfg": false,
"pulse": 0
},
"di-frequency": {
"detect-level": 0,
"report-dur": 0,
"pullup-cfg": false,
"frequency": 0
}
},
"mru": "2018-07-12 12:06:47.800 UTC"
}
}
glp/0/1401/fb/dev/iox.409eb1/dio/if/di/8 {
"desc": "Digital input with level, pulse and frequency inputs",
"type": "iox-profiles-0/di",
"di-val": {
"desc": "Digital input control value",
"type": "iox-datapoints-0/di-val",
"property": false,
"cat": "out",
"monitor": {
"rate": 0,
"cat": "data",
"inFeedback": false,
"report": "any",
"throttle": 0,
"threshold": 0
},
"value": {
"type": "none",
"di-level": {
"detect-level": 0,
"report-dur": 0,
"pullup-cfg": false,
"level": false
},
"di-pulse": {
"detect-level": 0,
"report-dur": 0,
"pullup-cfg": false,
"pulse": 0
},
"di-frequency": {
"detect-level": 0,
"report-dur": 0,
"pullup-cfg": false,
"frequency": 0
}
},
"mru": "2018-07-12 12:06:48.100 UTC"
}
}


DIO device provision

Request

Provisioning device will get the device from present state to a fully operational state. 

glp/0/1401/rq/dev/iox.409eb1/dio/do {
"action":"provision"
}


Response

On successful completion leaves the device in the provisioned state. The device’s interface must be fully reported when the device enters the provisioned state, and data about profile, datapoint and property types must be available at this time.

glp/0/1401/fb/dev/iox.409eb1/dio/sts {
"state": "provisioned",
"unid": "256",
"health": "normal",
"cat": "i/o",
"type": "dio",
"interfaceType": "static",
"usage": "mixed",
"version": "1.0.0"
}


There are multiple blocks in the DIO device like Relay, Digital Input, Digital Output etc. Below example explains the Relay block operations of DIO device.

Send data for relay on interface 1

Request

As relay is the output we need configuration from the user to set the state of relay. The below message configure the level false for the relay port 1.


mosquitto_pub -t glp/0/1401/rq/dev/iox.409eb1/dio/if/relay/1 -m '{

"relay-val": {

"value": {
"level": false
} 
}
}'



Response


This is the response that we get after successful configuration of relay.


Topic: glp/0/1401/fb/dev/iox.409eb1/dio/if/relay/1

Data: {
"desc": "Digital relay output with level output mode",
"type": "iox-profiles-0/relay",
"relay-val": {
"desc": "iox-relay",
"type": "iox-datapoints-0/relay-val",
"property": false,
"cat": "in",
"value": {
"level":false
}
}
}



DIO device deprovision

Request


glp/0/1401/rq/dev/iox.409eb1/dio/do {
"action":"deprovision"

}


Response


glp/0/1401/fb/dev/iox.409eb1/dio/sts {
"state": "unprovisioned",
"unid": "256",
"health": "normal",
"cat": "i/o",
"type": "dio",
"interfaceType": "static",
"usage": "mixed",
"version": "1.0.0"
}