Call flow
The script is invoked for every downlink message sent or uplink message received. The downlink request from IMPACT IoT console or API is converted to the payload format supported by the device. Similarly, payload received from device in uplink is converted to IMPACT IoT specific format. Hence the script acts as a codec, encoding or decoding the payloads between device and IMPACT IoT.
Following is an example of Read requests made which results in an encoded Downlink Payload followed by an Uplink Payload which is decoded into a Read response.
Following is an example, IMPACT IoT is sending a request to set the reporting interval as 30 minutes for the notification messages from the device. Once the reporting interval is set, the device will send periodic notifications about the usage of the device resource(s). The flow diagram also depicts unconfirmable messaging for cases where the device does not acknowledge the downlink message and as such a notification is not sent to the Console or API.
IMPACT IoT expects an acknowledgment for every request. So the script while returning the encoded payload to the script engine, should indicate if it is a one-way messaging to the device. The script engine can then self-acknowledge the IMPACT IoT, in case of unconfirmable messaging. The third parameter in the API utils.createBinaryResponse() indicates one-way-messaging.
The next call flow is about unsolicited notification messages that the device will send based on the reporting interval.
When the script receives an uplink message to decode, it determines if there exists any related IMPACT IoT request for the uplink by ascertaining If the correlation ID exists then the script will have a response message as seen in the first flow diagram. Otherwise, the uplink is considered an unsolicited message, and a notification message is returned by the script engine as seen in the preceding call flow.