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.

[参考译文] CC2652R:在哪里启用中央通知?

Guru**** 2874030 points
请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/wireless-connectivity/bluetooth-group/bluetooth/f/bluetooth-forum/1047803/cc2652r-where-to-enable-central-notifications

器件型号:CC2652R

我编写了一个可通过 simple_central .c 中的菜单访问的小函数

/*********************************************************************
 * @fn      SimpleCentral_enableNotif
 *
 * @brief   Enable Notifications
 *
 * @param   index - NOT USED
 *
 * @return  always true
 */
bool SimpleCentral_enableNotif(uint8_t index) {
	uint8_t connIndex = SimpleCentral_getConnIndex(scConnHandle);

	status_t status;
	attWriteReq_t req;
	req.pValue = GATT_bm_alloc(scConnHandle, ATT_WRITE_REQ, 2, NULL);
	if (req.pValue != NULL) {
		req.handle = connList[connIndex].charHandle;
		req.len = 2;
		req.pValue[0] = LO_UINT16(GATT_CLIENT_CFG_NOTIFY);
		req.pValue[1] = HI_UINT16(GATT_CLIENT_CFG_NOTIFY);
		req.sig = 0;
		req.cmd = 0;

		status = GATT_WriteCharValue(scConnHandle, &req, selfEntity);
		if (status != SUCCESS) {
			GATT_bm_free((gattMsg_t*) &req, ATT_WRITE_REQ);
		}
	}

	return (true);
}

在  遇到 BLE_DISC_State_char 并且已设置 charHandle 后调用此函数。 我从函数中获取状态= 0x00、但在  SimpleCentral_processGATTMsg 中、我最终会遇到写入错误(0x03)。 我对启用这些通知非常困惑。 它们在我的 iPhone 中央应用程序上工作、因此我知道外设设置正确、订阅后会推送通知。

此示例 非常有用、非常接近我所做的工作。 那么、我假设它与句柄有关、我是否需要找到要通过的 CCCD? 以及如何实现?

SDK 5.20.00.52

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好!

    共享的代码写入一个长度为1字节的特定特征。 当您写入两个字节时、写入会被拒绝。

    现在、如果要打开通知、则必须在 CCCD 中写入(而不是在特征本身中写入)。

    您可以查看 simple_serial_socket_client 示例以了解如何完成此操作。

    我希望这将有所帮助、

    此致、

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    谢谢、Clement。 基本上、我选择了该示例中的所有结构和函数、并最终使其正常工作。 我在上面提到的这个示例可能起作用、前提是您先验地知道 CCCD、它是 simple_central .c 中尚未存在但在套接字示例文件树中存在的大量工作负载。

    对于任何其他人,请注意,此代码仍会在 SimpleCentral_enableNotif()中手动选择第0个特征,这目前还可以,因为我现在只有一个特征: https://github.com/mattgaidica/simple_central_CC26X2R1_ESLO_SPEAKER/tree/2f4f85e6813d3344768a92fe54ccedb5f3d5c0ac 它还 将 UUID 字段修改为 uint_8*2 (即 uint_16),并且仍具有来自 simple_central 的一些保留区,但它可以操作,如果外设确实在推送通知,则会遇到 pMsg->method =ATT_handle_value_noti。