Skip to content
Permalink
Browse files

Merge branch 'develop'

  • Loading branch information...
mringwal committed Sep 9, 2019
2 parents 28681d3 + ae7be28 commit a3030cc2d645d821f3ab5a3f5fb915cee5a482df
@@ -0,0 +1,14 @@
# List of Third-Party Libaries

This folder contains all third-party libarires used by BTstack. The following table lists their source, license type, and what it is used for.

Library | Version | License | Used | Notes
----------------------------------------------------------------------------------------------------------------|----------|---------------|------------------|----------
[Android SBC Codec](https://android.googlesource.com/platform/external/bluetooth/bluedroid/+/master/embdrv/sbc) | e8c3d75b | Apache 2.0 | HFP WBS, A2DP | optimized audio codec
[hxcmod-player](https://github.com/jfdelnero/HxCModPlayer) | 03d495c8 | Public Domain | A2DP Source Demo | mod music player
[lwIP](http://savannah.nongnu.org/projects/lwip/) | b3a93941 | BSD 3-Clause | PAN Demo | complete network stack
[md5](http://openwall.info/wiki/people/solar/software/public-domain-source-code/md5) | 1.0 | Public Domain | PBAP | cryptographic hash function
[micro-ecc](https://github.com/kmackay/micro-ecc) | e4d264b5 | BSD 2-Clause | LE SC, Mesh | elliptic curve library
[segger-rtt](https://www.segger.com/products/debug-probes/j-link/technology/about-real-time-transfer/) | v6.20d | BSD 3-Clause | HCI PacketLog | high-speed logging with SEGGER J-Link debug probes (development)
[tinydir](https://github.com/cxong/tinydir) | 677733da | BSD 2-Clause | GAP Bonding | get a directory listing on POSIX + Windwows systems
[Yxml](https://dev.yorhel.nl/yxml) | 10f968b0 | MIT | PBAP | minimal stream XML parser
@@ -8,13 +8,25 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]

### Fixed

### Added
- GAP: allow to reject GAP classic connection via gap_register_classic_connection_filter
- GAP: support reading RSSI for Classic+LE using gap_read_rssi. Emits GAP_EVENT_RSSI_MEASUREMENT

## Changed


## Changes August 2019

### Fixed
- POSIX, WICED, Windows, FreeRTOS run loops: handle time_ms overrun after 49 days
- RFCOMM: accept incoming L2CAP connection in Basic mode if ERTM is enabled but not requested for this connection
- RFCOMM: limit RFCOMM MTU by local L2CAP MTU for outgoing connections (only revelvant for ERTM)
- L2CAP ERTM: stop timers on disconnect
- L2CAP ERTM: fix sending of segmented SDUs
- L2CAP ERTM: handle unsupported Information Response
- SM: generate local nonce for confirm value in JW+NC+PK in Secure Connections Responder role

### Added
- btstack_run_loop_base: portable implementation of timer and data source managment as base for platform specific implementations
@@ -18,8 +18,11 @@ BTstack is free for non-commercial use. However, for commercial use, <a href="ma

**Documentation:** [HTML](http://bluekitchen-gmbh.com/btstack/), [PDF](http://bluekitchen-gmbh.com/btstack.pdf)

**Third-party libraries (FOSS):** [List of used libraries and their licenses](https://github.com/bluekitchen/btstack/blob/develop/3rd-party/README.md)

**Discussion and Community Support:** [BTstack Google Group](http://groups.google.com/group/btstack-dev)


### Supported Protocols and Profiles

**Protocols:** L2CAP (incl. LE Data Channels), RFCOMM, SDP, BNEP, AVDTP, AVCTP, ATT, SM (incl. LE Secure Connections).
@@ -33,7 +36,6 @@ BTstack is free for non-commercial use. However, for commercial use, <a href="ma
It has been qualified with the Bluetooth SIG (QDID 110883) for GAP, IOP, HFP, HSP, SPP, PAN, A2DP, AVRCP profiles and
GATT, SM of the Bluetooth 5 specification. For information on MFi/iAP2 support, please <a href="mailto:contact@bluekitchen-gmbh.com">contact us</a>.


## Evaluation Platforms

#### Embedded Platforms:
@@ -62,6 +62,7 @@ static char gap_name_prefix[] = "Mesh ";

static btstack_packet_callback_registration_t hci_event_callback_registration;

#ifdef ENABLE_MESH_GATT_BEARER
static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
UNUSED(channel);
UNUSED(size);
@@ -90,6 +91,7 @@ static uint16_t att_read_callback(hci_con_handle_t connection_handle, uint16_t a
}
return 0;
}
#endif

static void mesh_provisioning_message_handler (uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
UNUSED(packet_type);
@@ -180,12 +182,15 @@ static void stdin_process(char cmd){
int btstack_main(void);
int btstack_main(void)
{
#ifdef HAVE_BTSTACK_STDIN
// console
btstack_stdin_setup(stdin_process);
#endif

// crypto
btstack_crypto_init();

#ifdef ENABLE_GATT_BEARER
// l2cap
l2cap_init();

@@ -197,21 +202,26 @@ int btstack_main(void)

//
sm_init();
#endif

#ifdef ENABLE_MESH_GATT_BEARER
// register for HCI events
hci_event_callback_registration.callback = &packet_handler;
hci_add_event_handler(&hci_event_callback_registration);
#endif

// mesh
mesh_init();

#ifdef ENABLE_GATT_BEARER
// setup connectable advertisments
bd_addr_t null_addr;
memset(null_addr, 0, 6);
uint8_t adv_type = 0; // AFV_IND
uint16_t adv_int_min = 0x0030;
uint16_t adv_int_max = 0x0030;
adv_bearer_advertisements_set_params(adv_int_min, adv_int_max, adv_type, 0, null_addr, 0x07, 0x00);
#endif

// Track Provisioning as device role
mesh_register_provisioning_device_packet_handler(&mesh_provisioning_message_handler);
@@ -1759,8 +1759,16 @@ static void daemon_sigint_handler(int param){

log_info(" <= SIGINT received, shutting down..\n");

hci_power_control( HCI_POWER_OFF);
hci_close();
int send_power_off = 1;
#ifdef HAVE_INTEL_USB
// power off and close only if hci was initialized before
send_power_off = intel_firmware_loaded;
#endif

if (send_power_off){
hci_power_control( HCI_POWER_OFF);
hci_close();
}

log_info("Good bye, see you.\n");

@@ -75,6 +75,7 @@ static bd_addr_t local_addr;
static int main_argc;
static const char ** main_argv;
static const hci_transport_t * transport;
static int intel_firmware_loaded;

int btstack_main(int argc, const char * argv[]);

@@ -109,9 +110,12 @@ static void sigint_handler(int param){
// reset anyway
btstack_stdin_reset();

// power down
hci_power_control(HCI_POWER_OFF);
hci_close();
// power off and close only if hci was initialized before
if (intel_firmware_loaded){
hci_power_control( HCI_POWER_OFF);
hci_close();
}

log_info("Good bye, see you.\n");
exit(0);
}
@@ -126,6 +130,8 @@ static void intel_firmware_done(int result){

printf("Done %x\n", result);

intel_firmware_loaded = 1;

// init HCI
hci_init(transport, NULL);

@@ -9,14 +9,14 @@
#define HAVE_EMBEDDED_TICK

// BTstack features that can be enabled
#define ENABLE_BLE
#define ENABLE_CLASSIC
#define ENABLE_LE_PERIPHERAL
// #define ENABLE_BLE
// #define ENABLE_LE_PERIPHERAL
// #define ENABLE_LE_CENTRAL
// #define ENABLE_LOG_ERROR
// #define ENABLE_LOG_INFO
// #define ENABLE_EHCILL
#define ENABLE_SCO_OVER_HCI
// #define ENABLE_SCO_OVER_HCI

// BTstack configuration. buffers, sizes, ...
#define HCI_ACL_PAYLOAD_SIZE 52
@@ -69,6 +69,7 @@ static btstack_packet_callback_registration_t hci_event_callback_registration;
static int main_argc;
static const char ** main_argv;
static const hci_transport_t * transport;
static int intel_firmware_loaded;

static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
if (packet_type != HCI_EVENT_PACKET) return;
@@ -88,10 +89,11 @@ static void sigint_handler(int param){
// reset anyway
btstack_stdin_reset();

// power down
hci_power_control(HCI_POWER_OFF);
hci_close();
log_info("Good bye, see you.\n");
// power off and close only if hci was initialized before
if (intel_firmware_loaded){
hci_power_control( HCI_POWER_OFF);
hci_close();
}
exit(0);
}

@@ -106,6 +108,8 @@ static void intel_firmware_done(int result){

printf("Done %x\n", result);

intel_firmware_loaded = 1;

// init HCI
hci_init(transport, NULL);

@@ -36,8 +36,8 @@
*/


#ifndef ATT_H
#define ATT_H
#ifndef ATT_DB_H
#define ATT_DB_H

#include <stdint.h>
#include "bluetooth.h"
@@ -81,7 +81,7 @@ static mesh_provisioning_t mesh_provisioning;
static void mesh_provisioning_service_emit_link_open(hci_con_handle_t con_handle, uint8_t status){
uint8_t event[7] = { HCI_EVENT_MESH_META, 5, MESH_SUBEVENT_PB_TRANSPORT_LINK_OPEN, status};
little_endian_store_16(event, 4, con_handle);
event[6] = PB_TYPE_GATT;
event[6] = MESH_PB_TYPE_GATT;
mesh_provisioning_service_packet_handler(HCI_EVENT_PACKET, 0, event, sizeof(event));
}

@@ -3081,6 +3081,9 @@ static void sm_event_packet_handler (uint8_t packet_type, uint16_t channel, uint
sm_validate_er_ir();
dkg_state = DKG_CALC_IRK;
}

// restart random address updates after power cycle
gap_random_address_set_mode(gap_random_adress_type);
}
break;

@@ -1046,6 +1046,14 @@ typedef uint8_t sm_key_t[16];
*/
#define GAP_EVENT_INQUIRY_COMPLETE 0xE4

/**
* @format H1
* @param con_handle
* @param rssi (signed integer -127..127)
* @note Classic: rssi is in dB relative to Golden Receive Power Range
* @note LE: rssi is absolute dBm
*/
#define GAP_EVENT_RSSI_MEASUREMENT 0xE5

// Meta Events, see below for sub events
#define HCI_EVENT_HSP_META 0xE8
@@ -3258,6 +3258,25 @@ static inline uint8_t gap_event_inquiry_complete_get_status(const uint8_t * even
return event[2];
}

/**
* @brief Get field con_handle from event GAP_EVENT_RSSI_MEASUREMENT
* @param event packet
* @return con_handle
* @note: btstack_type H
*/
static inline hci_con_handle_t gap_event_rssi_measurement_get_con_handle(const uint8_t * event){
return little_endian_read_16(event, 2);
}
/**
* @brief Get field rssi from event GAP_EVENT_RSSI_MEASUREMENT
* @param event packet
* @return rssi
* @note: btstack_type 1
*/
static inline uint8_t gap_event_rssi_measurement_get_rssi(const uint8_t * event){
return event[4];
}

/**
* @brief Get field status from event HCI_SUBEVENT_LE_CONNECTION_COMPLETE
* @param event packet
@@ -53,7 +53,7 @@
#include "classic/core.h"
#include "classic/sdp_util.h"

void spp_create_sdp_record(uint8_t *service, uint32_t service_record_handle, int rfcomm_channel, const char *name){
static void spp_create_sdp_record_internal(uint8_t *service, uint32_t service_record_handle, const uint8_t * service_uuid128, int rfcomm_channel, const char *name){

uint8_t* attribute;
de_create_sequence(service);
@@ -66,7 +66,11 @@ void spp_create_sdp_record(uint8_t *service, uint32_t service_record_handle, int
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, BLUETOOTH_SERVICE_CLASS_SERIAL_PORT );
if (service_uuid128 == NULL){
de_add_number(attribute, DE_UUID, DE_SIZE_16, BLUETOOTH_SERVICE_CLASS_SERIAL_PORT );
} else {
de_add_uuid128(attribute, (uint8_t *) service_uuid128);
}
}
de_pop_sequence(service, attribute);

@@ -124,3 +128,11 @@ void spp_create_sdp_record(uint8_t *service, uint32_t service_record_handle, int
de_add_number(service, DE_UINT, DE_SIZE_16, 0x0100);
de_add_data(service, DE_STRING, strlen(name), (uint8_t *) name);
}

void spp_create_sdp_record(uint8_t *service, uint32_t service_record_handle, int rfcomm_channel, const char *name){
spp_create_sdp_record_internal(service, service_record_handle, NULL, rfcomm_channel, name);
}

void spp_create_custom_sdp_record(uint8_t *service, uint32_t service_record_handle, const uint8_t * service_uuid128, int rfcomm_channel, const char *name){
spp_create_sdp_record_internal(service, service_record_handle, service_uuid128, rfcomm_channel, name);
}
@@ -53,14 +53,24 @@ extern "C" {
/* API_START */

/**
* @brief Create SDP record for SPP service
* @brief Create SDP record for SPP service with official SPP Service Class
* @param service buffer - needs to large enough
* @param service_record_handle
* @param rfcomm_channel
* @param name
*/
void spp_create_sdp_record(uint8_t *service, uint32_t service_record_handle, int rfcomm_channel, const char *name);

/**
* @brief Create SDP record for SPP service with custom service UUID (e.g. for use with Android)
* @param service buffer - needs to large enough
* @param service_record_handle
* @param service_uuid128 buffer
* @param rfcomm_channel
* @param name
*/
void spp_create_custom_sdp_record(uint8_t *service, uint32_t service_record_handle, const uint8_t * service_uuid128, int rfcomm_channel, const char *name);

/* API_END */

#if defined __cplusplus
@@ -176,6 +176,13 @@ void gap_set_bondable_mode(int enabled);
*/
int gap_get_bondable_mode(void);

/**
* @brief Register filter for rejecting classic connections. Callback will return 1 accept connection, 0 on reject.
*/

void gap_register_classic_connection_filter(int (*accept_callback)(bd_addr_t addr));


/* Configure Secure Simple Pairing */

/**
@@ -546,6 +553,13 @@ int gap_inquiry_stop(void);
*/
int gap_remote_name_request(bd_addr_t addr, uint8_t page_scan_repetition_mode, uint16_t clock_offset);

/**
* @brief Read RSSI
* @param con_handle
* @events: GAP_EVENT_RSSI_MEASUREMENT
*/
int gap_read_rssi(hci_con_handle_t con_handle);

/**
* @brief Legacy Pairing Pin Code Response
* @param addr

0 comments on commit a3030cc

Please sign in to comment.
You can’t perform that action at this time.