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.

CC2340R5: CC2340 ported ANCS, but the module can't receive cell phone data.

Part Number: CC2340R5
Other Parts Discussed in Thread: CC2640

After porting the ANCS program to CC2340, it is found that the service subscription features are successful, and the mobile phone also sends data to the module, but the module does not trigger the ATT_HANDLE_VALUE_NOTI event, that is, the data of the mobile phone cannot be received.

All the GATT events are opened here.

Looking at the Bluetooth packet capture data, the mobile phone sent data, but did not execute the ancs_gattEventHandler function.

ANCS-2.rar

  • Hi,

    Thank you for reaching out  Can you share the SDK version you are using for your develompent? Also, can you share a screenshot of the code where the event handler is registered?

    Best Regards,

    Jan

  • When the MTU is updated, run the ATT_MTU_UPDATED_EVENT command to indicate that the GATT event is registered successfully

    sdk:simplelink_lowpower_f3_sdk_7_20_01_10

    BLEAppUtil_EventHandler_t ancsConnHandler =
    {
        .handlerType    = BLEAPPUTIL_GAP_CONN_TYPE,
        .pEventHandler  = ancs_connEventHandler,
        .eventMask      = BLEAPPUTIL_LINK_ESTABLISHED_EVENT | BLEAPPUTIL_LINK_TERMINATED_EVENT 
    };
    
    BLEAppUtil_EventHandler_t ancsPairingPairStateHandler =
    {
        .handlerType    = BLEAPPUTIL_PAIR_STATE_TYPE,
        .pEventHandler  = ancs_pairStateHandler,
        .eventMask      = BLEAPPUTIL_PAIRING_STATE_BOND_SAVED
    };
    
    BLEAppUtil_EventHandler_t ancsDataGATTHandler =
    {
        .handlerType    = BLEAPPUTIL_GATT_TYPE,
        .pEventHandler  = ancs_gattEventHandler,
        .eventMask      = 0xFFFFFFFF
    };
    
    
    
    
    bStatus_t ancs_start(void)
    {
        BLEAppUtil_registerEventHandler(&ancsDataGATTHandler);
    
        BLEAppUtil_registerEventHandler(&ancsConnHandler);
    
        BLEAppUtil_registerEventHandler(&ancsPairingPairStateHandler);
    
    
        return( SUCCESS );
    }
    
    
    
    
    static void ancs_connEventHandler(uint32 event, BLEAppUtil_msgHdr_t *pMsgData)
    {
        switch(event)
        {
            case BLEAPPUTIL_LINK_ESTABLISHED_EVENT:
            {
                gapEstLinkReqEvent_t *gapEstMsg = (gapEstLinkReqEvent_t *)pMsgData;
    
                u_printf("Established:%d %s",gapEstMsg->connectionHandle,BLEAppUtil_convertBdAddr2Str(gapEstMsg->devAddr));
                 
            }break;
    
            case BLEAPPUTIL_LINK_TERMINATED_EVENT:
            {
                gapTerminateLinkEvent_t *gapTermMsg = (gapTerminateLinkEvent_t *)pMsgData;
    
                u_printf("Terminated:%d %d",gapTermMsg->connectionHandle, gapTermMsg->reason);
    
            }break;
    
    
            default:
            {    
            }break;
        }
    }
    
    
    /*********************************************************************
     * @fn      ancs_pairStateHandler
     *
     * @brief   The purpose of this function is to handle pairing state
     *          events that rise from the GAPBondMgr and were registered
     *          in @ref BLEAppUtil_RegisterGAPEvent
     *
     * @param   event - message event.
     * @param   pMsgData - pointer to message data.
     *
     * @return  none
     */
    static void ancs_pairStateHandler(uint32 event, BLEAppUtil_msgHdr_t *pMsgData)
    {
        BLEAppUtil_PairStateData_t *PairStateData = (BLEAppUtil_PairStateData_t *)pMsgData;
    
        u_printf("ancs_pairStateHandler:%d %d",event,PairStateData->status);
    
        switch(event)
        {
            case BLEAPPUTIL_PAIRING_STATE_BOND_SAVED:
            {             
                if(PairStateData->status == SUCCESS)
                {
                    ancs_pairingBondDone(PairStateData->connHandle);
                }                            
            }break;
    
            default:
            {
                
            }break;
        }
    }
    
    
    
    static void ancs_gattEventHandler(uint32 event, BLEAppUtil_msgHdr_t *pMsgData)
    {
        gattMsgEvent_t *gattMsg = ( gattMsgEvent_t * )pMsgData;
    
        u_printf("ancs_gattEventHandler: %02x %02x %d",event,gattMsg->method,gattMsg->hdr.status);
    
    
        switch ( gattMsg->method )
        {
            case ATT_MTU_UPDATED_EVENT:
            {
                ancs_mtuUpdate(gattMsg->connHandle,gattMsg->msg.mtuEvt.MTU-3);
            }break;
    
            case ATT_HANDLE_VALUE_IND:
            {
                u_printf("ATT_HANDLE_VALUE_IND:\r\n");
                //log_hex(gattMsg->msg.handleValueInd.pValue,gattMsg->msg.handleValueInd.len);
            }break;
    
            case ATT_HANDLE_VALUE_NOTI:
            {
                u_printf("ATT_HANDLE_VALUE_NOTI:\r\n");
                //log_hex(gattMsg->msg.handleValueNoti.pValue,gattMsg->msg.handleValueNoti.len);
            }break;
    
            default:
            break;
        }
    
        
    	...
    	
    	Code that handles the discovery service
    }
    
    
    
    
    
    
    
    
    
    
    
    
    Call ancs_start in App_StackInitDoneHandler of app_main.c
    
    /*********************************************************************
     * @fn      App_StackInitDone
     *
     * @brief   This function will be called when the BLE stack init is
     *          done.
     *          It should call the applications modules start functions.
     *
     * @return  none
     */
    void App_StackInitDoneHandler(gapDeviceInitDoneEvent_t *deviceInitDoneData)
    {
        bStatus_t status = SUCCESS;
    
        // Menu
        Menu_start();
    
        // Print the device ID address
        MenuModule_printf(APP_MENU_DEVICE_ADDRESS, 0, "BLE ID Address: "
                          MENU_MODULE_COLOR_BOLD MENU_MODULE_COLOR_GREEN "%s" MENU_MODULE_COLOR_RESET,
                          BLEAppUtil_convertBdAddr2Str(deviceInitDoneData->devAddr));
    
        if ( appMainParams.addressMode > ADDRMODE_RANDOM)
        {
          // Print the RP address
            MenuModule_printf(APP_MENU_DEVICE_RP_ADDRESS, 0,
                         "BLE RP Address: "
                         MENU_MODULE_COLOR_BOLD MENU_MODULE_COLOR_GREEN "%s" MENU_MODULE_COLOR_RESET,
                         BLEAppUtil_convertBdAddr2Str(GAP_GetDevAddress(FALSE)));
        }
    
    #if defined( HOST_CONFIG ) && ( HOST_CONFIG & ( PERIPHERAL_CFG ) )
        // Any device that accepts the establishment of a link using
        // any of the connection establishment procedures referred to
        // as being in the Peripheral role.
        // A device operating in the Peripheral role will be in the
        // Peripheral role in the Link Layer Connection state.
        status = Peripheral_start();
        if(status != SUCCESS)
        {
            // TODO: Call Error Handler
        }
    #endif
    
    #if defined( HOST_CONFIG ) && ( HOST_CONFIG & ( BROADCASTER_CFG ) )
        // A device operating in the Broadcaster role is a device that
        // sends advertising events or periodic advertising events
        status = Broadcaster_start();
        if(status != SUCCESS)
        {
            // TODO: Call Error Handler
        }
    #endif
    
    #if defined( HOST_CONFIG ) && ( HOST_CONFIG & ( CENTRAL_CFG ) )
        // A device that supports the Central role initiates the establishment
        // of an active physical link. A device operating in the Central role will
        // be in the Central role in the Link Layer Connection state.
        // A device operating in the Central role is referred to as a Central.
        status = Central_start();
        if(status != SUCCESS)
        {
            // TODO: Call Error Handler
        }
    #endif
    
    #if defined( HOST_CONFIG ) && ( HOST_CONFIG & ( OBSERVER_CFG ) )
        // A device operating in the Observer role is a device that
        // receives advertising events or periodic advertising events
        status = Observer_start();
        if(status != SUCCESS)
        {
            // TODO: Call Error Handler
        }
    #endif
    
    #if defined( HOST_CONFIG ) && ( HOST_CONFIG & ( PERIPHERAL_CFG | CENTRAL_CFG ) )
        status = Connection_start();
        if(status != SUCCESS)
        {
            // TODO: Call Error Handler
        }
        status = Pairing_start();
        if(status != SUCCESS)
        {
            // TODO: Call Error Handler
        }
        status = Data_start();
        if(status != SUCCESS)
        {
            // TODO: Call Error Handler
        }
        status = DevInfo_start();
        if(status != SUCCESS)
        {
            // TODO: Call Error Handler
        }
        status = SimpleGatt_start();
        if(status != SUCCESS)
        {
            // TODO: Call Error Handler
        }
    #endif
    
    #if defined( HOST_CONFIG ) && ( HOST_CONFIG & ( PERIPHERAL_CFG | CENTRAL_CFG ))  &&  defined(OAD_CFG)
        status =  OAD_start();
        if(status != SUCCESS)
        {
            // TODO: Call Error Handler
        }
    #endif
    
    
        status =  ancs_start();
        if(status != SUCCESS)
        {
            // TODO: Call Error Handler
        }
    }
    

  • Hi,

    Are you receiving any other event? In other words, is the default case in line 129 ever being executed? As a quick test, instead of masking for all events could you try just masking for the events that are of interest?  For example, instead of doing 0xFFFFFFFF, could you do BLEAPPUTIL_ATT_MTU_UPDATED_EVENT | BLEAPPUTIL_ATT_HANDLE_VALUE_NOTI | BLEAPPUTIL_ATT_HANDLE_VALUE_NOTI?

    Taking a bit of a step back, are you attempting to send a notification to the phone or receive one from the phone?

    Best Regards,

    Jan

  • Hi.

    ANCS function is that CC2340 does peripheral mode, after the Apple cell phone is connected, CC2340 carries out the discovery of ANCS service, subscription. However, when the phone has information, the phone sends notificationdata to the CC2340,CC2340 did not execute ATT_ HANDLE_ Value_ NOTI Event

    Looking at the LOG print, when the phone sends data to the CC2340, it does not call the ancs_gattEventHandler function, i.e., it does not execute the default

    I am able to receive ATT_MTU_UPDATED_EVENT, ATT_FIND_BY_TYPE_VALUE_RSP, ATT_READ_BY_TYPE_RSP, ATT_FIND_INFO_RSP, ATT_WRITE_RSP, and ATT_ERROR_RSP events, I am just not able to receive ATT_HANDLE_VALUE_NOTI

    For another project, I have tested the CC2340 in central mode with eventMask configured to 0xFFFFFFFF and it is possible to execute the ATT_HANDLE_VALUE_NOTI event when data is received from the slave.I suspect that perhaps the protocol stack ATT_HANDLE_VALUE_NOTI events are not reported to the application layer when the CC2340 is configured in peripheral mode

  • Hi,

    Got it. Thank you for the additional information. Do you have access to a bluetooth sniffer? If so, then could you take a log of the CC2340R5 advertising, connecting, and then the iOS device sending the notifications? I would like to see what is happening over the air and confirm that the expected data is being sent.

    Best Regards,

    Jan

  • There's one near the front. I'll upload it again

    ANCS-2 (1).rar

  • Hi,

    My apologies, I missed the uploaded file. Based on the provided logs, it does seem that the central is sending the notifications properly. Have notifications been enabled on both sides (iOS and CC23XX application)?

    Best Regards,

    Jan

  • Hi.

    cc2340 turned on notifications,The phone does not need to turn on the notification of this service, right, I grabbed the CC2640 ANCS project, this project is able to receive data normally, I compared the ANCS service handle these are no problem

    CC2640 ANCS.rar

  • Hi,

    Thanks! Understood, Thank you for clarifying. Can you share how you are turning on notifications on the CC2340R5 side?

    Best Regards,

    Jan

  • Hi.

    The code is as follows: The value of ancsCharHandleCache[HDL_ANCS_NTF_CCCD] is 41, and the value of ancsCharHandleCache[HDL_ANCS_DATA_SRC_CCCD] is 44.After discovering the service and characteristic, call ancs_cfigNotifSrc(1) and ancs_cfigDataSrc(1)

    static bStatus_t ancs_cfigNotifSrc(uint8_t enable)
    {
        bStatus_t status;
    
    
        uint8_t data[2];
        if(enable)
        {
            data[0] = LO_UINT16(GATT_CLIENT_CFG_NOTIFY);
            data[1] = HI_UINT16(GATT_CLIENT_CFG_NOTIFY);    
        }
        else
        {
            data[0] = 0;
            data[1] = 0;   
        }
    
        status = ancs_writeData(ancsConnHandle,ancsCharHandleCache[HDL_ANCS_NTF_CCCD],data,sizeof(data));    
      
        return status;
    }
    
    static bStatus_t ancs_cfigDataSrc(uint8_t enable)
    {
        bStatus_t status;
    
        uint8_t data[2];
        if(enable)
        {
            data[0] = LO_UINT16(GATT_CLIENT_CFG_NOTIFY);
            data[1] = HI_UINT16(GATT_CLIENT_CFG_NOTIFY);    
        }
        else
        {
            data[0] = 0;
            data[1] = 0;   
        }
    
        status = ancs_writeData(ancsConnHandle,ancsCharHandleCache[HDL_ANCS_DATA_SRC_CCCD],data,sizeof(data));    
      
        return status;
    }
    
    
    bStatus_t ancs_writeData(uint16_t connHandle,uint16_t charHandle,void *pData,uint16_t size)
    {
        uint16 len, maxSize;
        attWriteReq_t writeReq;
        
        len = size;
            
        if(pData == NULL || size == 0 || connHandle == LINKDB_CONNHANDLE_INVALID) 
        {
            return bleInvalidRange;
        }
    
        writeReq.pValue = GATT_bm_alloc(connHandle, ATT_WRITE_REQ, len, &maxSize);
        
        if(len > maxSize) 
        {
            len = maxSize; 
        }
        
        if(writeReq.pValue == NULL) 
        {
            return bleNoResources;  
        }
    
        writeReq.handle = charHandle;
        writeReq.len    = len;
        writeReq.sig    = 0;
        writeReq.cmd = 0;
        memcpy((uint8_t *)writeReq.pValue, pData, len);
        
        bStatus_t status;
        status = GATT_WriteCharValue(connHandle, &writeReq, BLEAppUtil_getSelfEntity());
        
        if(status != SUCCESS) 
        {
            u_printf("ancs_writeData fail:%d %d\r\n",connHandle,status);
    
            GATT_bm_free((gattMsg_t *)&writeReq, ATT_WRITE_REQ);    
        } 
        else
        {
            if(size != len)
            {
                u_printf("ancs_writeData data cut:%d %d %d\r\n",connHandle,size,len);
            }  
        } 
    
        return status; 
    }

  • Hi,

    At a glance, it looks okay. Can you confirm what the call for ancs_writeData() returns when done as part of the notification enabling procedure? I want to ensure we are not getting a bleInvalidRange or bleNoresources error.

    Best Regard,

    Jan

  • Hi.

    ancs_cfigNotifSrc and ancs_cfigDataSrc both return a value of 0

  • Hi,

    Got it. Returning code 0 indicates that the functions all returned SUCCESS which is good. I would like to see if the bleapputil framework is catching the event, but failing to pass it up to the application.

    Can you take a look at the BLEAppUtil_processGATTEvents inside the bleapputil_process.c linked resource located within the common/BLEAppUtil folder in your project? I would recommend replacing the bleapputil_process.c linked resource with a local copy. You can do this by right clicking on bleapputil_process.c and clicking on Show in local terminal -> system explorer. Then delete the local linked reference in your project and then click and drag the local file located in the file explorer that opened when you clicked on system explorer and drop it in the BLEAppUtil folder in your project. When prompted with a window, ensure you select the copy option to create a local copy of the file.

    This will allow you to modify the file freely without modifying the SDK copy of the file which will impact other projects.

    At this point, lets add a case ATT_HANDLE_VALUE_NOTI and inside lets add a global variable that is increment every time the case is triggered. Lets run a test where we monitor the global variable while in debug mode to determine if the case is ever entered.

    Best Regards,

    Jan

  • Hi.

    According to your method, after the phone sends notify data to the module, the program does not execute to BLEAppUtil_processGATTEvents

  • Hi,

    Got it. Thank you for running the test! I think we may need to take a bit of a step back and see if this issue is due to the ANCS implementation itself or something more closely linked to how the BLEAppUtil Framework handles incoming notifications when in peripheral mode. Can you share the extent of the modifications made to the example and can you clarify if you are working off the datastream or ble basic example?

    Best Regards,

    Jan

  • Hi.

    The project uses the "basic_ble" example and only adds ancs_start at the end of the App_StackInitDoneHandler, nothing else is changed.

    BLEAppUtil_EventHandler_t ancsConnHandler =
    {
        .handlerType    = BLEAPPUTIL_GAP_CONN_TYPE,
        .pEventHandler  = ancs_connEventHandler,
        .eventMask      = BLEAPPUTIL_LINK_ESTABLISHED_EVENT | BLEAPPUTIL_LINK_TERMINATED_EVENT 
    };
    
    BLEAppUtil_EventHandler_t ancsPairingPairStateHandler =
    {
        .handlerType    = BLEAPPUTIL_PAIR_STATE_TYPE,
        .pEventHandler  = ancs_pairStateHandler,
        .eventMask      = BLEAPPUTIL_PAIRING_STATE_BOND_SAVED
    };
    
    BLEAppUtil_EventHandler_t ancsDataGATTHandler =
    {
        .handlerType    = BLEAPPUTIL_GATT_TYPE,
        .pEventHandler  = ancs_gattEventHandler,
        .eventMask      = 0xFFFFFFFF
    };
    
    
    
    bStatus_t ancs_start(void)
    {
        BLEAppUtil_registerEventHandler(&ancsDataGATTHandler);
    
        BLEAppUtil_registerEventHandler(&ancsConnHandler);
    
        BLEAppUtil_registerEventHandler(&ancsPairingPairStateHandler);
    
    
        Util_constructClock(&clkAncsRetry, 
                            (void *)BLEAppUtil_invokeFunctionNoData,
                            500, 
                            0, 
                            false,
                            (uint32)ancs_retryTimeoutCallback);
    
    
        return( SUCCESS );
    }
    
    

  • Hi,

    Got it. Thank you! I think there may be an issue here with how the event is being handled by the bleapputil. I will file a ticket for this. Could you provide the iOS version you are using for your testing?

    Best Regards,

    Jan

  • HI.

    Tested two phones:

    iphone 13    IOS 15.2.1

    iphone 11 Promax    IOS 15.3.1

  • Hi,

    Got it. Thank you for verifying. Looking into this further, it we should be able to receive these notions on the CC23XX device based on my understanding. We may be missing a setup step somewhere. Have you called "GATTServApp_ProcessCCCWriteReq" to enable the notifcations on the peripheral side? I believe this function is necessary to enable notifcations so that may be what we are missing. There is some information in the following e2e thread:

    https://e2e.ti.com/support/wireless-connectivity/bluetooth-group/bluetooth/f/bluetooth-forum/1031608/cc2640r2f-how-to-turn-the-notification-on-of-simple-peripheral-example-internally-in-simple_peripheral-code/3814225#3814225

    Could you also share if you have sourced the ANCS service from the CC2640R2 or have you created your own version?

    Best Regards,

    Jan

  • Hi.

    The ANCS service is on the phone, and I can't pass in the gattAttribute_t parameter when calling the GATTServApp_ProcessCCCWriteReq interface.

    I've successfully implemented the ANCS function on the CC2640, but the CC2340 doesn't work with the same approach

    I'll upload the code, can you verify directly on it

    SDK:simplelink_lowpower_f3_sdk_7_20_01_10

    2100.basic_ble_LP_EM_CC2340R5_freertos_ticlang.zip

  • Hi,

    Looking through the code, I don't believe we are registering for indications/notifications on the BLE stack itself. This is done by calling GATT_RegisterForInd(). This is done when the device is in central mode automatically within the ble_stack_api.c file located inside the common/iCallBLE directory contained within the basic_ble project. This file is a referenced resource so lets replace it with a local copy before we make any modifications (using the instructions provided previously. The original file has the following relevant code within the bleStack_initGATT() file:

    Can you try changing it such that the case for the observer also registers for notifications as follows?

    Ensure this is done in a local copy to not impact other projects in your SDK. Can you test if this works on your side? I do not have an iOS with me at this time. I will try to source one tomorrow to assist with testing.

    Best Regards,

    Jan

  • Hi.

    Thanks, after calling this interface GATT_RegisterForInd, I can receive data from the phone. But when I send data to the cell phone, sometimes calling the GATT_WriteCharValue interface will not quit,Usually occurs when the phone is disconnected, after reconnection

    basic_ble_LP_EM_CC2340R5_freertos_ticlang_2.rar

  • Hi,

    Im glad to hear we were able to resolve the notification not being received issue! Can you clarify what you mean by the function wont quit? DO you mean it never returns or returns failure? Does the code hang? If it does hang, then can you try pausing the execution and sharing a picture of the call stack? If the program does not get stuck, but simply not perform the write, then can you share the return code of GATT_WriteCharValue()? If it does get stuck, then can you record the return codes leading up to the code hanging?

    Best Regards,

    Jan

  • The program does not return after calling GATT_WriteCharValue, the program executes to ICall_abort.

    This is the serial port log, the code was uploaded in the last reply

    [10:26:26.344]收←◆========================= Menu Navigation =========================
    |   BTN-1(Left) : Press ---> Next   | Long Press ---> Back        |
    |   BTN-2(Right): Press ---> Select | Long Press ---> Main Menu   |
    ===================================================================
    ===================================================================
    Basic BLE Menu
    
    [10:26:26.354]收←◆Connection >    Connection menu
    BLE ID Address: 0xA434F1AED7AA
    Adv status: Started - handle: 0
    
    [10:26:29.184]收←◆Adv status: Ended - handle: 0
    Conn status: Established - Connected to 0x5CFBF3C2817F connectionHandle = 0
    Connections number: 1 
    
    [10:26:29.194]收←◆Established:0 0x5CFBF3C2817F
    
    [10:26:29.587]收←◆Conn status: Phy update - connHandle = 0 PHY = 2 Mbps
    
    [10:26:29.647]收←◆GATT status: ATT MTU update to 176
    ancs_gattEventHandler: 80000000 7f 0
    ancs_mtuUpdate: 248
    GATT_DiscPrimaryServiceByUUID: 0
    
    [10:26:29.707]收←◆ancs_gattEventHandler: 40 07 0
    service handle:35~44
    
    [10:26:29.767]收←◆ancs_gattEventHandler: 40 07 26
    GATT_DiscAllChars: 0
    
    [10:26:29.827]收←◆ancs_gattEventHandler: 100 09 0
    find char uuid:d9d9 37
    find char uuid:1dbd 40
    find char uuid:7bfb 43
    GATT_DiscAllChars2: 22
    
    [10:26:29.887]收←◆ancs_gattEventHandler: 100 09 26
    
    [10:26:29.898]收←◆GATT_DiscAllCharDescs: 0
    
    [10:26:29.944]收←◆ancs_gattEventHandler: 10 05 0
    
    [10:26:29.954]收←◆HDL_ANCS_NTF_CCCD HANDLE:41
    ancs_gattEventHandler: 10 05 26
    GATT_DiscAllCharDescs: 0
    
    [10:26:30.004]收←◆ancs_gattEventHandler: 10 05 0
    
    [10:26:30.014]收←◆HDL_ANCS_DATA_SRC_CCCD HANDLE:44
    ancs_gattEventHandler: 10 05 26
    DelNotificationCategoryList
    ancs_writeData:0 41 2
    GATT_WriteCharValue
    GATT_WriteCharValue end:0
    ancs_cfigNotifSrc: 0
    
    [10:26:30.064]收←◆ancs_gattEventHandler: 01 01 0
    
    [10:26:30.737]收←◆Pairing Status: Started - connectionHandle = 0 status = 0 
    
    [10:26:30.747]收←◆Pairing Status: Started - connectionHandle = 0 status = 0 
    
    [10:26:33.277]收←◆Pairing Status: Complete - connectionHandle = 0 status = 0 
    Pairing Status: Bond saved - connectionHandle = 0 status = 0 
    ancs_pairStateHandler:8 0
    DelNotificationCategoryList
    ancs_writeData:0 41 2
    GATT_WriteCharValue
    GATT_WriteCharValue end:22
    ancs_writeData fail:0 22
    ancs_cfigNotifSrc: 22
    
    [10:26:33.297]收←◆9e 9a 05 2f 3c 26 9a d6 20 ef be 4c 0f 80 b1 68 
    
    [10:26:33.487]收←◆DelNotificationCategoryList
    
    [10:26:33.497]收←◆ancs_writeData:0 41 2
    GATT_WriteCharValue
    GATT_WriteCharValue end:0
    ancs_cfigNotifSrc: 0
    
    [10:26:33.547]收←◆ancs_gattEventHandler: 40000 13 0
    ancs_writeData:0 44 2
    GATT_WriteCharValue
    GATT_WriteCharValue end:0
    ancs_cfigDataSrc: 0
    
    [10:26:33.608]收←◆ancs_gattEventHandler: 40000 13 0
    ancs finish
    HDL_ANCS_NTF_NOTIF_START: 40
    HDL_ANCS_NTF_NOTIF_END: 41
    HDL_ANCS_NTF_CCCD: 41
    HDL_ANCS_CTRL_PT_START: 37
    HDL_ANCS_CTRL_PT_END: 38
    HDL_ANCS_DATA_SRC_START: 43
    HDL_ANCS_DATA_SRC_END: 44
    HDL_ANCS_DATA_SRC_CCCD: 44
    
    [10:26:40.713]收←◆ancs_gattEventHandler: 800000 1b 0
    
    [10:26:40.723]收←◆ancs_recvDataHandler: 0 40
    00 10 04 2a 30 00 00 00 
    NotificationSource
    EventID: 00
    EventFlags: 10
    CategoryID: 04
    CategoryCount: 42
    NotificationUID: 30000000
    FindNotificationCategoryList,ret=0,NotificationUID:30000000
    AddNotificationCategoryList,CategoryID:4,NotificationUID:30000000
    NotiAttrRspHandler:0,NotificationUID:30000000
    ancs_writeData:0 37 6
    
    [10:26:40.733]收←◆GATT_WriteCharValue
    GATT_WriteCharValue end:0
    GetNotificationAttributes:0,CommandID:0,NotificationUID:30000000,AttributeID:0,Length:0
    
    [10:26:40.773]收←◆ancs_gattEventHandler: 40000 13 0
    
    [10:26:40.783]收←◆ancs_gattEventHandler: 800000 1b 0
    ancs_recvDataHandler: 0 43
    00 30 00 00 00 00 0f 00 63 6f 6d 2e 74 65 6e 63 65 6e 74 2e 6d 71 71 
    DataSource
    CommandID: 00
    NotificationUID: 30000000
    AttributeIDs: 00
    Length: 15
    
    [10:26:40.793]收←◆63 6f 6d 2e 74 65 6e 63 65 6e 74 2e 6d 71 71 
    AppIdentifier:com.tencent.mqq
    NotiAttrRspHandler:1,NotificationUID:30000000
    ancs_writeData:0 37 8
    GATT_WriteCharValue
    GATT_WriteCharValue end:0
    GetNotificationAttributes:0,CommandID:0,NotificationUID:30000000,AttributeID:1,Length:30
    
    [10:26:40.833]收←◆ancs_gattEventHandler: 40000 13 0
    
    [10:26:40.843]收←◆ancs_gattEventHandler: 800000 1b 0
    ancs_recvDataHandler: 0 43
    00 30 00 00 00 01 11 00 e3 81 98 76 65 e7 88 b2 e4 bd a0 e9 8d be e6 83 85 
    DataSource
    CommandID: 00
    NotificationUID: 30000000
    AttributeIDs: 01
    Length: 17
    e3 81 98 76 65 e7 88 b2 e4 bd a0 e9 8d be e6 83 85 
    Title:銇榲e鐖蹭綘閸炬儏
    NotiAttrRspHandler:2,NotificationUID:30000000
    FindNotificationCategoryList,ret=536881080,NotificationUID:30000000
    ancs_writeData:0 37 8
    GATT_WriteCharValue
    GATT_WriteCharValue end:0
    GetNotificationAttributes:0,CommandID:0,NotificationUID:30000000,AttributeID:2,Length:20
    
    [10:26:40.893]收←◆ancs_gattEventHandler: 40000 13 0
    ancs_gattEventHandler: 800000 1b 0
    ancs_recvDataHandler: 0 43
    
    [10:26:40.903]收←◆00 30 00 00 00 02 00 00 
    DataSource
    CommandID: 00
    NotificationUID: 30000000
    AttributeIDs: 02
    Length: 0
    
    Subtitle:
    NotiAttrRspHandler:3,NotificationUID:30000000
    ancs_writeData:0 37 8
    GATT_WriteCharValue
    GATT_WriteCharValue end:0
    GetNotificationAttributes:0,CommandID:0,NotificationUID:30000000,AttributeID:3,Length:100
    
    [10:26:40.953]收←◆ancs_gattEventHandler: 40000 13 0
    ancs_gattEventHandler: 800000 1b 0
    ancs_recvDataHandler: 0 43
    00 30 00 00 00 03 02 00 79 79 
    DataSource
    CommandID: 00
    NotificationUID: 30000000
    AttributeIDs: 03
    Length: 2
    79 79 
    Message:yy
    NotiAttrRspHandler:4,NotificationUID:30000000
    ancs_writeData:0 37 6
    GATT_WriteCharValue
    GATT_WriteCharValue end:0
    
    [10:26:40.973]收←◆GetNotificationAttributes:0,CommandID:0,NotificationUID:30000000,AttributeID:4,Length:0
    
    [10:26:41.013]收←◆ancs_gattEventHandler: 40000 13 0
    ancs_gattEventHandler: 800000 1b 0
    ancs_recvDataHandler: 0 43
    00 30 00 00 00 04 01 00 32 
    DataSource
    CommandID: 00
    NotificationUID: 30000000
    AttributeIDs: 04
    Length: 1
    32 
    MessageSize:2
    NotiAttrRspHandler:5,NotificationUID:30000000
    ancs_writeData:0 37 6
    GATT_WriteCharValue
    
    [10:26:41.039]收←◆GATT_WriteCharValue end:0
    GetNotificationAttributes:0,CommandID:0,NotificationUID:30000000,AttributeID:5,Length:0
    
    [10:26:41.076]收←◆ancs_gattEventHandler: 40000 13 0
    ancs_gattEventHandler: 800000 1b 0
    ancs_recvDataHandler: 0 43
    00 30 00 00 00 05 0f 00 32 30 32 33 31 31 31 34 54 31 30 32 36 34 30 
    DataSource
    CommandID: 00
    NotificationUID: 30000000
    AttributeIDs: 05
    Length: 15
    32 30 32 33 31 31 31 34 54 31 30 32 36 34 30 
    Date:20231114T102640
    NotiAttrRspHandler:6,NotificationUID:30000000
    
    [10:26:45.729]收←◆Conn status: Terminated - connectionHandle = 0 reason = 19
    Connections number: 0 
    Terminated:0 19
    DelNotificationCategoryList
    Adv status: Started - handle: 0
    
    [10:26:49.619]收←◆Adv status: Ended - handle: 0
    
    [10:26:49.629]收←◆Conn status: Established - Connected to 0x646D2F0D549E connectionHandle = 0
    Connections number: 1 
    Established:0 0x646D2F0D549E
    
    [10:26:50.009]收←◆Conn status: Phy update - connHandle = 0 PHY = 2 Mbps
    
    [10:26:50.132]收←◆GATT_DiscPrimaryServiceByUUID: 0
    
    [10:26:50.222]收←◆Pairing Status: Encrypted - connectionHandle = 0 status = 0 
    
    [10:26:50.252]收←◆GATT status: ATT MTU update to 176
    
    [10:26:50.262]收←◆ancs_gattEventHandler: 80000000 7f 0
    ancs_mtuUpdate: 248
    
    [10:26:50.282]收←◆ancs_gattEventHandler: 40 07 0
    service handle:35~44
    
    [10:26:50.342]收←◆ancs_gattEventHandler: 40 07 26
    GATT_DiscAllChars: 0
    
    [10:26:50.406]收←◆ancs_gattEventHandler: 100 09 0
    find char uuid:d9d9 37
    find char uuid:1dbd 40
    find char uuid:7bfb 43
    GATT_DiscAllChars2: 22
    
    [10:26:50.466]收←◆ancs_gattEventHandler: 100 09 26
    GATT_DiscAllCharDescs: 0
    
    [10:26:50.526]收←◆ancs_gattEventHandler: 10 05 0
    HDL_ANCS_NTF_CCCD HANDLE:41
    ancs_gattEventHandler: 10 05 26
    GATT_DiscAllCharDescs: 0
    
    [10:26:50.588]收←◆ancs_gattEventHandler: 10 05 0
    HDL_ANCS_DATA_SRC_CCCD HANDLE:44
    ancs_gattEventHandler: 10 05 26
    DelNotificationCategoryList
    ancs_writeData:0 41 2
    GATT_WriteCharValue
    GATT_WriteCharValue end:0
    ancs_cfigNotifSrc: 0
    
    [10:26:50.649]收←◆ancs_gattEventHandler: 40000 13 0
    
    [10:26:50.659]收←◆ancs_writeData:0 44 2
    GATT_WriteCharValue
    GATT_WriteCharValue end:0
    ancs_cfigDataSrc: 0
    ancs_gattEventHandler: 800000 1b 0
    ancs_gattEventHandler: 800000 1b 0
    
    [10:26:50.679]收←◆ancs_gattEventHandler: 800000 1b 0
    
    [10:26:50.689]收←◆ancs_gattEventHandler: 800000 1b 0
    ancs_gattEventHandler: 800000 1b 0
    
    [10:26:50.719]收←◆ancs_gattEventHandler: 800000 1b 0
    ancs_gattEventHandler: 800000 1b 0
    ancs_gattEventHandler: 800000 1b 0
    ancs_gattEventHandler: 800000 1b 0
    ancs_gattEventHandler: 800000 1b 0
    ancs_gattEventHandler: 800000 1b 0
    
    [10:26:50.739]收←◆ancs_gattEventHandler: 800000 1b 0
    ancs_gattEventHandler: 800000 1b 0
    ancs_gattEventHandler: 800000 1b 0
    ancs_gattEventHandler: 40000 13 0
    ancs finish
    HDL_ANCS_NTF_NOTIF_START: 40
    HDL_ANCS_NTF_NOTIF_END: 41
    HDL_ANCS_NTF_CCCD: 41
    HDL_ANCS_CTRL_PT_START: 37
    HDL_ANCS_CTRL_PT_END: 38
    
    [10:26:50.749]收←◆HDL_ANCS_DATA_SRC_START: 43
    HDL_ANCS_DATA_SRC_END: 44
    HDL_ANCS_DATA_SRC_CCCD: 44
    ancs_gattEventHandler: 800000 1b 0
    ancs_recvDataHandler: 0 40
    00 15 04 0d 0e 00 00 00 
    NotificationSource
    EventID: 00
    EventFlags: 15
    CategoryID: 04
    CategoryCount: 13
    NotificationUID: 0e000000
    FindNotificationCategoryList,ret=0,NotificationUID:0e000000
    AddNotificationCategoryList,CategoryID:4,NotificationUID:0e000000
    NotiAttrRspHandler:0,NotificationUID:0e000000
    ancs_writeData:0 37 6
    GATT_WriteCharValue
    GATT_WriteCharValue end:0
    GetNotificationAttributes:0,CommandID:0,NotificationUID:0e000000,AttributeID:0,Length:0
    ancs_gattEventHandler: 800000 1b 0
    ancs_recvDataHandler: 0 40
    00 15 04 0e 0f 00 00 00 
    NotificationSource
    EventID: 00
    EventFlags: 15
    CategoryID: 04
    CategoryCount: 14
    NotificationUID: 0f000000
    FindNotificationCategoryList,ret=0,NotificationUID:0f000000
    AddNotificationCategoryList,CategoryID:4,NotificationUID:0f000000
    NotiAttrRspHandler:0,NotificationUID:0f000000
    ancs_writeData:0 37 6
    GATT_WriteCharValue
    GATT_WriteCharValue end:22
    ancs_writeData fail:0 22
    GetNotificationAttributes:22,CommandID:0,NotificationUID:0f000000,AttributeID:0,Length:0
    ancs_gattEventHandler: 800000 1b 0
    ancs_recvDataHandler: 0 40
    00 15 04 0f 10 00 00 00 
    NotificationSource
    EventID: 00
    EventFlags: 15
    CategoryID: 04
    CategoryCount: 15
    NotificationUID: 10000000
    
    [10:26:50.779]收←◆FindNotificationCategoryList,ret=0,NotificationUID:10000000
    AddNotificationCategoryList,CategoryID:4,NotificationUID:10000000
    NotiAttrRspHandler:0,NotificationUID:10000000
    ancs_writeData:0 37 6
    GATT_WriteCharValue
    

  • Hi,

    Got it. Thank you for clarifying. I should be able to source an iOS device tomorrow. Can you share the steps to reproduce the behavior? Will this code work on a LaunchPad without any modifications? Also, does the issue happen after the device has been working for some time?

    Best Regards,

    Jan

  • Hi

    The test steps are as follows:

    1, for the first time in the IOS Bluetooth list click on the connection ANCS demo device, click on the pairing, after allowing the display of notifications, with a second cell phone to send information to the IOS device, and then in the CC2340 can receive the message!

    2、Disconnect IOS and reconnect again, then IOS will send information to CC2340, CC2340 will be stuck when calling GATT_WriteCharValue to reply data.

    The code can be run directly and can be connected to a serial LOG to see the information. Need to reset to recover after a problem occurs

  • Hi,

    I was unable to source an iPhone that can receive calls/texts. Would an iPad work on this case or does it have to be an iOS device that can receive calls/texts?

    Best Regards,

    Jan

  • Hi,

    I retried it without sending a message, the phone disconnected and reconnected and it came up

  • Hi,

    Understood. I will try to reproduce this with an iPad and report back.

    Best Regards,

    Jan

  • Hi,

    Can the problem be reproduced?

  • Hi,

    My sincerest apologies for the extended delay. I am catching up on this thread again after U.S. Holidays and it has taken much longer than expected. I had issues using my iPad (had difficulties connecting) and have not been able to set up a test with an iOS device on my side. I truly apologize for the inconvenience that this delay caused.

    Can you share if there have been any further updates from your side? This will ensure we can both debug this issue together as effectively as possible.

    Best Regards,

    Jan

  • Hi,

    I haven't found a solution.

  • Hi,

    Got it. Thank you for the update. I think we should observe if the heap or stack is overflowing. 

    Can you reference the Debugging Common Heap Issues section of the debugging guide and verify what what the status of the heap is in the events leading up to the behavior and once the device hands?

    The ICall Abort section also provides some more information on why the abort may be occurring.

    Best Regards,

    Jan