To understand the device plugin implementation let's take a look at the Raspberry Pi device implementation. Follow the steps given below to create a new device plugin:
Implement an interface for Raspberry Pi. For more information, see the implementation of
DeviceManagerService
for Raspberry Pi.Example: Implementing the interface
DeviceManagementService
.public interface DeviceManagementService extends ApplicationManager { void init() throws DeviceManagementException; String getType(); OperationMonitoringTaskConfig getOperationMonitoringConfig(); DeviceManager getDeviceManager(); ApplicationManager getApplicationManager(); ProvisioningConfig getProvisioningConfig(); PushNotificationConfig getPushNotificationConfig(); PolicyMonitoringManager getPolicyMonitoringManager(); }
Implement the
DeviceManager
interface. For more information, see the implementation ofDeviceManager
for Raspberry Pi .Why is this step required?
Implement the interface
DeviceManager
for Connected Cup via theorg.wso2.carbon.device.mgt.common.DeviceManager
in order to implement thegetDeviceManager()
method that is shown in step 1. TheDeviceManager
interface will be used for enrolling, disenrolling, activating and deactivating a device.Create a Database Access Object (DAO) on the created
DeviceManager
interface to manage data source connections.Register as an OSGI service.
Example:ServiceRegistration raspberrypiServiceRegRef = bundleContext.registerService(DeviceManagementService.class.getName(), new RaspberrypiManagerService(), null);
RaspberrypiManagerService
is the implementation of the interface showed in step 1.Start the IoT Server.
cd <IoTS_HOME> ./wso2server.sh
How it works
The following section describes how a Raspberry Pi is enrolled using a created device plugin:
The device enrollment calls will be passed through the
DeviceManager
implementation in theDeviceManagerService
.- The
DeviceManager
implementation implements the interfaceorg.wso2.carbon.device.mgt.common.DeviceManager
. - The implemented interface manages the data of the Raspberry Pi, such as information related to enrollment, status, ownership, claimable, license and tenant configuration.
- The implementation needs to be included in an OSGI bundle. Once the bundle is activated, the device will be registered on the Connected Device Management Framework (CDMF).