TI中文支持网
TI专业的中文技术问题搜集分享网站

CC2640R2 如何处理收到的 “prepare write request” 命令?

处理器:CC2640R2

协议栈:simplelink_cc2640r2_sdk_1_50_00_58

问题描述:

1、IOS APP 一次性发送 10K 数据给 CC2640R2 模块,会自动使用 “prepare write request” 命令,我想将收到的数据通过串口打印出来,请问这个命令如何在协议栈的应用层处理?

Alvin Chen:

Prepare Write commands allows a GATT server to send more payload data by queuing up multiple write requests. The default queue size is 5. With a default MTU of 23 and payload of 18 bytes, up to 90 bytes of payload can be sent. For more information on queued writes, refer to the Queued Writes section ([Vol 3], Part F, Section 3.4.6) of the Bluetooth Core Specification Version 4.2.
这是一个GATT 的命令,如果需要获取可以在下面的函数里面获取event
static uint8_t SimplePeripheral_processGATTMsg(gattMsgEvent_t *pMsg)

Jesse Huang:

回复 Alvin Chen:

接收不了啊,收到命令后到不了这里。

static void SerialSocketServer_init(void)

{

// Set up services. GGS_AddService(GATT_ALL_SERVICES); // GAP GATTServApp_AddService(GATT_ALL_SERVICES); // GATT attributes

}

static void SerialSocketServer_taskFxn(UArg a0, UArg a1)

