add sdp_register_service_record, sdp_unregister_service_record commands

This commit is contained in:
matthias.ringwald 2010-06-12 19:03:58 +00:00
parent 79a786f96b
commit 7a26a9baa7
4 changed files with 36 additions and 13 deletions

View File

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

View File

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

View File

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

View File

@ -36,6 +36,7 @@
*/
#include <btstack/hci_cmds.h>
#include <btstack/sdp_util.h>
#include "hci.h"
#include <string.h>
@ -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)
};