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.

RE: CC2340R5: ANCS caller information not receiving

Hi Clement,         

I have added GATT_bm_free(&(gattMsg->msg), ATT_HANDLE_VALUE_NOTI); in In app_data.c > GATT_EventHandler, at the end of the case “ATT_HANDLE_VALUE_NOTI”. when I tried to call to that iPhone and caller  information receiving in my peripheral device at n Number of times and the problem has been  resolved but facing the other issues and test cases where listed below.

 And here the test cases: 

 Test Case 1: Basic_ble with ANCS implementation.(iPhone) 

  1. Connecting to the BLE module--> pairing --> notification enabled.
  2. After successful connection making the incoming call to the connected mobile with the module. Module receives the incoming notification in UART.
  3. Now I am to terminate the connection by disabling the Bluetooth from the mobile Bluetooth settings and after few seconds enabling the Bluetooth from the settings mobile will auto connect to the module.
  4. After multiple connection and disconnection mobile and module indicates in connected state but making the incoming call to the connected mobile with the module. Module will not receive the incoming notification in UART.
  5. When this condition occurs module need a power reset to recover. 

 Test Case 2: Basic_ble with ANCS implementation.(Android) 

  1. Connecting to the BLE module--> pairing --> notification enabled.
  2. Now I am to terminate the connection by disabling the Bluetooth from the mobile Bluetooth settings and after few seconds enabling the Bluetooth from the NRF application.
  3. After multiple connection and disconnection module is not advertising(weather advertisement is happening or not conformed using spectrum analyser and module current).
  4. When this condition occurs module need a power reset to recover.

CCS: code Composer Studio 12.5.0   - SDK : simplelink_lowpower_f3_sdk_7_20_01_10

Note: we have also tried without adding this GATT_bm_free(&(gattMsg->msg), ATT_HANDLE_VALUE_NOTI); in a basic_ble ANCS project.

Thanks, 

