Send Android BLE GATT notification

I am currently developing BLE application

based on the Gatt sample project provided by Google.

I want to figure out what to send a notification from my device Android

(smartphone) to another device BLE

(like TI CC2540 ). There is a lot of discussion about how to get notified online.

However, I am unable to find out about any discussions on sending notification. So is there a way to send a notification through an Android device? Thank you in advance.

+3


source to share


2 answers


There is technically a difference between the Central / Peripheral classification, which belongs to GAP, and the client / server, which belongs to GATT. The central one (the one that crawls and connects) is usually the Client, and the Peripheral (the one that advertises) is usually the server, but not required.

The smartphone is central (it might be a peripheral since Android 5.0, but I doubt it applies to you) and usually a client because it connects to the GATT servers located on the peripherals like your sensor (or whatever you build).

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



  • Create a GATT server on your smartphone.
  • Build your peripheral to execute GATT client routines (review specifications, read / write, etc.).

This may be optional, as @istirbu pointed out. If your application is already running, your Central smartphone is a client. The client-side equivalent of notification is the Write command (no response). So use this.

+2


source


Notifications are used by a peripheral to send information to a client (such as an Android device). There is no need to send notification to the device in terms of GATT, you can perform write operation on the characteristic. As a result of this recording or any periodic operation, the peripheral device will send (notify) some information to the client on the same or a different sign you are subscribed to.



0


source







All Articles