Reputation: 371
I'm developing an application that tries to connect my smartphone to a BLE device with Gatt (it can be either a smartphone or a BLE device) and read just a piece of data. This data will dynamically change and I want to keep this data as the value of a characteristic of a service. My main purpose is to read this data from the client side. Since I am connecting with Gatt, I think the only way is to store that data as the value of characteristic.
How can I add a service and a characteristic to the BLE device from the app which I created for the BLE device? I did a research and found some useful information from here. But this helps you create a service for a device you have connected to. Please help me or give me an idea. Thank you very much
Upvotes: 2
Views: 2730
Reputation: 150
Android (prior to 5.0) doesn't support acting as a peripheral mode you can write applications in order to act as central(master) or Observer mode.
Since Android 5.0, you can use android.bluetooth.le API along with BluetoothGattServer to adopt peripheral role on your Android 5.0+ devices.
Upvotes: 2
Reputation: 1624
Seems to me that what you are trying to do is to connect to a device and add a service on that remote device. That is not have it works and you will not be able to create an app that does this.
In BLE, both sides have a Gatt server. The addService API call in BluetoothGattService is only for adding services to your local Gatt server, not the remote server.
This is how it needs to work:
To be able to answer more detailed a lot more information on the setup is necessary.
Upvotes: 3