mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-04-04 22:20:26 +00:00
example/panu_demo: use static buffer for service names
This commit is contained in:
parent
76780d6ce5
commit
9975f1a3b6
@ -114,7 +114,7 @@ static void panu_setup(void){
|
|||||||
/* LISTING_END */
|
/* LISTING_END */
|
||||||
|
|
||||||
// PANU client routines
|
// PANU client routines
|
||||||
static char * get_string_from_data_element(uint8_t * element){
|
static void get_string_from_data_element(uint8_t * element, uint16_t buffer_size, char * buffer_data){
|
||||||
de_size_t de_size = de_get_size_type(element);
|
de_size_t de_size = de_get_size_type(element);
|
||||||
int pos = de_get_header_size(element);
|
int pos = de_get_header_size(element);
|
||||||
int len = 0;
|
int len = 0;
|
||||||
@ -128,10 +128,9 @@ static char * get_string_from_data_element(uint8_t * element){
|
|||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
char * str = (char*)malloc(len+1);
|
uint16_t bytes_to_copy = btstack_min(buffer_size-1,len);
|
||||||
memcpy(str, &element[pos], len);
|
memcpy(buffer_data, &element[pos], bytes_to_copy);
|
||||||
str[len] ='\0';
|
buffer_data[bytes_to_copy] ='\0';
|
||||||
return str;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -160,7 +159,7 @@ static void handle_sdp_client_query_result(uint8_t packet_type, uint16_t channel
|
|||||||
|
|
||||||
des_iterator_t des_list_it;
|
des_iterator_t des_list_it;
|
||||||
des_iterator_t prot_it;
|
des_iterator_t prot_it;
|
||||||
char *str;
|
char str[20];
|
||||||
|
|
||||||
switch (hci_event_packet_get_type(packet)){
|
switch (hci_event_packet_get_type(packet)){
|
||||||
case SDP_EVENT_QUERY_ATTRIBUTE_VALUE:
|
case SDP_EVENT_QUERY_ATTRIBUTE_VALUE:
|
||||||
@ -198,7 +197,7 @@ static void handle_sdp_client_query_result(uint8_t packet_type, uint16_t channel
|
|||||||
break;
|
break;
|
||||||
case 0x0100:
|
case 0x0100:
|
||||||
case 0x0101:
|
case 0x0101:
|
||||||
str = get_string_from_data_element(attribute_value);
|
get_string_from_data_element(attribute_value, sizeof(str), str);
|
||||||
printf("SDP Attribute: 0x%04x: %s\n", sdp_event_query_attribute_byte_get_attribute_id(packet), str);
|
printf("SDP Attribute: 0x%04x: %s\n", sdp_event_query_attribute_byte_get_attribute_id(packet), str);
|
||||||
free(str);
|
free(str);
|
||||||
break;
|
break;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user