|
楼主 |
发表于 2021-1-25 11:24:35
|
显示全部楼层
本帖最后由 lolifrog 于 2021-1-25 11:27 编辑
请问一下蓝牙主机可以找到DFU服务,却发现不了下面的特征是什么原因?
我用hrs的一个例子并把它的UUID改成DFU的
初始化函数:
- uint32_t ble_hrs_c_init(ble_hrs_c_t * p_ble_hrs_c, ble_hrs_c_init_t * p_ble_hrs_c_init)
- {
- uint32_t err_code;
- VERIFY_PARAM_NOT_NULL(p_ble_hrs_c);
- VERIFY_PARAM_NOT_NULL(p_ble_hrs_c_init);
- uint8_t dfu_uuid_type;
- ble_uuid_t dfu_uuid;
- ble_uuid_t dfu_nus_uuid;
- //DFU_BASE_UUID = {{0xfb,0x34,0x9b,0x5f,0x80,0x00,0x00,0x80,0x00,0x10,0x00,0x00,0x0,0x0,0x00,0x00}};
- // 从Android Studio找到的128位dfu base UUID
- ble_uuid128_t dfu_base_uuid = DFU_BASE_UUID;
- err_code = sd_ble_uuid_vs_add(&dfu_base_uuid, &dfu_uuid_type);
- VERIFY_SUCCESS(err_code);
- dfu_uuid.type = dfu_uuid_type;
- dfu_uuid.uuid = BLE_DFU_SERVER_UUID; //0xFE59
- p_ble_hrs_c->evt_handler = p_ble_hrs_c_init->evt_handler;
- p_ble_hrs_c->error_handler = p_ble_hrs_c_init->error_handler;
- p_ble_hrs_c->p_gatt_queue = p_ble_hrs_c_init->p_gatt_queue;
- p_ble_hrs_c->conn_handle = BLE_CONN_HANDLE_INVALID;
- p_ble_hrs_c->peer_hrs_db.hrm_cccd_handle = BLE_GATT_HANDLE_INVALID;
- p_ble_hrs_c->peer_hrs_db.hrm_handle = BLE_GATT_HANDLE_INVALID;
- return ble_db_discovery_evt_register(&dfu_uuid);
- }
复制代码
发现到服务的处理函数里只是输出当前的服务uuid和特征uuid- void ble_hrs_on_db_disc_evt(ble_hrs_c_t * p_ble_hrs_c, const ble_db_discovery_evt_t * p_evt)
- {
- NRF_LOG_INFO("discovered_db.srv_uuid.uuid :%x",p_evt->params.discovered_db.srv_uuid.uuid);
- // Check if the Heart Rate Service was discovered.
- if (p_evt->evt_type == BLE_DB_DISCOVERY_COMPLETE &&
- p_evt->params.discovered_db.srv_uuid.uuid == BLE_DFU_SERVER_UUID &&
- p_evt->params.discovered_db.srv_uuid.type == BLE_UUID_TYPE_BLE)
- {
- NRF_LOG_INFO("discovered_db.char_count:%x",p_evt->params.discovered_db.char_count);
- NRF_LOG_INFO("discovered_db.charateristics[i].uuid:%d",p_evt->params.discovered_db.charateristics[0].characteristic.uuid.uuid);
-
- }
- }
复制代码
结果就是可以发现DFU的服务0xfe59,但找不到它下面的特征,只有一个uuid=0的特征。请问这该怎么解决?
谢谢!
|
|