{

   // Initialize application

   SerialSocketServer_init();

   // Application main loop

   for (;;)

   {

       uint32_t events;

       events = Event_pend(syncEvent, Event_Id_NONE, SSSS_ALL_EVENTS, ICALL_TIMEOUT_FOREVER);

       if (events)

       {

           ICall_EntityID dest;

           ICall_ServiceEnum src;

           ICall_HciExtEvt *pMsg = NULL;

           if (ICall_fetchServiceMsg(&src, &dest, (void **)&pMsg) == ICALL_ERRNO_SUCCESS)

           {

               uint8 safeToDealloc = TRUE;

               if ((src == ICALL_SERVICE_CLASS_BLE) && (dest == selfEntity))

               {

                 ICall_Stack_Event *pEvt = (ICall_Stack_Event *)pMsg;

                 if (pEvt->signature != 0xffff)

                 {

                   // Process inter-task message

                   safeToDealloc = SimpleSerialSocketServer_processStackMsg((ICall_Hdr *)pMsg);

                 }

               }

               if (pMsg && safeToDealloc)

               {

                 ICall_freeMsg(pMsg);

               }

           }

……

}

static uint8_t SimpleSerialSocketServer_processStackMsg(ICall_Hdr *pMsg){ uint8_t safeToDealloc = TRUE;

switch (pMsg->event) { case GAP_MSG_EVENT: { SimpleSerialSocketServer_processGapMessage((gapEventHdr_t*) pMsg); } break;

case GATT_MSG_EVENT: case GATT_SERV_MSG_EVENT: { SerialSocket_ProcessGATTMsg( (gattMsgEvent_t *)pMsg ); } break;

default: break;

}

return (safeToDealloc);}

Alvin Chen:

回复 Jesse Huang:

SerialSocket_ProcessGATTMsg 进不去吗? gattMsgEvent_t;里面的gattMsg_t包含了prepareWriteReq

typedef union
{// Request messagesattExchangeMTUReq_t exchangeMTUReq;//!< ATT Exchange MTU RequestattFindInfoReq_t findInfoReq;//!< ATT Find Information RequestattFindByTypeValueReq_t findByTypeValueReq;//!< ATT Find By Type Value RequestattReadByTypeReq_t readByTypeReq;//!< ATT Read By Type RequestattReadReq_t readReq;//!< ATT Read RequestattReadBlobReq_t readBlobReq;//!< ATT Read Blob RequestattReadMultiReq_t readMultiReq;//!< ATT Read Multiple RequestattReadByGrpTypeReq_t readByGrpTypeReq;//!< ATT Read By Group Type RequestattWriteReq_t writeReq;//!< ATT Write RequestattPrepareWriteReq_t prepareWriteReq;//!< ATT Prepare Write RequestattExecuteWriteReq_t executeWriteReq;//!< ATT Execute Write RequestgattFindByTypeValueReq_t gattFindByTypeValueReq; //!< GATT Find By Type Value RequestgattReadByTypeReq_t gattReadByTypeReq;//!< GATT Read By Type RequestgattWriteLongReq_t gattWriteLongReq;//!< GATT Long Write RequestgattReliableWritesReq_t gattReliableWritesReq;//!< GATT Reliable Writes Request// Response messagesattErrorRsp_t errorRsp;//!< ATT Error ResponseattExchangeMTURsp_t exchangeMTURsp;//!< ATT Exchange MTU ResponseattFindInfoRsp_t findInfoRsp;//!< ATT Find Information ResponseattFindByTypeValueRsp_t findByTypeValueRsp;//!< ATT Find By Type Value ResponseattReadByTypeRsp_t readByTypeRsp;//!< ATT Read By Type ResponseattReadRsp_t readRsp;//!< ATT Read ResponseattReadBlobRsp_t readBlobRsp;//!< ATT Read Blob ResponseattReadMultiRsp_t readMultiRsp;//!< ATT Read Multiple ResponseattReadByGrpTypeRsp_t readByGrpTypeRsp;//!< ATT Read By Group Type ResponseattPrepareWriteRsp_t prepareWriteRsp;//!< ATT Prepare Write Response// Indication and Notification messagesattHandleValueNoti_t handleValueNoti;//!< ATT Handle Value NotificationattHandleValueInd_t handleValueInd;//!< ATT Handle Value Indication// Locally-generated event messagesattFlowCtrlViolatedEvt_t flowCtrlEvt;//!< ATT Flow Control Violated EventattMtuUpdatedEvt_t mtuEvt;//!< ATT MTU Updated Event
} gattMsg_t;

Jesse Huang:

回复 Alvin Chen:

不行,这个连 ATT_WRITE_REQ 都收不到,ATT_WRITE_REQ 的回调函数是这里的。

 // Register GATT attribute list and CBs with GATT Server App

 status = GATTServApp_RegisterService( StreamServerAttrTbl,

                                       GATT_NUM_ATTRS( StreamServerAttrTbl ),

                                       GATT_MAX_ENCRYPT_KEY_SIZE,

                                       &StreamServerCBs );

typedef struct{      pfnGATTReadAttrCB_t pfnReadAttrCB; //!< Read callback function pointer      pfnGATTWriteAttrCB_t pfnWriteAttrCB; //!< Write callback function pointer      pfnGATTAuthorizeAttrCB_t pfnAuthorizeAttrCB; //!< Authorization callback function pointer} gattServiceCBs_t;

这里可以处理 write request 命令。

Alvin Chen:

回复 Jesse Huang:

write request 和read request 是用GATTServApp_RegisterService注册了回调。这个我要找AE去测试一下为什么不去触发这个event. 有后续会更新到这个帖子。

Jesse Huang:

回复 Alvin Chen:

好的,麻烦你了。

Jesse Huang:

回复 Alvin Chen:

Hi, Alvin.

请问有最新的消息吗?

Jesse Huang:

回复 Alvin Chen:

请问能快点吗,项目急用,现在要换别的芯片的话有点赶。

Alvin Chen:

回复 Jesse Huang:

已经assign给了相应的同事,我也在等回复我已经催促过了。

Alvin Chen:

回复 Alvin Chen:

ATT Prepare Write Request 在我们stack 层处理不会给应用层indication.换言之客户无需处理。

赞(0)
未经允许不得转载:TI中文支持网 » CC2640R2 如何处理收到的 “prepare write request” 命令?
分享到: 更多 (0)