完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
#define BLE_HCI_STATUS_CODE_SUCCESS 0x00
#define BLE_HCI_STATUS_CODE_UNKNOWN_BTLE_COMMAND 0x01 #define BLE_HCI_STATUS_CODE_UNKNOWN_CONNECTION_IDENTIFIER 0x02 #define BLE_HCI_AUTHENTICATION_FAILURE 0x05 #define BLE_HCI_STATUS_CODE_PIN_OR_KEY_MISSING 0x06 #define BLE_HCI_MEMORY_CAPACITY_EXCEEDED 0x07 #define BLE_HCI_CONNECTION_TIMEOUT 0x08 #define BLE_HCI_STATUS_CODE_COMMAND_DISALLOWED 0x0C #define BLE_HCI_STATUS_CODE_INVALID_BTLE_COMMAND_PARAMETERS 0x12 #define BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION 0x13 #define BLE_HCI_REMOTE_DEV_TERMINATION_DUE_TO_LOW_RESOURCES 0x14 #define BLE_HCI_REMOTE_DEV_TERMINATION_DUE_TO_POWER_OFF 0x15 #define BLE_HCI_LOCAL_HOST_TERMINATED_CONNECTION 0x16 #define BLE_HCI_UNSUPPORTED_REMOTE_FEATURE 0x1A #define BLE_HCI_STATUS_CODE_INVALID_LMP_PARAMETERS 0x1E #define BLE_HCI_STATUS_CODE_UNSPECIFIED_ERROR 0x1F #define BLE_HCI_STATUS_CODE_LMP_RESPONSE_TIMEOUT 0x22 #define BLE_HCI_STATUS_CODE_LMP_ERROR_TRANSACTION_COLLISION 0x23 #define BLE_HCI_STATUS_CODE_LMP_PDU_NOT_ALLOWED 0x24 #define BLE_HCI_INSTANT_PASSED 0x28 #define BLE_HCI_PAIRING_WITH_UNIT_KEY_UNSUPPORTED 0x29 #define BLE_HCI_DIFFERENT_TRANSACTION_COLLISION 0x2A #define BLE_HCI_PARAMETER_OUT_OF_MANDATORY_RANGE 0x30 #define BLE_HCI_CONTROLLER_BUSY 0x3A #define BLE_HCI_CONN_INTERVAL_UNACCEPTABLE 0x3B #define BLE_HCI_DIRECTED_ADVERTISER_TIMEOUT 0x3C #define BLE_HCI_CONN_TERMINATED_DUE_TO_MIC_FAILURE 0x3D #define BLE_HCI_CONN_FAILED_TO_BE_ESTABLISHED 0x3E |
|
|
|
主机用的是CH573,使用的是Central例程,蓝牙设备是N21的NB模组,我修改例程中的MAC地址和UUID后可以跟N21模组连接上,并通过UUID=0XFFF0获取到主服务,
Waiting for advertising.. [22-04-24 16:33:25.634]MTU: f6 [22-04-24 16:33:25.711] [22-04-24 16:33:26.397]exchange mtu:23 [22-04-24 16:33:26.397]MTU: 17 [22-04-24 16:33:26.554]Found Profile Service handle : 1d ~ 27 [22-04-24 16:33:26.704] [22-04-24 16:33:28.532]Param Update... 再通过UUID=0XFFF2获取handle时,获取不到,如果我不获取handle,直接将handle设置为0x24,就可以和N21模组正常收发数据。这是什么原因? |
|
|
|
以下是更改后的UUID
#define SIMPLEPROFILE_SERV_UUID 0xFFF0 // Key Pressed UUID #define SIMPLEPROFILE_CHAR1_UUID 0xFFF1 #define SIMPLEPROFILE_CHAR2_UUID 0xFFF2 #define SIMPLEPROFILE_CHAR3_UUID 0xFFF3 #define SIMPLEPROFILE_CHAR4_UUID 0xFFF4 #define SIMPLEPROFILE_CHAR5_UUID 0xFFF5 if(pMsg->method == ATT_FIND_BY_TYPE_VALUE_RSP && pMsg->msg.findByTypeValueRsp.numInfo > 0) { centralSvcStartHdl = ATT_ATTR_HANDLE(pMsg->msg.findByTypeValueRsp.pHandlesInfo, 0); centralSvcEndHdl = ATT_GRP_END_HANDLE(pMsg->msg.findByTypeValueRsp.pHandlesInfo, 0); // Display Profile Service handle range PRINT("Found Profile Service handle : %x ~ %x n", centralSvcStartHdl, centralSvcEndHdl); } // If procedure complete if((pMsg->method == ATT_FIND_BY_TYPE_VALUE_RSP && //ATT按类型查找值响应 pMsg->hdr.status == bleProcedureComplete) || //程序完成了 (pMsg->method == ATT_ERROR_RSP)) { if(centralSvcStartHdl != 0) { // Discover characteristic centralDiscState = BLE_DISC_STATE_CHAR; req.startHandle = centralSvcStartHdl; req.endHandle = centralSvcEndHdl; req.type.len = ATT_BT_UUID_SIZE; req.type.uuid[0] = LO_UINT16(SIMPLEPROFILE_CHAR2_UUID); req.type.uuid[1] = HI_UINT16(SIMPLEPROFILE_CHAR2_UUID); GATT_ReadUsingCharUUID(centralConnHandle, &req, centralTaskId); // centralCharHdl = 0x24; // centralProcedureInProgress = FALSE; // // // Start do read or write // tmos_start_task(centralTaskId, START_READ_OR_WRITE_EVT, DEFAULT_READ_OR_WRITE_DELAY); // // // Display Characteristic 1 handle // PRINT("Found Characteristic 1 handle : %x n", centralCharHdl); // centralDiscState = BLE_DISC_STATE_IDLE; } } } else if(centralDiscState == BLE_DISC_STATE_CHAR) { // Characteristic found, store handle if(pMsg->method == ATT_READ_BY_TYPE_RSP && pMsg->msg.readByTypeRsp.numPairs > 0) { centralCharHdl = BUILD_UINT16(pMsg->msg.readByTypeRsp.pDataList[0], pMsg->msg.readByTypeRsp.pDataList[1]); centralProcedureInProgress = FALSE; // Start do read or write tmos_start_task(centralTaskId, START_READ_OR_WRITE_EVT, DEFAULT_READ_OR_WRITE_DELAY); // Display Characteristic 1 handle PRINT("Found Characteristic 1 handle : %x n", centralCharHdl); } centralDiscState = BLE_DISC_STATE_IDLE; } 将GATT_ReadUsingCharUUID(centralConnHandle, &req, centralTaskId);屏蔽,直接用注释掉的代码,就可以和从设备正常通信了。 |
|
|
|
只有小组成员才能发言,加入小组>>
522 浏览 1 评论
CH579M+RT-Thread,RTC从Sleep模式唤醒失败是什么原因?
2903 浏览 2 评论
2399 浏览 1 评论
867浏览 2评论
687浏览 1评论
riscv-none-embed-objcopy: \'PWM_Output.elf\': No such file这个咋解决,
417浏览 1评论
522浏览 1评论
请教一下,Mounriver 编译不成功:找不到库文件,怎么整
812浏览 1评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-23 04:06 , Processed in 1.082543 second(s), Total 50, Slave 43 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号