Merge branch 'develop' of https://github.com/bluekitchen/btstack into develop

This commit is contained in:
Milanka Ringwald 2017-07-07 14:09:36 +02:00
commit 21fd2cebe7
5 changed files with 80 additions and 24 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 500 KiB

View File

@ -1,6 +1,8 @@
# BTstack port for STM32 Nucleo-L053R8 Board with an EM9304 Shield
# BTstack port for STM32 Nucleo-L053R8 Board with an EM9304 Shield - EM9304 DVK
This port uses the STM32 Nucleo-L053R8 Board with EM's EM9304 Shield. STM32CubeMX was used to provide the HAL, initialize the device, and create a basic Makefile. The Makefile has been exteneded to compile all BTstack LE examples. An examples can be uploaded onto the device by copying it to the Nucleo virtual mass storage drive.
This port uses the STM32 Nucleo-L053R8 Board with EM's EM9304 Shield.
The STM32CubeMX tool was used to provide the HAL, initialize the device, and create a basic Makefile. The Makefile has been exteneded to compile all BTstack LE examples. An examples can be uploaded onto the device by copying it to the Nucleo virtual mass storage drive.
## Hardware
@ -29,10 +31,13 @@ Also, the full packet log can be enabled in port.c by uncommenting the hci_dump_
In BTstack, the GATT Database is defined via the .gatt file in the example folder. During the build, the .gatt file is converted into a .h file with a binary representation of the GATT Database and useful defines for the application.
## Stability
When sending at full speed, it's possible that the EM9304 hangs up. A patch is available from EM Technical Support and from [this post](https://forums.emdeveloper.com/index.php?threads/em9304-seems-to-hang-up-streaming-data-in-hci-mode.484/#post-2083) in the EM Developer Forum. You can get access to the forum via the EM Technical Support as well.
When sending at full speed, it's possible that the EM9304 hangs up. This [patch (connection_event_overlay.emp)](https://bluekitchen-gmbh.com/files/em/patches/connection_event_overlay.emp) fixes this problems in our tests. It can be applied with the EM ConfigEditor available via the EM Technical Support.
## Multiple LE Peripheral/Central Roles
It should be possible to use the EM9304 in multiple roles. In the default configuration, it only supports a single connection. For multiple roles, it needs to be configured for more connections at least.
## Performace
With the patch, the LE Streamer example is able to send up to 10 packets per Connection Event to an iPhone SE with iOS 10.2, resulting in around 6.5 kB/s throughput for this direction.
## Image
![EM9304 DVK](EM9304DVK.jpg)

View File

