This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CC2640R2F: BLE no longer TX & RX data after some time connecting with iPhone but not with Android phone

Part Number: CC2640R2F
Other Parts Discussed in Thread: CC2640

Tool/software:

I have my BLE profile configured like this :

#define SBP_PERIODIC_EVT_PERIOD               20

///////////////////////////////////

#define SIMPLEPROFILE_CHAR1_LEN 4
#define SIMPLEPROFILE_CHAR4_LEN 20

///////////////////////////////////

When cc2640 is connected with iPhone or Android phone, cc2640 will keep TX char4 data to iPhone or Android phone. Meanwhile, not sync with char4 data event, iPhone or Android phone will keep TX one char1 data to cc2640 for every 5 seconds.

In the case of connecting with iPhone, cc2640 will not TX/RX any more data from iPhone after random time (few ten seconds to few minutes). After cc2640 and iPhone is disconnected, cc2640 advertises again and is able to be connected again but data TX/Rx still does not work. 

This issue does not occur in the case of connecting with Android phone.

  • Hello Jeff,

    Thanks for reaching out. May I ask what SDK version are you using and what example if you are using one out of the box? In addition, are you using blestack (4.2 BLE spec) or ble5stack (5 BLE spec)? May I ask what exactly do you mean by TX/RX does not work, do you mean write/read/notifications are not working?

    BR,

    David.

  • Hello David,

    Thank you for your prompt reply and question. 

    I am using the sdk "simplelink_cc2640r2_sdk_2_20_00_49" and example "\rtos\CC2640R2_LAUNCHXL\blestack\tida_01624". It's under 4.2 BLE stack.

    Yes, write/read/notifications are not working. And I also found that once the issue happened the program no longer run inside the main loop as normal.

    Here is the code for reference:

    >>>>>>>>>>>>>>>>>>>>>>>>>

    static void SimplePeripheral_taskFxn(UArg a0, UArg a1)
    {
    // Initialize application
    SimplePeripheral_init();

    // Application main loop
    for (;;)
    {
    uint32_t events;

    >>>>>>>>>>>>>>>>>>>>>>>> I added a test toggle pin here >>>>>>>>>>>>>>>>>>>>>>>>>>>

    // Waits for an event to be posted associated with the calling thread.
    // Note that an event associated with a thread is posted when a
    // message is queued to the message receive queue of the thread
    events = Event_pend(syncEvent, Event_Id_NONE, SBP_ALL_EVENTS,
    ICALL_TIMEOUT_FOREVER);

    if (events)

    .......

    }

    }

    }

    >>>>>>>>>>>>>>>>>

    Thanks again for your help.

  • Hello Jeff,

    May I ask how are you sending the information from the peripheral to the phone? I would assume notifications? I would expect the function to look something like this. Do you have a Bluetooth sniffer to take a look at what is happening over the air. This can be quite useful to compare between the android and iPhone behaviour.

    tatic bStatus_t gattServApp_SendNotiInd( uint16 connHandle, uint8 cccValue,
                                              uint8 authenticated, gattAttribute_t *pAttr,
                                              uint8 taskId, pfnGATTReadAttrCB_t pfnReadAttrCB )
    {
      attHandleValueNoti_t noti;
      uint16 len;
      bStatus_t status;
    
      // If the attribute value is longer than (ATT_MTU - 3) octets, then
      // only the first (ATT_MTU - 3) octets of this attributes value can
      // be sent in a notification.
      noti.pValue = (uint8 *)GATT_bm_alloc( connHandle, ATT_HANDLE_VALUE_NOTI,
                                            GATT_MAX_MTU, &len );
      if ( noti.pValue != NULL )
      {
        status = (*pfnReadAttrCB)( connHandle, pAttr, noti.pValue, &noti.len,
                                   0, len, GATT_LOCAL_READ );
        if ( status == SUCCESS )
        {
          noti.handle = pAttr->handle;
    
          if ( cccValue & GATT_CLIENT_CFG_NOTIFY )
          {
            status = GATT_Notification( connHandle, &noti, authenticated );
          }
          else // GATT_CLIENT_CFG_INDICATE
          {
            status = GATT_Indication( connHandle, (attHandleValueInd_t *)&noti,
                                      authenticated, taskId );
          }
        }
    
        if ( status != SUCCESS )
        {
          GATT_bm_free( (gattMsg_t *)&noti, ATT_HANDLE_VALUE_NOTI );
        }
      }
      else
      {
        status = bleNoResources;
      }
    
      return ( status );
    }

    BR,

    David.

  • Hello David,

    Thank you again for your response and review on my case.

    For your question, yes , I send information from peripheral to the phone in the way you mentioned above. And the code quoted above is also as the same as what it is included in my sdk example project which has been called to use as the suggested way in the example.

    And yes I got a BT sniffer to use and it is a good idea to me to check over the data in the air. Thank you. Let me do this and then I will come back with more relevant details to share. Thanks again!

  • Have used the BLE sniffer tool to compare those captured data on both Android and iPhone cases. Seems I cannot see the differences between them.

    Continuously 20+7 bytes are sending from Slave and periodically 4+7 bytes are sending from Master for every 5 seconds.

    Picture1. Android case

    Picture2. iPhone case, writing 4+7 bytes for every 5 second without reading from Slave.

    Picture3. iPhone case, writing 4+7 bytes for every 5 seconds with reading from Slave.

    Please advise if any clues for me to further check. Thanks.

  • Hello Jeff,

    Thank you for the insights. May I please ask you to share a complete sniffer log for me to look at the entire sequence of events? This includes the events that are happening while the connection is established (to see for instance, MTU exchanges, update parameters - connection interval value for example).

    BR,

    David.

  • Hi David,

    Thanks again for reviewing.

    Here is the link i shared those log files to. 

    https://drive.google.com/drive/folders/1AVZzWefy-EI_o6aS8AhkXnTbFgI-SaIR

    Look forward ro hearing from you.

  • Hello Jeff,

    Apologies the delay. I am not able to access drive files (public or private). May I ask you to share the logs here (if they don't contain any confidential/private information of course)? In addition, could you please confirm if you are not able to transmit notification from the peripheral to the central as well as to execute write operations (central to peripheral)?

    BR,

    David.

  • Hi David,

    It's okay and thanks again. I shared the log files at two links this time. Please download it again and hope it works for you.

    https://www.dropbox.com/scl/fi/frxgv8qrz2fu26gntn3h5/sniffer_test_logfiles.zip?rlkey=bdxe2anb0f3ax9ush6n9axku5&st=jgiu4v5s&dl=0
    https://namiorghk-my.sharepoint.com/:u:/g/personal/jeffchu_nami_org_hk/EV7R5k5i661Dv51cWNbutysBcY-d3O2NbVrmXyeJvUO-FQ?e=8FY1x6

    To answer your question, yes when the issue happened which is being connected and communicated for few minutes I am not able to transmit notification from peripheral as well as read/write.

  • Hello Jeff,

    Thanks for providing the links again. I am able to download the logs. Could you please help me understand where the issue is. According to what we discussed, when the device reconnects it is not able to transmit/receive data. However I am not able to see that happening, could you please point it out in the logs? For instance, I see the peripheral is sending some notifications up to a point and then it just sends empty packets, is this the case you are referring to?

    BR,

    David.

  • Hi David,

    Good and thanks for reviewing again.

    The device connects once started at time 0.000 and then it keeps sending 20 bytes to master (app) continuously . At master (app) side, it keeps sending back a 4 bytes packet for every 5 seconds to the device. It supposed to be that this connection and data communication operation will keep running without end. But in the ios case, after time 326.295 second the device stopped sending 20 bytes to master which is not expected. In my device program I set a test toggle pin keep running inside the main loop to let me know the main program is running normally. After the UNKNOWN issue happened, the test pin no longer toggle any more, so I think the device program is running out of control after time 326.295. 

  • Hello Jeff,

    Thanks for the extra info. I see that the device does not crash, it just basically starts sending empty packets to keep the communication alive. What triggers the data transmission (notifications) - is the data coming from a sensor for instance?

    May I also ask if you can consider migrating to a more updated SDK version? There are several improvements and fixes that have been implemented in the last 5 years.

    BR,

    David.

  • Hi David,

    Thanks for your advice. I spent few days to migrate my code to an updated SDK version which is sdk 5.30.01.11. Now the old issue did not happen again. The device works fine with connected to either Android or iPhone app. The issue has been fixed in the new sdk. Thanks again for your help.