Device Controller

    The device controller makes use of device model and device instance to implement device management : - Device Model: A describes the device properties exposed by the device and property visitors to access these properties. A device model is like a reusable template using which many devices can be created and managed. Details on device model definition can be found here. - Device Instance: A instance represents an actual device object. It is like an instantiation of the and references properties defined in the model. The device spec is static while the device status contains dynamically changing data like the desired state of a device property and the state reported by the device. Details on device instance definition can be found .

    Note: Sample device model and device instance for a few protocols can be found at $GOPATH/src/github.com/kubeedge/kubeedge/build/crd-samples/devices

    The following are the functions performed by the device controller :- - Downstream Controller: Synchronize the device updates from the cloud to the edge node, by watching on K8S API server - Upstream Controller: Synchronize the device updates from the edge node to the cloud using device twin component

    | Update Type | Action | |——————————- |———————————————- | |Device Twin Reported State Updated | The controller patches the reported state of the device twin property in the cloud. |

    Device Upstream Controller

    The mapper watches devices for updates and reports them to the event bus via the MQTT broker. The event bus sends the reported state of the device to the device twin which stores it locally and then syncs the updates to the cloud. The device controller watches for device updates from the edge ( via the cloudhub ) and updates the reported state in the cloud.

    Device Downstream Controller

    The idea behind using config map to store device properties and visitors is that these metadata are only required by the mapper applications running on the edge node in order to connect to the device and collect data. Mappers if run as containers can load these properties as config maps . Any additions , deletions or updates to properties , visitors etc in the cloud are watched upon by the downstream controller and config maps are updated in etcd. If the mapper wants to discover what properties a device supports, it can get the model information from the device instance. Also, it can get the protocol information to connect to the device from the device instance. Once it has access to the device model, it can get the properties supported by the device. In order to access the property, the mapper needs to get the corresponding visitor information. This can be retrieved from the propertyVisitors list. Finally, using the visitorConfig, the mapper can read/write the data associated with the property.

    Syncing Desired Device Twin Property Update From Cloud To Edge

    The device controller watches device updates in the cloud and relays them to the edge node. These updates are stored locally by the device twin. The mapper gets these updates via the MQTT broker and operates on the device based on the updates.