I am trying to implement a BTLE SERVER on the Nexus 7 with the new BTLE API in 4.3. I am running into several problems. First there are no examples with the SDK. The only example is for a client. Second, the documentation actually tells you to do the wrong thing. It states that one must use the BluetoothAdapter.getProfileProxy() with a BluetoothProfile.GATT_SERVER
parameter to obtain the BluetoothGattServer
object. This approach will work, but one will be unable to link one's implementation of the BluetoothGattServerCallback
to the BLE stack. (This callback is how one responds to client read and write requests among other things.) However, after stumbling on issue 58582 a developer pointed to the new BluetoothManager.openGattServer()
method which takes your callback as a parameter and returns a BluetoothGattServer
object. Well, one problem solved.
The next issue is more problematic. The BluetoothGattServer
documentation states that one can use this class to create and advertise Bluetooth LE services and characteristics. Creating the services, etc. was not problem but they neglect to say how to start advertising. There is no method in the class itself or any other of the classes that I can find.
Does anyone know how to do this? At the moment all I can see is to use the same approach as used by the client, but that approach involves scanning (which is not advertising). All the documentation further suggests that the BluetoothAdapter.startLeScan()
IS indeed JUST for scanning.
So how do I invoke advertisements once all my services, characteristics, and descriptors are in place?