The Driver Framework is started from index.js and uses Adesto's IAP Toolkit, which is supplied in a sub-directory.
The modules supplied in the driver-framework folder are as follows:
- index.js is responsible for registering all the actions supported by the driver such as "create", "update", "delete", "test", "provision", "deprovision", "replace", "load", and publishes the about object, cfg object and sts object for the driver. It also connects to the local SmartServer IoT MQTT broker and registers a connection handler, and restores all old devices after receiving an SID from the topic glp/0/././sid. The restore step includes restoring old connections, monitoring, and populating the in-memory UNID map from the feedback channel.
- literals.js is a constant file that provides the protocol name and interface objects for the driver.
- create_action.js handles the creation of devices and maintains an in-memory unid map against the device handle. It stores the created device in the SQLITE database, checks to ensure the UNID is unique and publishes cfg and sts objects for the device if the device is successfully created.
- provision_action.js provisions the device and publishes the interface objects, registers to all the deep interface object topics, and publishes cfg and sts objects.
- deprovision_action.js deprovisions the created device and publishes cfg and sts objects, and deregisters from all the interface topics.
- update_action.js updates created device properties and publishes cfg and sts objects on the feedback channel.
- handle_interface_object.js handles deep topic assignments to interface topics and calls monitor.js or value_control.js when any of the property is changed in a deep topic.
- replace_action.js validates replacement request.
- delete_action.js deletes a created device from the SQLITE database (via the IAP Toolkit) and publishes null to the cfg object and state: "deleted" to the feedback channel. It also updates the UNID map.
- load.js gets the load action request and publishes a successful response.
- test_action.js publishes the status object on the feedback channel.
- connection.js handles datapoint peer-to-peer and point-to-point connections.
- monitor.js publishes the monitoring object at the specified rate to the monitoring service.
- value_control.js publishes the requested value to the datapoint value control service and then updates the value on the feedback channel.
- get.js publishes the current value for the requested datapoint.