Vignesh.

  • Hi Vignesh,

    Thank you for reaching out.

    The description of both issues makes me think about memory leaks (it was also the case for your initial report).

    In order to do this, could you please use the ROV and monitor the heap after each connection/disconnection cycle? The documentation of the ROV can be found here: https://software-dl.ti.com/simplelink/esd/simplelink_lowpower_f3_sdk/7.20.01.10/exports/docs/ble5stack/ble_user_guide/html/ble-stack-5.x-guide/debugging-index-cc23xx.html#runtime-object-viewer

    Best regards,

  • Hi,

    I have worked to reproduce your issue.

    I have noticed a memory leak when repeatedly establishing and closing the connection. 

    For the moment I could not locate the place where the memory leak occurs. When preventing the device to discover the services, i.e. pair, bond and exchange data, the memory leak disappears. To do this, I have commented out all the code in AncsApp_discoverService(). 

    One approach to keep narrowing down the root cause possibilities is to keep removing (commenting out) some pieces of code.

    Please let me know your progress.

    Best regards,

  • Hi Vignesh,

    The issue can be resolved by moving the line "GATT_bm_free(&(gattMsg->msg), gattMsg->method);" to the end of the GATT_EventHandler() function.

    Setting the function mentioned at the very end of the GATT_EventHandler() function seems to fix the issue.

    In addition,

    - in AncsApp_discoverService(), I have mentioned some calls to "BLEAppUtil_invokeFunction(AncsApp_discoverService, NULL);". I am not sure I understand why the second parameter is "NULL". Can you please tell me the reasons for this?

    - I recommend replacing the calls to ICall_getEntityId() by calls to BLEAppUtil_getSelfEntity().

    Best regards,

  • Hi clement,

          I have added "GATT_bm_free(&(gattMsg->msg), gattMsg->method);" in In app_data.c > GATT_EventHandler, at the end of the function.

    -->Replaced  the calls to ICall_getEntityId() by calls to BLEAppUtil_getSelfEntity().

    --> in AncsApp_discoverService(), I have mentioned some calls to "BLEAppUtil_invokeFunction(AncsApp_discoverService, NULL);". I am not sure I understand why the second parameter is "NULL". Can you please tell me the reasons for this?

    Where we are not passing any data in the second parameter .so we are using the "Null". If we are using the BLEAppUtil_invokeFunctionNoData will return the BLEAppUtil_invokeFunction(callback, NULL);

    /*********************************************************************
     * @fn      BLEAppUtil_invokeFunctionNoData
     *
     * @brief   This function receives a callback and data and switches
     *          the context in order to call the callback from the BLE
     *          App Util module context
     *
     * @param   callback - The callback to invoke from the BLE App Util
     *                     module context
     *
     * @return  SUCCESS, FAILURE
     */
    bStatus_t BLEAppUtil_invokeFunctionNoData(InvokeFromBLEAppUtilContext_t callback)
    {
        return BLEAppUtil_invokeFunction(callback, NULL);
    }

    We are doing an continuous testing if issue occurs please let us support.

    Thanks,

    Vignesh.

  • Hi,

    --> in AncsApp_discoverService(), I have mentioned some calls to "BLEAppUtil_invokeFunction(AncsApp_discoverService, NULL);". I am not sure I understand why the second parameter is "NULL". Can you please tell me the reasons for this?

    Where we are not passing any data in the second parameter .so we are using the "Null". If we are using the BLEAppUtil_invokeFunctionNoData will return the BLEAppUtil_invokeFunction(callback, NULL);

    The point was rather that, based on my understanding, AncsApp_discoverService() expects a non-NULL parameter. 

    We are doing an continuous testing if issue occurs please let us support.

    Keep me updated, I'll help!

    Regards,

  • Hi Clement,               

      I have added "GATT_bm_free(&(gattMsg->msg), gattMsg->method);" in In app_data.c > GATT_EventHandler, at the end of the function.

    -->Replaced  the calls to ICall_getEntityId() by calls to BLEAppUtil_getSelfEntity().

    Now I am facing an issue when continuous connection and disconnection mobile is not going for auto connection with module and even UART is not responding.when after some number of continuous connection and disconnection in module ANCS notifications not receiving.  

    But  before adding this line "GATT_bm_free(&(gattMsg->msg), gattMsg->method);" when continuous connection and disconnection mobile is not going for auto connection with module but UART is responding.

    -->The point was rather that, based on my understanding, AncsApp_discoverService() expects a non-NULL parameter. 

    Referred an  https://github.com/TexasInstruments/ble_examples/blob/simplelink_cc2640r2_sdk-2.20/examples/rtos/CC2640R2_LAUNCHXL/bleapps/ancs/src/app/ancs.c#L116  in ancs_app.c line no 666 where passing  an NULL parameter to the AncsApp_discoverService() function as AncsApp_discoverService(NULL);

    Thanks,

    Vignesh.

  • Hi,

    I have added "GATT_bm_free(&(gattMsg->msg), gattMsg->method);" in In app_data.c > GATT_EventHandler, at the end of the function.

    Can you confirm you are calling "GATT_bm_free(&(gattMsg->msg), gattMsg->method);" only once for each message? If you free two times a message, then the device will crash?

    Best regards,

  • Hi clement,

           Yes,I am calling "GATT_bm_free(&(gattMsg->msg), gattMsg->method);" only once for each message.

    Thank,

    Vignesh.

  • Hi Vignesh,

    Can you please share your updated code?

    Best regards,

  • Hi clement,

       Sorry for the delay.

    I have attached the Updated code.

    /*********************************************************************
     * @fn      GATT_EventHandler
     *
     * @brief   The purpose of this function is to handle GATT events
     *          that rise from the GATT and were registered in
     *          @ref BLEAppUtil_RegisterGAPEvent
     *
     * @param   event - message event.
     * @param   pMsgData - pointer to message data.
     *
     * @return  none
     */
    static void GATT_EventHandler(uint32 event, BLEAppUtil_msgHdr_t *pMsgData)
    {
      gattMsgEvent_t *gattMsg = ( gattMsgEvent_t * )pMsgData;
    
      if (ancsAppState == ANCS_STATE_DISCOVERY)
        {
            AncsApp_discoverService(gattMsg);
        }
      switch ( gattMsg->method )
      {
        case ATT_FLOW_CTRL_VIOLATED_EVENT:
          {
    //          MenuModule_printf(APP_MENU_PROFILE_STATUS_LINE, 0, "GATT status: ATT flow control is violated");
          }
          break;
    
        case ATT_MTU_UPDATED_EVENT:
          {
    //          MenuModule_printf(APP_MENU_PROFILE_STATUS_LINE, 0, "GATT status: ATT MTU update to %d",
    //                            (( attMtuUpdatedEvt_t * )pMsgData)->MTU);
          }
          break;
    
        case ATT_ERROR_RSP:
        {
            if (gattMsg->msg.errorRsp.reqOpcode == ATT_WRITE_REQ
                    && gattMsg->msg.errorRsp.errCode == ATT_ERR_INSUFFICIENT_AUTHEN)
            {
    
                uint8_t mitm;
                uint8_t bonding;
                GAPBondMgr_GetParameter(GAPBOND_MITM_PROTECTION, &mitm);
                GAPBondMgr_GetParameter(GAPBOND_BONDING_ENABLED, &bonding);
                uint8_t authRequest = ((mitm & 0x01) << 2) | ((bonding & 0x01) << 1)
                        | (bonding & 0x01);
    
                discoveryState = ANCS_DISC_FINISH;
                ancsAppState = ANCS_STATE_READY;
                GAP_SendSlaveSecurityRequest(gattMsg->connHandle/*conn_handle*/,
                                             authRequest);
    
            }
        }
            break;
    
        case ATT_WRITE_RSP:
        {
    
            break;
        }
    
    
        case ATT_HANDLE_VALUE_NOTI:
        case ATT_HANDLE_VALUE_IND:
        {
            //        // If we receive a GATT notification, we can assume it pertains to ANCS
            //       // because we only subscribe to notifications from the Notification Source
            //       // ancs Data Source.
            //
            //       // This variable is used just to make the code look clearer for the
            //       // two conditionals below :)
            uint8_t notifHandle = gattMsg->msg.handleValueNoti.handle;
            //       //      Display_print1(dispHandle,16,0,"Notif Handler : %d", notifHandle);
            //       // Check if the handle matches the handle of the Notification Source
            //       // stored in the handle cache. If so, store the notification in the queue.
            if (notifHandle == Ancs_handleCache[ANCS_NOTIF_SCR_HDL_START])
            {
                //        Display_print0(dispHandle,16,0,"Ancs_queueNewNotif");
                Ancs_queueNewNotif(gattMsg);
            }
            //
            //       // If it is not from the Notification Source we check to see if it is from
            //       // the Data Source by checking if the handle is equal to the Data Source
            //       // Start handle stored in the cache. If so, process the data it holds,
            //       // and ask for more.
            else if (notifHandle == Ancs_handleCache[ANCS_DATA_SRC_HDL_START])
            {
    
                Ancs_processDataServiceNotif(gattMsg);
            }
    //        GATT_bm_free(&(gattMsg->msg), ATT_HANDLE_VALUE_NOTI);
    
    
            break;
        }
    
        default:
          break;
      }
      GATT_bm_free(&(gattMsg->msg), gattMsg->method);
    }

    Thank you.