Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Send a Android BLE GATT Notification

I´m currently developing an BLE application, based on the Gatt sample project provided by Google.

What I want to realize is to send a notification from my Android device(smartphone) to another BLE device(e.g. TI CC2540). There are many discussion about how to receive a notification on the Internet.

However, I can't find out any discussions about sending a notification. So is there any method to sending a notification through Android device? Thank you in advance.

like image 573
Hao-Lun Hsu Avatar asked Oct 27 '25 04:10

Hao-Lun Hsu


1 Answers

Technically, there is a difference between the Central/Peripheral classification, which belongs to the GAP, and the Client/Server one, which belongs to the GATT. A Central (one that scans and connects) is usually a Client, and the Peripheral (one that advertises) is usually a Server, but not necessarily.

The smartphone is the Central (it can be Peripheral as of Android 5.0 but I doubt that's the case for you), and usually it's the Client because it connects to GATT Servers located on Peripherals such as your sensor (or whatever you are building).

So, if you want to send a Notification from your device you need 2 things:

  1. Create a GATT Server on your smartphone.
  2. Design your Peripheral to execute GATT Client procedures (Discover Characteristics, Read/Write etc).

This may not be necessary, as @istirbu pointed out. If your application is already up-and-running, your smartphone Central is a Client. The equivalent of a Notification at Client-side is the Write Command (without response). So use that.

like image 169
Bogdan Alexandru Avatar answered Oct 29 '25 19:10

Bogdan Alexandru



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!