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: [CC2340R5]How to register Notify and write char in central?

Expert 1075 points
Part Number: CC2340R5

Hi Ti Experts.

I need to make a central role to connect peripherals.

I have completed Scan and connect.

Next, when I wanted to discover services, he did not respond to any events.

void Central_disc_start()
{
  uint8_t uuid[ATT_BT_UUID_SIZE] = { gServiceUUID[1],gServiceUUID[0]};
  // Initialize service discovery variables
  svcStartHdl = svcEndHdl = charHdl = 0;

  // Discover service by UUID
  //bStatus_t status = GATT_DiscPrimaryServiceByUUID(Connection_getConnhandle(0), uuid,
  //                               ATT_BT_UUID_SIZE, ICall_getEntityId());
  bStatus_t status = GATT_DiscAllPrimaryServices(Connection_getConnhandle(0),/*ICall_getEntityId()*/INVALID_TASK_ID);
  PRINT_DATA("[weli]%s-%d,status:%d\r\n",__FUNCTION__,__LINE__,status);
}

the log as below.

[weli]Central_disc_start-568,status:0

But when I change INVALID_TASK_ID to ICall_getEntityId(), the GATT_EventHandler will return event:4 when I call Central_disc_start.

static void GATT_EventHandler(uint32 event, BLEAppUtil_msgHdr_t *pMsgData)
{
  PRINT_DATA("[weli]%s-%d:event:%d\r\n",__FUNCTION__,__LINE__,event);
  //response event:4
  gattMsgEvent_t *gattMsg = ( gattMsgEvent_t * )pMsgData;
  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;


    default:
      break;
  }
}

In addition, I have set Gatt's event mask to 0xffff,

BLEAppUtil_EventHandler_t dataGATTHandler =
{
    .handlerType    = BLEAPPUTIL_GATT_TYPE,
    .pEventHandler  = GATT_EventHandler,
    .eventMask      = 0xffff//BLEAPPUTIL_ATT_FLOW_CTRL_VIOLATED_EVENT |
                      //BLEAPPUTIL_ATT_MTU_UPDATED_EVENT
};

Please tell me if I missed anything.

Also, are there any tutorials on discovering service notify characteristics?

Thanks.