This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

What profile to use for cmd-response app type?

Hi, I have a simple application that requires command-response, and notifications interaction between an Android App and an embedded device. The communication is bidirectional, with the Android App being the master sending commands to the peripheral device which is required to respond to each command, and the slave having notifications/alarms to be sent to the master.

I want to avoid polling, so the following communication models I might need:

  1. client-server type, where [Android App==client], and sends commands to the [embedded device==server]; server responds to commands.

  2. publisher-subscriber, where [Android App==subscriber], and subscribes to receive data from the [embedded device==publisher]. The data published by the embedded device is periodic (i.e. sensors readings)

  3. alarms and alerts notification -- this probably could be the reverse of (1) with the [embedded device==client] notifying the [Android App==server] that alarms are available to be read. The master then would perform a read of new/unread alarms from the slave device using (1). The alarms are considered critical and must be processed immediately thus they cannot be sent periodically by (2).

What would be the recommended existing service(s) to be used in such application? I am thinking of using the ANS and/or a custom service like Nordic's example of BLE_UART (ble_nus). Please let me know your opinion. Regards, G

  • Hi

    To start with, you could look at this blog to realize the different message types.

    1-3) In most of the examples in the SDK, the nRF51 device acts as a server and the central device (e.g. an Android app) as a client. For this scenario, you can perform a write from the client and receive a reply as notification from the server. For this purpose you could create a service with a characteristic with both notification and write property, so you can send messages in both directions.

    The procedure is that the client will enable notifications from the server, or subscribe to receive messages from a certain service as you might call it. The server then decides if it sends notification messages periodically or on request. I think the best way to start out with this development is with the ble_app_lbs example available here on Nordic's Github. Here is an application note that explains the different aspects of the application, and is meant for beginners on BLE and nRF51 development.

Related