diff --git a/CHANGELOG.md b/CHANGELOG.md index 34affa92f..62e689004 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,14 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ### Fixed ### Changed +## Release v1.5.1 + +### Fixed +- pbap_client: support disconnect while operation is ongoing + +### Changed +- Example: init SM if LE supported to avoid issue with Android Cross-Transport Key-Derivation + ## Release v1.5.0 diff --git a/example/a2dp_sink_demo.c b/example/a2dp_sink_demo.c index 36d558966..2d2197596 100644 --- a/example/a2dp_sink_demo.c +++ b/example/a2dp_sink_demo.c @@ -213,7 +213,14 @@ static void stdin_process(char cmd); #endif static int a2dp_and_avrcp_setup(void){ + l2cap_init(); + +#ifdef ENABLE_BLE + // Initialize LE Security Manager. Needed for cross-transport key derivation + sm_init(); +#endif + // Initialize AVDTP Sink a2dp_sink_init(); a2dp_sink_register_packet_handler(&a2dp_sink_packet_handler); diff --git a/example/a2dp_source_demo.c b/example/a2dp_source_demo.c index d63ae6342..d9597359b 100644 --- a/example/a2dp_source_demo.c +++ b/example/a2dp_source_demo.c @@ -249,10 +249,17 @@ static void stdin_process(char cmd); static void a2dp_demo_hexcmod_configure_sample_rate(int sample_rate); static int a2dp_source_and_avrcp_services_init(void){ + // Request role change on reconnecting headset to always use them in slave mode hci_set_master_slave_policy(0); l2cap_init(); + +#ifdef ENABLE_BLE + // Initialize LE Security Manager. Needed for cross-transport key derivation + sm_init(); +#endif + // Initialize A2DP Source a2dp_source_init(); a2dp_source_register_packet_handler(&a2dp_source_packet_handler); diff --git a/example/avrcp_browsing_client.c b/example/avrcp_browsing_client.c index 0acdbc4d0..c31f4119e 100644 --- a/example/avrcp_browsing_client.c +++ b/example/avrcp_browsing_client.c @@ -246,6 +246,11 @@ int btstack_main(int argc, const char * argv[]){ // Initialize L2CAP. l2cap_init(); +#ifdef ENABLE_BLE + // Initialize LE Security Manager. Needed for cross-transport key derivation + sm_init(); +#endif + a2dp_sink_init(); a2dp_sink_register_packet_handler(&a2dp_sink_packet_handler); diff --git a/example/gap_dedicated_bonding.c b/example/gap_dedicated_bonding.c index 5de57ec23..1ac478fb0 100644 --- a/example/gap_dedicated_bonding.c +++ b/example/gap_dedicated_bonding.c @@ -77,6 +77,13 @@ int btstack_main(int argc, const char * argv[]){ hci_event_callback_registration.callback = &packet_handler; hci_add_event_handler(&hci_event_callback_registration); + l2cap_init(); + +#ifdef ENABLE_BLE + // Initialize LE Security Manager. Needed for cross-transport key derivation + sm_init(); +#endif + // turn on! hci_power_control(HCI_POWER_ON); diff --git a/example/hfp_ag_demo.c b/example/hfp_ag_demo.c index f8a337557..b256ff71b 100644 --- a/example/hfp_ag_demo.c +++ b/example/hfp_ag_demo.c @@ -706,6 +706,11 @@ int btstack_main(int argc, const char * argv[]){ // L2CAP l2cap_init(); +#ifdef ENABLE_BLE + // Initialize LE Security Manager. Needed for cross-transport key derivation + sm_init(); +#endif + uint16_t supported_features = (1<<HFP_AGSF_ESCO_S4) | (1<<HFP_AGSF_HF_INDICATORS) | diff --git a/example/hfp_hf_demo.c b/example/hfp_hf_demo.c index 60edf01e0..88852d81a 100644 --- a/example/hfp_hf_demo.c +++ b/example/hfp_hf_demo.c @@ -684,6 +684,11 @@ int btstack_main(int argc, const char * argv[]){ // init L2CAP l2cap_init(); +#ifdef ENABLE_BLE + // Initialize LE Security Manager. Needed for cross-transport key derivation + sm_init(); +#endif + uint16_t hf_supported_features = (1<<HFP_HFSF_ESCO_S4) | (1<<HFP_HFSF_CLI_PRESENTATION_CAPABILITY) | diff --git a/example/hid_host_demo.c b/example/hid_host_demo.c index 428f413b9..9bc8a5662 100644 --- a/example/hid_host_demo.c +++ b/example/hid_host_demo.c @@ -138,10 +138,15 @@ static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *pack static void hid_host_setup(void){ - // Initialize L2CAP + // Initialize L2CAP l2cap_init(); - // Initialize HID Host +#ifdef ENABLE_BLE + // Initialize LE Security Manager. Needed for cross-transport key derivation + sm_init(); +#endif + + // Initialize HID Host hid_host_init(hid_descriptor_storage, sizeof(hid_descriptor_storage)); hid_host_register_packet_handler(packet_handler); diff --git a/example/hid_keyboard_demo.c b/example/hid_keyboard_demo.c index 64642004b..ec42fc763 100644 --- a/example/hid_keyboard_demo.c +++ b/example/hid_keyboard_demo.c @@ -408,6 +408,11 @@ int btstack_main(int argc, const char * argv[]){ // L2CAP l2cap_init(); +#ifdef ENABLE_BLE + // Initialize LE Security Manager. Needed for cross-transport key derivation + sm_init(); +#endif + // SDP Server sdp_init(); memset(hid_service_buffer, 0, sizeof(hid_service_buffer)); diff --git a/example/hid_mouse_demo.c b/example/hid_mouse_demo.c index 06b4d35af..bac9304b0 100644 --- a/example/hid_mouse_demo.c +++ b/example/hid_mouse_demo.c @@ -297,6 +297,11 @@ int btstack_main(int argc, const char * argv[]){ // L2CAP l2cap_init(); +#ifdef ENABLE_BLE + // Initialize LE Security Manager. Needed for cross-transport key derivation + sm_init(); +#endif + // SDP Server sdp_init(); memset(hid_service_buffer, 0, sizeof(hid_service_buffer)); diff --git a/example/hsp_ag_demo.c b/example/hsp_ag_demo.c index 03a0948f9..cdaf2dd10 100644 --- a/example/hsp_ag_demo.c +++ b/example/hsp_ag_demo.c @@ -295,6 +295,11 @@ int btstack_main(int argc, const char * argv[]){ l2cap_init(); +#ifdef ENABLE_BLE + // Initialize LE Security Manager. Needed for cross-transport key derivation + sm_init(); +#endif + sdp_init(); memset((uint8_t *)hsp_service_buffer, 0, sizeof(hsp_service_buffer)); diff --git a/example/hsp_hs_demo.c b/example/hsp_hs_demo.c index a1f770870..2f5115e6f 100644 --- a/example/hsp_hs_demo.c +++ b/example/hsp_hs_demo.c @@ -277,6 +277,11 @@ int btstack_main(int argc, const char * argv[]){ l2cap_init(); +#ifdef ENABLE_BLE + // Initialize LE Security Manager. Needed for cross-transport key derivation + sm_init(); +#endif + sdp_init(); memset(hsp_service_buffer, 0, sizeof(hsp_service_buffer)); hsp_hs_create_sdp_record(hsp_service_buffer, 0x10001, rfcomm_channel_nr, hsp_hs_service_name, 0); diff --git a/example/pan_lwip_http_server.c b/example/pan_lwip_http_server.c index 18131052c..8fd8a04ea 100644 --- a/example/pan_lwip_http_server.c +++ b/example/pan_lwip_http_server.c @@ -175,6 +175,11 @@ static void pan_bnep_setup(void){ // Initialize L2CAP l2cap_init(); +#ifdef ENABLE_BLE + // Initialize LE Security Manager. Needed for cross-transport key derivation + sm_init(); +#endif + // Initialize BNEP bnep_init(); diff --git a/example/panu_demo.c b/example/panu_demo.c index 6612b878b..247da7895 100644 --- a/example/panu_demo.c +++ b/example/panu_demo.c @@ -112,9 +112,13 @@ static void network_send_packet_callback(const uint8_t * packet, uint16_t size); static void panu_setup(void){ - // Initialize L2CAP + // Initialize L2CAP l2cap_init(); +#ifdef ENABLE_BLE + // Initialize LE Security Manager. Needed for cross-transport key derivation + sm_init(); +#endif // init SDP, create record for PANU and register with SDP sdp_init(); diff --git a/example/pbap_client_demo.c b/example/pbap_client_demo.c index d3128f885..4bda13824 100644 --- a/example/pbap_client_demo.c +++ b/example/pbap_client_demo.c @@ -54,12 +54,7 @@ #include <stdlib.h> #include <string.h> -#include "btstack_run_loop.h" -#include "l2cap.h" -#include "classic/rfcomm.h" -#include "btstack_event.h" -#include "classic/goep_client.h" -#include "classic/pbap_client.h" +#include "btstack.h" #ifdef HAVE_BTSTACK_STDIN #include "btstack_stdin.h" @@ -370,13 +365,17 @@ static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packe int btstack_main(int argc, const char * argv[]); int btstack_main(int argc, const char * argv[]){ - (void)argc; (void)argv; - + // init L2CAP l2cap_init(); +#ifdef ENABLE_BLE + // Initialize LE Security Manager. Needed for cross-transport key derivation + sm_init(); +#endif + // init RFCOM rfcomm_init(); diff --git a/example/spp_counter.c b/example/spp_counter.c index d6045371b..e88ff9d9c 100644 --- a/example/spp_counter.c +++ b/example/spp_counter.c @@ -90,6 +90,11 @@ static void spp_service_setup(void){ l2cap_init(); +#ifdef ENABLE_BLE + // Initialize LE Security Manager. Needed for cross-transport key derivation + sm_init(); +#endif + rfcomm_init(); rfcomm_register_service(packet_handler, RFCOMM_SERVER_CHANNEL, 0xffff); // reserved channel, mtu limited by l2cap diff --git a/example/spp_flowcontrol.c b/example/spp_flowcontrol.c index ac582f648..0240eea3f 100644 --- a/example/spp_flowcontrol.c +++ b/example/spp_flowcontrol.c @@ -200,6 +200,13 @@ int btstack_main(int argc, const char * argv[]){ (void)argc; (void)argv; + l2cap_init(); + +#ifdef ENABLE_BLE + // Initialize LE Security Manager. Needed for cross-transport key derivation + sm_init(); +#endif + spp_service_setup(); one_shot_timer_setup(); diff --git a/example/spp_streamer.c b/example/spp_streamer.c index 605789bad..361a5742d 100644 --- a/example/spp_streamer.c +++ b/example/spp_streamer.c @@ -283,6 +283,11 @@ int btstack_main(int argc, const char * argv[]) l2cap_init(); +#ifdef ENABLE_BLE + // Initialize LE Security Manager. Needed for cross-transport key derivation + sm_init(); +#endif + rfcomm_init(); rfcomm_register_service(packet_handler, RFCOMM_SERVER_CHANNEL, 0xffff); diff --git a/example/spp_streamer_client.c b/example/spp_streamer_client.c index 53b586ba7..b277b3dc7 100644 --- a/example/spp_streamer_client.c +++ b/example/spp_streamer_client.c @@ -392,6 +392,11 @@ int btstack_main(int argc, const char * argv[]){ l2cap_init(); +#ifdef ENABLE_BLE + // Initialize LE Security Manager. Needed for cross-transport key derivation + sm_init(); +#endif + rfcomm_init(); #ifdef ENABLE_L2CAP_ENHANCED_RETRANSMISSION_MODE_FOR_RFCOMM diff --git a/src/btstack.h b/src/btstack.h index 131e9811b..b074d184d 100644 --- a/src/btstack.h +++ b/src/btstack.h @@ -129,6 +129,7 @@ #include "classic/btstack_sbc.h" #include "classic/device_id_server.h" #include "classic/gatt_sdp.h" +#include "classic/goep_client.h" #include "classic/hfp.h" #include "classic/hfp_ag.h" #include "classic/hfp_hf.h" @@ -137,6 +138,7 @@ #include "classic/hsp_ag.h" #include "classic/hsp_hs.h" #include "classic/pan.h" +#include "classic/pbap_client.h" #include "classic/rfcomm.h" #include "classic/sdp_client.h" #include "classic/sdp_client_rfcomm.h"