Previous Topic

Next Topic

Book Contents

Book Index

HomeProtocolAdapter

The HomeProtocolAdapter - com.prosyst.mbs.services.hdm.spi.HomeProtocolAdapter, provides the ability to add support for a particular protocol adapter. Device Access interacts with a protocol adapter using the implementation of this interface.

Device Access requests the protocol adapter to:

...and so on.

HomeProtocolAdapter can also receive a callback to notify Device Access for any changes to the devices.

Notifying Device Access about Devices

When Device Access "detects" your HomeProtocolAdapter, it will call the setHomeDeviceAdminSpi(HomeDeviceAdminSpi)method. The HomeProtocolAdapter will save the HomeDeviceAdminSpi as the method's parameter. This parameter will be used to transmit information to Device Access about the devices and the device class objects.

Refer to the DA Protocol Adapter demo (com.prosyst.mbs.da.adapter-demo), to see how the implementation of setHomeDeviceAdminSpi(HomeDeviceAdminSpi)creates three devices with some device class objects.

For a full list of demos, and how to use them, please refer to Working with Demos guide with Device Access demos in particular.

Supported Operations

If the protocol adapter supports this operation, you need to implement the method addHomeDevice(Map<String, ?>)for manual device registration. This method takes one parameter which is Мap that holds the device properties. The result is a newly added HomeDeviceSpi instance. The protocol adapter does not need to call the HomeDeviceAdminSpi for the added new device. The DeviceAdmin will send an event for the added device when the method returns.

This operation is related to the protocol adapters which are for HDM API implementation. For this reason this operation is deprecated.

If the protocol adapter supports this operation, you need to implement the method removeHomeDevice(HomeDeviceSpi). The protocol adapter does not need to call the HomeDeviceAdminSpi for the removed device. The Device Access will send an event for the removed device when the method returns.

If the device cannot be removed immediately (for example, the user needs to press a button before removing the device), the protocol adapter has to put the device in the removing status and throw NotRemovedException - com.prosyst.mbs.services.hdm.spi.NotRemovedException, to Device Access. When the protocol adapter throws this exception, this means that the device will be removed later. If the protocol supports the operation to "cancel remove" the device, then you should implement HomeProtocolAdapterExt. In this case, when the protocol adapter throws a NotRemovedException, the application might force the protocol adapter to cancel a "device remove" operation by invoking the DeviceAdmin.cancelRemove(String) method.

In addition, you can extend the implementation of your protocol adapter by implementing the HomeProtocolAdapterRemover interface.

This operation is related to the protocol adapters which are for the HDM API implementation.

This operation is related to the protocol adapters which are for the HDM API implementation.

Be sure to indicate that your implementation of the protocol adapter supports the corresponding flags in the bitwise, or that the return value of the getOperations() method of ProtocolAdapterInfo is the correct bitmask:

• ProtocolAdapterInfo.OPERATION_ADD
• ProtocolAdapterInfo.ADD_WITHOUT_DEVICE_CLASS
• ProtocolAdapterInfo.OPERATION_REMOVE
• ProtocolAdapterInfo.OPERATION_REMOVE_PARENT
• ProtocolAdapterInfo.OPERATION_SEARCH
• ProtocolAdapterInfoExt.OPERATION_CANCEL_REMOVE

For example, for the protocol adapter in the Device Access Protocol Adapter demo this method looks like:

public int getOperations() {

return SUPPORTED_OPERATIONS;

}

where the defined constant is: private static final int SUPPORTED_OPERATIONS = OPERATION_ADD | OPERATION_REMOVE.