Writing Device Plugins via Java Code
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 { 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 ofÂDeviceManager
 for Raspberry Pi .Why is this step required?
Implement the interface
DeviceManager
for Connected Cup via theÂorg.wso2.carbon.device.mgt.common.DeviceManager
in order to implement theÂgetDeviceManager()
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 theÂDeviceManagerService
. Â- TheÂ
DeviceManager
 implementation implements the interfaceÂorg.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).