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

PSoC 4

Anonymous
Not applicable

Hello,

I am chandresh and i am using CYBLE-014008-00 BLE Psoc-4 MCU. In my project, The CYBLE MCU communicates with an android device and sends 25-30 bytes of data every 250 msec. However if i keep both the android device and CYBLE on for testing for longer period of time, My Connection gets dropped after few hours for no reason.

To send the data i use this BLE API,

void senddata(void *payload, int sizeofPayload)

{

CYBLE_GATTS_HANDLE_VALUE_NTF_T tempHandle;

    

    tempHandle.attrHandle = CYBLE_TAPSERVICE_TAPDATA_CHAR_HANDLE;

  tempHandle.value.val = (uint8 *) payload;

    tempHandle.value.len = sizeOfPayload;

    CyBle_GattsWriteAttributeValue(&tempHandle,0,&cyBle_connHandle,CYBLE_GATT_DB_LOCALLY_INITIATED); 

   

    /* send notification to client if notifications are enabled and finger location has changed */

    CyBle_GattsNotification(cyBle_connHandle,&tempHandle);

}

Here is the log of what i have been facing,

At 0: Initializing BLE Hardware     // At t=0 seconds, i have turned on the BLE hardware

At 0: CYBLE_EVT_STACK_ON  

At 0: CYBLE_EVT_GAPP_ADVERTISEMENT_START_STOP

At 46: CYBLE_EVT_GATT_CONNECT_IND           

At 46: CYBLE_EVT_GAP_DEVICE_CONNECTED    // After 46 seconds, it gets connected to the android device

At 20600: CYBLE_EVT_GATT_DISCONNECT_IND    // After 20600 secs since uptime,it gets disconnected,Now when BLE gets disconnected, it first gives STACK BUSY

At 20600: CYBLE_EVT_GAP_DEVICE_DISCONNECTED

At 20600: CYBLE_EVT_GAPP_ADVERTISEMENT_START_STOP

At 20602: CYBLE_EVT_GATT_CONNECT_IND

At 20602: CYBLE_EVT_GAP_DEVICE_CONNECTED         // At 20602 seconds since uptime, It again connects to the android device

At 24444: CYBLE_EVT_STACK_BUSY_STATUS                 // At 24444 seconds since uptime, it gets BLE STACK BUSY EVENT

At 24462: CYBLE_EVT_STACK_BUSY_STATUS            // 18 seconds later, again it receives BLE STACK BUSY EVENT, this time it gets disconnected.

At 24462: CYBLE_EVT_GATT_DISCONNECT_IND

At 24462: CYBLE_EVT_GAP_DEVICE_DISCONNECTED

At 24462: CYBLE_EVT_GAPP_ADVERTISEMENT_START_STOP    // BLE STARTS advertising and again after few seconds it receives connect event and connects

At 24477: CYBLE_EVT_GATT_CONNECT_IND

At 24477: CYBLE_EVT_GAP_DEVICE_CONNECTED

At 24477: CYBLE_EVT_GAP_CONNECTION_UPDATE_COMPLETE

At 24477: CYBLE_EVT_GAP_CONNECTION_UPDATE_COMPLETE

At 52698: CYBLE_EVT_STACK_BUSY_STATUS          // AT 52698 seconds since uptime, it again receives STACK BUSY event

At 52716: CYBLE_EVT_STACK_BUSY_STATUS         //// 18 seconds later, again it receives BLE STACK BUSY EVENT, this time it gets disconnected.

At 52716: CYBLE_EVT_GATT_DISCONNECT_IND

At 52716: CYBLE_EVT_GAP_DEVICE_DISCONNECTED

At 52716: CYBLE_EVT_GAPP_ADVERTISEMENT_START_STOP

At 52941: CYBLE_EVT_GATT_CONNECT_IND

At 52941: CYBLE_EVT_GAP_DEVICE_CONNECTED

At 52941: CYBLE_EVT_GAP_CONNECTION_UPDATE_COMPLETE

At 52942: CYBLE_EVT_GAP_CONNECTION_UPDATE_COMPLETE

So this is what happends, everytime when i receive STACK BUSY event, 18 seconds later i receive another STACK BUSY event and it gets disconnected. then it connects again and after few hours i receive STACK BUSY event once, 18 seconds later i receive another STACK BUSY event and on that very second it gets disconnected.

