Previous Topic

Next Topic

Book Contents

Book Index

Creating Custom Service Provider

How to Write a Service Provider

A Service Provider in the Bluetooth LE module is an OSGi bundle, which provides to other bundles your GATT services, characteristics and descriptors. It must register an implementation of com.prosyst.mbs.services.btle.GattProviderService:

  providerService = new GattProviderServiceImpl();
  providerServReg = bc.registerService(GattProviderService.class.getName(), providerService, null);

By registering the service, your provider will be automatically tracked by the driver. If there is an interaction with the services the new implementations will be loaded (e.g. calling BluetoothLEDevice.getService(String uuid), BluetoothLEDevice.getServicesUuid(String uuid), BluetoothLEDevice.getServices()).

If "ble.ls -f <ID/deviceAddr>" is executed from the command line, all GATT services for the specified device, including the provided in this module will be displayed.