From 681f1afeb1f9290c4416a3a1ef76eb740168e4c3 Mon Sep 17 00:00:00 2001 From: "matthias.ringwald@gmail.com" <matthias.ringwald@gmail.com@1a0a8af8-31b5-11de-8e0c-53a27eea117e> Date: Fri, 18 Oct 2013 14:48:08 +0000 Subject: [PATCH] continue SDP query in daemon --- src/daemon.c | 26 +++++++++++++++++++++++--- src/hci_cmds.c | 2 +- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/src/daemon.c b/src/daemon.c index 374a20777..c8e6940d2 100644 --- a/src/daemon.c +++ b/src/daemon.c @@ -131,6 +131,9 @@ static int rfcomm_channel_generator = 1; static uint8_t attribute_value[1000]; static const int attribute_value_buffer_size = sizeof(attribute_value); +static uint8_t serviceSearchPattern[200]; +static uint8_t attributeIDList[50]; + static int loggingEnabled; @@ -157,6 +160,9 @@ static int btstack_command_handler(connection_t *connection, uint8_t *packet, ui uint32_t service_record_handle; client_state_t *client; + uint16_t serviceSearchPatternLen; + uint16_t attributeIDListLen; + // BTstack internal commands - 16 Bit OpCode, 8 Bit ParamLen, Params... switch (READ_CMD_OCF(packet)){ case BTSTACK_GET_STATE: @@ -327,16 +333,30 @@ static int btstack_command_handler(connection_t *connection, uint8_t *packet, ui log_info("SDP_UNREGISTER_SERVICE_RECORD handle 0x%x ", service_record_handle); sdp_unregister_service_internal(connection, service_record_handle); break; - case SDP_CLIENT_QUERY_RFCOMM_SERVICES: + case SDP_CLIENT_QUERY_RFCOMM_SERVICES: bt_flip_addr(addr, &packet[3]); + + serviceSearchPatternLen = de_get_len(&packet[9]); + memcpy(serviceSearchPattern, &packet[9], serviceSearchPatternLen); + sdp_query_rfcomm_register_callback(handle_sdp_rfcomm_service_result, connection); - sdp_query_rfcomm_channel_and_name_for_search_pattern(addr, &packet[9]); + sdp_query_rfcomm_channel_and_name_for_search_pattern(addr, serviceSearchPattern); + break; case SDP_CLIENT_QUERY_SERVICES: bt_flip_addr(addr, &packet[3]); sdp_parser_init(); sdp_parser_register_callback(handle_sdp_client_query_result); - sdp_general_query_for_uuid(addr, 0x1002); + + serviceSearchPatternLen = de_get_len(&packet[9]); + memcpy(serviceSearchPattern, &packet[9], serviceSearchPatternLen); + + attributeIDListLen = de_get_len(&packet[9+serviceSearchPatternLen]); + memcpy(attributeIDList, &packet[9+serviceSearchPatternLen], attributeIDListLen); + + sdp_client_query(addr, (uint8_t*)&serviceSearchPattern[0], (uint8_t*)&attributeIDList[0]); + + // sdp_general_query_for_uuid(addr, 0x1002); break; default: log_error("Error: command %u not implemented\n:", READ_CMD_OCF(packet)); diff --git a/src/hci_cmds.c b/src/hci_cmds.c index 79b13c3db..1b6eea665 100644 --- a/src/hci_cmds.c +++ b/src/hci_cmds.c @@ -677,7 +677,7 @@ OPCODE(OGF_BTSTACK, SDP_CLIENT_QUERY_RFCOMM_SERVICES), "BS" }; const hci_cmd_t sdp_client_query_services = { -OPCODE(OGF_BTSTACK, SDP_CLIENT_QUERY_SERVICES), "BS" +OPCODE(OGF_BTSTACK, SDP_CLIENT_QUERY_SERVICES), "BSS" // @param service record handle (32) };