我们实际应用中,经常会遇到修改UUID的应用,默认SDK的UUID是16位,现在介绍修改方法 1) 2) void service_tspp_init(void) { ble_uuid_t ble_uuid; ble_gatts_char_handles_t handles; uint8_t tspp_uuid_type; static const ble_uuid128_t tspp_vs_uuid = { {0x1F, 0x77, 0x8A, 0xAB, 0x78, 0x7D, 0xA3, 0xB6, 0xBE, 0x41, 0x82, 0xE5, 0x00, 0x00, 0x66, 0xFE}}; ble_uuid_vs_add(&tspp_vs_uuid, &tspp_uuid_type); ble_uuid.type = tspp_uuid_type; ble_uuid.uuid = 0x0001; // BLE_UUID_BLE_ASSIGN(ble_uuid, 0xFF01); // TSPP service UUID sd_ble_gatts_service_add(BLE_GATTS_SRVC_TYPE_PRIMARY, &ble_uuid, &m_start_handle); ble_gatts_char_md_t char_md; ble_gatts_attr_t attr_char_value; ble_gatts_attr_md_t attr_md; ble_gatts_attr_md_t cccd_md; memset(&attr_char_value, 0, sizeof(attr_char_value)); memset(&attr_md, 0, sizeof(attr_md)); memset(&char_md, 0, sizeof(char_md)); attr_md.vloc = BLE_GATTS_VLOC_USER; char_md.char_props.write_wo_resp = 1; char_md.char_props.write = 1; ble_uuid.uuid = 0x0002; // BLE_UUID_BLE_ASSIGN(ble_uuid, 0xFF02); // TSPP write command characteristic uuid attr_char_value.p_uuid = &ble_uuid; attr_char_value.p_attr_md = &attr_md; sd_ble_gatts_characteristic_add(m_start_handle, &char_md, &attr_char_value, &handles); memset(&char_md, 0, sizeof(char_md)); memset(&attr_char_value, 0, sizeof(attr_char_value)); memset(&cccd_md, 0, sizeof(cccd_md)); char_md.char_props.notify = 1; char_md.p_cccd_md = &cccd_md; ble_uuid.uuid = 0x0003; // BLE_UUID_BLE_ASSIGN(ble_uuid, 0xFF03); // TSPP notify characteristic uuid attr_char_value.p_uuid = &ble_uuid; attr_char_value.p_attr_md = &attr_md; sd_ble_gatts_characteristic_add(m_start_handle, &char_md, &attr_char_value, &handles); co_fifo_init(&tspp_fifo, tspp_buffer, TSPP_BUFFER_SIZE); } 3)服务UUID修改后 |