@ -272,6 +272,19 @@ void gap_advertisements_enable(int enabled);
*/
void gap_scan_response_set_data(uint8_t scan_response_data_length, uint8_t * scan_response_data);
/**
* @brief Set connection parameters for outgoing connections
* @param conn_interval_min (unit: 1.25ms), default: 10 ms
* @param conn_interval_max (unit: 1.25ms), default: 30 ms
* @param conn_latency, default: 4
* @param supervision_timeout (unit: 10ms), default: 720 ms
* @param min_ce_length (unit: 0.625ms), default: 10 ms
* @param max_ce_length (unit: 0.625ms), default: 30 ms
*/
void gap_set_connection_parameters(uint16_t conn_interval_min, uint16_t conn_interval_max,
uint16_t conn_latency, uint16_t supervision_timeout, uint16_t min_ce_length, uint16_t max_ce_length);
/**
* @brief Request an update of the connection parameter for a given LE connection
* @param handle

View File

@ -2293,8 +2293,17 @@ static void hci_state_reset(void){
hci_stack->le_connecting_state = LE_CONNECTING_IDLE;
hci_stack->le_whitelist = 0;
hci_stack->le_whitelist_capacity = 0;
// connection parameter to use for outgoing connections
hci_stack->le_connection_interval_min = 0x0008; // 10 ms
hci_stack->le_connection_interval_max = 0x0018; // 30 ms
hci_stack->le_connection_latency = 4; // 4
hci_stack->le_supervision_timeout = 0x0048; // 720 ms
hci_stack->le_minimum_ce_length = 2; // 1.25 ms
hci_stack->le_maximum_ce_length = 0x0030; // 30 ms
#endif
// connection parameter range used to answer connection parameter update requests in l2cap
hci_stack->le_connection_parameter_range.le_conn_interval_min = 6;
hci_stack->le_connection_parameter_range.le_conn_interval_max = 3200;
hci_stack->le_connection_parameter_range.le_conn_latency_min = 0;
@ -2981,13 +2990,13 @@ static void hci_run(void){
0, // peer address type
null_addr, // peer bd addr
hci_stack->le_own_addr_type, // our addr type:
0x0008, // conn interval min
0x0018, // conn interval max
0, // conn latency
0x0048, // supervision timeout
0x0001, // min ce length
0x0001 // max ce length
);
hci_stack->le_connection_interval_min, // conn interval min
hci_stack->le_connection_interval_max, // conn interval max
hci_stack->le_connection_latency, // conn latency
hci_stack->le_supervision_timeout, // conn latency
hci_stack->le_minimum_ce_length, // min ce length
hci_stack->le_maximum_ce_length // max ce length
);
return;
}
#endif
@ -3012,20 +3021,19 @@ static void hci_run(void){
#ifdef ENABLE_LE_CENTRAL
log_info("sending hci_le_create_connection");
hci_send_cmd(&hci_le_create_connection,
0x0060, // scan interval: 60 ms
0x0030, // scan interval: 30 ms
0, // don't use whitelist
connection->address_type, // peer address type
connection->address, // peer bd addr
hci_stack->le_own_addr_type, // our addr type:
0x0008, // conn interval min
0x0018, // conn interval max
0, // conn latency
0x0048, // supervision timeout
0x0001, // min ce length
0x0001 // max ce length
);
0x0060, // scan interval: 60 ms
0x0030, // scan interval: 30 ms
0, // don't use whitelist
connection->address_type, // peer address type
connection->address, // peer bd addr
hci_stack->le_own_addr_type, // our addr type:
hci_stack->le_connection_interval_min, // conn interval min
hci_stack->le_connection_interval_max, // conn interval max
hci_stack->le_connection_latency, // conn latency
hci_stack->le_supervision_timeout, // conn latency
hci_stack->le_minimum_ce_length, // min ce length
hci_stack->le_maximum_ce_length // max ce length
);
connection->state = SENT_CREATE_CONNECTION;
#endif
#endif
@ -3947,6 +3955,28 @@ uint8_t gap_connect_cancel(void){
}
#endif
#ifdef ENABLE_LE_CENTRAL
/**
* @brief Set connection parameters for outgoing connections
* @param conn_interval_min (unit: 1.25ms), default: 10 ms
* @param conn_interval_max (unit: 1.25ms), default: 30 ms
* @param conn_latency, default: 4
* @param supervision_timeout (unit: 10ms), default: 720 ms
* @param min_ce_length (unit: 0.625ms), default: 10 ms
* @param max_ce_length (unit: 0.625ms), default: 30 ms
*/
void gap_set_connection_parameters(uint16_t conn_interval_min, uint16_t conn_interval_max,
uint16_t conn_latency, uint16_t supervision_timeout, uint16_t min_ce_length, uint16_t max_ce_length){
hci_stack->le_connection_interval_min = conn_interval_min;
hci_stack->le_connection_interval_max = conn_interval_max;
hci_stack->le_connection_latency = conn_latency;
hci_stack->le_supervision_timeout = supervision_timeout;
hci_stack->le_minimum_ce_length = min_ce_length;
hci_stack->le_maximum_ce_length = max_ce_length;
}
#endif
/**
* @brief Updates the connection parameters for a given LE connection
* @param handle

View File

@ -782,6 +782,14 @@ typedef struct {
// LE Whitelist Management
uint8_t le_whitelist_capacity;
btstack_linked_list_t le_whitelist;
// Connection parameters
uint16_t le_connection_interval_min;
uint16_t le_connection_interval_max;
uint16_t le_connection_latency;
uint16_t le_supervision_timeout;
uint16_t le_minimum_ce_length;
uint16_t le_maximum_ce_length;
#endif
le_connection_parameter_range_t le_connection_parameter_range;