mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-04-09 21:45:54 +00:00
Merge branch 'master' of https://github.com/bluekitchen/btstack
This commit is contained in:
commit
f4908f57ee
21
src/pan.c
21
src/pan.c
@ -58,7 +58,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_name[] = "Group Ad-hoc Network Service";
|
||||||
static const char default_gn_service_desc[] = "Personal Group Ad-hoc Network Service";
|
static const char default_gn_service_desc[] = "Personal Group Ad-hoc Network Service";
|
||||||
|
|
||||||
void pan_create_service(uint32_t service_uuid, uint8_t *service, const char *name, const char *descriptor,
|
void pan_create_service(uint8_t *service, uint32_t service_uuid, uint16_t * network_packet_types, const char *name, const char *descriptor,
|
||||||
security_description_t security_desc, net_access_type_t net_access_type, uint32_t max_net_access_rate,
|
security_description_t security_desc, net_access_type_t net_access_type, uint32_t max_net_access_rate,
|
||||||
const char *IPv4Subnet, const char *IPv6Subnet){
|
const char *IPv4Subnet, const char *IPv6Subnet){
|
||||||
|
|
||||||
@ -96,8 +96,11 @@ void pan_create_service(uint32_t service_uuid, uint8_t *service, const char *nam
|
|||||||
|
|
||||||
uint8_t * net_packet_type_list = de_push_sequence(bnep);
|
uint8_t * net_packet_type_list = de_push_sequence(bnep);
|
||||||
{
|
{
|
||||||
// add Supported Network Packet Type List
|
if (network_packet_types){
|
||||||
// de_add_number(net_packet_type_list, DE_UINT, DE_SIZE_16, 0x0100); // version
|
while (*network_packet_types){
|
||||||
|
de_add_number(net_packet_type_list, DE_UINT, DE_SIZE_16, *network_packet_types++);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
de_pop_sequence(bnep, net_packet_type_list);
|
de_pop_sequence(bnep, net_packet_type_list);
|
||||||
}
|
}
|
||||||
@ -211,17 +214,17 @@ void pan_create_service(uint32_t service_uuid, uint8_t *service, const char *nam
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void pan_create_nap_service(uint8_t *service, const char *name, const char *description, security_description_t security_desc,
|
void pan_create_nap_service(uint8_t *service, 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){
|
net_access_type_t net_access_type, uint32_t max_net_access_rate, const char *IPv4Subnet, const char *IPv6Subnet){
|
||||||
|
|
||||||
pan_create_service(SDP_NAP, service, name, description, security_desc, net_access_type, max_net_access_rate, IPv4Subnet, IPv6Subnet);
|
pan_create_service(service, SDP_NAP, network_packet_types, 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,
|
void pan_create_gn_service(uint8_t *service, uint16_t * network_packet_types, const char *name, const char *description, security_description_t security_desc,
|
||||||
const char *IPv4Subnet, const char *IPv6Subnet){
|
const char *IPv4Subnet, const char *IPv6Subnet){
|
||||||
pan_create_service(SDP_GN, service, name, description, security_desc, PAN_NET_ACCESS_TYPE_NONE, 0, IPv4Subnet, IPv6Subnet);
|
pan_create_service(service, SDP_GN, network_packet_types, 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){
|
void pan_create_panu_service(uint8_t *service, uint16_t * network_packet_types, const char *name, const char *description, security_description_t security_desc){
|
||||||
pan_create_service(SDP_PANU, service, name, description, security_desc, PAN_NET_ACCESS_TYPE_NONE, 0, NULL, NULL);
|
pan_create_service(service, SDP_PANU, network_packet_types, name, description, security_desc, PAN_NET_ACCESS_TYPE_NONE, 0, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
23
src/pan.h
23
src/pan.h
@ -91,25 +91,29 @@ typedef enum {
|
|||||||
* @note Make sure the buffer is big enough.
|
* @note Make sure the buffer is big enough.
|
||||||
*
|
*
|
||||||
* @param service is an empty buffer to store service record
|
* @param service is an empty buffer to store service record
|
||||||
* @param security_desc
|
* @param network_packet_types array of types terminated by a 0x0000 entry
|
||||||
* @param name if NULL, the default service name will be assigned
|
* @param name if NULL, the default service name will be assigned
|
||||||
* @param description if NULL, the default service description will be assigned
|
* @param description if NULL, the default service description will be assigned
|
||||||
|
* @param security_desc
|
||||||
*/
|
*/
|
||||||
void pan_create_panu_service(uint8_t *service, const char *name, const char *description, security_description_t security_desc);
|
void pan_create_panu_service(uint8_t *service, uint16_t * network_packet_types, const char *name,
|
||||||
|
const char *description, security_description_t security_desc);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Creates SDP record for GN BNEP service in provided empty buffer.
|
* @brief Creates SDP record for GN BNEP service in provided empty buffer.
|
||||||
* @note Make sure the buffer is big enough.
|
* @note Make sure the buffer is big enough.
|
||||||
*
|
*
|
||||||
* @param service is an empty buffer to store service record
|
* @param service is an empty buffer to store service record
|
||||||
* @param security_desc
|
* @param network_packet_types array of types terminated by a 0x0000 entry
|
||||||
* @param name if NULL, the default service name will be assigned
|
* @param name if NULL, the default service name will be assigned
|
||||||
* @param description if NULL, the default service description will be assigned
|
* @param description if NULL, the default service description will be assigned
|
||||||
|
* @param security_desc
|
||||||
* @param IPv4Subnet is optional subnet definition, e.g. "10.0.0.0/8"
|
* @param IPv4Subnet is optional subnet definition, e.g. "10.0.0.0/8"
|
||||||
* @param IPv6Subnet is optional subnet definition given in the standard IETF format with the absolute attribute IDs
|
* @param IPv6Subnet is optional subnet definition given in the standard IETF format with the absolute attribute IDs
|
||||||
*/
|
*/
|
||||||
void pan_create_gn_service(uint8_t *service, const char *name, const char *description, security_description_t security_desc,
|
void pan_create_gn_service(uint8_t *service, uint16_t * network_packet_types, const char *name,
|
||||||
const char *IPv4Subnet, const char *IPv6Subnet);
|
const char *description, security_description_t security_desc, const char *IPv4Subnet,
|
||||||
|
const char *IPv6Subnet);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Creates SDP record for NAP BNEP service in provided empty buffer.
|
* @brief Creates SDP record for NAP BNEP service in provided empty buffer.
|
||||||
@ -117,15 +121,18 @@ void pan_create_gn_service(uint8_t *service, const char *name, const char *descr
|
|||||||
*
|
*
|
||||||
* @param service is an empty buffer to store service record
|
* @param service is an empty buffer to store service record
|
||||||
* @param name if NULL, the default service name will be assigned
|
* @param name if NULL, the default service name will be assigned
|
||||||
* @param security_desc
|
* @param network_packet_types array of types terminated by a 0x0000 entry
|
||||||
* @param description if NULL, the default service description will be assigned
|
* @param description if NULL, the default service description will be assigned
|
||||||
|
* @param security_desc
|
||||||
* @param net_access_type type of available network access
|
* @param net_access_type type of available network access
|
||||||
* @param max_net_access_rate based on net_access_type measured in byte/s
|
* @param max_net_access_rate based on net_access_type measured in byte/s
|
||||||
* @param IPv4Subnet is optional subnet definition, e.g. "10.0.0.0/8"
|
* @param IPv4Subnet is optional subnet definition, e.g. "10.0.0.0/8"
|
||||||
* @param IPv6Subnet is optional subnet definition given in the standard IETF format with the absolute attribute IDs
|
* @param IPv6Subnet is optional subnet definition given in the standard IETF format with the absolute attribute IDs
|
||||||
*/
|
*/
|
||||||
void pan_create_nap_service(uint8_t *service, const char *name, const char *description, security_description_t security_desc,
|
void pan_create_nap_service(uint8_t *service, uint16_t * network_packet_types, const char *name,
|
||||||
net_access_type_t net_access_type, uint32_t max_net_access_rate, const char *IPv4Subnet, const char *IPv6Subnet);
|
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);
|
||||||
|
|
||||||
/* API_END */
|
/* API_END */
|
||||||
|
|
||||||
#if defined __cplusplus
|
#if defined __cplusplus
|
||||||
|
@ -63,10 +63,12 @@
|
|||||||
#include "btstack_memory.h"
|
#include "btstack_memory.h"
|
||||||
#include "hci_dump.h"
|
#include "hci_dump.h"
|
||||||
#include "l2cap.h"
|
#include "l2cap.h"
|
||||||
|
#include "sdp.h"
|
||||||
#include "pan.h"
|
#include "pan.h"
|
||||||
#include "stdin_support.h"
|
#include "stdin_support.h"
|
||||||
|
|
||||||
#define NETWORK_TYPE_IPv4 0x800
|
#define NETWORK_TYPE_IPv4 0x0800
|
||||||
|
#define NETWORK_TYPE_ARP 0x0806
|
||||||
#define NETWORK_TYPE_IPv6 0x86DD
|
#define NETWORK_TYPE_IPv6 0x86DD
|
||||||
#define ICMP_TYPE_PING_REQUEST 0x08
|
#define ICMP_TYPE_PING_REQUEST 0x08
|
||||||
#define ICMP_TYPE_PING_RESPONSE 0x00
|
#define ICMP_TYPE_PING_RESPONSE 0x00
|
||||||
@ -112,6 +114,8 @@ static uint16_t bnep_cid = 0;
|
|||||||
static uint8_t network_buffer[BNEP_MTU_MIN];
|
static uint8_t network_buffer[BNEP_MTU_MIN];
|
||||||
static size_t network_buffer_len = 0;
|
static size_t network_buffer_len = 0;
|
||||||
|
|
||||||
|
static uint8_t panu_sdp_record[200];
|
||||||
|
|
||||||
static uint16_t setup_ethernet_header(int src_compressed, int dst_compressed, int broadcast, uint16_t network_protocol_type){
|
static uint16_t setup_ethernet_header(int src_compressed, int dst_compressed, int broadcast, uint16_t network_protocol_type){
|
||||||
// setup packet
|
// setup packet
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
@ -619,6 +623,7 @@ static void packet_handler (void * connection, uint8_t packet_type, uint16_t cha
|
|||||||
int btstack_main(int argc, const char * argv[]);
|
int btstack_main(int argc, const char * argv[]);
|
||||||
int btstack_main(int argc, const char * argv[]){
|
int btstack_main(int argc, const char * argv[]){
|
||||||
|
|
||||||
|
|
||||||
/* Initialize L2CAP */
|
/* Initialize L2CAP */
|
||||||
l2cap_init();
|
l2cap_init();
|
||||||
l2cap_register_packet_handler(packet_handler);
|
l2cap_register_packet_handler(packet_handler);
|
||||||
@ -628,8 +633,24 @@ int btstack_main(int argc, const char * argv[]){
|
|||||||
bnep_register_packet_handler(packet_handler);
|
bnep_register_packet_handler(packet_handler);
|
||||||
bnep_register_service(NULL, bnep_local_service_uuid, 1691); /* Minimum L2CAP MTU for bnep is 1691 bytes */
|
bnep_register_service(NULL, bnep_local_service_uuid, 1691); /* Minimum L2CAP MTU for bnep is 1691 bytes */
|
||||||
|
|
||||||
|
/* Initialize SDP and add PANU record */
|
||||||
|
sdp_init();
|
||||||
|
|
||||||
|
uint16_t network_packet_types[] = { NETWORK_TYPE_IPv4, NETWORK_TYPE_ARP, 0}; // 0 as end of list
|
||||||
|
#ifdef EMBEDDED
|
||||||
|
service_record_item_t * service_record_item = (service_record_item_t *) panu_sdp_record;
|
||||||
|
pan_create_panu_service((uint8_t*) &service_record_item->service_record, network_packet_types, NULL, NULL, BNEP_SECURITY_NONE);
|
||||||
|
printf("SDP service buffer size: %u\n", (uint16_t) (sizeof(service_record_item_t) + de_get_len((uint8_t*) &service_record_item->service_record)));
|
||||||
|
sdp_register_service_internal(NULL, service_record_item);
|
||||||
|
#else
|
||||||
|
pan_create_panu_service(panu_sdp_record, network_packet_types, NULL, NULL, BNEP_SECURITY_NONE);
|
||||||
|
printf("SDP service record size: %u\n", de_get_len((uint8_t*) panu_sdp_record));
|
||||||
|
sdp_register_service_internal(NULL, (uint8_t*)panu_sdp_record);
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Turn on the device */
|
/* Turn on the device */
|
||||||
hci_power_control(HCI_POWER_ON);
|
hci_power_control(HCI_POWER_ON);
|
||||||
|
hci_discoverable_control(1);
|
||||||
|
|
||||||
btstack_stdin_setup(stdin_process);
|
btstack_stdin_setup(stdin_process);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user