Data collection using token
The topic format is oriented around the following model:
${token}/${serialNumber}/${object}/${objectInstance}/${resource}/ ${resourceInstanceId}
- ${token}, This is the token of the device provided ahead of time, see the security section.
- ${serialNumber}, This is the serial number of the device which was used when the token was requested.
- ${object}, This is the object name. This can be any strong with the exception of "device" which has a special meaning in IMPACT IoT. For future compatibility it is recommended not use the values: “firmware”, “security” and “server”.
- ${objectInstance}, This is an instance of the object and is a number and used to differentiate if there are multiple objects. The usual case is that the object is single, and the value is “0”.
- ${resource}, This is the value name and can be any string.
The exception is when the object is “device”, in this case the following values
apply:
- make
- model
- firmwareVersion
- ${resourceInstanceId}, This is an instance of the resource and is a number and used to differentiate if there are multiple objects. The usual case is that the object is single and this is not used.
Multiple Values in an object
It is possible to publish multiple values within a single object with a single PUBLISH message, the topic has the format as below and the values are a JSON composition as detailed in the example. This is used when there is only one object.
${token}/${serialNumber}/${object}
Topic = t8cwp2uneipj/8800002400000/power Value = {"battery":80,"amps":"1","volts":"5"}
In this example, the power object with resources battery at 80, amps at 1, and volts at 5.
Multiple values in an object instance
It is possible to publish multiple values within a single object instance with a single PUBLISH message, the topic has the format as below and the values are a JSON composition as detailed in the example. This is used when there are multiple object instances.
${token}/${serialNumber}/${object}}/${objectInstance}
Topic = t8cwp2uneipj/8800002400000/radio/0 Value = {"radiotype":”lora”,"receivepower":"22","sendpower":"35"}
In this example, the first radio object with resources radiotype at lora, receivepower at 22 and sendpower at 35.
Single values in a resource
To perform a publish of a single value for a resource, the topic will have the following format:
${token}/${serialNumber}/${object}/${objectInstance}/${resource}
Topic = t8cwp2uneipj/8800002400000/processor/0/freeMemory Value = 10
In this example, the freeMemory value is set to 10.
Single value in a resource instance
To perform a publish of a single value for a resource instance, the topic will have the following format:
${token}/${serialNumber}/${object}/${objectInstance}/${resource}/ ${resourceInstanceId}
Topic = t8cwp2uneipj/8800002400000/monitor/0/errorCode/0 Value = 10
In this example, the errorCode at instance 0 is set to value 10.
Multiple values in a multiple resource instance
To perform a publish of multiple values in a multi resource instance, the topic will have the following format, the values are a JSON composition as detailed in the example.
${token}/${serialNumber}/${object}
Topic = t8cwp2uneipj/8800002400000/monitor Value = {"errorCode":[22,13]}
In this example the errorCode at instance 0 and 1 are set to values 22 and 13.
Multiple values in a multiple resource instance with multiple resources
To perform a publish of multiple values in a multi resource instance for multiple resource, the topic will have the following format, the values are a JSON composition as detailed in the example.
${token}/${serialNumber}/${object}
Topic = t8cwp2uneipj/8800002400000/monitor Value = {"errorCode":[22,13],”criticality”:[“major”, “minor”]}
In this example, the errorCode at instance 0 and 1 are set to values 22 and 13 respectively and the criticality at 0 and 1 are set to major and minor expectedly.