bluetooth_sdp: use scraped SDP UUID and PSMs for SDP record creation and parsing

This commit is contained in:
Matthias Ringwald 2017-03-26 22:19:18 +02:00
parent 46b212911c
commit 235946f152
31 changed files with 245 additions and 252 deletions

View File

@ -149,7 +149,7 @@ static void panu_setup(void){
// Initialise BNEP
bnep_init();
// Minimum L2CAP MTU for bnep is 1691 bytes
bnep_register_service(packet_handler, SDP_PANU, 1691);
bnep_register_service(packet_handler, BLUETOOTH_SERVICE_CLASS_PANU, 1691);
}
/* LISTING_END */
@ -344,16 +344,16 @@ static void handle_sdp_client_query_result(uint8_t packet_type, uint16_t channel
if ((uint16_t)(sdp_event_query_attribute_byte_get_data_offset(packet)+1) == sdp_event_query_attribute_byte_get_attribute_length(packet)) {
switch(sdp_event_query_attribute_byte_get_attribute_id(packet)) {
case SDP_ServiceClassIDList:
case BLUETOOTH_ATTRIBUTE_SERVICE_CLASS_ID_LIST:
if (de_get_element_type(attribute_value) != DE_DES) break;
for (des_iterator_init(&des_list_it, attribute_value); des_iterator_has_more(&des_list_it); des_iterator_next(&des_list_it)) {
uint8_t * element = des_iterator_get_element(&des_list_it);
if (de_get_element_type(element) != DE_UUID) continue;
uint32_t uuid = de_get_uuid32(element);
switch (uuid){
case SDP_PANU:
case SDP_NAP:
case SDP_GN:
case BLUETOOTH_SERVICE_CLASS_PANU:
case BLUETOOTH_SERVICE_CLASS_NAP:
case BLUETOOTH_SERVICE_CLASS_GN:
printf("SDP Attribute 0x%04x: BNEP PAN protocol UUID: %04x\n", sdp_event_query_attribute_byte_get_attribute_id(packet), uuid);
bnep_remote_uuid = uuid;
break;
@ -368,7 +368,7 @@ static void handle_sdp_client_query_result(uint8_t packet_type, uint16_t channel
printf("SDP Attribute: 0x%04x: %s\n", sdp_event_query_attribute_byte_get_attribute_id(packet), str);
free(str);
break;
case 0x0004: {
case BLUETOOTH_ATTRIBUTE_PROTOCOL_DESCRIPTOR_LIST: {
printf("SDP Attribute: 0x%04x\n", sdp_event_query_attribute_byte_get_attribute_id(packet));
for (des_iterator_init(&des_list_it, attribute_value); des_iterator_has_more(&des_list_it); des_iterator_next(&des_list_it)) {
@ -386,12 +386,12 @@ static void handle_sdp_client_query_result(uint8_t packet_type, uint16_t channel
uuid = de_get_uuid32(element);
switch (uuid){
case SDP_L2CAPProtocol:
case BLUETOOTH_PROTOCOL_L2CAP:
if (!des_iterator_has_more(&prot_it)) continue;
des_iterator_next(&prot_it);
de_element_get_uint16(des_iterator_get_element(&prot_it), &bnep_l2cap_psm);
break;
case SDP_BNEPProtocol:
case BLUETOOTH_PROTOCOL_BNEP:
if (!des_iterator_has_more(&prot_it)) continue;
des_iterator_next(&prot_it);
de_element_get_uint16(des_iterator_get_element(&prot_it), &bnep_version);
@ -454,7 +454,7 @@ static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *pack
case BTSTACK_EVENT_STATE:
if (btstack_event_state_get_state(packet) == HCI_STATE_WORKING){
printf("Start SDP BNEP query.\n");
sdp_client_query_uuid16(&handle_sdp_client_query_result, remote, SDP_BNEPProtocol);
sdp_client_query_uuid16(&handle_sdp_client_query_result, remote, BLUETOOTH_PROTOCOL_BNEP);
}
break;

View File

@ -116,7 +116,7 @@ static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *pack
// BTstack activated, get started
if (btstack_event_state_get_state(packet) == HCI_STATE_WORKING){
printf("Start SDP BNEP query.\n");
sdp_client_query_uuid16(&handle_sdp_client_query_result, remote, SDP_BNEPProtocol);
sdp_client_query_uuid16(&handle_sdp_client_query_result, remote, BLUETOOTH_PROTOCOL_BNEP);
}
break;
default:
@ -186,7 +186,7 @@ static void handle_sdp_client_query_result(uint8_t packet_type, uint16_t channel
switch(sdp_event_query_attribute_byte_get_attribute_id(packet)){
// 0x0001 "Service Class ID List"
case SDP_ServiceClassIDList:
case BLUETOOTH_ATTRIBUTE_SERVICE_CLASS_ID_LIST:
if (de_get_element_type(attribute_value) != DE_DES) break;
for (des_iterator_init(&des_list_it, attribute_value); des_iterator_has_more(&des_list_it); des_iterator_next(&des_list_it)){
uint8_t * element = des_iterator_get_element(&des_list_it);
@ -219,7 +219,7 @@ static void handle_sdp_client_query_result(uint8_t packet_type, uint16_t channel
* a DES with the L2CAP Protocol UUID and a PSM,
* and another DES with the BNEP UUID and the the BNEP version.
*/
case SDP_ProtocolDescriptorList:{
case BLUETOOTH_ATTRIBUTE_PROTOCOL_DESCRIPTOR_LIST:{
printf(" ** Attribute 0x%04x: ", sdp_event_query_attribute_byte_get_attribute_id(packet));
uint16_t l2cap_psm = 0;
@ -233,12 +233,12 @@ static void handle_sdp_client_query_result(uint8_t packet_type, uint16_t channel
if (de_get_element_type(element) != DE_UUID) continue;
uint32_t uuid = de_get_uuid32(element);
switch (uuid){
case SDP_L2CAPProtocol:
case BLUETOOTH_PROTOCOL_L2CAP:
if (!des_iterator_has_more(&prot_it)) continue;
des_iterator_next(&prot_it);
de_element_get_uint16(des_iterator_get_element(&prot_it), &l2cap_psm);
break;
case SDP_BNEPProtocol:
case BLUETOOTH_PROTOCOL_BNEP:
if (!des_iterator_has_more(&prot_it)) continue;
des_iterator_next(&prot_it);
de_element_get_uint16(des_iterator_get_element(&prot_it), &bnep_version);

View File

@ -52,15 +52,7 @@
#include <stdlib.h>
#include <string.h>
#include "btstack_event.h"
#include "btstack_memory.h"
#include "btstack_run_loop.h"
#include "classic/sdp_client.h"
#include "classic/sdp_util.h"
#include "hci.h"
#include "hci_cmd.h"
#include "hci_dump.h"
#include "l2cap.h"
#include "btstack.h"
int record_id = -1;
int attribute_id = -1;
@ -119,7 +111,7 @@ static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *pack
case BTSTACK_EVENT_STATE:
// BTstack activated, get started
if (btstack_event_state_get_state(packet) == HCI_STATE_WORKING){
sdp_client_query_uuid16(&handle_sdp_client_query_result, remote, SDP_PublicBrowseGroup);
sdp_client_query_uuid16(&handle_sdp_client_query_result, remote, BLUETOOTH_ATTRIBUTE_PUBLIC_BROWSE_ROOT);
}
break;
default:

View File

@ -54,12 +54,7 @@
#include "hci_cmd.h"
#include "btstack_run_loop.h"
#include "hci.h"
#include "btstack_memory.h"
#include "hci_dump.h"
#include "l2cap.h"
#include "classic/sdp_client_rfcomm.h"
#include "btstack_event.h"
#include "btstack.h"
static void handle_query_rfcomm_event(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size);
@ -83,7 +78,7 @@ static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packe
case BTSTACK_EVENT_STATE:
// BTstack activated, get started
if (btstack_event_state_get_state(packet) == HCI_STATE_WORKING){
sdp_client_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, BLUETOOTH_ATTRIBUTE_PUBLIC_BROWSE_ROOT);
}
break;
default:

View File

@ -43,24 +43,13 @@
//
// *****************************************************************************
#include "btstack_config.h"
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "btstack.h"
#include "hci_cmd.h"
#include "btstack_run_loop.h"
#include "hci.h"
#include "btstack_memory.h"
#include "hci_dump.h"
#include "l2cap.h"
#include "classic/sdp_client_rfcomm.h"
#include "classic/rfcomm.h"
#include "btstack_event.h"
#define NUM_ROWS 25
#define NUM_COLS 40
@ -162,7 +151,7 @@ static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *pack
// bt stack activated, get started
if (btstack_event_state_get_state(packet) == HCI_STATE_WORKING){
printf("SDP Query for RFCOMM services on %s started\n", bd_addr_to_str(remote));
sdp_client_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, BLUETOOTH_ATTRIBUTE_PUBLIC_BROWSE_ROOT);
}
break;
case RFCOMM_EVENT_CHANNEL_OPENED:

View File

@ -673,14 +673,14 @@ typedef enum {
#define L2CAP_ERTX_TIMEOUT_MS 120000
// Fixed PSM numbers
#define PSM_SDP 0x01
#define PSM_RFCOMM 0x03
#define PSM_BNEP 0x0F
#define PSM_SDP BLUETOOTH_PROTOCOL_SDP
#define PSM_RFCOMM BLUETOOTH_PROTOCOL_RFCOMM
#define PSM_BNEP BLUETOOTH_PROTOCOL_BNEP
#define PSM_HID_CONTROL 0x11
#define PSM_HID_INTERRUPT 0x13
/**
* SDP Protocl
* SDP Protocol
*/
// PDU Types
@ -695,45 +695,49 @@ typedef enum {
SDP_ServiceSearchAttributeResponse
} SDP_PDU_ID_t;
/* Please use assigned numbers from bluetooth_sdp.h instead for thsese ...*/
// UNIVERSAL ATTRIBUTE DEFINITIONS
#define SDP_ServiceRecordHandle 0x0000
#define SDP_ServiceClassIDList 0x0001
#define SDP_ServiceRecordState 0x0002
#define SDP_ServiceID 0x0003
#define SDP_ProtocolDescriptorList 0x0004
#define SDP_BrowseGroupList 0x0005
#define SDP_LanguageBaseAttributeIDList 0x0006
#define SDP_ServiceInfoTimeToLive 0x0007
#define SDP_ServiceAvailability 0x0008
#define SDP_BluetoothProfileDescriptorList 0x0009
#define SDP_DocumentationURL 0x000a
#define SDP_ClientExecutableURL 0x000b
#define SDP_IconURL 0x000c
#define SDP_AdditionalProtocolDescriptorList 0x000d
#define SDP_SupportedFormatsList 0x0303
#define SDP_ServiceRecordHandle BLUETOOTH_ATTRIBUTE_SERVICE_RECORD_HANDLE
#define SDP_ServiceClassIDList BLUETOOTH_ATTRIBUTE_SERVICE_CLASS_ID_LIST
#define SDP_ServiceRecordState BLUETOOTH_ATTRIBUTE_SERVICE_RECORD_STATE
#define SDP_ServiceID BLUETOOTH_ATTRIBUTE_SERVICE_ID
#define SDP_ProtocolDescriptorList BLUETOOTH_ATTRIBUTE_PROTOCOL_DESCRIPTOR_LIST
#define SDP_BrowseGroupList BLUETOOTH_ATTRIBUTE_BROWSE_GROUP_LIST
#define SDP_LanguageBaseAttributeIDList BLUETOOTH_ATTRIBUTE_LANGUAGE_BASE_ATTRIBUTE_ID_LIST
#define SDP_ServiceInfoTimeToLive BLUETOOTH_ATTRIBUTE_SERVICE_INFO_TIME_TO_LIVE
#define SDP_ServiceAvailability BLUETOOTH_ATTRIBUTE_SERVICE_AVAILABILITY
#define SDP_BluetoothProfileDescriptorList BLUETOOTH_ATTRIBUTE_BLUETOOTH_PROFILE_DESCRIPTOR_LIST
#define SDP_DocumentationURL BLUETOOTH_ATTRIBUTE_DOCUMENTATION_URL
#define SDP_ClientExecutableURL BLUETOOTH_ATTRIBUTE_CLIENT_EXECUTABLE_URL
#define SDP_IconURL BLUETOOTH_ATTRIBUTE_ICON_URL
#define SDP_AdditionalProtocolDescriptorList BLUETOOTH_ATTRIBUTE_ADDITIONAL_PROTOCOL_DESCRIPTOR_LISTS
#define SDP_SupportedFormatsList BLUETOOTH_ATTRIBUTE_SUPPORTED_FORMATS_LIST
// SERVICE CLASSES
#define SDP_OBEXObjectPush 0x1105
#define SDP_OBEXFileTransfer 0x1106
#define SDP_PublicBrowseGroup 0x1002
#define SDP_HSP 0x1108
#define SDP_Headset_AG 0x1112
#define SDP_PANU 0x1115
#define SDP_NAP 0x1116
#define SDP_GN 0x1117
#define SDP_Handsfree 0x111E
#define SDP_HandsfreeAudioGateway 0x111F
#define SDP_Headset_HS 0x1131
#define SDP_GenericAudio 0x1203
#define SDP_OBEXObjectPush BLUETOOTH_SERVICE_CLASS_OBEX_OBJECT_PUSH
#define SDP_OBEXFileTransfer BLUETOOTH_SERVICE_CLASS_OBEX_FILE_TRANSFER
#define SDP_PublicBrowseGroup BLUETOOTH_ATTRIBUTE_PUBLIC_BROWSE_ROOT
#define SDP_HSP BLUETOOTH_SERVICE_CLASS_HEADSET
#define SDP_Headset_AG BLUETOOTH_SERVICE_CLASS_HEADSET_AUDIO_GATEWAY_AG
#define SDP_PANU BLUETOOTH_SERVICE_CLASS_PANU
#define SDP_NAP BLUETOOTH_SERVICE_CLASS_NAP
#define SDP_GN BLUETOOTH_SERVICE_CLASS_GN
#define SDP_Handsfree BLUETOOTH_SERVICE_CLASS_HANDSFREE
#define SDP_HandsfreeAudioGateway BLUETOOTH_SERVICE_CLASS_HANDSFREE_AUDIO_GATEWAY
#define SDP_Headset_HS BLUETOOTH_SERVICE_CLASS_HEADSET_HS
#define SDP_GenericAudio BLUETOOTH_SERVICE_CLASS_GENERIC_AUDIO
// PROTOCOLS
#define SDP_SDPProtocol 0x0001
#define SDP_UDPProtocol 0x0002
#define SDP_RFCOMMProtocol 0x0003
#define SDP_OBEXProtocol 0x0008
#define SDP_L2CAPProtocol 0x0100
#define SDP_BNEPProtocol 0x000F
#define SDP_AVDTPProtocol 0x0019
#define SDP_SDPProtocol BLUETOOTH_PROTOCOL_SDP
#define SDP_UDPProtocol BLUETOOTH_PROTOCOL_UDP
#define SDP_RFCOMMProtocol BLUETOOTH_PROTOCOL_RFCOMM
#define SDP_OBEXProtocol BLUETOOTH_PROTOCOL_OBEX
#define SDP_L2CAPProtocol BLUETOOTH_PROTOCOL_L2CAP
#define SDP_BNEPProtocol BLUETOOTH_PROTOCOL_BNEP
#define SDP_AVDTPProtocol BLUETOOTH_PROTOCOL_AVDTP
/** .. until here ..*/
// OFFSETS FOR LOCALIZED ATTRIBUTES - SDP_LanguageBaseAttributeIDList
#define SDP_Offest_ServiceName 0x0000

View File

@ -370,7 +370,7 @@ void avdtp_packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet
break;
}
psm = l2cap_event_channel_opened_get_psm(packet);
if (psm != PSM_AVDTP){
if (psm != BLUETOOTH_PROTOCOL_AVDTP){
log_error("unexpected PSM - Not implemented yet, avdtp sink: L2CAP_EVENT_CHANNEL_OPENED");
return;
}
@ -381,7 +381,7 @@ void avdtp_packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet
// printf("L2CAP_EVENT_CHANNEL_OPENED: Channel successfully opened: %s, handle 0x%02x, psm 0x%02x, local cid 0x%02x, remote cid 0x%02x\n",
// bd_addr_to_str(event_addr), con_handle, psm, local_cid, l2cap_event_channel_opened_get_remote_cid(packet));
if (psm != PSM_AVDTP) break;
if (psm != BLUETOOTH_PROTOCOL_AVDTP) break;
connection = avdtp_connection_for_bd_addr(event_addr, context);
if (!connection) break;

View File

@ -62,8 +62,8 @@ extern "C" {
#define MAX_NUM_SEPS 10
// protocols
#define PSM_AVCTP 0x0017
#define PSM_AVDTP 0x0019
#define PSM_AVCTP BLUETOOTH_PROTOCOL_AVCTP
#define PSM_AVDTP BLUETOOTH_PROTOCOL_AVDTP
// service classes
#define AUDIO_SOURCE_GROUP 0x110A

View File

@ -208,7 +208,7 @@ void avdtp_initiator_stream_config_subsm(avdtp_connection_t * connection, uint8_
}
stream_endpoint->state = AVDTP_STREAM_ENDPOINT_W4_L2CAP_FOR_MEDIA_CONNECTED;
connection->query_seid = stream_endpoint->sep.seid;
l2cap_create_channel(context->packet_handler, connection->remote_addr, PSM_AVDTP, 0xffff, NULL);
l2cap_create_channel(context->packet_handler, connection->remote_addr, BLUETOOTH_PROTOCOL_AVDTP, 0xffff, NULL);
return;
case AVDTP_SI_START:
printf("AVDTP_SI_START\n");

View File

@ -65,11 +65,11 @@ void a2dp_sink_create_sdp_record(uint8_t * service, uint32_t service_record_han
de_create_sequence(service);
// 0x0000 "Service Record Handle"
de_add_number(service, DE_UINT, DE_SIZE_16, SDP_ServiceRecordHandle);
de_add_number(service, DE_UINT, DE_SIZE_16, BLUETOOTH_ATTRIBUTE_SERVICE_RECORD_HANDLE);
de_add_number(service, DE_UINT, DE_SIZE_32, service_record_handle);
// 0x0001 "Service Class ID List"
de_add_number(service, DE_UINT, DE_SIZE_16, SDP_ServiceClassIDList);
de_add_number(service, DE_UINT, DE_SIZE_16, BLUETOOTH_ATTRIBUTE_SERVICE_CLASS_ID_LIST);
attribute = de_push_sequence(service);
{
de_add_number(attribute, DE_UUID, DE_SIZE_16, AUDIO_SINK_GROUP);
@ -77,19 +77,19 @@ void a2dp_sink_create_sdp_record(uint8_t * service, uint32_t service_record_han
de_pop_sequence(service, attribute);
// 0x0004 "Protocol Descriptor List"
de_add_number(service, DE_UINT, DE_SIZE_16, SDP_ProtocolDescriptorList);
de_add_number(service, DE_UINT, DE_SIZE_16, BLUETOOTH_ATTRIBUTE_PROTOCOL_DESCRIPTOR_LIST);
attribute = de_push_sequence(service);
{
uint8_t* l2cpProtocol = de_push_sequence(attribute);
{
de_add_number(l2cpProtocol, DE_UUID, DE_SIZE_16, SDP_L2CAPProtocol);
de_add_number(l2cpProtocol, DE_UINT, DE_SIZE_16, PSM_AVDTP);
de_add_number(l2cpProtocol, DE_UUID, DE_SIZE_16, BLUETOOTH_PROTOCOL_L2CAP);
de_add_number(l2cpProtocol, DE_UINT, DE_SIZE_16, BLUETOOTH_PROTOCOL_AVDTP);
}
de_pop_sequence(attribute, l2cpProtocol);
uint8_t* avProtocol = de_push_sequence(attribute);
{
de_add_number(avProtocol, DE_UUID, DE_SIZE_16, PSM_AVDTP); // avProtocol_service
de_add_number(avProtocol, DE_UUID, DE_SIZE_16, BLUETOOTH_PROTOCOL_AVDTP); // avProtocol_service
de_add_number(avProtocol, DE_UINT, DE_SIZE_16, 0x0103); // version
}
de_pop_sequence(attribute, avProtocol);
@ -97,15 +97,15 @@ void a2dp_sink_create_sdp_record(uint8_t * service, uint32_t service_record_han
de_pop_sequence(service, attribute);
// 0x0005 "Public Browse Group"
de_add_number(service, DE_UINT, DE_SIZE_16, SDP_BrowseGroupList); // public browse group
de_add_number(service, DE_UINT, DE_SIZE_16, BLUETOOTH_ATTRIBUTE_BROWSE_GROUP_LIST); // public browse group
attribute = de_push_sequence(service);
{
de_add_number(attribute, DE_UUID, DE_SIZE_16, SDP_PublicBrowseGroup);
de_add_number(attribute, DE_UUID, DE_SIZE_16, BLUETOOTH_ATTRIBUTE_PUBLIC_BROWSE_ROOT);
}
de_pop_sequence(service, attribute);
// 0x0009 "Bluetooth Profile Descriptor List"
de_add_number(service, DE_UINT, DE_SIZE_16, SDP_BluetoothProfileDescriptorList);
de_add_number(service, DE_UINT, DE_SIZE_16, BLUETOOTH_ATTRIBUTE_BLUETOOTH_PROFILE_DESCRIPTOR_LIST);
attribute = de_push_sequence(service);
{
uint8_t *a2dProfile = de_push_sequence(attribute);
@ -200,7 +200,7 @@ void avdtp_sink_init(void){
avdtp_sink_context.stream_endpoints_id_counter = 0;
// TODO: assign dummy handlers;
l2cap_register_service(&packet_handler, PSM_AVDTP, 0xffff, LEVEL_0);
l2cap_register_service(&packet_handler, BLUETOOTH_PROTOCOL_AVDTP, 0xffff, LEVEL_0);
}
avdtp_stream_endpoint_t * avdtp_sink_create_stream_endpoint(avdtp_sep_type_t sep_type, avdtp_media_type_t media_type){
@ -230,7 +230,7 @@ void avdtp_sink_connect(bd_addr_t bd_addr){
}
if (connection->state != AVDTP_SIGNALING_CONNECTION_IDLE) return;
connection->state = AVDTP_SIGNALING_CONNECTION_W4_L2CAP_CONNECTED;
l2cap_create_channel(packet_handler, connection->remote_addr, PSM_AVDTP, 0xffff, NULL);
l2cap_create_channel(packet_handler, connection->remote_addr, BLUETOOTH_PROTOCOL_AVDTP, 0xffff, NULL);
}
void avdtp_sink_disconnect(uint16_t con_handle){

View File

@ -66,11 +66,11 @@ void a2dp_source_create_sdp_record(uint8_t * service, uint32_t service_record_ha
de_create_sequence(service);
// 0x0000 "Service Record Handle"
de_add_number(service, DE_UINT, DE_SIZE_16, SDP_ServiceRecordHandle);
de_add_number(service, DE_UINT, DE_SIZE_16, BLUETOOTH_ATTRIBUTE_SERVICE_RECORD_HANDLE);
de_add_number(service, DE_UINT, DE_SIZE_32, service_record_handle);
// 0x0001 "Service Class ID List"
de_add_number(service, DE_UINT, DE_SIZE_16, SDP_ServiceClassIDList);
de_add_number(service, DE_UINT, DE_SIZE_16, BLUETOOTH_ATTRIBUTE_SERVICE_CLASS_ID_LIST);
attribute = de_push_sequence(service);
{
de_add_number(attribute, DE_UUID, DE_SIZE_16, AUDIO_SOURCE_GROUP);
@ -78,19 +78,19 @@ void a2dp_source_create_sdp_record(uint8_t * service, uint32_t service_record_ha
de_pop_sequence(service, attribute);
// 0x0004 "Protocol Descriptor List"
de_add_number(service, DE_UINT, DE_SIZE_16, SDP_ProtocolDescriptorList);
de_add_number(service, DE_UINT, DE_SIZE_16, BLUETOOTH_ATTRIBUTE_PROTOCOL_DESCRIPTOR_LIST);
attribute = de_push_sequence(service);
{
uint8_t* l2cpProtocol = de_push_sequence(attribute);
{
de_add_number(l2cpProtocol, DE_UUID, DE_SIZE_16, SDP_L2CAPProtocol);
de_add_number(l2cpProtocol, DE_UINT, DE_SIZE_16, PSM_AVDTP);
de_add_number(l2cpProtocol, DE_UUID, DE_SIZE_16, BLUETOOTH_PROTOCOL_L2CAP);
de_add_number(l2cpProtocol, DE_UINT, DE_SIZE_16, BLUETOOTH_PROTOCOL_AVDTP);
}
de_pop_sequence(attribute, l2cpProtocol);
uint8_t* avProtocol = de_push_sequence(attribute);
{
de_add_number(avProtocol, DE_UUID, DE_SIZE_16, PSM_AVDTP); // avProtocol_service
de_add_number(avProtocol, DE_UUID, DE_SIZE_16, BLUETOOTH_PROTOCOL_AVDTP); // avProtocol_service
de_add_number(avProtocol, DE_UINT, DE_SIZE_16, 0x0103); // version
}
de_pop_sequence(attribute, avProtocol);
@ -98,15 +98,15 @@ void a2dp_source_create_sdp_record(uint8_t * service, uint32_t service_record_ha
de_pop_sequence(service, attribute);
// 0x0005 "Public Browse Group"
de_add_number(service, DE_UINT, DE_SIZE_16, SDP_BrowseGroupList); // public browse group
de_add_number(service, DE_UINT, DE_SIZE_16, BLUETOOTH_ATTRIBUTE_BROWSE_GROUP_LIST); // public browse group
attribute = de_push_sequence(service);
{
de_add_number(attribute, DE_UUID, DE_SIZE_16, SDP_PublicBrowseGroup);
de_add_number(attribute, DE_UUID, DE_SIZE_16, BLUETOOTH_ATTRIBUTE_PUBLIC_BROWSE_ROOT);
}
de_pop_sequence(service, attribute);
// 0x0009 "Bluetooth Profile Descriptor List"
de_add_number(service, DE_UINT, DE_SIZE_16, SDP_BluetoothProfileDescriptorList);
de_add_number(service, DE_UINT, DE_SIZE_16, BLUETOOTH_ATTRIBUTE_BLUETOOTH_PROFILE_DESCRIPTOR_LIST);
attribute = de_push_sequence(service);
{
uint8_t *a2dProfile = de_push_sequence(attribute);
@ -200,7 +200,7 @@ void avdtp_source_connect(bd_addr_t bd_addr){
}
if (connection->state != AVDTP_SIGNALING_CONNECTION_IDLE) return;
connection->state = AVDTP_SIGNALING_CONNECTION_W4_L2CAP_CONNECTED;
l2cap_create_channel(packet_handler, connection->remote_addr, PSM_AVDTP, 0xffff, NULL);
l2cap_create_channel(packet_handler, connection->remote_addr, BLUETOOTH_PROTOCOL_AVDTP, 0xffff, NULL);
}
void avdtp_source_disconnect(uint16_t con_handle){
@ -436,5 +436,5 @@ void avdtp_source_init(void){
wav_writer_open(wav_filename, NUM_CHANNELS, SAMPLE_RATE);
btstack_sbc_decoder_init(&state, mode, handle_pcm_data, NULL);
l2cap_register_service(&packet_handler, PSM_AVDTP, 0xffff, LEVEL_0);
l2cap_register_service(&packet_handler, BLUETOOTH_PROTOCOL_AVDTP, 0xffff, LEVEL_0);
}

View File

@ -50,7 +50,7 @@
#define AV_REMOTE_CONTROL 0x110E
#define AV_REMOTE_CONTROL_CONTROLLER 0x110F
#define PSM_AVCTP 0x0017
#define PSM_AVCTP BLUETOOTH_PROTOCOL_AVCTP
#define PSM_AVCTP_BROWSING 0xFF17
/*
@ -211,11 +211,11 @@ static void avrcp_create_sdp_record(uint8_t controller, uint8_t * service, uint3
de_create_sequence(service);
// 0x0000 "Service Record Handle"
de_add_number(service, DE_UINT, DE_SIZE_16, SDP_ServiceRecordHandle);
de_add_number(service, DE_UINT, DE_SIZE_16, BLUETOOTH_ATTRIBUTE_SERVICE_RECORD_HANDLE);
de_add_number(service, DE_UINT, DE_SIZE_32, service_record_handle);
// 0x0001 "Service Class ID List"
de_add_number(service, DE_UINT, DE_SIZE_16, SDP_ServiceClassIDList);
de_add_number(service, DE_UINT, DE_SIZE_16, BLUETOOTH_ATTRIBUTE_SERVICE_CLASS_ID_LIST);
attribute = de_push_sequence(service);
{
if (controller){
@ -228,37 +228,37 @@ static void avrcp_create_sdp_record(uint8_t controller, uint8_t * service, uint3
de_pop_sequence(service, attribute);
// 0x0004 "Protocol Descriptor List"
de_add_number(service, DE_UINT, DE_SIZE_16, SDP_ProtocolDescriptorList);
de_add_number(service, DE_UINT, DE_SIZE_16, BLUETOOTH_ATTRIBUTE_PROTOCOL_DESCRIPTOR_LIST);
attribute = de_push_sequence(service);
{
uint8_t* l2cpProtocol = de_push_sequence(attribute);
{
de_add_number(l2cpProtocol, DE_UUID, DE_SIZE_16, SDP_L2CAPProtocol);
de_add_number(l2cpProtocol, DE_UINT, DE_SIZE_16, PSM_AVCTP);
de_add_number(l2cpProtocol, DE_UUID, DE_SIZE_16, BLUETOOTH_PROTOCOL_L2CAP);
de_add_number(l2cpProtocol, DE_UINT, DE_SIZE_16, BLUETOOTH_PROTOCOL_AVCTP);
}
de_pop_sequence(attribute, l2cpProtocol);
uint8_t* avctpProtocol = de_push_sequence(attribute);
{
de_add_number(avctpProtocol, DE_UUID, DE_SIZE_16, PSM_AVCTP); // avctpProtocol_service
de_add_number(avctpProtocol, DE_UUID, DE_SIZE_16, BLUETOOTH_PROTOCOL_AVCTP); // avctpProtocol_service
de_add_number(avctpProtocol, DE_UINT, DE_SIZE_16, 0x0103); // version
}
de_pop_sequence(attribute, avctpProtocol);
if (browsing){
de_add_number(service, DE_UINT, DE_SIZE_16, SDP_ProtocolDescriptorList);
de_add_number(service, DE_UINT, DE_SIZE_16, BLUETOOTH_ATTRIBUTE_PROTOCOL_DESCRIPTOR_LIST);
attribute = de_push_sequence(service);
{
uint8_t* browsing_l2cpProtocol = de_push_sequence(attribute);
{
de_add_number(browsing_l2cpProtocol, DE_UUID, DE_SIZE_16, SDP_L2CAPProtocol);
de_add_number(browsing_l2cpProtocol, DE_UUID, DE_SIZE_16, BLUETOOTH_PROTOCOL_L2CAP);
de_add_number(browsing_l2cpProtocol, DE_UINT, DE_SIZE_16, PSM_AVCTP_BROWSING);
}
de_pop_sequence(attribute, browsing_l2cpProtocol);
uint8_t* browsing_avctpProtocol = de_push_sequence(attribute);
{
de_add_number(browsing_avctpProtocol, DE_UUID, DE_SIZE_16, PSM_AVCTP); // browsing_avctpProtocol_service
de_add_number(browsing_avctpProtocol, DE_UUID, DE_SIZE_16, BLUETOOTH_PROTOCOL_AVCTP); // browsing_avctpProtocol_service
de_add_number(browsing_avctpProtocol, DE_UINT, DE_SIZE_16, 0x0103); // version
}
de_pop_sequence(attribute, browsing_avctpProtocol);
@ -269,15 +269,15 @@ static void avrcp_create_sdp_record(uint8_t controller, uint8_t * service, uint3
de_pop_sequence(service, attribute);
// 0x0005 "Public Browse Group"
de_add_number(service, DE_UINT, DE_SIZE_16, SDP_BrowseGroupList); // public browse group
de_add_number(service, DE_UINT, DE_SIZE_16, BLUETOOTH_ATTRIBUTE_BROWSE_GROUP_LIST); // public browse group
attribute = de_push_sequence(service);
{
de_add_number(attribute, DE_UUID, DE_SIZE_16, SDP_PublicBrowseGroup);
de_add_number(attribute, DE_UUID, DE_SIZE_16, BLUETOOTH_ATTRIBUTE_PUBLIC_BROWSE_ROOT);
}
de_pop_sequence(service, attribute);
// 0x0009 "Bluetooth Profile Descriptor List"
de_add_number(service, DE_UINT, DE_SIZE_16, SDP_BluetoothProfileDescriptorList);
de_add_number(service, DE_UINT, DE_SIZE_16, BLUETOOTH_ATTRIBUTE_BLUETOOTH_PROFILE_DESCRIPTOR_LIST);
attribute = de_push_sequence(service);
{
uint8_t *avrcProfile = de_push_sequence(attribute);
@ -1081,7 +1081,7 @@ static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packe
break;
}
psm = l2cap_event_channel_opened_get_psm(packet);
if (psm != PSM_AVCTP){
if (psm != BLUETOOTH_PROTOCOL_AVCTP){
log_error("unexpected PSM - Not implemented yet: L2CAP_EVENT_CHANNEL_OPENED");
return;
}
@ -1129,7 +1129,7 @@ static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packe
void avrcp_init(void){
avrcp_connections = NULL;
l2cap_register_service(&packet_handler, PSM_AVCTP, 0xffff, LEVEL_0);
l2cap_register_service(&packet_handler, BLUETOOTH_PROTOCOL_AVCTP, 0xffff, LEVEL_0);
}
void avrcp_register_packet_handler(btstack_packet_handler_t callback){
@ -1151,7 +1151,7 @@ void avrcp_connect(bd_addr_t bd_addr){
}
if (connection->state != AVCTP_CONNECTION_IDLE) return;
connection->state = AVCTP_CONNECTION_W4_L2CAP_CONNECTED;
l2cap_create_channel(packet_handler, connection->remote_addr, PSM_AVCTP, 0xffff, NULL);
l2cap_create_channel(packet_handler, connection->remote_addr, BLUETOOTH_PROTOCOL_AVCTP, 0xffff, NULL);
}
void avrcp_unit_info(uint16_t con_handle){

View File

@ -49,6 +49,7 @@
#include <stdint.h>
#include "bnep.h"
#include "bluetooth_sdp.h"
#include "btstack_debug.h"
#include "btstack_event.h"
#include "btstack_memory.h"
@ -821,15 +822,15 @@ static int bnep_handle_connection_request(bnep_channel_t *channel, uint8_t *pack
channel->uuid_dest = big_endian_read_16(packet, 2 + uuid_offset);
channel->uuid_source = big_endian_read_16(packet, 2 + uuid_offset + uuid_size);
if ((channel->uuid_dest != SDP_PANU) &&
(channel->uuid_dest != SDP_NAP) &&
(channel->uuid_dest != SDP_GN)) {
if ((channel->uuid_dest != BLUETOOTH_SERVICE_CLASS_PANU) &&
(channel->uuid_dest != BLUETOOTH_SERVICE_CLASS_NAP) &&
(channel->uuid_dest != BLUETOOTH_SERVICE_CLASS_GN)) {
log_error("BNEP_CONNECTION_REQUEST: Invalid destination service UUID: %04x", channel->uuid_dest);
channel->uuid_dest = 0;
}
if ((channel->uuid_source != SDP_PANU) &&
(channel->uuid_source != SDP_NAP) &&
(channel->uuid_source != SDP_GN)) {
if ((channel->uuid_source != BLUETOOTH_SERVICE_CLASS_PANU) &&
(channel->uuid_source != BLUETOOTH_SERVICE_CLASS_NAP) &&
(channel->uuid_source != BLUETOOTH_SERVICE_CLASS_GN)) {
log_error("BNEP_CONNECTION_REQUEST: Invalid source service UUID: %04x", channel->uuid_source);
channel->uuid_source = 0;
}
@ -842,7 +843,7 @@ static int bnep_handle_connection_request(bnep_channel_t *channel, uint8_t *pack
// use packet handler for service
channel->packet_handler = service->packet_handler;
if ((channel->uuid_source != SDP_PANU) && (channel->uuid_dest != SDP_PANU)) {
if ((channel->uuid_source != BLUETOOTH_SERVICE_CLASS_PANU) && (channel->uuid_dest != BLUETOOTH_SERVICE_CLASS_PANU)) {
response_code = BNEP_RESP_SETUP_INVALID_SOURCE_UUID;
}
}
@ -1182,7 +1183,7 @@ static int bnep_hci_event_handler(uint8_t *packet, uint16_t size)
switch (hci_event_packet_get_type(packet)) {
/* Accept an incoming L2CAP connection on PSM_BNEP */
/* Accept an incoming L2CAP connection on BLUETOOTH_PROTOCOL_BNEP */
case L2CAP_EVENT_INCOMING_CONNECTION:
/* L2CAP event data: event(8), len(8), address(48), handle (16), psm (16), source cid(16) dest cid(16) */
reverse_bd_addr(&packet[2], event_addr);
@ -1190,12 +1191,12 @@ static int bnep_hci_event_handler(uint8_t *packet, uint16_t size)
psm = little_endian_read_16(packet, 10);
l2cap_cid = little_endian_read_16(packet, 12);
if (psm != PSM_BNEP) break;
if (psm != BLUETOOTH_PROTOCOL_BNEP) break;
channel = bnep_channel_for_addr(event_addr);
if (channel) {
log_error("INCOMING_CONNECTION (l2cap_cid 0x%02x) for PSM_BNEP => decline - channel already exists", l2cap_cid);
log_error("INCOMING_CONNECTION (l2cap_cid 0x%02x) for BLUETOOTH_PROTOCOL_BNEP => decline - channel already exists", l2cap_cid);
l2cap_decline_connection(l2cap_cid);
return 1;
}
@ -1204,7 +1205,7 @@ static int bnep_hci_event_handler(uint8_t *packet, uint16_t size)
channel = bnep_channel_create_for_addr(event_addr);
if (!channel) {
log_error("INCOMING_CONNECTION (l2cap_cid 0x%02x) for PSM_BNEP => decline - no memory left", l2cap_cid);
log_error("INCOMING_CONNECTION (l2cap_cid 0x%02x) for BLUETOOTH_PROTOCOL_BNEP => decline - no memory left", l2cap_cid);
l2cap_decline_connection(l2cap_cid);
return 1;
}
@ -1219,19 +1220,19 @@ static int bnep_hci_event_handler(uint8_t *packet, uint16_t size)
/* Start connection timeout timer */
bnep_channel_start_timer(channel, BNEP_CONNECTION_TIMEOUT_MS);
log_info("L2CAP_EVENT_INCOMING_CONNECTION (l2cap_cid 0x%02x) for PSM_BNEP => accept", l2cap_cid);
log_info("L2CAP_EVENT_INCOMING_CONNECTION (l2cap_cid 0x%02x) for BLUETOOTH_PROTOCOL_BNEP => accept", l2cap_cid);
l2cap_accept_connection(l2cap_cid);
return 1;
/* Outgoing L2CAP connection has been opened -> store l2cap_cid, remote_addr */
case L2CAP_EVENT_CHANNEL_OPENED:
/* Check if the l2cap channel has been opened for PSM_BNEP */
if (little_endian_read_16(packet, 11) != PSM_BNEP) {
/* Check if the l2cap channel has been opened for BLUETOOTH_PROTOCOL_BNEP */
if (little_endian_read_16(packet, 11) != BLUETOOTH_PROTOCOL_BNEP) {
break;
}
status = packet[2];
log_info("L2CAP_EVENT_CHANNEL_OPENED for PSM_BNEP, status %u", status);
log_info("L2CAP_EVENT_CHANNEL_OPENED for BLUETOOTH_PROTOCOL_BNEP, status %u", status);
/* Get the bnep channel fpr remote address */
con_handle = little_endian_read_16(packet, 9);
@ -1587,9 +1588,9 @@ uint8_t bnep_register_service(btstack_packet_handler_t packet_handler, uint16_t
}
/* Only alow one the three service types: PANU, NAP, GN */
if ((service_uuid != SDP_PANU) &&
(service_uuid != SDP_NAP) &&
(service_uuid != SDP_GN)) {
if ((service_uuid != BLUETOOTH_SERVICE_CLASS_PANU) &&
(service_uuid != BLUETOOTH_SERVICE_CLASS_NAP) &&
(service_uuid != BLUETOOTH_SERVICE_CLASS_GN)) {
log_info("BNEP_REGISTER_SERVICE: Invalid service UUID: %04x", service_uuid);
return BNEP_SERVICE_ALREADY_REGISTERED; // TODO: define own error
}
@ -1602,7 +1603,7 @@ uint8_t bnep_register_service(btstack_packet_handler_t packet_handler, uint16_t
memset(service, 0, sizeof(bnep_service_t));
/* register with l2cap if not registered before, max MTU */
l2cap_register_service(bnep_packet_handler, PSM_BNEP, 0xffff, bnep_security_level);
l2cap_register_service(bnep_packet_handler, BLUETOOTH_PROTOCOL_BNEP, 0xffff, bnep_security_level);
/* Setup the service struct */
service->max_frame_size = max_frame_size;
@ -1629,6 +1630,6 @@ void bnep_unregister_service(uint16_t service_uuid)
btstack_memory_bnep_service_free(service);
service = NULL;
l2cap_unregister_service(PSM_BNEP);
l2cap_unregister_service(BLUETOOTH_PROTOCOL_BNEP);
}

View File

@ -71,10 +71,10 @@ void device_id_create_sdp_record(uint8_t *service, uint32_t service_record_handl
de_pop_sequence(service, attribute);
// 0x0005 "Public Browse Group"
de_add_number(service, DE_UINT, DE_SIZE_16, SDP_BrowseGroupList); // public browse group
de_add_number(service, DE_UINT, DE_SIZE_16, BLUETOOTH_ATTRIBUTE_BROWSE_GROUP_LIST); // public browse group
attribute = de_push_sequence(service);
{
de_add_number(attribute, DE_UUID, DE_SIZE_16, SDP_PublicBrowseGroup );
de_add_number(attribute, DE_UUID, DE_SIZE_16, BLUETOOTH_ATTRIBUTE_PUBLIC_BROWSE_ROOT );
}
de_pop_sequence(service, attribute);

View File

@ -46,6 +46,7 @@
#include <string.h>
#include <inttypes.h>
#include "bluetooth_sdp.h"
#include "btstack_debug.h"
#include "btstack_event.h"
#include "btstack_memory.h"
@ -395,32 +396,32 @@ void hfp_create_sdp_record(uint8_t * service, uint32_t service_record_handle, ui
de_create_sequence(service);
// 0x0000 "Service Record Handle"
de_add_number(service, DE_UINT, DE_SIZE_16, SDP_ServiceRecordHandle);
de_add_number(service, DE_UINT, DE_SIZE_16, BLUETOOTH_ATTRIBUTE_SERVICE_RECORD_HANDLE);
de_add_number(service, DE_UINT, DE_SIZE_32, service_record_handle);
// 0x0001 "Service Class ID List"
de_add_number(service, DE_UINT, DE_SIZE_16, SDP_ServiceClassIDList);
de_add_number(service, DE_UINT, DE_SIZE_16, BLUETOOTH_ATTRIBUTE_SERVICE_CLASS_ID_LIST);
attribute = de_push_sequence(service);
{
// "UUID for Service"
de_add_number(attribute, DE_UUID, DE_SIZE_16, service_uuid);
de_add_number(attribute, DE_UUID, DE_SIZE_16, SDP_GenericAudio);
de_add_number(attribute, DE_UUID, DE_SIZE_16, BLUETOOTH_SERVICE_CLASS_GENERIC_AUDIO);
}
de_pop_sequence(service, attribute);
// 0x0004 "Protocol Descriptor List"
de_add_number(service, DE_UINT, DE_SIZE_16, SDP_ProtocolDescriptorList);
de_add_number(service, DE_UINT, DE_SIZE_16, BLUETOOTH_ATTRIBUTE_PROTOCOL_DESCRIPTOR_LIST);
attribute = de_push_sequence(service);
{
uint8_t* l2cpProtocol = de_push_sequence(attribute);
{
de_add_number(l2cpProtocol, DE_UUID, DE_SIZE_16, SDP_L2CAPProtocol);
de_add_number(l2cpProtocol, DE_UUID, DE_SIZE_16, BLUETOOTH_PROTOCOL_L2CAP);
}
de_pop_sequence(attribute, l2cpProtocol);
uint8_t* rfcomm = de_push_sequence(attribute);
{
de_add_number(rfcomm, DE_UUID, DE_SIZE_16, SDP_RFCOMMProtocol); // rfcomm_service
de_add_number(rfcomm, DE_UUID, DE_SIZE_16, BLUETOOTH_PROTOCOL_RFCOMM); // rfcomm_service
de_add_number(rfcomm, DE_UINT, DE_SIZE_8, rfcomm_channel_nr); // rfcomm channel
}
de_pop_sequence(attribute, rfcomm);
@ -429,20 +430,20 @@ void hfp_create_sdp_record(uint8_t * service, uint32_t service_record_handle, ui
// 0x0005 "Public Browse Group"
de_add_number(service, DE_UINT, DE_SIZE_16, SDP_BrowseGroupList); // public browse group
de_add_number(service, DE_UINT, DE_SIZE_16, BLUETOOTH_ATTRIBUTE_BROWSE_GROUP_LIST); // public browse group
attribute = de_push_sequence(service);
{
de_add_number(attribute, DE_UUID, DE_SIZE_16, SDP_PublicBrowseGroup);
de_add_number(attribute, DE_UUID, DE_SIZE_16, BLUETOOTH_ATTRIBUTE_PUBLIC_BROWSE_ROOT);
}
de_pop_sequence(service, attribute);
// 0x0009 "Bluetooth Profile Descriptor List"
de_add_number(service, DE_UINT, DE_SIZE_16, SDP_BluetoothProfileDescriptorList);
de_add_number(service, DE_UINT, DE_SIZE_16, BLUETOOTH_ATTRIBUTE_BLUETOOTH_PROFILE_DESCRIPTOR_LIST);
attribute = de_push_sequence(service);
{
uint8_t *sppProfile = de_push_sequence(attribute);
{
de_add_number(sppProfile, DE_UUID, DE_SIZE_16, SDP_Handsfree);
de_add_number(sppProfile, DE_UUID, DE_SIZE_16, BLUETOOTH_SERVICE_CLASS_HANDSFREE);
de_add_number(sppProfile, DE_UINT, DE_SIZE_16, 0x0107); // Verision 1.7
}
de_pop_sequence(attribute, sppProfile);

View File

@ -53,6 +53,7 @@
#include "hci_cmd.h"
#include "btstack_run_loop.h"
#include "bluetooth_sdp.h"
#include "hci.h"
#include "btstack_memory.h"
#include "hci_dump.h"
@ -186,7 +187,7 @@ void hfp_ag_create_sdp_record(uint8_t * service, uint32_t service_record_handle,
if (!name){
name = default_hfp_ag_service_name;
}
hfp_create_sdp_record(service, service_record_handle, SDP_HandsfreeAudioGateway, rfcomm_channel_nr, name);
hfp_create_sdp_record(service, service_record_handle, BLUETOOTH_SERVICE_CLASS_HANDSFREE_AUDIO_GATEWAY, rfcomm_channel_nr, name);
/*
* 0x01 Ability to reject a call
@ -2093,7 +2094,7 @@ void hfp_ag_init(uint16_t rfcomm_channel_nr){
}
void hfp_ag_establish_service_level_connection(bd_addr_t bd_addr){
hfp_establish_service_level_connection(bd_addr, SDP_Handsfree);
hfp_establish_service_level_connection(bd_addr, BLUETOOTH_SERVICE_CLASS_HANDSFREE);
}
void hfp_ag_release_service_level_connection(hci_con_handle_t acl_handle){

View File

@ -50,6 +50,7 @@
#include <stdlib.h>
#include <string.h>
#include "bluetooth_sdp.h"
#include "btstack_debug.h"
#include "btstack_memory.h"
#include "btstack_run_loop.h"
@ -166,7 +167,7 @@ void hfp_hf_create_sdp_record(uint8_t * service, uint32_t service_record_handle,
if (!name){
name = default_hfp_hf_service_name;
}
hfp_create_sdp_record(service, service_record_handle, SDP_Handsfree, rfcomm_channel_nr, name);
hfp_create_sdp_record(service, service_record_handle, BLUETOOTH_SERVICE_CLASS_HANDSFREE, rfcomm_channel_nr, name);
// Construct SupportedFeatures for SDP bitmap:
//
@ -1148,7 +1149,7 @@ void hfp_hf_init_hf_indicators(int indicators_nr, uint16_t * indicators){
}
void hfp_hf_establish_service_level_connection(bd_addr_t bd_addr){
hfp_establish_service_level_connection(bd_addr, SDP_HandsfreeAudioGateway);
hfp_establish_service_level_connection(bd_addr, BLUETOOTH_SERVICE_CLASS_HANDSFREE_AUDIO_GATEWAY);
}
void hfp_hf_release_service_level_connection(hci_con_handle_t acl_handle){

View File

@ -50,6 +50,7 @@
#include <stdlib.h>
#include <string.h>
#include "bluetooth_sdp.h"
#include "btstack_debug.h"
#include "btstack_event.h"
#include "btstack_memory.h"
@ -173,32 +174,32 @@ void hsp_ag_create_sdp_record(uint8_t * service, uint32_t service_record_handle,
de_create_sequence(service);
// 0x0000 "Service Record Handle"
de_add_number(service, DE_UINT, DE_SIZE_16, SDP_ServiceRecordHandle);
de_add_number(service, DE_UINT, DE_SIZE_16, BLUETOOTH_ATTRIBUTE_SERVICE_RECORD_HANDLE);
de_add_number(service, DE_UINT, DE_SIZE_32, service_record_handle);
// 0x0001 "Service Class ID List"
de_add_number(service, DE_UINT, DE_SIZE_16, SDP_ServiceClassIDList);
de_add_number(service, DE_UINT, DE_SIZE_16, BLUETOOTH_ATTRIBUTE_SERVICE_CLASS_ID_LIST);
attribute = de_push_sequence(service);
{
// "UUID for PAN Service"
de_add_number(attribute, DE_UUID, DE_SIZE_16, SDP_Headset_AG);
de_add_number(attribute, DE_UUID, DE_SIZE_16, SDP_GenericAudio);
de_add_number(attribute, DE_UUID, DE_SIZE_16, BLUETOOTH_SERVICE_CLASS_HEADSET_AUDIO_GATEWAY_AG);
de_add_number(attribute, DE_UUID, DE_SIZE_16, BLUETOOTH_SERVICE_CLASS_GENERIC_AUDIO);
}
de_pop_sequence(service, attribute);
// 0x0004 "Protocol Descriptor List"
de_add_number(service, DE_UINT, DE_SIZE_16, SDP_ProtocolDescriptorList);
de_add_number(service, DE_UINT, DE_SIZE_16, BLUETOOTH_ATTRIBUTE_PROTOCOL_DESCRIPTOR_LIST);
attribute = de_push_sequence(service);
{
uint8_t* l2cpProtocol = de_push_sequence(attribute);
{
de_add_number(l2cpProtocol, DE_UUID, DE_SIZE_16, SDP_L2CAPProtocol);
de_add_number(l2cpProtocol, DE_UUID, DE_SIZE_16, BLUETOOTH_PROTOCOL_L2CAP);
}
de_pop_sequence(attribute, l2cpProtocol);
uint8_t* rfcomm = de_push_sequence(attribute);
{
de_add_number(rfcomm, DE_UUID, DE_SIZE_16, SDP_RFCOMMProtocol); // rfcomm_service
de_add_number(rfcomm, DE_UUID, DE_SIZE_16, BLUETOOTH_PROTOCOL_RFCOMM); // rfcomm_service
de_add_number(rfcomm, DE_UINT, DE_SIZE_8, rfcomm_channel_nr); // rfcomm channel
}
de_pop_sequence(attribute, rfcomm);
@ -206,20 +207,20 @@ void hsp_ag_create_sdp_record(uint8_t * service, uint32_t service_record_handle,
de_pop_sequence(service, attribute);
// 0x0005 "Public Browse Group"
de_add_number(service, DE_UINT, DE_SIZE_16, SDP_BrowseGroupList); // public browse group
de_add_number(service, DE_UINT, DE_SIZE_16, BLUETOOTH_ATTRIBUTE_BROWSE_GROUP_LIST); // public browse group
attribute = de_push_sequence(service);
{
de_add_number(attribute, DE_UUID, DE_SIZE_16, SDP_PublicBrowseGroup);
de_add_number(attribute, DE_UUID, DE_SIZE_16, BLUETOOTH_ATTRIBUTE_PUBLIC_BROWSE_ROOT);
}
de_pop_sequence(service, attribute);
// 0x0009 "Bluetooth Profile Descriptor List"
de_add_number(service, DE_UINT, DE_SIZE_16, SDP_BluetoothProfileDescriptorList);
de_add_number(service, DE_UINT, DE_SIZE_16, BLUETOOTH_ATTRIBUTE_BLUETOOTH_PROFILE_DESCRIPTOR_LIST);
attribute = de_push_sequence(service);
{
uint8_t *sppProfile = de_push_sequence(attribute);
{
de_add_number(sppProfile, DE_UUID, DE_SIZE_16, SDP_HSP);
de_add_number(sppProfile, DE_UUID, DE_SIZE_16, BLUETOOTH_SERVICE_CLASS_HEADSET);
de_add_number(sppProfile, DE_UINT, DE_SIZE_16, 0x0102); // Verision 1.2
}
de_pop_sequence(attribute, sppProfile);
@ -468,8 +469,8 @@ static void hsp_run(void){
switch (hsp_state){
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_client_query_rfcomm_channel_and_name_for_uuid(&handle_query_rfcomm_event, remote, SDP_HSP);
log_info("Start SDP query %s, 0x%02x", bd_addr_to_str(remote), BLUETOOTH_SERVICE_CLASS_HEADSET);
sdp_client_query_rfcomm_channel_and_name_for_uuid(&handle_query_rfcomm_event, remote, BLUETOOTH_SERVICE_CLASS_HEADSET);
break;
case HSP_W4_RING_ANSWER:

View File

@ -50,6 +50,7 @@
#include <stdlib.h>
#include <string.h>
#include "bluetooth_sdp.h"
#include "btstack_debug.h"
#include "btstack_event.h"
#include "btstack_memory.h"
@ -197,33 +198,33 @@ void hsp_hs_create_sdp_record(uint8_t * service, uint32_t service_record_handle
de_create_sequence(service);
// 0x0000 "Service Record Handle"
de_add_number(service, DE_UINT, DE_SIZE_16, SDP_ServiceRecordHandle);
de_add_number(service, DE_UINT, DE_SIZE_16, BLUETOOTH_ATTRIBUTE_SERVICE_RECORD_HANDLE);
de_add_number(service, DE_UINT, DE_SIZE_32, service_record_handle);
// 0x0001 "Service Class ID List"
de_add_number(service, DE_UINT, DE_SIZE_16, SDP_ServiceClassIDList);
de_add_number(service, DE_UINT, DE_SIZE_16, BLUETOOTH_ATTRIBUTE_SERVICE_CLASS_ID_LIST);
attribute = de_push_sequence(service);
{
// see Bluetooth Erratum #3507
de_add_number(attribute, DE_UUID, DE_SIZE_16, SDP_HSP); // 0x1108
de_add_number(attribute, DE_UUID, DE_SIZE_16, SDP_Headset_HS); // 0x1131
de_add_number(attribute, DE_UUID, DE_SIZE_16, SDP_GenericAudio); // 0x1203
de_add_number(attribute, DE_UUID, DE_SIZE_16, BLUETOOTH_SERVICE_CLASS_HEADSET); // 0x1108
de_add_number(attribute, DE_UUID, DE_SIZE_16, BLUETOOTH_SERVICE_CLASS_HEADSET_HS); // 0x1131
de_add_number(attribute, DE_UUID, DE_SIZE_16, BLUETOOTH_SERVICE_CLASS_GENERIC_AUDIO); // 0x1203
}
de_pop_sequence(service, attribute);
// 0x0004 "Protocol Descriptor List"
de_add_number(service, DE_UINT, DE_SIZE_16, SDP_ProtocolDescriptorList);
de_add_number(service, DE_UINT, DE_SIZE_16, BLUETOOTH_ATTRIBUTE_PROTOCOL_DESCRIPTOR_LIST);
attribute = de_push_sequence(service);
{
uint8_t* l2cpProtocol = de_push_sequence(attribute);
{
de_add_number(l2cpProtocol, DE_UUID, DE_SIZE_16, SDP_L2CAPProtocol);
de_add_number(l2cpProtocol, DE_UUID, DE_SIZE_16, BLUETOOTH_PROTOCOL_L2CAP);
}
de_pop_sequence(attribute, l2cpProtocol);
uint8_t* rfcomm = de_push_sequence(attribute);
{
de_add_number(rfcomm, DE_UUID, DE_SIZE_16, SDP_RFCOMMProtocol); // rfcomm_service
de_add_number(rfcomm, DE_UUID, DE_SIZE_16, BLUETOOTH_PROTOCOL_RFCOMM); // rfcomm_service
de_add_number(rfcomm, DE_UINT, DE_SIZE_8, rfcomm_channel_nr); // rfcomm channel
}
de_pop_sequence(attribute, rfcomm);
@ -231,20 +232,20 @@ void hsp_hs_create_sdp_record(uint8_t * service, uint32_t service_record_handle
de_pop_sequence(service, attribute);
// 0x0005 "Public Browse Group"
de_add_number(service, DE_UINT, DE_SIZE_16, SDP_BrowseGroupList); // public browse group
de_add_number(service, DE_UINT, DE_SIZE_16, BLUETOOTH_ATTRIBUTE_BROWSE_GROUP_LIST); // public browse group
attribute = de_push_sequence(service);
{
de_add_number(attribute, DE_UUID, DE_SIZE_16, SDP_PublicBrowseGroup);
de_add_number(attribute, DE_UUID, DE_SIZE_16, BLUETOOTH_ATTRIBUTE_PUBLIC_BROWSE_ROOT);
}
de_pop_sequence(service, attribute);
// 0x0009 "Bluetooth Profile Descriptor List"
de_add_number(service, DE_UINT, DE_SIZE_16, SDP_BluetoothProfileDescriptorList);
de_add_number(service, DE_UINT, DE_SIZE_16, BLUETOOTH_ATTRIBUTE_BLUETOOTH_PROFILE_DESCRIPTOR_LIST);
attribute = de_push_sequence(service);
{
uint8_t *hsp_profile = de_push_sequence(attribute);
{
de_add_number(hsp_profile, DE_UUID, DE_SIZE_16, SDP_HSP);
de_add_number(hsp_profile, DE_UUID, DE_SIZE_16, BLUETOOTH_SERVICE_CLASS_HEADSET);
de_add_number(hsp_profile, DE_UINT, DE_SIZE_16, 0x0102); // Verision 1.2
}
de_pop_sequence(attribute, hsp_profile);
@ -409,7 +410,7 @@ static void hsp_run(void){
switch (hsp_state){
case HSP_SDP_QUERY_RFCOMM_CHANNEL:
hsp_state = HSP_W4_SDP_QUERY_COMPLETE;
sdp_client_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, BLUETOOTH_SERVICE_CLASS_HEADSET_AUDIO_GATEWAY_AG);
break;
case HSP_AUDIO_CONNECTION_ESTABLISHED:

View File

@ -48,6 +48,7 @@
#include <stdio.h>
#include <string.h>
#include "bluetooth_sdp.h"
#include "btstack_config.h"
#include "classic/core.h"
#include "classic/sdp_util.h"
@ -70,11 +71,11 @@ static void pan_create_service(uint8_t *service, uint32_t service_record_handle,
de_create_sequence(service);
// 0x0000 "Service Record Handle"
de_add_number(service, DE_UINT, DE_SIZE_16, SDP_ServiceRecordHandle);
de_add_number(service, DE_UINT, DE_SIZE_16, BLUETOOTH_ATTRIBUTE_SERVICE_RECORD_HANDLE);
de_add_number(service, DE_UINT, DE_SIZE_32, service_record_handle);
// 0x0001 "Service Class ID List"
de_add_number(service, DE_UINT, DE_SIZE_16, SDP_ServiceClassIDList);
de_add_number(service, DE_UINT, DE_SIZE_16, BLUETOOTH_ATTRIBUTE_SERVICE_CLASS_ID_LIST);
attribute = de_push_sequence(service);
{
// "UUID for PAN Service"
@ -83,19 +84,19 @@ static void pan_create_service(uint8_t *service, uint32_t service_record_handle,
de_pop_sequence(service, attribute);
// 0x0004 "Protocol Descriptor List"
de_add_number(service, DE_UINT, DE_SIZE_16, SDP_ProtocolDescriptorList);
de_add_number(service, DE_UINT, DE_SIZE_16, BLUETOOTH_ATTRIBUTE_PROTOCOL_DESCRIPTOR_LIST);
attribute = de_push_sequence(service);
{
uint8_t* l2cpProtocol = de_push_sequence(attribute);
{
de_add_number(l2cpProtocol, DE_UUID, DE_SIZE_16, SDP_L2CAPProtocol);
de_add_number(l2cpProtocol, DE_UUID, DE_SIZE_16, BLUETOOTH_PROTOCOL_L2CAP);
de_add_number(l2cpProtocol, DE_UINT, DE_SIZE_16, PSM_BNEP); // l2cap psm
}
de_pop_sequence(attribute, l2cpProtocol);
uint8_t* bnep = de_push_sequence(attribute);
{
de_add_number(bnep, DE_UUID, DE_SIZE_16, SDP_BNEPProtocol);
de_add_number(bnep, DE_UUID, DE_SIZE_16, BLUETOOTH_PROTOCOL_BNEP);
de_add_number(bnep, DE_UINT, DE_SIZE_16, 0x0100); // version
uint8_t * net_packet_type_list = de_push_sequence(bnep);
@ -113,15 +114,15 @@ static void pan_create_service(uint8_t *service, uint32_t service_record_handle,
de_pop_sequence(service, attribute);
// 0x0005 "Public Browse Group"
de_add_number(service, DE_UINT, DE_SIZE_16, SDP_BrowseGroupList); // public browse group
de_add_number(service, DE_UINT, DE_SIZE_16, BLUETOOTH_ATTRIBUTE_BROWSE_GROUP_LIST); // public browse group
attribute = de_push_sequence(service);
{
de_add_number(attribute, DE_UUID, DE_SIZE_16, SDP_PublicBrowseGroup);
de_add_number(attribute, DE_UUID, DE_SIZE_16, BLUETOOTH_ATTRIBUTE_PUBLIC_BROWSE_ROOT);
}
de_pop_sequence(service, attribute);
// 0x0006 "LanguageBaseAttributeIDList"
de_add_number(service, DE_UINT, DE_SIZE_16, SDP_LanguageBaseAttributeIDList);
de_add_number(service, DE_UINT, DE_SIZE_16, BLUETOOTH_ATTRIBUTE_LANGUAGE_BASE_ATTRIBUTE_ID_LIST);
attribute = de_push_sequence(service);
{
de_add_number(attribute, DE_UINT, DE_SIZE_16, 0x656e);
@ -135,7 +136,7 @@ static void pan_create_service(uint8_t *service, uint32_t service_record_handle,
// de_add_number(service, DE_UINT, DE_SIZE_8, service_availability);
// 0x0009 "Bluetooth Profile Descriptor List"
de_add_number(service, DE_UINT, DE_SIZE_16, SDP_BluetoothProfileDescriptorList);
de_add_number(service, DE_UINT, DE_SIZE_16, BLUETOOTH_ATTRIBUTE_BLUETOOTH_PROFILE_DESCRIPTOR_LIST);
attribute = de_push_sequence(service);
{
uint8_t *sppProfile = de_push_sequence(attribute);
@ -153,13 +154,13 @@ static void pan_create_service(uint8_t *service, uint32_t service_record_handle,
de_add_data(service, DE_STRING, strlen(name), (uint8_t *) name);
} else {
switch (service_uuid){
case SDP_PANU:
case BLUETOOTH_SERVICE_CLASS_PANU:
de_add_data(service, DE_STRING, strlen(default_panu_service_name), (uint8_t *) default_panu_service_name);
break;
case SDP_NAP:
case BLUETOOTH_SERVICE_CLASS_NAP:
de_add_data(service, DE_STRING, strlen(default_nap_service_name), (uint8_t *) default_nap_service_name);
break;
case SDP_GN:
case BLUETOOTH_SERVICE_CLASS_GN:
de_add_data(service, DE_STRING, strlen(default_gn_service_name), (uint8_t *) default_gn_service_name);
break;
default:
@ -173,13 +174,13 @@ static void pan_create_service(uint8_t *service, uint32_t service_record_handle,
de_add_data(service, DE_STRING, strlen(descriptor), (uint8_t *) descriptor);
} else {
switch (service_uuid){
case SDP_PANU:
case BLUETOOTH_SERVICE_CLASS_PANU:
de_add_data(service, DE_STRING, strlen(default_panu_service_desc), (uint8_t *) default_panu_service_desc);
break;
case SDP_NAP:
case BLUETOOTH_SERVICE_CLASS_NAP:
de_add_data(service, DE_STRING, strlen(default_nap_service_desc), (uint8_t *) default_nap_service_desc);
break;
case SDP_GN:
case BLUETOOTH_SERVICE_CLASS_GN:
de_add_data(service, DE_STRING, strlen(default_gn_service_desc), (uint8_t *) default_gn_service_desc);
break;
default:
@ -191,7 +192,7 @@ static void pan_create_service(uint8_t *service, uint32_t service_record_handle,
de_add_number(service, DE_UINT, DE_SIZE_16, 0x030A);
de_add_number(service, DE_UINT, DE_SIZE_16, security_desc);
if (service_uuid == SDP_PANU) return;
if (service_uuid == BLUETOOTH_SERVICE_CLASS_PANU) return;
if (IPv4Subnet){
// 0x030D "IPv4Subnet", optional
@ -205,7 +206,7 @@ static void pan_create_service(uint8_t *service, uint32_t service_record_handle,
de_add_data(service, DE_STRING, strlen(IPv6Subnet), (uint8_t *) IPv6Subnet);
}
if (service_uuid == SDP_GN) return;
if (service_uuid == BLUETOOTH_SERVICE_CLASS_GN) return;
// 0x030B "NetAccessType"
de_add_number(service, DE_UINT, DE_SIZE_16, 0x030B);
@ -221,14 +222,14 @@ static void pan_create_service(uint8_t *service, uint32_t service_record_handle,
void pan_create_nap_sdp_record(uint8_t *service, uint32_t service_record_handle, uint16_t * network_packet_types, const char *name, const char *description, security_description_t security_desc,
net_access_type_t net_access_type, uint32_t max_net_access_rate, const char *IPv4Subnet, const char *IPv6Subnet){
pan_create_service(service, service_record_handle, SDP_NAP, network_packet_types, name, description, security_desc, net_access_type, max_net_access_rate, IPv4Subnet, IPv6Subnet);
pan_create_service(service, service_record_handle, BLUETOOTH_SERVICE_CLASS_NAP, network_packet_types, name, description, security_desc, net_access_type, max_net_access_rate, IPv4Subnet, IPv6Subnet);
}
void pan_create_gn_sdp_service(uint8_t *service, uint32_t service_record_handle, uint16_t * network_packet_types, const char *name, const char *description, security_description_t security_desc,
const char *IPv4Subnet, const char *IPv6Subnet){
pan_create_service(service, service_record_handle, SDP_GN, network_packet_types, name, description, security_desc, PAN_NET_ACCESS_TYPE_NONE, 0, IPv4Subnet, IPv6Subnet);
pan_create_service(service, service_record_handle, BLUETOOTH_SERVICE_CLASS_GN, network_packet_types, name, description, security_desc, PAN_NET_ACCESS_TYPE_NONE, 0, IPv4Subnet, IPv6Subnet);
}
void pan_create_panu_sdp_record(uint8_t *service, uint32_t service_record_handle, uint16_t * network_packet_types, const char *name, const char *description, security_description_t security_desc){
pan_create_service(service, service_record_handle, SDP_PANU, network_packet_types, name, description, security_desc, PAN_NET_ACCESS_TYPE_NONE, 0, NULL, NULL);
pan_create_service(service, service_record_handle, BLUETOOTH_SERVICE_CLASS_PANU, network_packet_types, name, description, security_desc, PAN_NET_ACCESS_TYPE_NONE, 0, NULL, NULL);
}

View File

@ -46,6 +46,7 @@
#include <string.h> // memcpy
#include <stdint.h>
#include "bluetooth_sdp.h"
#include "btstack_debug.h"
#include "btstack_event.h"
#include "btstack_memory.h"
@ -922,7 +923,7 @@ static int rfcomm_hci_event_handler(uint8_t *packet, uint16_t size){
switch (hci_event_packet_get_type(packet)) {
// accept incoming PSM_RFCOMM connection if no multiplexer exists yet
// accept incoming rfcomm connection if no multiplexer exists yet
case L2CAP_EVENT_INCOMING_CONNECTION:
// data: event(8), len(8), address(48), handle (16), psm (16), source cid(16) dest cid(16)
reverse_bd_addr(&packet[2], event_addr);
@ -930,12 +931,12 @@ static int rfcomm_hci_event_handler(uint8_t *packet, uint16_t size){
psm = little_endian_read_16(packet, 10);
l2cap_cid = little_endian_read_16(packet, 12);
if (psm != PSM_RFCOMM) break;
if (psm != BLUETOOTH_PROTOCOL_RFCOMM) break;
multiplexer = rfcomm_multiplexer_for_addr(event_addr);
if (multiplexer) {
log_info("INCOMING_CONNECTION (l2cap_cid 0x%02x) for PSM_RFCOMM => decline - multiplexer already exists", l2cap_cid);
log_info("INCOMING_CONNECTION (l2cap_cid 0x%02x) for BLUETOOTH_PROTOCOL_RFCOMM => decline - multiplexer already exists", l2cap_cid);
l2cap_decline_connection(l2cap_cid);
return 1;
}
@ -943,7 +944,7 @@ static int rfcomm_hci_event_handler(uint8_t *packet, uint16_t size){
// create and inititialize new multiplexer instance (incoming)
multiplexer = rfcomm_multiplexer_create_for_addr(event_addr);
if (!multiplexer){
log_info("INCOMING_CONNECTION (l2cap_cid 0x%02x) for PSM_RFCOMM => decline - no memory left", l2cap_cid);
log_info("INCOMING_CONNECTION (l2cap_cid 0x%02x) for BLUETOOTH_PROTOCOL_RFCOMM => decline - no memory left", l2cap_cid);
l2cap_decline_connection(l2cap_cid);
return 1;
}
@ -952,17 +953,17 @@ static int rfcomm_hci_event_handler(uint8_t *packet, uint16_t size){
multiplexer->l2cap_cid = l2cap_cid;
//
multiplexer->state = RFCOMM_MULTIPLEXER_W4_SABM_0;
log_info("L2CAP_EVENT_INCOMING_CONNECTION (l2cap_cid 0x%02x) for PSM_RFCOMM => accept", l2cap_cid);
log_info("L2CAP_EVENT_INCOMING_CONNECTION (l2cap_cid 0x%02x) for BLUETOOTH_PROTOCOL_RFCOMM => accept", l2cap_cid);
l2cap_accept_connection(l2cap_cid);
return 1;
// l2cap connection opened -> store l2cap_cid, remote_addr
case L2CAP_EVENT_CHANNEL_OPENED:
if (little_endian_read_16(packet, 11) != PSM_RFCOMM) break;
if (little_endian_read_16(packet, 11) != BLUETOOTH_PROTOCOL_RFCOMM) break;
status = packet[2];
log_info("L2CAP_EVENT_CHANNEL_OPENED for PSM_RFCOMM, status %u", status);
log_info("L2CAP_EVENT_CHANNEL_OPENED for BLUETOOTH_PROTOCOL_RFCOMM, status %u", status);
// get multiplexer for remote addr
con_handle = little_endian_read_16(packet, 9);
@ -2237,7 +2238,7 @@ static uint8_t rfcomm_channel_create_internal(btstack_packet_handler_t packet_ha
if (multiplexer->state != RFCOMM_MULTIPLEXER_OPEN) {
channel->state = RFCOMM_CHANNEL_W4_MULTIPLEXER;
uint16_t l2cap_cid = 0;
status = l2cap_create_channel(rfcomm_packet_handler, addr, PSM_RFCOMM, l2cap_max_mtu(), &l2cap_cid);
status = l2cap_create_channel(rfcomm_packet_handler, addr, BLUETOOTH_PROTOCOL_RFCOMM, l2cap_max_mtu(), &l2cap_cid);
if (status) goto fail;
multiplexer->l2cap_cid = l2cap_cid;
return 0;
@ -2292,7 +2293,7 @@ static uint8_t rfcomm_register_service_internal(btstack_packet_handler_t packet_
// register with l2cap if not registered before, max MTU
if (btstack_linked_list_empty(&rfcomm_services)){
l2cap_register_service(rfcomm_packet_handler, PSM_RFCOMM, 0xffff, rfcomm_security_level);
l2cap_register_service(rfcomm_packet_handler, BLUETOOTH_PROTOCOL_RFCOMM, 0xffff, rfcomm_security_level);
}
// fill in
@ -2329,8 +2330,8 @@ void rfcomm_unregister_service(uint8_t service_channel){
// unregister if no services active
if (btstack_linked_list_empty(&rfcomm_services)){
// bt_send_cmd(&l2cap_unregister_service, PSM_RFCOMM);
l2cap_unregister_service(PSM_RFCOMM);
// bt_send_cmd(&l2cap_unregister_service, BLUETOOTH_PROTOCOL_RFCOMM);
l2cap_unregister_service(BLUETOOTH_PROTOCOL_RFCOMM);
}
}

View File

@ -41,6 +41,7 @@
* sdp_client.c
*/
#include "bluetooth_sdp.h"
#include "btstack_config.h"
#include "btstack_debug.h"
#include "btstack_event.h"
@ -687,7 +688,7 @@ uint8_t sdp_client_query(btstack_packet_handler_t callback, bd_addr_t remote, co
PDU_ID = SDP_ServiceSearchAttributeResponse;
sdp_client_state = W4_CONNECT;
l2cap_create_channel(sdp_client_packet_handler, remote, PSM_SDP, l2cap_max_mtu(), NULL);
l2cap_create_channel(sdp_client_packet_handler, remote, BLUETOOTH_PROTOCOL_SDP, l2cap_max_mtu(), NULL);
return 0;
}
@ -719,7 +720,7 @@ uint8_t sdp_client_service_attribute_search(btstack_packet_handler_t callback, b
PDU_ID = SDP_ServiceAttributeResponse;
sdp_client_state = W4_CONNECT;
l2cap_create_channel(sdp_client_packet_handler, remote, PSM_SDP, l2cap_max_mtu(), NULL);
l2cap_create_channel(sdp_client_packet_handler, remote, BLUETOOTH_PROTOCOL_SDP, l2cap_max_mtu(), NULL);
return 0;
}
@ -733,7 +734,7 @@ uint8_t sdp_client_service_search(btstack_packet_handler_t callback, bd_addr_t r
PDU_ID = SDP_ServiceSearchResponse;
sdp_client_state = W4_CONNECT;
l2cap_create_channel(sdp_client_packet_handler, remote, PSM_SDP, l2cap_max_mtu(), NULL);
l2cap_create_channel(sdp_client_packet_handler, remote, BLUETOOTH_PROTOCOL_SDP, l2cap_max_mtu(), NULL);
return 0;
}
#endif

View File

@ -46,6 +46,7 @@
#include <stdlib.h>
#include <string.h>
#include "bluetooth_sdp.h"
#include "btstack_debug.h"
#include "btstack_event.h"
#include "classic/core.h"
@ -181,7 +182,7 @@ static void sdp_client_query_rfcomm_handle_protocol_descriptor_list_data(uint32_
if (protocol_value_bytes_received < protocol_value_size) break;
if (protocol_id == 0x0003){
if (protocol_id == BLUETOOTH_PROTOCOL_RFCOMM){
// log_info("\n\n ******* Data ***** %02x\n\n", data);
sdp_rfcomm_channel_nr = data;
}
@ -264,7 +265,7 @@ static void sdp_client_query_rfcomm_handle_sdp_parser_event(uint8_t packet_type,
// ve->attribute_id, sdp_event_query_attribute_byte_get_attribute_length(packet),
// sdp_event_query_attribute_byte_get_data_offset(packet), sdp_event_query_attribute_byte_get_data(packet));
switch (sdp_event_query_attribute_byte_get_attribute_id(packet)){
case SDP_ProtocolDescriptorList:
case BLUETOOTH_ATTRIBUTE_PROTOCOL_DESCRIPTOR_LIST:
// find rfcomm channel
sdp_client_query_rfcomm_handle_protocol_descriptor_list_data(sdp_event_query_attribute_byte_get_attribute_length(packet),
sdp_event_query_attribute_byte_get_data_offset(packet),

View File

@ -44,6 +44,7 @@
#include <stdio.h>
#include <string.h>
#include "bluetooth_sdp.h"
#include "btstack_debug.h"
#include "btstack_event.h"
#include "btstack_memory.h"
@ -76,12 +77,12 @@ static uint16_t sdp_response_size = 0;
void sdp_init(void){
// register with l2cap psm sevices - max MTU
l2cap_register_service(sdp_packet_handler, PSM_SDP, 0xffff, LEVEL_0);
l2cap_register_service(sdp_packet_handler, BLUETOOTH_PROTOCOL_SDP, 0xffff, LEVEL_0);
}
uint32_t sdp_get_service_record_handle(const uint8_t * record){
// TODO: make sdp_get_attribute_value_for_attribute_id accept const data to remove cast
uint8_t * serviceRecordHandleAttribute = sdp_get_attribute_value_for_attribute_id((uint8_t *)record, SDP_ServiceRecordHandle);
uint8_t * serviceRecordHandleAttribute = sdp_get_attribute_value_for_attribute_id((uint8_t *)record, BLUETOOTH_ATTRIBUTE_SERVICE_RECORD_HANDLE);
if (!serviceRecordHandleAttribute) return 0;
if (de_get_element_type(serviceRecordHandleAttribute) != DE_UINT) return 0;
if (de_get_size_type(serviceRecordHandleAttribute) != DE_SIZE_32) return 0;

View File

@ -48,6 +48,7 @@
#include <string.h>
#include "bluetooth.h"
#include "bluetooth_sdp.h"
#include "btstack_config.h"
#include "classic/core.h"
#include "classic/sdp_util.h"
@ -58,30 +59,30 @@ void spp_create_sdp_record(uint8_t *service, uint32_t service_record_handle, int
de_create_sequence(service);
// 0x0000 "Service Record Handle"
de_add_number(service, DE_UINT, DE_SIZE_16, SDP_ServiceRecordHandle);
de_add_number(service, DE_UINT, DE_SIZE_16, BLUETOOTH_ATTRIBUTE_SERVICE_RECORD_HANDLE);
de_add_number(service, DE_UINT, DE_SIZE_32, service_record_handle);
// 0x0001 "Service Class ID List"
de_add_number(service, DE_UINT, DE_SIZE_16, SDP_ServiceClassIDList);
de_add_number(service, DE_UINT, DE_SIZE_16, BLUETOOTH_ATTRIBUTE_SERVICE_CLASS_ID_LIST);
attribute = de_push_sequence(service);
{
de_add_number(attribute, DE_UUID, DE_SIZE_16, 0x1101 );
de_add_number(attribute, DE_UUID, DE_SIZE_16, BLUETOOTH_SERVICE_CLASS_SERIAL_PORT );
}
de_pop_sequence(service, attribute);
// 0x0004 "Protocol Descriptor List"
de_add_number(service, DE_UINT, DE_SIZE_16, SDP_ProtocolDescriptorList);
de_add_number(service, DE_UINT, DE_SIZE_16, BLUETOOTH_ATTRIBUTE_PROTOCOL_DESCRIPTOR_LIST);
attribute = de_push_sequence(service);
{
uint8_t* l2cpProtocol = de_push_sequence(attribute);
{
de_add_number(l2cpProtocol, DE_UUID, DE_SIZE_16, SDP_L2CAPProtocol);
de_add_number(l2cpProtocol, DE_UUID, DE_SIZE_16, BLUETOOTH_PROTOCOL_L2CAP);
}
de_pop_sequence(attribute, l2cpProtocol);
uint8_t* rfcomm = de_push_sequence(attribute);
{
de_add_number(rfcomm, DE_UUID, DE_SIZE_16, SDP_RFCOMMProtocol); // rfcomm_service
de_add_number(rfcomm, DE_UUID, DE_SIZE_16, BLUETOOTH_PROTOCOL_RFCOMM); // rfcomm_service
de_add_number(rfcomm, DE_UINT, DE_SIZE_8, rfcomm_channel); // rfcomm channel
}
de_pop_sequence(attribute, rfcomm);
@ -89,15 +90,15 @@ void spp_create_sdp_record(uint8_t *service, uint32_t service_record_handle, int
de_pop_sequence(service, attribute);
// 0x0005 "Public Browse Group"
de_add_number(service, DE_UINT, DE_SIZE_16, SDP_BrowseGroupList); // public browse group
de_add_number(service, DE_UINT, DE_SIZE_16, BLUETOOTH_ATTRIBUTE_BROWSE_GROUP_LIST); // public browse group
attribute = de_push_sequence(service);
{
de_add_number(attribute, DE_UUID, DE_SIZE_16, 0x1002 );
de_add_number(attribute, DE_UUID, DE_SIZE_16, BLUETOOTH_ATTRIBUTE_PUBLIC_BROWSE_ROOT );
}
de_pop_sequence(service, attribute);
// 0x0006
de_add_number(service, DE_UINT, DE_SIZE_16, SDP_LanguageBaseAttributeIDList);
de_add_number(service, DE_UINT, DE_SIZE_16, BLUETOOTH_ATTRIBUTE_LANGUAGE_BASE_ATTRIBUTE_ID_LIST);
attribute = de_push_sequence(service);
{
de_add_number(attribute, DE_UINT, DE_SIZE_16, 0x656e);
@ -107,13 +108,13 @@ void spp_create_sdp_record(uint8_t *service, uint32_t service_record_handle, int
de_pop_sequence(service, attribute);
// 0x0009 "Bluetooth Profile Descriptor List"
de_add_number(service, DE_UINT, DE_SIZE_16, SDP_BluetoothProfileDescriptorList);
de_add_number(service, DE_UINT, DE_SIZE_16, BLUETOOTH_ATTRIBUTE_BLUETOOTH_PROFILE_DESCRIPTOR_LIST);
attribute = de_push_sequence(service);
{
uint8_t *sppProfile = de_push_sequence(attribute);
{
de_add_number(sppProfile, DE_UUID, DE_SIZE_16, 0x1101);
de_add_number(sppProfile, DE_UINT, DE_SIZE_16, 0x0102);
de_add_number(sppProfile, DE_UUID, DE_SIZE_16, BLUETOOTH_SERVICE_CLASS_SERIAL_PORT);
de_add_number(sppProfile, DE_UINT, DE_SIZE_16, BLUETOOTH_SERVICE_CLASS_LAN_ACCESS_USING_PPP);
}
de_pop_sequence(attribute, sppProfile);
}

View File

@ -48,6 +48,7 @@
#include "l2cap.h"
#include "hci.h"
#include "hci_dump.h"
#include "bluetooth_sdp.h"
#include "btstack_debug.h"
#include "btstack_event.h"
#include "btstack_memory.h"
@ -435,7 +436,7 @@ void l2cap_require_security_level_2_for_outgoing_sdp(void){
}
static int l2cap_security_level_0_allowed_for_PSM(uint16_t psm){
return (psm == PSM_SDP) && (!require_security_level2_for_outgoing_sdp);
return (psm == BLUETOOTH_PROTOCOL_SDP) && (!require_security_level2_for_outgoing_sdp);
}
static int l2cap_send_signaling_packet(hci_con_handle_t handle, L2CAP_SIGNALING_COMMANDS cmd, uint8_t identifier, ...){

View File

@ -555,7 +555,7 @@ static void stdin_process(btstack_data_source_t *ds, btstack_data_source_callbac
sep.seid = 1;
switch (cmd){
case 'c':
printf("Creating L2CAP Connection to %s, PSM_AVDTP\n", bd_addr_to_str(remote));
printf("Creating L2CAP Connection to %s, BLUETOOTH_PROTOCOL_AVDTP\n", bd_addr_to_str(remote));
avdtp_sink_connect(remote);
break;
case 'C':

View File

@ -348,7 +348,7 @@ static void stdin_process(btstack_data_source_t *ds, btstack_data_source_callbac
sep.seid = 1;
switch (cmd){
case 'c':
printf("Creating L2CAP Connection to %s, PSM_AVDTP\n", bd_addr_to_str(remote));
printf("Creating L2CAP Connection to %s, BLUETOOTH_PROTOCOL_AVDTP\n", bd_addr_to_str(remote));
avdtp_source_connect(remote);
break;
case 'C':

View File

@ -90,12 +90,12 @@ TEST(DESParser, DESIterator2){
CHECK_EQUAL(de_get_element_type(element), DE_UUID);
uint32_t uuid = de_get_uuid32(element);
switch (uuid){
case SDP_L2CAPProtocol:
case BLUETOOTH_PROTOCOL_L2CAP:
CHECK_EQUAL(des_iterator_has_more(&prot_it), 1);
des_iterator_next(&prot_it);
de_element_get_uint16(des_iterator_get_element(&prot_it), &l2cap_psm);
break;
case SDP_BNEPProtocol:
case BLUETOOTH_PROTOCOL_BNEP:
CHECK_EQUAL(des_iterator_has_more(&prot_it), 1);
des_iterator_next(&prot_it);
de_element_get_uint16(des_iterator_get_element(&prot_it), &bnep_version);

View File

@ -607,7 +607,7 @@ static void stdin_process(btstack_data_source_t *ds, btstack_data_source_callbac
hci_send_cmd(&hci_create_connection, remote, hci_usable_acl_packet_types(), 0, 0, 0, 1);
break;
// printf("Creating L2CAP Connection to %s, PSM SDP\n", bd_addr_to_str(remote));
// l2cap_create_channel(packet_handler, remote, PSM_SDP, 100);
// l2cap_create_channel(packet_handler, remote, BLUETOOTH_PROTOCOL_SDP, 100);
// break;
// case 'u':
// printf("Creating L2CAP Connection to %s, PSM 3\n", bd_addr_to_str(remote));
@ -694,11 +694,11 @@ static void sdp_create_dummy_service(uint8_t *service, const char *name){
de_create_sequence(service);
// 0x0000 "Service Record Handle"
de_add_number(service, DE_UINT, DE_SIZE_16, SDP_ServiceRecordHandle);
de_add_number(service, DE_UINT, DE_SIZE_16, BLUETOOTH_ATTRIBUTE_SERVICE_RECORD_HANDLE);
de_add_number(service, DE_UINT, DE_SIZE_32, 0x10002);
// 0x0001 "Service Class ID List"
de_add_number(service, DE_UINT, DE_SIZE_16, SDP_ServiceClassIDList);
de_add_number(service, DE_UINT, DE_SIZE_16, BLUETOOTH_ATTRIBUTE_SERVICE_CLASS_ID_LIST);
attribute = de_push_sequence(service);
{
de_add_uuid128(attribute, &dummy_uuid128[0] );
@ -706,27 +706,27 @@ static void sdp_create_dummy_service(uint8_t *service, const char *name){
de_pop_sequence(service, attribute);
// 0x0004 "Protocol Descriptor List"
de_add_number(service, DE_UINT, DE_SIZE_16, SDP_ProtocolDescriptorList);
de_add_number(service, DE_UINT, DE_SIZE_16, BLUETOOTH_ATTRIBUTE_PROTOCOL_DESCRIPTOR_LIST);
attribute = de_push_sequence(service);
{
uint8_t* l2cpProtocol = de_push_sequence(attribute);
{
de_add_number(l2cpProtocol, DE_UUID, DE_SIZE_16, 0x0100);
de_add_number(l2cpProtocol, DE_UUID, DE_SIZE_16, BLUETOOTH_PROTOCOL_L2CAP);
}
de_pop_sequence(attribute, l2cpProtocol);
}
de_pop_sequence(service, attribute);
// 0x0005 "Public Browse Group"
de_add_number(service, DE_UINT, DE_SIZE_16, SDP_BrowseGroupList); // public browse group
de_add_number(service, DE_UINT, DE_SIZE_16, BLUETOOTH_ATTRIBUTE_BROWSE_GROUP_LIST); // public browse group
attribute = de_push_sequence(service);
{
de_add_number(attribute, DE_UUID, DE_SIZE_16, SDP_PublicBrowseGroup);
de_add_number(attribute, DE_UUID, DE_SIZE_16, BLUETOOTH_ATTRIBUTE_PUBLIC_BROWSE_ROOT);
}
de_pop_sequence(service, attribute);
// 0x0006
de_add_number(service, DE_UINT, DE_SIZE_16, SDP_LanguageBaseAttributeIDList);
de_add_number(service, DE_UINT, DE_SIZE_16, BLUETOOTH_ATTRIBUTE_LANGUAGE_BASE_ATTRIBUTE_ID_LIST);
attribute = de_push_sequence(service);
{
de_add_number(attribute, DE_UINT, DE_SIZE_16, 0x656e);
@ -736,7 +736,7 @@ static void sdp_create_dummy_service(uint8_t *service, const char *name){
de_pop_sequence(service, attribute);
// 0x0009 "Bluetooth Profile Descriptor List"
de_add_number(service, DE_UINT, DE_SIZE_16, SDP_BluetoothProfileDescriptorList);
de_add_number(service, DE_UINT, DE_SIZE_16, BLUETOOTH_ATTRIBUTE_BLUETOOTH_PROFILE_DESCRIPTOR_LIST);
attribute = de_push_sequence(service);
{
uint8_t *sppProfile = de_push_sequence(attribute);

View File

@ -162,7 +162,7 @@ int btstack_main(int argc, const char * argv[]){
hci_add_event_handler(&hci_event_callback_registration);
l2cap_init();
l2cap_register_service(packet_handler, PSM_SDP, 100, LEVEL_0);
l2cap_register_service(packet_handler, BLUETOOTH_PROTOCOL_SDP, 100, LEVEL_0);
// turn on!
hci_power_control(HCI_POWER_ON);