Hello all,
I am currently working in a project that uses the nRF5340 SoC, nRF Connect SDK and Zephyr. The system has multiple sensors to measure various quantities such as temperature, humidity and pressure. All measurements are perfomed periodically and the data gathered is stored internally in form of data sets (each data set contains the measurement values of one iteration; e.g.: temperature, humidity and pressure). The system includes a BLE Server with various custom services, which will send the data sets to a BLE Client after a Client has sent a valid command request.
I have a few questions related to the best way to send the data to the BLE Client and the use of notifications (or indications):
- The first doubt is whether notifications or indications should be used. I found this interesting discussion and I understand that notifications are the better approach for my project, as there is indeed an ACK at the link layer and a minimal power consumption is also a desired goal. Do you see any reason to use indications?
- In the aforementioned discussion, the first answer states that Notifications "are still guaranteed to reach the target because of the link layer ACK". I am interested to know what happens with the Acknowledge of the link layer. Is Zephyr checking that it is received? How does my implementation know that the ACK has been received?
- At the moment, I have implemented a custom service using the Nordic Uart Service (NUS) as reference and I can send data to the BLE Client by calling the function bt_gatt_notify_cb. I am interested in the error situations. First, I tried to send data without any BLE Client being connected to the BLE Server. Secondly, I tried to send data without the BLE Client being subscribed. In both situations the function returns a negative value, which indicates that the function failed and the data could not be sent. So far so good, but shouldn`t the function retry to send the data until the ACK is received/timeout occurs?
- The function bt_gatt_notify_cb takes two input parameters. The second paremeter is the struct bt_gatt_notify_params, which contains the notification value callback bt_gatt_complete_func_t. The Zephyr documentation states that this is the "notification complete result callback". Am I right to assume that this callback will be called when the BLE Server has received the ACK of the link layer sent by the BLE Client?
- Each data set contains ~50Bytes and will be sent individually. I already modified the MTU in order to be able to send more than the 23 Bytes that are active per default. What would be the best way to send a significant amount of data sets (e.g. 100)? I was thinking of a for loop that calls the bt_gatt_notify_cb function as many times as data sets are to be sent.
- When sending multiple consecutive data sets as notifications, is there any way to detect if one or more packages were not sent successfully?
Many thanks in advance