主题中讨论的其他器件:CC2652RB
大家好、
我使用 simplelink_cc13xx_cc26xx_sdk_7_10_01_24 SDK、这是 CC2652RB 的 simple_central 示例
e2e.ti.com/.../2860.simple_5F00_central_5F00_LP_5F00_CC2652RB_5F00_tirtos7_5F00_ticlang.zip
在服务器端、我每100ms 通知一次 I byte 数据、我可以在手机上接收该数据。 我希望使用我们的 LP cc2652rb EVM 板和使用简单的中央示例接收该通知。 我从 该线程迁移代码。 我将服务器端的服务和特征 uuid 设置为与启用 simple_central 相同。 以下是示例中添加的2个主要 fxn、您是否需要指导我如何接收通知? 我的代码中遗漏了什么?
bool SimpleCentral_enableNotif(uint8_t index) {
// Process message.
attWriteReq_t req;
bStatus_t retVal = FAILURE;
uint8 configData[2] = { 0x01, 0x00 };
req.pValue = GATT_bm_alloc(scConnHandle, ATT_WRITE_REQ, 2, NULL);
uint8_t connIndex = SimpleCentral_getConnIndex(scConnHandle);
SIMPLECENTRAL_ASSERT(connIndex < MAX_NUM_BLE_CONNS);
// Enable notify for outgoing data Notification
if ((req.pValue != NULL) && streamServiceHandle.chars[0].cccdHandle) {
req.handle = streamServiceHandle.chars[0].cccdHandle;
req.len = 2;
memcpy(req.pValue, configData, 2);
req.cmd = TRUE;
req.sig = FALSE;
retVal = GATT_WriteNoRsp(scConnHandle, &req);
Display_printf(dispHandle, SC_ROW_NON_CONN, 0, "gatt read 0x%02x",
retVal);
}
if (retVal == SUCCESS) {
return (true);
}
return (false);
}
static void SimpleCentral_processGATTMsg(gattMsgEvent_t *pMsg) {
if (linkDB_Up(pMsg->connHandle)) {
// See if GATT server was unable to transmit an ATT response
if (pMsg->hdr.status == blePending) {
// No HCI buffer was available. App can try to retransmit the response
// on the next connection event. Drop it for now.
Display_printf(dispHandle, SC_ROW_CUR_CONN, 0, "ATT Rsp dropped %d",
pMsg->method);
} else if ((pMsg->method == ATT_READ_RSP)
|| ((pMsg->method == ATT_ERROR_RSP)
&& (pMsg->msg.errorRsp.reqOpcode == ATT_READ_REQ))) {
if (pMsg->method == ATT_ERROR_RSP) {
Display_printf(dispHandle, SC_ROW_CUR_CONN, 0, "Read Error %d",
pMsg->msg.errorRsp.errCode);
} else {
// After a successful read, display the read value
Display_printf(dispHandle, SC_ROW_CUR_CONN, 0,
"Read rsp: 0x%02x", pMsg->msg.readRsp.pValue[0]);
}
} else if ((pMsg->method == ATT_WRITE_RSP)
|| ((pMsg->method == ATT_ERROR_RSP)
&& (pMsg->msg.errorRsp.reqOpcode == ATT_WRITE_REQ))) {
if (pMsg->method == ATT_ERROR_RSP) {
Display_printf(dispHandle, SC_ROW_CUR_CONN, 0, "Write Error %d",
pMsg->msg.errorRsp.errCode);
} else {
// After a successful write, display the value that was written and
// increment value
Display_printf(dispHandle, SC_ROW_CUR_CONN, 0,
"Write sent: 0x%02x", charVal);
}
tbm_goTo(&scMenuPerConn);
} else if (pMsg->method == ATT_HANDLE_VALUE_NOTI) {
// Matt
Display_printf(dispHandle, SC_ROW_CUR_CONN, 0,
"Notification: 0x%02x",
pMsg->msg.handleValueNoti.pValue[0]);
} else if (pMsg->method == ATT_FLOW_CTRL_VIOLATED_EVENT) {
// ATT request-response or indication-confirmation flow control is
// violated. All subsequent ATT requests or indications will be dropped.
// The app is informed in case it wants to drop the connection.
// Display the opcode of the message that caused the violation.
Display_printf(dispHandle, SC_ROW_CUR_CONN, 0, "FC Violated: %d",
pMsg->msg.flowCtrlEvt.opcode);
} else if (pMsg->method == ATT_MTU_UPDATED_EVENT) {
// MTU size updated
Display_printf(dispHandle, SC_ROW_CUR_CONN, 0, "MTU Size: %d",
pMsg->msg.mtuEvt.MTU);
} else if (discState != BLE_DISC_STATE_IDLE) {
SimpleCentral_processGATTDiscEvent(pMsg);
}
} // else - in case a GATT message came after a connection has dropped, ignore it.
// Needed only for ATT Protocol messages
GATT_bm_free(&pMsg->msg, pMsg->method);
}
马修