sdp_client: use sdp_client_query prefix for rfcomm queries

This commit is contained in:
Matthias Ringwald 2016-03-17 10:42:14 +01:00
parent 129e4f7d58
commit 7fbb5f59ef
16 changed files with 47 additions and 47 deletions

View File

@ -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}
}

View File

@ -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);

View File

@ -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:

View File

@ -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:

View File

@ -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:

View File

@ -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;

View File

@ -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:

View File

@ -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:

View File

@ -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);
}

View File

@ -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

View File

@ -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");
}

View File

@ -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':

View File

@ -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;

View File

@ -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);

View File

@ -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);
}
};

View File

@ -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;