From 7fbb5f59ef9d20fd850335e773f5a31631ca7a31 Mon Sep 17 00:00:00 2001 From: Matthias Ringwald Date: Thu, 17 Mar 2016 10:42:14 +0100 Subject: [PATCH] sdp_client: use sdp_client_query prefix for rfcomm queries --- doc/manual/btstack_gettingstarted.tex | 2 +- doc/manual/docs/protocols.md | 8 ++++---- example/sdp_rfcomm_query.c | 2 +- example/spp_streamer.c | 2 +- platform/daemon/src/daemon.c | 2 +- src/classic/hfp.c | 2 +- src/classic/hsp_ag.c | 2 +- src/classic/hsp_hs.c | 2 +- src/classic/sdp_query_rfcomm.c | 24 ++++++++++++------------ src/classic/sdp_query_rfcomm.h | 6 +++--- test/hfp/mock.c | 12 ++++++------ test/pts/classic_test.c | 2 +- test/pts/hfp_test.c | 2 +- test/sdp_client/mock.h | 2 +- test/sdp_client/sdp_rfcomm_query.c | 2 +- tool/migration_to_v1.0/migration.cocci | 22 +++++++++++----------- 16 files changed, 47 insertions(+), 47 deletions(-) diff --git a/doc/manual/btstack_gettingstarted.tex b/doc/manual/btstack_gettingstarted.tex index 732c1332e..ab2c2511b 100644 --- a/doc/manual/btstack_gettingstarted.tex +++ b/doc/manual/btstack_gettingstarted.tex @@ -62,7 +62,7 @@ stringstyle=\color{blue}, morekeywords={*, btstack_timer_source_t, btstack_data_source_t, uint32_t, uint16_t, uint8_t, btstack_run_loop_TYPE, le_command_status_t, gatt_client_t, gatt_client_characteristic_t, gatt_client_service_t, gatt_client_characteristic_descriptor_t, service_record_item_t, bd_addr_t, btstack_packet_handler_t, hci_cmd_t, btstack_control_t, remote_device_db_t, link_key_t, device_name_t, hci_transport_t, hci_uart_config_t, sdp_query_event_t, - sdp_query_complete_event_t, sdp_query_rfcomm_service_event_t, sdp_parser_event_t, sdp_parser_event_type_t, + sdp_query_complete_event_t, sdp_client_query_rfcomm_service_event_t, sdp_parser_event_t, sdp_parser_event_type_t, sdp_parser_attribute_value_event_t, sdp_parser_complete_event_t, advertising_report_t, gc_state_t, le_service_event_t, le_characteristic_event_t} } diff --git a/doc/manual/docs/protocols.md b/doc/manual/docs/protocols.md index 23a9e47d2..f2a21c455 100644 --- a/doc/manual/docs/protocols.md +++ b/doc/manual/docs/protocols.md @@ -648,7 +648,7 @@ registered callback, as shown in Listing [below](#lst:SDPClientRFCOMM). case BTSTACK_EVENT_STATE: // bt stack activated, get started if (packet[2] == HCI_STATE_WORKING){ - sdp_query_rfcomm_channel_and_name_for_uuid(remote, 0x0003); + sdp_client_query_rfcomm_channel_and_name_for_uuid(remote, 0x0003); } break; default: @@ -664,11 +664,11 @@ registered callback, as shown in Listing [below](#lst:SDPClientRFCOMM). } void handle_query_rfcomm_event(sdp_query_event_t * event, void * context){ - sdp_query_rfcomm_service_event_t * ve; + sdp_client_query_rfcomm_service_event_t * ve; switch (event->type){ case SDP_EVENT_QUERY_RFCOMM_SERVICE: - ve = (sdp_query_rfcomm_service_event_t*) event; + ve = (sdp_client_query_rfcomm_service_event_t*) event; printf("Service name: '%s', RFCOMM port %u\n", ve->service_name, ve->channel_nr); break; case SDP_EVENT_QUERY_COMPLETE: @@ -684,7 +684,7 @@ registered callback, as shown in Listing [below](#lst:SDPClientRFCOMM). // register callback to receive matching RFCOMM Services and // query complete event - sdp_query_rfcomm_register_callback(handle_query_rfcomm_event, NULL); + sdp_client_query_rfcomm_register_callback(handle_query_rfcomm_event, NULL); // turn on! hci_power_control(HCI_POWER_ON); diff --git a/example/sdp_rfcomm_query.c b/example/sdp_rfcomm_query.c index 047bc1591..deab8efcd 100644 --- a/example/sdp_rfcomm_query.c +++ b/example/sdp_rfcomm_query.c @@ -78,7 +78,7 @@ static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packe case BTSTACK_EVENT_STATE: // bt stack activated, get started if (packet[2] == HCI_STATE_WORKING){ - sdp_query_rfcomm_channel_and_name_for_uuid(&handle_query_rfcomm_event, remote, SDP_PublicBrowseGroup); + sdp_client_query_rfcomm_channel_and_name_for_uuid(&handle_query_rfcomm_event, remote, SDP_PublicBrowseGroup); } break; default: diff --git a/example/spp_streamer.c b/example/spp_streamer.c index bb957772a..8cf161492 100644 --- a/example/spp_streamer.c +++ b/example/spp_streamer.c @@ -124,7 +124,7 @@ static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *pack case BTSTACK_EVENT_STATE: // bt stack activated, get started if (packet[2] == HCI_STATE_WORKING){ - sdp_query_rfcomm_channel_and_name_for_uuid(&handle_query_rfcomm_event, remote, SDP_PublicBrowseGroup); + sdp_client_query_rfcomm_channel_and_name_for_uuid(&handle_query_rfcomm_event, remote, SDP_PublicBrowseGroup); } break; case RFCOMM_EVENT_OPEN_CHANNEL_COMPLETE: diff --git a/platform/daemon/src/daemon.c b/platform/daemon/src/daemon.c index 10d5e90a8..5fcd4fead 100644 --- a/platform/daemon/src/daemon.c +++ b/platform/daemon/src/daemon.c @@ -1116,7 +1116,7 @@ static int btstack_command_handler(connection_t *connection, uint8_t *packet, ui memcpy(serviceSearchPattern, &packet[9], serviceSearchPatternLen); sdp_client_query_connection = connection; - sdp_query_rfcomm_channel_and_name_for_search_pattern(&handle_sdp_rfcomm_service_result, addr, serviceSearchPattern); + sdp_client_query_rfcomm_channel_and_name_for_search_pattern(&handle_sdp_rfcomm_service_result, addr, serviceSearchPattern); break; case SDP_CLIENT_QUERY_SERVICES: diff --git a/src/classic/hfp.c b/src/classic/hfp.c index dea2281e9..8b98555ca 100644 --- a/src/classic/hfp.c +++ b/src/classic/hfp.c @@ -1284,7 +1284,7 @@ void hfp_establish_service_level_connection(bd_addr_t bd_addr, uint16_t service_ hfp_connection->state = HFP_W4_SDP_QUERY_COMPLETE; connection_doing_sdp_query = hfp_connection; hfp_connection->service_uuid = service_uuid; - sdp_query_rfcomm_channel_and_name_for_uuid(&handle_query_rfcomm_event, hfp_connection->remote_addr, service_uuid); + sdp_client_query_rfcomm_channel_and_name_for_uuid(&handle_query_rfcomm_event, hfp_connection->remote_addr, service_uuid); break; default: break; diff --git a/src/classic/hsp_ag.c b/src/classic/hsp_ag.c index cdb2781df..765f1583f 100644 --- a/src/classic/hsp_ag.c +++ b/src/classic/hsp_ag.c @@ -368,7 +368,7 @@ static void hsp_run(void){ case HSP_SDP_QUERY_RFCOMM_CHANNEL: hsp_state = HSP_W4_SDP_EVENT_QUERY_COMPLETE; log_info("Start SDP query %s, 0x%02x", bd_addr_to_str(remote), SDP_HSP); - sdp_query_rfcomm_channel_and_name_for_uuid(&handle_query_rfcomm_event, remote, SDP_HSP); + sdp_client_query_rfcomm_channel_and_name_for_uuid(&handle_query_rfcomm_event, remote, SDP_HSP); break; case HSP_W4_RING_ANSWER: diff --git a/src/classic/hsp_hs.c b/src/classic/hsp_hs.c index 0c3634e3d..021f8e989 100644 --- a/src/classic/hsp_hs.c +++ b/src/classic/hsp_hs.c @@ -336,7 +336,7 @@ static void hsp_run(void){ switch (hsp_state){ case HSP_SDP_QUERY_RFCOMM_CHANNEL: hsp_state = HSP_W4_SDP_EVENT_QUERY_COMPLETE; - sdp_query_rfcomm_channel_and_name_for_uuid(&handle_query_rfcomm_event, remote, SDP_Headset_AG); + sdp_client_query_rfcomm_channel_and_name_for_uuid(&handle_query_rfcomm_event, remote, SDP_Headset_AG); break; case HSP_W2_CONNECT_SCO: diff --git a/src/classic/sdp_query_rfcomm.c b/src/classic/sdp_query_rfcomm.c index a5ef8f5b3..673bac7e5 100644 --- a/src/classic/sdp_query_rfcomm.c +++ b/src/classic/sdp_query_rfcomm.c @@ -52,7 +52,7 @@ #include "hci_cmd.h" // called by test/sdp_client -void sdp_query_rfcomm_init(void); +void sdp_client_query_rfcomm_init(void); typedef enum { GET_PROTOCOL_LIST_LENGTH = 1, @@ -98,7 +98,7 @@ static void sdp_rfcomm_query_emit_service(void){ sdp_rfcomm_channel_nr = 0; } -static void sdp_query_rfcomm_emit_busy(btstack_packet_handler_t callback){ +static void sdp_client_query_rfcomm_emit_busy(btstack_packet_handler_t callback){ log_error("sdp_query_rfcomm initiated when not ready"); uint8_t event[] = { SDP_EVENT_QUERY_COMPLETE, 1, SDP_QUERY_BUSY}; (*callback)(HCI_EVENT_PACKET, 0, event, sizeof(event)); @@ -290,7 +290,7 @@ static void handle_sdp_parser_event(uint8_t packet_type, uint16_t channel, uint8 // insert higher level code HERE } -void sdp_query_rfcomm_init(void){ +void sdp_client_query_rfcomm_init(void){ // init de_state_init(&de_header_state); de_state_init(&sn_de_header_state); @@ -302,25 +302,25 @@ void sdp_query_rfcomm_init(void){ // Public API -int sdp_query_rfcomm_ready(void){ +int sdp_client_query_rfcomm_ready(void){ return sdp_client_ready(); } -void sdp_query_rfcomm_channel_and_name_for_search_pattern(btstack_packet_handler_t callback, bd_addr_t remote, uint8_t * serviceSearchPattern){ - if (!sdp_query_rfcomm_ready()){ - sdp_query_rfcomm_emit_busy(callback); +void sdp_client_query_rfcomm_channel_and_name_for_search_pattern(btstack_packet_handler_t callback, bd_addr_t remote, uint8_t * serviceSearchPattern){ + if (!sdp_client_query_rfcomm_ready()){ + sdp_client_query_rfcomm_emit_busy(callback); return; } sdp_app_callback = callback; - sdp_query_rfcomm_init(); + sdp_client_query_rfcomm_init(); sdp_client_query(&handle_sdp_parser_event, remote, serviceSearchPattern, (uint8_t*)&des_attributeIDList[0]); } -void sdp_query_rfcomm_channel_and_name_for_uuid(btstack_packet_handler_t callback, bd_addr_t remote, uint16_t uuid){ - if (!sdp_query_rfcomm_ready()){ - sdp_query_rfcomm_emit_busy(callback); +void sdp_client_query_rfcomm_channel_and_name_for_uuid(btstack_packet_handler_t callback, bd_addr_t remote, uint16_t uuid){ + if (!sdp_client_query_rfcomm_ready()){ + sdp_client_query_rfcomm_emit_busy(callback); return; } big_endian_store_16(des_serviceSearchPattern, 3, uuid); - sdp_query_rfcomm_channel_and_name_for_search_pattern(callback, remote, (uint8_t*)des_serviceSearchPattern); + sdp_client_query_rfcomm_channel_and_name_for_search_pattern(callback, remote, (uint8_t*)des_serviceSearchPattern); } diff --git a/src/classic/sdp_query_rfcomm.h b/src/classic/sdp_query_rfcomm.h index 0bab00f99..6a5d70bbf 100644 --- a/src/classic/sdp_query_rfcomm.h +++ b/src/classic/sdp_query_rfcomm.h @@ -56,17 +56,17 @@ extern "C" { * @brief Checks if the SDP Client is ready * @return 1 when no query is active */ -int sdp_query_rfcomm_ready(void); +int sdp_client_query_rfcomm_ready(void); /** * @brief Searches SDP records on a remote device for RFCOMM services with a given UUID. */ -void sdp_query_rfcomm_channel_and_name_for_uuid(btstack_packet_handler_t callback, bd_addr_t remote, uint16_t uuid); +void sdp_client_query_rfcomm_channel_and_name_for_uuid(btstack_packet_handler_t callback, bd_addr_t remote, uint16_t uuid); /** * @brief Searches SDP records on a remote device for RFCOMM services with a given service search pattern. */ -void sdp_query_rfcomm_channel_and_name_for_search_pattern(btstack_packet_handler_t callback, bd_addr_t remote, uint8_t * des_serviceSearchPattern); +void sdp_client_query_rfcomm_channel_and_name_for_search_pattern(btstack_packet_handler_t callback, bd_addr_t remote, uint8_t * des_serviceSearchPattern); /* API_END */ #if defined __cplusplus diff --git a/test/hfp/mock.c b/test/hfp/mock.c index 64a445bc7..f2fc36ea1 100644 --- a/test/hfp/mock.c +++ b/test/hfp/mock.c @@ -206,7 +206,7 @@ static void sdp_query_complete_response(uint8_t status){ (*registered_sdp_app_callback)(HCI_EVENT_PACKET, 0, event, sizeof(event)); } -static void sdp_query_rfcomm_service_response(uint8_t status){ +static void sdp_client_query_rfcomm_service_response(uint8_t status){ int sdp_service_name_len = strlen(sdp_rfcomm_service_name); uint8_t event[3+SDP_SERVICE_NAME_LEN+1]; event[0] = SDP_EVENT_QUERY_RFCOMM_SERVICE; @@ -217,10 +217,10 @@ static void sdp_query_rfcomm_service_response(uint8_t status){ (*registered_sdp_app_callback)(HCI_EVENT_PACKET, 0, event, sizeof(event)); } -void sdp_query_rfcomm_channel_and_name_for_uuid(btstack_packet_handler_t callback, bd_addr_t remote, uint16_t uuid){ - // printf("sdp_query_rfcomm_channel_and_name_for_uuid %p\n", registered_sdp_app_callback); +void sdp_client_query_rfcomm_channel_and_name_for_uuid(btstack_packet_handler_t callback, bd_addr_t remote, uint16_t uuid){ + // printf("sdp_client_query_rfcomm_channel_and_name_for_uuid %p\n", registered_sdp_app_callback); registered_sdp_app_callback = callback; - sdp_query_rfcomm_service_response(0); + sdp_client_query_rfcomm_service_response(0); sdp_query_complete_response(0); } @@ -269,8 +269,8 @@ uint8_t rfcomm_register_service(btstack_packet_handler_t handler, uint8_t channe } -void sdp_query_rfcomm_channel_and_name_for_search_pattern(bd_addr_t remote, uint8_t * des_serviceSearchPattern){ - printf("sdp_query_rfcomm_channel_and_name_for_search_pattern\n"); +void sdp_client_query_rfcomm_channel_and_name_for_search_pattern(bd_addr_t remote, uint8_t * des_serviceSearchPattern){ + printf("sdp_client_query_rfcomm_channel_and_name_for_search_pattern\n"); } diff --git a/test/pts/classic_test.c b/test/pts/classic_test.c index 993cadc75..e5a0fab96 100644 --- a/test/pts/classic_test.c +++ b/test/pts/classic_test.c @@ -596,7 +596,7 @@ static int stdin_process(struct btstack_data_source *ds){ case 'k': printf("Start SDP query for SPP service\n"); - sdp_query_rfcomm_channel_and_name_for_uuid(&handle_query_rfcomm_event, remote_rfcomm, 0x1101); + sdp_client_query_rfcomm_channel_and_name_for_uuid(&handle_query_rfcomm_event, remote_rfcomm, 0x1101); break; case 't': diff --git a/test/pts/hfp_test.c b/test/pts/hfp_test.c index e923ec8a3..87608cca8 100644 --- a/test/pts/hfp_test.c +++ b/test/pts/hfp_test.c @@ -107,7 +107,7 @@ static void packet_handler(void * connection, uint8_t packet_type, uint16_t chan // bt stack activated, get started if (packet[2] == HCI_STATE_WORKING){ printf("Start SDP RFCOMM Query for UUID 0x%02x\n", SDP_Handsfree); - sdp_query_rfcomm_channel_and_name_for_uuid(&handle_query_rfcomm_event, remote, SDP_Handsfree); + sdp_client_query_rfcomm_channel_and_name_for_uuid(&handle_query_rfcomm_event, remote, SDP_Handsfree); } break; diff --git a/test/sdp_client/mock.h b/test/sdp_client/mock.h index 987404257..4f446d235 100644 --- a/test/sdp_client/mock.h +++ b/test/sdp_client/mock.h @@ -7,7 +7,7 @@ void sdp_parser_init_service_attribute_search(void); void sdp_parser_init_service_search(void); void sdp_parser_handle_service_search(uint8_t * data, uint16_t total_count, uint16_t record_handle_count); -void sdp_query_rfcomm_init(void); +void sdp_client_query_rfcomm_init(void); void sdp_client_reset(void); diff --git a/test/sdp_client/sdp_rfcomm_query.c b/test/sdp_client/sdp_rfcomm_query.c index ee00f8119..e3441deef 100644 --- a/test/sdp_client/sdp_rfcomm_query.c +++ b/test/sdp_client/sdp_rfcomm_query.c @@ -110,7 +110,7 @@ TEST_GROUP(SDPClient){ service_index = 0; sdp_client_reset(); // avoid "not ready" warning // start query using public API although data will be injected - sdp_query_rfcomm_channel_and_name_for_uuid(&handle_query_rfcomm_event, address, 0x1234); + sdp_client_query_rfcomm_channel_and_name_for_uuid(&handle_query_rfcomm_event, address, 0x1234); } }; diff --git a/tool/migration_to_v1.0/migration.cocci b/tool/migration_to_v1.0/migration.cocci index 06c7649a7..4dd085dce 100644 --- a/tool/migration_to_v1.0/migration.cocci +++ b/tool/migration_to_v1.0/migration.cocci @@ -143,19 +143,19 @@ expression E1, E2, E3; + sdp_client_query(E1, E2, E3) - sdp_client_query(sdp_client_callback, E1, E2, E3) -// track calls to sdp_query_rfcomm_register_callback +// track calls to sdp_client_query_rfcomm_register_callback @@ identifier sdp_client_callback; expression E1; @@ -- sdp_query_rfcomm_register_callback(sdp_client_callback, E1); -+ sdp_query_rfcomm_register_callback(&sdp_client_callback, E1); +- sdp_client_query_rfcomm_register_callback(sdp_client_callback, E1); ++ sdp_client_query_rfcomm_register_callback(&sdp_client_callback, E1); -@sdp_query_rfcomm_register_callback @ +@sdp_client_query_rfcomm_register_callback @ identifier sdp_client_callback; expression E1; @@ -- sdp_query_rfcomm_register_callback(&sdp_client_callback, E1); +- sdp_client_query_rfcomm_register_callback(&sdp_client_callback, E1); @@ typedef sdp_query_event_t; @@ -172,18 +172,18 @@ type T; // fix calls to sdp_query_rfcomm @@ -identifier sdp_query_rfcomm_register_callback.sdp_client_callback; +identifier sdp_client_query_rfcomm_register_callback.sdp_client_callback; expression E1, E2; @@ -- sdp_query_rfcomm_channel_and_name_for_uuid(E1, E2) -+ sdp_query_rfcomm_channel_and_name_for_uuid(sdp_client_callback, E1, E2) +- sdp_client_query_rfcomm_channel_and_name_for_uuid(E1, E2) ++ sdp_client_query_rfcomm_channel_and_name_for_uuid(sdp_client_callback, E1, E2) @@ -identifier sdp_query_rfcomm_register_callback.sdp_client_callback; +identifier sdp_client_query_rfcomm_register_callback.sdp_client_callback; expression E1, E2; @@ -- sdp_query_rfcomm_channel_and_name_for_search_pattern(E1, E2) -+ sdp_query_rfcomm_channel_and_name_for_search_pattern(sdp_client_callback, E1, E2) +- sdp_client_query_rfcomm_channel_and_name_for_search_pattern(E1, E2) ++ sdp_client_query_rfcomm_channel_and_name_for_search_pattern(sdp_client_callback, E1, E2) @@ identifier fn, event, context;