mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-03-29 13:20:39 +00:00
defined new SDP Sevice Class and Protocol constants
This commit is contained in:
parent
b4542301ea
commit
ff34c5fd2d
@ -93,7 +93,7 @@ static bnep_multi_filter_t multicast_filter [1] = {{{0x00, 0x00, 0x00, 0x00, 0x0
|
||||
static bd_addr_t local_addr;
|
||||
//static uint16_t bnep_protocol_uuid = 0x000f;
|
||||
static uint16_t bnep_l2cap_psm = 0x000f;
|
||||
static uint32_t bnep_remote_uuid = 0x1115;
|
||||
static uint32_t bnep_remote_uuid = SDP_PANU;
|
||||
//static uint16_t bnep_version = 0;
|
||||
static uint16_t bnep_cid = 0;
|
||||
|
||||
@ -210,7 +210,7 @@ static void send_dns_request(){
|
||||
static void show_usage(){
|
||||
|
||||
printf("\n--- Bluetooth BNEP Test Console ---\n");
|
||||
printf("Local UUID %04x, remote UUID %04x, \n", BNEP_UUID_PANU, bnep_remote_uuid);
|
||||
printf("Local UUID %04x, remote UUID %04x, \n", SDP_PANU, bnep_remote_uuid);
|
||||
printf("---\n");
|
||||
printf("p - connect to PTS\n");
|
||||
printf("e - send general Ethernet packet\n");
|
||||
@ -392,7 +392,7 @@ int btstack_main(int argc, const char * argv[]){
|
||||
/* Initialise BNEP */
|
||||
bnep_init();
|
||||
bnep_register_packet_handler(packet_handler);
|
||||
bnep_register_service(NULL, BNEP_UUID_PANU, 1691); /* Minimum L2CAP MTU for bnep is 1691 bytes */
|
||||
bnep_register_service(NULL, SDP_PANU, 1691); /* Minimum L2CAP MTU for bnep is 1691 bytes */
|
||||
|
||||
/* Turn on the device */
|
||||
hci_power_control(HCI_POWER_ON);
|
||||
|
@ -713,7 +713,7 @@ void sdp_create_dummy_service(uint8_t *service, const char *name){
|
||||
de_add_number(service, DE_UINT, DE_SIZE_16, SDP_BrowseGroupList); // 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, SDP_PublicBrowseGroup);
|
||||
}
|
||||
de_pop_sequence(service, attribute);
|
||||
|
||||
|
@ -88,7 +88,6 @@
|
||||
#include "pan.h"
|
||||
|
||||
static int record_id = -1;
|
||||
static uint16_t bnep_protocol_id = 0x000f;
|
||||
static uint16_t bnep_l2cap_psm = 0;
|
||||
static uint32_t bnep_remote_uuid = 0;
|
||||
static uint16_t bnep_version = 0;
|
||||
@ -299,9 +298,9 @@ static void handle_sdp_client_query_result(sdp_query_event_t *event)
|
||||
if (de_get_element_type(element) != DE_UUID) continue;
|
||||
uint32_t uuid = de_get_uuid32(element);
|
||||
switch (uuid){
|
||||
case BNEP_UUID_PANU:
|
||||
case BNEP_UUID_NAP:
|
||||
case BNEP_UUID_GN:
|
||||
case SDP_PANU:
|
||||
case SDP_NAP:
|
||||
case SDP_GN:
|
||||
printf("SDP Attribute 0x%04x: BNEP PAN protocol UUID: %04x\n", value_event->attribute_id, uuid);
|
||||
bnep_remote_uuid = uuid;
|
||||
break;
|
||||
@ -334,12 +333,12 @@ static void handle_sdp_client_query_result(sdp_query_event_t *event)
|
||||
|
||||
uuid = de_get_uuid32(element);
|
||||
switch (uuid){
|
||||
case 0x0100:
|
||||
case SDP_L2CAPProtocol:
|
||||
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 0x000f:
|
||||
case SDP_BNEPProtocol:
|
||||
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);
|
||||
@ -351,9 +350,6 @@ static void handle_sdp_client_query_result(sdp_query_event_t *event)
|
||||
printf("l2cap_psm 0x%04x, bnep_version 0x%04x\n", bnep_l2cap_psm, bnep_version);
|
||||
|
||||
/* Create BNEP connection */
|
||||
// hack - SDP Query seems to be broken
|
||||
// bnep_l2cap_psm = 0x000f;
|
||||
// bnep_remote_uuid = 0x1117; // adhoc group networking
|
||||
bnep_connect(NULL, &remote, bnep_l2cap_psm, bnep_remote_uuid);
|
||||
}
|
||||
break;
|
||||
@ -392,7 +388,7 @@ static void packet_handler (void * connection, uint8_t packet_type, uint16_t cha
|
||||
if (packet[2] == HCI_STATE_WORKING) {
|
||||
/* Send a general query for BNEP Protocol ID */
|
||||
printf("Start SDP BNEP query.\n");
|
||||
sdp_general_query_for_uuid(remote, bnep_protocol_id);
|
||||
sdp_general_query_for_uuid(remote, SDP_BNEPProtocol);
|
||||
}
|
||||
break;
|
||||
|
||||
@ -522,7 +518,7 @@ int btstack_main(int argc, const char * argv[]){
|
||||
/* Initialise BNEP */
|
||||
bnep_init();
|
||||
bnep_register_packet_handler(packet_handler);
|
||||
bnep_register_service(NULL, BNEP_UUID_PANU, 1691); /* Minimum L2CAP MTU for bnep is 1691 bytes */
|
||||
bnep_register_service(NULL, SDP_PANU, 1691); /* Minimum L2CAP MTU for bnep is 1691 bytes */
|
||||
|
||||
/* Turn on the device */
|
||||
hci_power_control(HCI_POWER_ON);
|
||||
|
@ -63,8 +63,6 @@
|
||||
|
||||
int record_id = -1;
|
||||
int attribute_id = -1;
|
||||
uint16_t public_browse_group = 0x1002;
|
||||
uint16_t bnep_protocol_id = 0x000f;
|
||||
|
||||
static uint8_t attribute_value[1000];
|
||||
static const int attribute_value_buffer_size = sizeof(attribute_value);
|
||||
@ -88,7 +86,7 @@ static void packet_handler (void * connection, uint8_t packet_type, uint16_t cha
|
||||
// bt stack activated, get started
|
||||
if (packet[2] == HCI_STATE_WORKING){
|
||||
printf("Start SDP BNEP query.\n");
|
||||
sdp_general_query_for_uuid(remote, bnep_protocol_id);
|
||||
sdp_general_query_for_uuid(remote, SDP_BNEPProtocol);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@ -177,12 +175,12 @@ static void handle_sdp_client_query_result(sdp_query_event_t * event){
|
||||
if (de_get_element_type(element) != DE_UUID) continue;
|
||||
uint32_t uuid = de_get_uuid32(element);
|
||||
switch (uuid){
|
||||
case 0x100:
|
||||
case SDP_L2CAPProtocol:
|
||||
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 0x000f:
|
||||
case SDP_BNEPProtocol:
|
||||
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);
|
||||
|
@ -81,7 +81,7 @@ static void packet_handler (void * connection, uint8_t packet_type, uint16_t cha
|
||||
case BTSTACK_EVENT_STATE:
|
||||
// bt stack activated, get started
|
||||
if (packet[2] == HCI_STATE_WORKING){
|
||||
sdp_general_query_for_uuid(remote, 0x1002);
|
||||
sdp_general_query_for_uuid(remote, SDP_PublicBrowseGroup);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
@ -76,7 +76,7 @@ static void packet_handler (void * connection, uint8_t packet_type, uint16_t cha
|
||||
case BTSTACK_EVENT_STATE:
|
||||
// bt stack activated, get started
|
||||
if (packet[2] == HCI_STATE_WORKING){
|
||||
sdp_query_rfcomm_channel_and_name_for_uuid(remote, 0x1002);
|
||||
sdp_query_rfcomm_channel_and_name_for_uuid(remote, SDP_PublicBrowseGroup);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
@ -122,7 +122,7 @@ static void packet_handler (void * connection, uint8_t packet_type, uint16_t cha
|
||||
case BTSTACK_EVENT_STATE:
|
||||
// bt stack activated, get started
|
||||
if (packet[2] == HCI_STATE_WORKING){
|
||||
sdp_query_rfcomm_channel_and_name_for_uuid(remote, 0x1002);
|
||||
sdp_query_rfcomm_channel_and_name_for_uuid(remote, SDP_PublicBrowseGroup);
|
||||
}
|
||||
break;
|
||||
case RFCOMM_EVENT_OPEN_CHANNEL_COMPLETE:
|
||||
|
@ -89,9 +89,17 @@ typedef enum {
|
||||
#define SDP_SupportedFormatsList 0x0303
|
||||
|
||||
// SERVICE CLASSES
|
||||
#define SDP_OBEXObjectPush 0x1105
|
||||
#define SDP_OBEXFileTransfer 0x1106
|
||||
#define SDP_PublicBrowseGroup 0x1002
|
||||
#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
|
||||
|
||||
|
||||
// PROTOCOLS
|
||||
#define SDP_SDPProtocol 0x0001
|
||||
@ -99,6 +107,8 @@ typedef enum {
|
||||
#define SDP_RFCOMMProtocol 0x0003
|
||||
#define SDP_OBEXProtocol 0x0008
|
||||
#define SDP_L2CAPProtocol 0x0100
|
||||
#define SDP_BNEPProtocol 0x000F
|
||||
#define SDP_AVDTPProtocol 0x0019
|
||||
|
||||
// OFFSETS FOR LOCALIZED ATTRIBUTES - SDP_LanguageBaseAttributeIDList
|
||||
#define SDP_Offest_ServiceName 0x0000
|
||||
|
@ -909,7 +909,7 @@ static int btstack_command_handler(connection_t *connection, uint8_t *packet, ui
|
||||
|
||||
sdp_client_query(addr, (uint8_t*)&serviceSearchPattern[0], (uint8_t*)&attributeIDList[0]);
|
||||
|
||||
// sdp_general_query_for_uuid(addr, 0x1002);
|
||||
// sdp_general_query_for_uuid(addr, SDP_PublicBrowseGroup);
|
||||
break;
|
||||
case GAP_LE_SCAN_START:
|
||||
le_central_start_scan();
|
||||
|
24
src/bnep.c
24
src/bnep.c
@ -49,8 +49,8 @@
|
||||
#include <btstack/btstack.h>
|
||||
#include <btstack/hci_cmds.h>
|
||||
#include <btstack/utils.h>
|
||||
#include <btstack/sdp_util.h>
|
||||
|
||||
#include <btstack/utils.h>
|
||||
#include "btstack_memory.h"
|
||||
#include "hci.h"
|
||||
#include "hci_dump.h"
|
||||
@ -827,15 +827,15 @@ static int bnep_handle_connection_request(bnep_channel_t *channel, uint8_t *pack
|
||||
channel->uuid_dest = READ_NET_16(packet, 2 + uuid_offset);
|
||||
channel->uuid_source = READ_NET_16(packet, 2 + uuid_offset + uuid_size);
|
||||
|
||||
if ((channel->uuid_dest != BNEP_UUID_PANU) &&
|
||||
(channel->uuid_dest != BNEP_UUID_NAP) &&
|
||||
(channel->uuid_dest != BNEP_UUID_GN)) {
|
||||
if ((channel->uuid_dest != SDP_PANU) &&
|
||||
(channel->uuid_dest != SDP_NAP) &&
|
||||
(channel->uuid_dest != SDP_GN)) {
|
||||
log_error("BNEP_CONNECTION_REQUEST: Invalid destination service UUID: %04x", channel->uuid_dest);
|
||||
channel->uuid_dest = 0;
|
||||
}
|
||||
if ((channel->uuid_source != BNEP_UUID_PANU) &&
|
||||
(channel->uuid_source != BNEP_UUID_NAP) &&
|
||||
(channel->uuid_source != BNEP_UUID_GN)) {
|
||||
if ((channel->uuid_source != SDP_PANU) &&
|
||||
(channel->uuid_source != SDP_NAP) &&
|
||||
(channel->uuid_source != SDP_GN)) {
|
||||
log_error("BNEP_CONNECTION_REQUEST: Invalid source service UUID: %04x", channel->uuid_source);
|
||||
channel->uuid_source = 0;
|
||||
}
|
||||
@ -845,7 +845,7 @@ static int bnep_handle_connection_request(bnep_channel_t *channel, uint8_t *pack
|
||||
if (service == NULL) {
|
||||
response_code = BNEP_RESP_SETUP_INVALID_DEST_UUID;
|
||||
} else
|
||||
if ((channel->uuid_source != BNEP_UUID_PANU) && (channel->uuid_dest != BNEP_UUID_PANU)) {
|
||||
if ((channel->uuid_source != SDP_PANU) && (channel->uuid_dest != SDP_PANU)) {
|
||||
response_code = BNEP_RESP_SETUP_INVALID_SOURCE_UUID;
|
||||
}
|
||||
}
|
||||
@ -1564,7 +1564,7 @@ int bnep_connect(void * connection, bd_addr_t *addr, uint16_t l2cap_psm, uint16_
|
||||
return -1;
|
||||
}
|
||||
|
||||
channel->uuid_source = BNEP_UUID_PANU;
|
||||
channel->uuid_source = SDP_PANU;
|
||||
channel->uuid_dest = uuid_dest;
|
||||
|
||||
l2cap_create_channel_internal(connection, bnep_packet_handler, *addr, l2cap_psm, l2cap_max_mtu());
|
||||
@ -1597,9 +1597,9 @@ void bnep_register_service(void * connection, uint16_t service_uuid, uint16_t ma
|
||||
}
|
||||
|
||||
/* Only alow one the three service types: PANU, NAP, GN */
|
||||
if ((service_uuid != BNEP_UUID_PANU) &&
|
||||
(service_uuid != BNEP_UUID_NAP) &&
|
||||
(service_uuid != BNEP_UUID_GN)) {
|
||||
if ((service_uuid != SDP_PANU) &&
|
||||
(service_uuid != SDP_NAP) &&
|
||||
(service_uuid != SDP_GN)) {
|
||||
log_info("BNEP_REGISTER_SERVICE: Invalid service UUID: %04x", service_uuid);
|
||||
return;
|
||||
}
|
||||
|
@ -72,11 +72,6 @@ extern "C" {
|
||||
#define BNEP_TYPE_MASK 0x7F
|
||||
#define BNEP_TYPE(header) ((header) & BNEP_TYPE_MASK)
|
||||
#define BNEP_HEADER_HAS_EXT(x) (((x) & BNEP_EXT_FLAG) == BNEP_EXT_FLAG)
|
||||
|
||||
/* BNEP UUIDs */
|
||||
#define BNEP_UUID_PANU 0x1115
|
||||
#define BNEP_UUID_NAP 0x1116
|
||||
#define BNEP_UUID_GN 0x1117
|
||||
|
||||
/* BNEP packet types */
|
||||
#define BNEP_PKT_TYPE_GENERAL_ETHERNET 0x00
|
||||
|
28
src/pan.c
28
src/pan.c
@ -57,7 +57,7 @@ static const char default_nap_service_desc[] = "Personal Ad-hoc Network Service
|
||||
static const char default_gn_service_name[] = "Group Ad-hoc Network Service";
|
||||
static const char default_gn_service_desc[] = "Personal Group Ad-hoc Network Service";
|
||||
|
||||
void pan_create_service(bnep_service_uuid_t service_uuid, uint8_t *service, const char *name, const char *descriptor,
|
||||
void pan_create_service(uint32_t service_uuid, uint8_t *service, const char *name, const char *descriptor,
|
||||
security_description_t security_desc, net_access_type_t net_access_type, uint32_t max_net_access_rate,
|
||||
const char *IPv4Subnet, const char *IPv6Subnet){
|
||||
|
||||
@ -89,7 +89,7 @@ void pan_create_service(bnep_service_uuid_t service_uuid, uint8_t *service, cons
|
||||
|
||||
uint8_t* bnep = de_push_sequence(attribute);
|
||||
{
|
||||
de_add_number(bnep, DE_UUID, DE_SIZE_16, 0x000F); // bnep
|
||||
de_add_number(bnep, DE_UUID, DE_SIZE_16, SDP_BNEPProtocol);
|
||||
de_add_number(bnep, DE_UINT, DE_SIZE_16, 0x0100); // version
|
||||
|
||||
uint8_t * net_packet_type_list = de_push_sequence(bnep);
|
||||
@ -107,7 +107,7 @@ void pan_create_service(bnep_service_uuid_t service_uuid, uint8_t *service, cons
|
||||
de_add_number(service, DE_UINT, DE_SIZE_16, SDP_BrowseGroupList); // 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, SDP_PublicBrowseGroup);
|
||||
}
|
||||
de_pop_sequence(service, attribute);
|
||||
|
||||
@ -144,13 +144,13 @@ void pan_create_service(bnep_service_uuid_t service_uuid, uint8_t *service, cons
|
||||
de_add_data(service, DE_STRING, strlen(name), (uint8_t *) name);
|
||||
} else {
|
||||
switch (service_uuid){
|
||||
case PANU_UUID:
|
||||
case SDP_PANU:
|
||||
de_add_data(service, DE_STRING, strlen(default_panu_service_name), (uint8_t *) default_panu_service_name);
|
||||
break;
|
||||
case NAP_UUID:
|
||||
case SDP_NAP:
|
||||
de_add_data(service, DE_STRING, strlen(default_nap_service_name), (uint8_t *) default_nap_service_name);
|
||||
break;
|
||||
case GN_UUID:
|
||||
case SDP_GN:
|
||||
de_add_data(service, DE_STRING, strlen(default_gn_service_name), (uint8_t *) default_gn_service_name);
|
||||
break;
|
||||
default:
|
||||
@ -164,13 +164,13 @@ void pan_create_service(bnep_service_uuid_t service_uuid, uint8_t *service, cons
|
||||
de_add_data(service, DE_STRING, strlen(descriptor), (uint8_t *) descriptor);
|
||||
} else {
|
||||
switch (service_uuid){
|
||||
case PANU_UUID:
|
||||
case SDP_PANU:
|
||||
de_add_data(service, DE_STRING, strlen(default_panu_service_desc), (uint8_t *) default_panu_service_desc);
|
||||
break;
|
||||
case NAP_UUID:
|
||||
case SDP_NAP:
|
||||
de_add_data(service, DE_STRING, strlen(default_nap_service_desc), (uint8_t *) default_nap_service_desc);
|
||||
break;
|
||||
case GN_UUID:
|
||||
case SDP_GN:
|
||||
de_add_data(service, DE_STRING, strlen(default_gn_service_desc), (uint8_t *) default_gn_service_desc);
|
||||
break;
|
||||
default:
|
||||
@ -182,7 +182,7 @@ void pan_create_service(bnep_service_uuid_t service_uuid, uint8_t *service, cons
|
||||
de_add_number(service, DE_UINT, DE_SIZE_16, 0x030A);
|
||||
de_add_number(service, DE_UINT, DE_SIZE_16, security_desc);
|
||||
|
||||
if (service_uuid == PANU_UUID) return;
|
||||
if (service_uuid == SDP_PANU) return;
|
||||
|
||||
if (IPv4Subnet){
|
||||
// 0x030D "IPv4Subnet", optional
|
||||
@ -196,7 +196,7 @@ void pan_create_service(bnep_service_uuid_t service_uuid, uint8_t *service, cons
|
||||
de_add_data(service, DE_STRING, strlen(IPv6Subnet), (uint8_t *) IPv6Subnet);
|
||||
}
|
||||
|
||||
if (service_uuid == GN_UUID) return;
|
||||
if (service_uuid == SDP_GN) return;
|
||||
|
||||
// 0x030B "NetAccessType"
|
||||
de_add_number(service, DE_UINT, DE_SIZE_16, 0x030B);
|
||||
@ -212,14 +212,14 @@ void pan_create_service(bnep_service_uuid_t service_uuid, uint8_t *service, cons
|
||||
void pan_create_nap_service(uint8_t *service, 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(NAP_UUID, service, name, description, security_desc, net_access_type, max_net_access_rate, IPv4Subnet, IPv6Subnet);
|
||||
pan_create_service(SDP_NAP, service, name, description, security_desc, net_access_type, max_net_access_rate, IPv4Subnet, IPv6Subnet);
|
||||
}
|
||||
|
||||
void pan_create_gn_service(uint8_t *service, const char *name, const char *description, security_description_t security_desc,
|
||||
const char *IPv4Subnet, const char *IPv6Subnet){
|
||||
pan_create_service(GN_UUID, service, name, description, security_desc, PAN_NET_ACCESS_TYPE_NONE, 0, IPv4Subnet, IPv6Subnet);
|
||||
pan_create_service(SDP_GN, service, name, description, security_desc, PAN_NET_ACCESS_TYPE_NONE, 0, IPv4Subnet, IPv6Subnet);
|
||||
}
|
||||
|
||||
void pan_create_panu_service(uint8_t *service, const char *name, const char *description, security_description_t security_desc){
|
||||
pan_create_service(PANU_UUID, service, name, description, security_desc, PAN_NET_ACCESS_TYPE_NONE, 0, NULL, NULL);
|
||||
pan_create_service(SDP_PANU, service, name, description, security_desc, PAN_NET_ACCESS_TYPE_NONE, 0, NULL, NULL);
|
||||
}
|
||||
|
@ -88,12 +88,12 @@ TEST(DESParser, DESIterator2){
|
||||
CHECK_EQUAL(de_get_element_type(element), DE_UUID);
|
||||
uint32_t uuid = de_get_uuid32(element);
|
||||
switch (uuid){
|
||||
case 0x100:
|
||||
case SDP_L2CAPProtocol:
|
||||
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 0x000f:
|
||||
case SDP_BNEPProtocol:
|
||||
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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user