This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Zephyr - BLE: How to send response after characteristic write operation?

Hello,

I'm using Zephyr SDK. I have got BLE characteristic (my device is a peripheral) with following settings:

BT_GATT_CHARACTERISTIC(BT_UUID_MY_SERIVCE_CHAR1,
			       BT_GATT_CHRC_WRITE,
			       BT_GATT_PERM_READ | BT_GATT_PERM_WRITE, 
                   NULL, on_receive, NULL)

After successful write operation, I want to reply with some value to the central. Is it possible in the SDK and BLE in general? To be honest, I think I've never seen device that acts like that. At the moment I have second characteristic with notification capabilities, and after the write operation I just send notification with desired value using the other characteristic , so the central device can read it. Is there any better way without the need of having the second characteristic?

I wonder what is the difference between BT_GATT_CHRC_WRITE_WITHOUT_RESP and BT_GATT_CHRC_WRITE, is it somehow related to response on lower BLE layer and is not really related to the application?

  • There is no feature in BLE where a write is to peer characteristic will automatically trigger a response with value.

    I think what you have is pretty good solution which many have used already. 

    I wonder what is the difference between BT_GATT_CHRC_WRITE_WITHOUT_RESP and BT_GATT_CHRC_WRITE, is it somehow related to response on lower BLE layer and is not really related to the application?

    BT_GATT_CHRC_WRITE gives response from the GATT layer to the app the write has been successful. No value can be exchanged from peer to your device in this response.

    BT_GATT_CHRC_WRITE_WITHOUT_RESP  wont give any response even from the own GATT from the stack of your device.

    Eventhough the message sequence charts are from different SDK the underlying logic is the same, just different API in zephyr

Related