mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-02-20 18:40:31 +00:00
sdp: support de-init
This commit is contained in:
parent
1ac69172e4
commit
0396d6ccc8
@ -83,7 +83,7 @@ static void assertBuffer(int size){
|
||||
static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size);
|
||||
static void handle_sdp_client_query_result(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size);
|
||||
|
||||
static void sdp_client_init(void){
|
||||
static void sdp_bnep_qeury_init(void){
|
||||
// init L2CAP
|
||||
l2cap_init();
|
||||
|
||||
@ -272,8 +272,8 @@ int btstack_main(int argc, const char * argv[]){
|
||||
(void)argv;
|
||||
|
||||
printf("Client HCI init done\r\n");
|
||||
|
||||
sdp_client_init();
|
||||
|
||||
sdp_bnep_qeury_init();
|
||||
|
||||
// turn on!
|
||||
hci_power_control(HCI_POWER_ON);
|
||||
|
@ -83,7 +83,7 @@ static btstack_packet_callback_registration_t hci_event_callback_registration;
|
||||
static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size);
|
||||
static void handle_sdp_client_query_result(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size);
|
||||
|
||||
static void sdp_client_init(void){
|
||||
static void sdp_general_query_init(void){
|
||||
// init L2CAP
|
||||
l2cap_init();
|
||||
|
||||
@ -205,8 +205,8 @@ int btstack_main(int argc, const char * argv[]){
|
||||
(void)argv;
|
||||
sscanf_bd_addr(remote_addr_string, remote_addr);
|
||||
#endif
|
||||
|
||||
sdp_client_init();
|
||||
|
||||
sdp_general_query_init();
|
||||
// turn on!
|
||||
hci_power_control(HCI_POWER_ON);
|
||||
|
||||
|
@ -94,16 +94,16 @@ static uint8_t des_attributeIDList[] = { 0x35, 0x05, 0x0A, 0x00, 0x00, 0xff, 0xf
|
||||
static de_state_t de_header_state;
|
||||
|
||||
// State SDP Parser
|
||||
static sdp_parser_state_t state = GET_LIST_LENGTH;
|
||||
static sdp_parser_state_t state;
|
||||
static uint16_t attribute_id = 0;
|
||||
static uint16_t attribute_bytes_received = 0;
|
||||
static uint16_t attribute_bytes_delivered = 0;
|
||||
static uint16_t list_offset = 0;
|
||||
static uint16_t attribute_bytes_received;
|
||||
static uint16_t attribute_bytes_delivered;
|
||||
static uint16_t list_offset;
|
||||
static uint16_t list_size;
|
||||
static uint16_t record_offset = 0;
|
||||
static uint16_t record_offset;
|
||||
static uint16_t record_size;
|
||||
static uint16_t attribute_value_size;
|
||||
static int record_counter = 0;
|
||||
static int record_counter;
|
||||
static btstack_packet_handler_t sdp_parser_callback;
|
||||
|
||||
// State SDP Client
|
||||
@ -111,7 +111,7 @@ static uint16_t mtu;
|
||||
static uint16_t sdp_cid = 0x40;
|
||||
static const uint8_t * service_search_pattern;
|
||||
static const uint8_t * attribute_id_list;
|
||||
static uint16_t transactionID = 0;
|
||||
static uint16_t transactionID;
|
||||
static uint8_t continuationState[16];
|
||||
static uint8_t continuationStateLen;
|
||||
static sdp_client_state_t sdp_client_state = INIT;
|
||||
@ -270,8 +270,43 @@ void sdp_parser_init(btstack_packet_handler_t callback){
|
||||
de_state_init(&de_header_state);
|
||||
state = GET_LIST_LENGTH;
|
||||
list_offset = 0;
|
||||
list_size = 0;
|
||||
record_offset = 0;
|
||||
record_counter = 0;
|
||||
record_size = 0;
|
||||
attribute_id = 0;
|
||||
attribute_bytes_received = 0;
|
||||
attribute_bytes_delivered = 0;
|
||||
}
|
||||
|
||||
static void sdp_parser_deinit(void) {
|
||||
sdp_parser_callback = NULL;
|
||||
attribute_value_size = 0;
|
||||
record_counter = 0;
|
||||
}
|
||||
|
||||
void sdp_client_init(void){
|
||||
}
|
||||
|
||||
void sdp_client_deinit(void){
|
||||
sdp_parser_deinit();
|
||||
sdp_client_state = INIT;
|
||||
sdp_cid = 0x40;
|
||||
service_search_pattern = NULL;
|
||||
attribute_id_list = NULL;
|
||||
transactionID = 0;
|
||||
continuationStateLen = 0;
|
||||
sdp_client_state = INIT;
|
||||
PDU_ID = SDP_Invalid;
|
||||
#ifdef ENABLE_SDP_EXTRA_QUERIES
|
||||
serviceRecordHandle = 0;
|
||||
record_handle = 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
// for testing only
|
||||
void sdp_client_reset(void){
|
||||
sdp_client_deinit();
|
||||
}
|
||||
|
||||
void sdp_parser_handle_chunk(uint8_t * data, uint16_t size){
|
||||
@ -695,11 +730,6 @@ static void sdp_client_parse_service_attribute_response(uint8_t* packet, uint16_
|
||||
}
|
||||
#endif
|
||||
|
||||
// for testing only
|
||||
void sdp_client_reset(void){
|
||||
sdp_client_state = INIT;
|
||||
}
|
||||
|
||||
// Public API
|
||||
|
||||
bool sdp_client_ready(void){
|
||||
|
@ -62,6 +62,11 @@ typedef struct de_state {
|
||||
void de_state_init(de_state_t * state);
|
||||
int de_state_size(uint8_t eventByte, de_state_t *de_state);
|
||||
|
||||
/**
|
||||
* @brief SDP Client Init
|
||||
*/
|
||||
void sdp_client_init(void);
|
||||
|
||||
/**
|
||||
* @brief Checks if the SDP Client is ready
|
||||
* @deprecated Please use sdp_client_register_query_callback instead
|
||||
@ -124,6 +129,11 @@ uint8_t sdp_client_service_search(btstack_packet_handler_t callback, bd_addr_t r
|
||||
void sdp_client_parse_service_record_handle_list(uint8_t* packet, uint16_t total_count, uint16_t current_count);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief De-Init SDP Client
|
||||
*/
|
||||
void sdp_client_deinit(void);
|
||||
|
||||
/* API_END */
|
||||
|
||||
#if defined __cplusplus
|
||||
|
@ -72,22 +72,29 @@
|
||||
static void sdp_packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size);
|
||||
|
||||
// registered service records
|
||||
static btstack_linked_list_t sdp_service_records = NULL;
|
||||
static btstack_linked_list_t sdp_service_records;
|
||||
|
||||
// our handles start after the reserved range
|
||||
static uint32_t sdp_next_service_record_handle = ((uint32_t) maxReservedServiceRecordHandle) + 2;
|
||||
static uint32_t sdp_next_service_record_handle;
|
||||
|
||||
static uint8_t sdp_response_buffer[SDP_RESPONSE_BUFFER_SIZE];
|
||||
|
||||
static uint16_t l2cap_cid = 0;
|
||||
static uint16_t sdp_response_size = 0;
|
||||
static uint16_t l2cap_cid;
|
||||
static uint16_t sdp_response_size;
|
||||
static uint16_t l2cap_waiting_list_cids[SDP_WAITING_LIST_MAX_COUNT];
|
||||
static int l2cap_waiting_list_count;
|
||||
|
||||
void sdp_init(void){
|
||||
l2cap_cid = 0;
|
||||
l2cap_waiting_list_count = 0;
|
||||
sdp_service_records = NULL;
|
||||
sdp_next_service_record_handle = ((uint32_t) maxReservedServiceRecordHandle) + 2;
|
||||
sdp_response_size = 0;
|
||||
// register with l2cap psm sevices - max MTU
|
||||
l2cap_register_service(sdp_packet_handler, BLUETOOTH_PSM_SDP, 0xffff, LEVEL_0);
|
||||
l2cap_waiting_list_count = 0;
|
||||
}
|
||||
|
||||
void sdp_deinit(void){
|
||||
}
|
||||
|
||||
uint32_t sdp_get_service_record_handle(const uint8_t * record){
|
||||
|
@ -61,7 +61,7 @@ int sdp_handle_service_search_attribute_request(uint8_t * packet, uint16_t remot
|
||||
/* API_START */
|
||||
|
||||
/**
|
||||
* @brief Set up SDP.
|
||||
* @brief Set up SDP Server.
|
||||
*/
|
||||
void sdp_init(void);
|
||||
|
||||
@ -79,9 +79,11 @@ uint8_t sdp_register_service(const uint8_t * record);
|
||||
*/
|
||||
void sdp_unregister_service(uint32_t service_record_handle);
|
||||
|
||||
/* API_END */
|
||||
|
||||
// used by daemon
|
||||
/**
|
||||
* @brief gets service record handle from record
|
||||
* @resutl service record handle or 0
|
||||
*/
|
||||
uint32_t sdp_get_service_record_handle(const uint8_t * record);
|
||||
|
||||
/**
|
||||
* @brief Finds an unused valid service record handle
|
||||
@ -97,10 +99,12 @@ uint32_t sdp_create_service_record_handle(void);
|
||||
uint8_t * sdp_get_record_for_handle(uint32_t handle);
|
||||
|
||||
/**
|
||||
* @brief gets service record handle from record
|
||||
* @resutl service record handle or 0
|
||||
* @brief De-Init SDP Server
|
||||
*/
|
||||
uint32_t sdp_get_service_record_handle(const uint8_t * record);
|
||||
void sdp_deinit(void);
|
||||
|
||||
/* API_END */
|
||||
|
||||
|
||||
#if defined __cplusplus
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user