Announcements
Community Announcement : Welcome to the NEW Cypress Developer Community.
cancel
Showing results for 
Search instead for 
Did you mean: 

PSoC 4 MCU

KaPa_2418181
New Contributor II

I am using the PSoC4 BLE and sending a notification to the peer when my device shuts down, with a reason code so that the peer knows why my device was turned off (e.g. user action, inactivity timeout, battery low and so on). Obviously on shutdown after CyBle_GattsNotification() I  need to loop on CyBle_ProcessEvents(), but I also want to avoid looping too long unnecessarily.

So is there a way to know if / when my notification was put on air? This is an indication so I don't care if the peer doesn't / cannot process it, so there is no need to e.g. use indication and wait for the peer to confirm. All I want to know is if my message was sent, irrespective if the peer got it or not.

Thx,

Karoly

0 Likes
1 Solution
GyanC_36
Employee

Hello kp_2418181 ,

    

  ->    As you mentioned  " CyBle_GattsNotification() I  need to loop on CyBle_ProcessEvents(), but I also want to avoid looping too long unnecessarily." 

Ans: The first response answers this query. Once the application confirms that the data has been pushed into the stack, you can just come out of the loop. After that everything is under the control of stack and the application will never come to know that the data has been sent over the air or has been received by the peer device etc..

-Gyan

View solution in original post

0 Likes
5 Replies
GyanC_36
Employee

Hello,

  Check the return value of API CyBle_GattsNotification(). When it returns CYBLE_ERROR_OK, the notification is sent. You can use either UART debug print or toggle any LED.

Pseudo code---

""""""""""""""""""""""""""""""

while(CYBLE_ERROR_OK!=CyBle_GattsNotification())

{

CyBle_ProcessEvents();

}

UART_DEBUG("Notification Sent");

""""""""""""""""""""""""""""""""""

-Gyan

0 Likes
KaPa_2418181
New Contributor II

I thought when it returns CYBLE_ERROR_OK it only means the notification has been successfully queued inside the stack. Are you sure when it returns CYBLE_ERROR_OK it means the notifications has already been sent on the air by that time?

0 Likes
GyanC_36
Employee

Hello kp_2418181 ,,

     This check only confirms that the Notification data packet has been successfully pushed into the BLE stack from the application layer and after that the stack should take care of sending the data over the air. Your understanding is correct. As you already know that in case of Notification packet there would not be any kind of ACK from the peer device and hence we ( The application) will never come to know that the Notification has been received by the peer device or not.

-Gyan

0 Likes
KaPa_2418181
New Contributor II

Hi, I know that, I have written that in the original question. I am not looking for an ACK from the peer. I am looking for a way to know if the notification was sent, irrespective if it arrived at the peer or not.

0 Likes
GyanC_36
Employee

Hello kp_2418181 ,

    

  ->    As you mentioned  " CyBle_GattsNotification() I  need to loop on CyBle_ProcessEvents(), but I also want to avoid looping too long unnecessarily." 

Ans: The first response answers this query. Once the application confirms that the data has been pushed into the stack, you can just come out of the loop. After that everything is under the control of stack and the application will never come to know that the data has been sent over the air or has been received by the peer device etc..

-Gyan

View solution in original post

0 Likes