From 7a26a9baa717fa2d92f9a8e29ef156b63d92456d Mon Sep 17 00:00:00 2001 From: "matthias.ringwald" Date: Sat, 12 Jun 2010 19:03:58 +0000 Subject: [PATCH] add sdp_register_service_record, sdp_unregister_service_record commands --- include/btstack/hci_cmds.h | 8 ++++++++ include/btstack/sdp_util.h | 4 ++-- src/Makefile.in | 3 +-- src/hci_cmds.c | 34 +++++++++++++++++++++++++--------- 4 files changed, 36 insertions(+), 13 deletions(-) diff --git a/include/btstack/hci_cmds.h b/include/btstack/hci_cmds.h index 26a9047ef..0437c607d 100644 --- a/include/btstack/hci_cmds.h +++ b/include/btstack/hci_cmds.h @@ -126,6 +126,9 @@ // data: event(8), len(8), handle(16) #define L2CAP_EVENT_TIMEOUT_CHECK 0x73 +// data: event(8), len(8), service_record_handle(32) +#define SDP_SERVICE_REGISTERED 0x80 + // last error code in 2.1 is 0x38 - we start with 0x50 for BTstack errors @@ -231,3 +234,8 @@ extern hci_cmd_t l2cap_decline_connection; extern hci_cmd_t l2cap_disconnect; extern hci_cmd_t l2cap_register_service; extern hci_cmd_t l2cap_unregister_service; + +extern hci_cmd_t sdp_register_service_record; +extern hci_cmd_t sdp_unregister_service_record; + + diff --git a/include/btstack/sdp_util.h b/include/btstack/sdp_util.h index 00ac62db6..4a682f9ab 100644 --- a/include/btstack/sdp_util.h +++ b/include/btstack/sdp_util.h @@ -69,11 +69,11 @@ void de_create_sequence(uint8_t *header); uint8_t * de_push_sequence(uint8_t *header); void de_pop_sequence(uint8_t * parent, uint8_t * child); void de_add_number(uint8_t *seq, de_type_t type, de_size_t size, uint32_t value); - +void de_add_data( uint8_t *seq, de_type_t type, uint16_t size, uint8_t *data); int de_get_data_size(uint8_t * header); #pragma mark SDP void sdp_append_attributes_in_attributeIDList(uint8_t *record, uint8_t *attributeIDList, uint8_t *buffer, uint16_t maxBytes); uint8_t * sdp_get_attribute_value_for_attribute_id(uint8_t * record, uint16_t attributeID); - +int sdp_record_matches_service_search_pattern(uint8_t *record, uint8_t *serviceSearchPattern); \ No newline at end of file diff --git a/src/Makefile.in b/src/Makefile.in index 5aa947505..9cf53e5b7 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -10,7 +10,7 @@ springboard_access_sources = @SPRINGBOARD_ACCESS_SOURCES@ usb_sources = @USB_SOURCES@ run_loop_sources = @RUN_LOOP_SOURCES@ -libBTstack_SOURCES = btstack.c hci_cmds.c linked_list.c run_loop.c $(run_loop_sources) socket_connection.c utils.c +libBTstack_SOURCES = btstack.c hci_cmds.c linked_list.c run_loop.c $(run_loop_sources) sdp_util.c socket_connection.c utils.c BTdaemon_SOURCES = $(libBTstack_SOURCES) \ bt_control_iphone.m \ @@ -23,7 +23,6 @@ BTdaemon_SOURCES = $(libBTstack_SOURCES) \ l2cap_signaling.c \ platform_iphone.c \ sdp.c \ - sdp_util.c \ $(springboard_access_sources) all: libBTstack.$(BTSTACK_LIB_EXTENSION) libBTstack.a BTdaemon diff --git a/src/hci_cmds.c b/src/hci_cmds.c index fb30886f0..a6d1f4573 100644 --- a/src/hci_cmds.c +++ b/src/hci_cmds.c @@ -36,6 +36,7 @@ */ #include +#include #include "hci.h" #include @@ -49,9 +50,10 @@ * 1,2,3,4: one to four byte value * H: HCI connection handle * B: Bluetooth Baseband Address (BD_ADDR) - * P: 16 byte Pairing code - * N: Name up to 248 chars * E: Extended Inquiry Result + * N: Name up to 248 chars + * P: 16 byte Pairing code + * S: Service Record (Data Element Sequence) */ uint16_t hci_create_cmd_internal(uint8_t *hci_cmd_buffer, hci_cmd_t *cmd, va_list argptr){ @@ -98,21 +100,28 @@ uint16_t hci_create_cmd_internal(uint8_t *hci_cmd_buffer, hci_cmd_t *cmd, va_lis hci_cmd_buffer[pos++] = ptr[1]; hci_cmd_buffer[pos++] = ptr[0]; break; - case 'P': // 16 byte PIN code or link key + case 'E': // Extended Inquiry Information 240 octets ptr = va_arg(argptr, uint8_t *); - memcpy(&hci_cmd_buffer[pos], ptr, 16); - pos += 16; + memcpy(&hci_cmd_buffer[pos], ptr, 240); + pos += 240; break; case 'N': // UTF-8 string, null terminated ptr = va_arg(argptr, uint8_t *); memcpy(&hci_cmd_buffer[pos], ptr, 248); pos += 248; break; - case 'E': // Extended Inquiry Information 240 octets + case 'P': // 16 byte PIN code or link key ptr = va_arg(argptr, uint8_t *); - memcpy(&hci_cmd_buffer[pos], ptr, 240); - pos += 240; + memcpy(&hci_cmd_buffer[pos], ptr, 16); + pos += 16; break; + case 'S': { // Service Record (Data Element Sequence) + ptr = va_arg(argptr, uint8_t *); + uint16_t len = de_get_len(ptr); + memcpy(&hci_cmd_buffer[pos], ptr, len); + pos += 16; + break; + } default: break; } @@ -338,5 +347,12 @@ hci_cmd_t l2cap_decline_connection = { OPCODE(OGF_BTSTACK, L2CAP_DECLINE_CONNECTION), "21" // @param source cid (16), reason(8) }; - +hci_cmd_t sdp_register_service_record = { +OPCODE(OGF_BTSTACK, SDP_REGISTER_SERVICE_RECORD), "S" +// @param service record handle (DES) +}; +hci_cmd_t sdp_unregister_service_record = { +OPCODE(OGF_BTSTACK, SDP_UNREGISTER_SERVICE_RECORD), "4" +// @param service record handle (32) +};