Can anyone help on how this is happening and how can i resolve this? disconnection and reconnection is expected in case of BLE after few hours?

Thanks,

Chandresh

0 Likes
1 Solution
Yugandhar
Moderator
Moderator

Hello Chandresh,

Please refer through the modified project.

In the project, CyDelay(250) is not recommended to use in infinite loop because we have to call the CyBle_ProcessEvents() Function continuously without any delay. We can use WDT timer (whose time value should be 250msec) and call the function sendDataToEdge(payload, sizeof(payload)) in it.

We have to call CyBle_GattsWriteRsp (CYBLE_CONN_HANDLE_T connHandle) API after every successfully write because this function sends a Write Response from a GATT Server to the GATT Client. This function has to be invoked in response to a valid Write Request event from the GATT Client (CYBLE_EVT_GATTS_WRITE_REQ) to acknowledge that the attribute has been successfully written.

Please let me know if this helps you.

Thanks,

PSYU.

View solution in original post

0 Likes
6 Replies
Yugandhar
Moderator
Moderator

Hello Chandresh,

Please share the project.

Thanks,

PSYU.

0 Likes
Anonymous
Not applicable

Hello,

Please find attached project

Thanks,

Chandresh

0 Likes
Yugandhar
Moderator
Moderator

Hello Chandresh,

Please refer through the modified project.

In the project, CyDelay(250) is not recommended to use in infinite loop because we have to call the CyBle_ProcessEvents() Function continuously without any delay. We can use WDT timer (whose time value should be 250msec) and call the function sendDataToEdge(payload, sizeof(payload)) in it.

We have to call CyBle_GattsWriteRsp (CYBLE_CONN_HANDLE_T connHandle) API after every successfully write because this function sends a Write Response from a GATT Server to the GATT Client. This function has to be invoked in response to a valid Write Request event from the GATT Client (CYBLE_EVT_GATTS_WRITE_REQ) to acknowledge that the attribute has been successfully written.

Please let me know if this helps you.

Thanks,

PSYU.

View solution in original post

0 Likes
Anonymous
Not applicable

Thanks for your reply,

In my set up, After BLE succesfully connected with the android device, BLE communicates properly with the android application for first few hours. In that Cypress BLE sends data to android and Android receives data also, but The event i receive during this entire operation is only these,

At 0: CYBLE_EVT_STACK_ON

At 0: CYBLE_EVT_GAPP_ADVERTISEMENT_START_STOP

At 8: CYBLE_EVT_GATT_CONNECT_IND

At 8: CYBLE_EVT_GAP_DEVICE_CONNECTED

<===== During this period, it communicates with the android device=====>

At 81: CYBLE_EVT_GATT_DISCONNECT_IND

At 81: CYBLE_EVT_GAP_DEVICE_DISCONNECTED

At 81: CYBLE_EVT_GAPP_ADVERTISEMENT_START_STOP

At 111: CYBLE_EVT_GATT_CONNECT_IND

At 111: CYBLE_EVT_GAP_DEVICE_CONNECTED

As you can see here, During its communication with the android device, i am not receiving any "CYBLE_EVT_GATTS_WRITE_REQ" event where i can call this function CyBle_GattsWriteRsp. My understanding here is that after every successful writing of attribute by CyBle_GattsWriteAttributeValue API and calling of CyBle_GattsNotification API should generate "CYBLE_EVT_GATTS_WRITE_REQ" event but i am not receiving "CYBLE_EVT_GATTS_WRITE_REQ" event during my entire connection.

Could you please tell me when "CYBLE_EVT_GATTS_WRITE_REQ" event gets generated and why am not not receiving this event.

Thanks,

Chandresh

0 Likes
Anonymous
Not applicable

Hello,

In my Setup, The Cypress BLE MCU is not generating the "CYBLE_EVT_GATTS_WRITE_REQ" event. I have observed that this event is not being generated even when the connection is established or when the connection is established and the communication is happening.

In summary, CYBLE_EVT_GATTS_WRITE_REQ event never gets generated and switch case related to this event never gets executed.

Please let me know your comments.

Chandresh

0 Likes
Yugandhar
Moderator
Moderator

Hello Chandresh,

Whenever there is a write request from the central( android device)  then only this event CYBLE_EVT_GATTS_WRITE_REQ is generated at the peripheral side. In your project there is no such write request from central you are directly sending the data from peripheral to central after establishing the connection.

Thanks,

PSYU.

0 Likes