From 02ad223eea69cc1bd7d9f9d9f88e406889a1691d Mon Sep 17 00:00:00 2001 From: yulong Date: Sat, 15 Oct 2016 05:46:10 -0400 Subject: [PATCH] component bt: 1.modified the btu buffer size from 15 to 60; 2.change the smp method --- components/bt/bluedroid/bta/dm/bta_dm_api.c | 2 +- components/bt/bluedroid/bta/dm/bta_dm_pm.c | 1 - .../bt/bluedroid/bta/gatt/bta_gatts_act.c | 2 +- components/bt/bluedroid/device/controller.c | 922 +++++++++--------- components/bt/bluedroid/include/bt_defs.h | 2 +- components/bt/bluedroid/osi/future.c | 200 ++-- components/bt/bluedroid/osi/include/future.h | 90 +- .../bt/bluedroid/profiles/core/bt_prf_task.c | 18 +- .../profiles/esp/ble_button/button_pro.c | 8 +- .../profiles/std/hid_le/hid_le_prf.c | 6 +- components/bt/bluedroid/stack/btm/btm_acl.c | 2 +- components/bt/bluedroid/stack/btu/btu_init.c | 8 +- .../bt/bluedroid/stack/l2cap/l2c_main.c | 2 +- components/bt/bluedroid/stack/smp/smp_act.c | 175 ++-- components/bt/bluedroid/stack/smp/smp_api.c | 4 +- components/bt/bluedroid/stack/smp/smp_keys.c | 99 +- components/bt/bluedroid/stack/smp/smp_l2c.c | 10 +- components/bt/bluedroid/stack/smp/smp_main.c | 15 +- components/bt/bluedroid/stack/smp/smp_utils.c | 120 +-- components/bt/bt.c | 268 ++--- 20 files changed, 978 insertions(+), 976 deletions(-) diff --git a/components/bt/bluedroid/bta/dm/bta_dm_api.c b/components/bt/bluedroid/bta/dm/bta_dm_api.c index 959c975855..5dd94b6ac3 100755 --- a/components/bt/bluedroid/bta/dm/bta_dm_api.c +++ b/components/bt/bluedroid/bta/dm/bta_dm_api.c @@ -983,7 +983,7 @@ void BTA_DmSetBleAdvParams (UINT16 adv_int_min, UINT16 adv_int_max, #if BLE_INCLUDED == TRUE tBTA_DM_API_BLE_ADV_PARAMS *p_msg; - APPL_TRACE_API ("BTA_DmSetBleAdvParam: %d, %d", adv_int_min, adv_int_max); + APPL_TRACE_API ("BTA_DmSetBleAdvParam: %d, %d\n", adv_int_min, adv_int_max); if ((p_msg = (tBTA_DM_API_BLE_ADV_PARAMS *) GKI_getbuf(sizeof(tBTA_DM_API_BLE_ADV_PARAMS))) != NULL) { diff --git a/components/bt/bluedroid/bta/dm/bta_dm_pm.c b/components/bt/bluedroid/bta/dm/bta_dm_pm.c index 87061eb9b0..2ebcb46d1f 100755 --- a/components/bt/bluedroid/bta/dm/bta_dm_pm.c +++ b/components/bt/bluedroid/bta/dm/bta_dm_pm.c @@ -636,7 +636,6 @@ static void bta_dm_pm_set_mode(BD_ADDR peer_addr, tBTA_DM_PM_ACTION pm_request, remaining_ticks = bta_dm_pm_get_remaining_ticks(&bta_dm_cb.pm_timer[i].timer[timer_idx]); if (remaining_ticks < timeout) { - ets_printf("remain 00\n"); /* Cancel and restart the timer */ /* * TODO: The value of pm_action[timer_idx] is diff --git a/components/bt/bluedroid/bta/gatt/bta_gatts_act.c b/components/bt/bluedroid/bta/gatt/bta_gatts_act.c index 1c0edfd770..6e1e46fa9e 100755 --- a/components/bt/bluedroid/bta/gatt/bta_gatts_act.c +++ b/components/bt/bluedroid/bta/gatt/bta_gatts_act.c @@ -620,7 +620,7 @@ void bta_gatts_send_rsp (tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA * p_msg) p_msg->api_rsp.status, (tGATTS_RSP *)p_msg->api_rsp.p_rsp) != GATT_SUCCESS) { - APPL_TRACE_ERROR("Sending response failed"); + APPL_TRACE_ERROR("Sending response failed\n"); } } diff --git a/components/bt/bluedroid/device/controller.c b/components/bt/bluedroid/device/controller.c index 2d928b3057..f8c268665c 100755 --- a/components/bt/bluedroid/device/controller.c +++ b/components/bt/bluedroid/device/controller.c @@ -1,461 +1,461 @@ -/****************************************************************************** - * - * Copyright (C) 2014 Google, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - ******************************************************************************/ -#include -#include "bt_trace.h" -#include "bdaddr.h" -#include "bt_types.h" -#include "controller.h" -#include "event_mask.h" -#include "hcimsgs.h" -#include "hci_layer.h" -#include "hci_packet_factory.h" -#include "hci_packet_parser.h" -#include "btm_ble_api.h" -#include "version.h" -#include "future.h" - -const bt_event_mask_t BLE_EVENT_MASK = { "\x00\x00\x00\x00\x00\x00\x06\x7f" }; - -#if (BLE_INCLUDED) -const bt_event_mask_t CLASSIC_EVENT_MASK = { HCI_DUMO_EVENT_MASK_EXT }; -#else -const bt_event_mask_t CLASSIC_EVENT_MASK = { HCI_LISBON_EVENT_MASK_EXT }; -#endif - -// TODO(zachoverflow): factor out into common module -const uint8_t SCO_HOST_BUFFER_SIZE = 0xff; - -#define HCI_SUPPORTED_COMMANDS_ARRAY_SIZE 64 -#define MAX_FEATURES_CLASSIC_PAGE_COUNT 3 -#define BLE_SUPPORTED_STATES_SIZE 8 -#define BLE_SUPPORTED_FEATURES_SIZE 8 - -static const hci_t *hci; -static const hci_packet_factory_t *packet_factory; -static const hci_packet_parser_t *packet_parser; - -static bt_bdaddr_t address; -static bt_version_t bt_version; - -static uint8_t supported_commands[HCI_SUPPORTED_COMMANDS_ARRAY_SIZE]; -static bt_device_features_t features_classic[MAX_FEATURES_CLASSIC_PAGE_COUNT]; -static uint8_t last_features_classic_page_index; - -static uint16_t acl_data_size_classic; -static uint16_t acl_data_size_ble; -static uint16_t acl_buffer_count_classic; -static uint8_t acl_buffer_count_ble; - -static uint8_t ble_white_list_size; -static uint8_t ble_resolving_list_max_size; -static uint8_t ble_supported_states[BLE_SUPPORTED_STATES_SIZE]; -static bt_device_features_t features_ble; -static uint16_t ble_suggested_default_data_length; - -static bool readable; -static bool ble_supported; -static bool simple_pairing_supported; -static bool secure_connections_supported; - -#define AWAIT_COMMAND(command) future_await(hci->transmit_command_futured(command)) - -// Module lifecycle functions - -static void start_up(void) { - BT_HDR *response; - - // Send the initial reset command - response = AWAIT_COMMAND(packet_factory->make_reset()); - packet_parser->parse_generic_command_complete(response); - - // Request the classic buffer size next - response = AWAIT_COMMAND(packet_factory->make_read_buffer_size()); - packet_parser->parse_read_buffer_size_response( - response, &acl_data_size_classic, &acl_buffer_count_classic); - - // Tell the controller about our buffer sizes and buffer counts next - // TODO(zachoverflow): factor this out. eww l2cap contamination. And why just a hardcoded 10? - response = AWAIT_COMMAND( - packet_factory->make_host_buffer_size( - L2CAP_MTU_SIZE, - SCO_HOST_BUFFER_SIZE, - L2CAP_HOST_FC_ACL_BUFS, - 10 - ) - ); - - packet_parser->parse_generic_command_complete(response); - - // Read the local version info off the controller next, including - // information such as manufacturer and supported HCI version - response = AWAIT_COMMAND(packet_factory->make_read_local_version_info()); - packet_parser->parse_read_local_version_info_response(response, &bt_version); - - // Read the bluetooth address off the controller next - response = AWAIT_COMMAND(packet_factory->make_read_bd_addr()); - packet_parser->parse_read_bd_addr_response(response, &address); - - // Request the controller's supported commands next - response = AWAIT_COMMAND(packet_factory->make_read_local_supported_commands()); - packet_parser->parse_read_local_supported_commands_response( - response, - supported_commands, - HCI_SUPPORTED_COMMANDS_ARRAY_SIZE - ); - - // Read page 0 of the controller features next - uint8_t page_number = 0; - response = AWAIT_COMMAND(packet_factory->make_read_local_extended_features(page_number)); - packet_parser->parse_read_local_extended_features_response( - response, - &page_number, - &last_features_classic_page_index, - features_classic, - MAX_FEATURES_CLASSIC_PAGE_COUNT - ); - - assert(page_number == 0); - page_number++; - - // Inform the controller what page 0 features we support, based on what - // it told us it supports. We need to do this first before we request the - // next page, because the controller's response for page 1 may be - // dependent on what we configure from page 0 - simple_pairing_supported = HCI_SIMPLE_PAIRING_SUPPORTED(features_classic[0].as_array); - if (simple_pairing_supported) { - response = AWAIT_COMMAND(packet_factory->make_write_simple_pairing_mode(HCI_SP_MODE_ENABLED)); - packet_parser->parse_generic_command_complete(response); - } - -#if (BLE_INCLUDED == TRUE) - if (HCI_LE_SPT_SUPPORTED(features_classic[0].as_array)) { - uint8_t simultaneous_le_host = HCI_SIMUL_LE_BREDR_SUPPORTED(features_classic[0].as_array) ? BTM_BLE_SIMULTANEOUS_HOST : 0; - response = AWAIT_COMMAND( - packet_factory->make_ble_write_host_support(BTM_BLE_HOST_SUPPORT, simultaneous_le_host) - ); - - packet_parser->parse_generic_command_complete(response); - } -#endif - - // Done telling the controller about what page 0 features we support - // Request the remaining feature pages - while (page_number <= last_features_classic_page_index && - page_number < MAX_FEATURES_CLASSIC_PAGE_COUNT) { - response = AWAIT_COMMAND(packet_factory->make_read_local_extended_features(page_number)); - packet_parser->parse_read_local_extended_features_response( - response, - &page_number, - &last_features_classic_page_index, - features_classic, - MAX_FEATURES_CLASSIC_PAGE_COUNT - ); - - page_number++; - } - -#if (SC_MODE_INCLUDED == TRUE) - secure_connections_supported = HCI_SC_CTRLR_SUPPORTED(features_classic[2].as_array); - if (secure_connections_supported) { - response = AWAIT_COMMAND(packet_factory->make_write_secure_connections_host_support(HCI_SC_MODE_ENABLED)); - packet_parser->parse_generic_command_complete(response); - } -#endif - -#if (BLE_INCLUDED == TRUE) - ble_supported = last_features_classic_page_index >= 1 && HCI_LE_HOST_SUPPORTED(features_classic[1].as_array); - if (ble_supported) { - // Request the ble white list size next - response = AWAIT_COMMAND(packet_factory->make_ble_read_white_list_size()); - packet_parser->parse_ble_read_white_list_size_response(response, &ble_white_list_size); - - // Request the ble buffer size next - response = AWAIT_COMMAND(packet_factory->make_ble_read_buffer_size()); - packet_parser->parse_ble_read_buffer_size_response( - response, - &acl_data_size_ble, - &acl_buffer_count_ble - ); - - // Response of 0 indicates ble has the same buffer size as classic - if (acl_data_size_ble == 0) - acl_data_size_ble = acl_data_size_classic; - - // Request the ble supported states next - response = AWAIT_COMMAND(packet_factory->make_ble_read_supported_states()); - packet_parser->parse_ble_read_supported_states_response( - response, - ble_supported_states, - sizeof(ble_supported_states) - ); - - // Request the ble supported features next - response = AWAIT_COMMAND(packet_factory->make_ble_read_local_supported_features()); - packet_parser->parse_ble_read_local_supported_features_response( - response, - &features_ble - ); - - if (HCI_LE_ENHANCED_PRIVACY_SUPPORTED(features_ble.as_array)) { - response = AWAIT_COMMAND(packet_factory->make_ble_read_resolving_list_size()); - packet_parser->parse_ble_read_resolving_list_size_response( - response, - &ble_resolving_list_max_size); - } - - if (HCI_LE_DATA_LEN_EXT_SUPPORTED(features_ble.as_array)) { - response = AWAIT_COMMAND(packet_factory->make_ble_read_suggested_default_data_length()); - packet_parser->parse_ble_read_suggested_default_data_length_response( - response, - &ble_suggested_default_data_length); - } - - // Set the ble event mask next - response = AWAIT_COMMAND(packet_factory->make_ble_set_event_mask(&BLE_EVENT_MASK)); - packet_parser->parse_generic_command_complete(response); - } -#endif - - if (simple_pairing_supported) { - response = AWAIT_COMMAND(packet_factory->make_set_event_mask(&CLASSIC_EVENT_MASK)); - packet_parser->parse_generic_command_complete(response); - } - - readable = true; - // return future_new_immediate(FUTURE_SUCCESS); - return; -} - -static void shut_down(void) { - readable = false; -} - -static bool get_is_ready(void) { - return readable; -} - -static const bt_bdaddr_t *get_address(void) { - assert(readable); - return &address; -} - -static const bt_version_t *get_bt_version(void) { - assert(readable); - return &bt_version; -} - -// TODO(zachoverflow): hide inside, move decoder inside too -static const bt_device_features_t *get_features_classic(int index) { - assert(readable); - assert(index < MAX_FEATURES_CLASSIC_PAGE_COUNT); - return &features_classic[index]; -} - -static uint8_t get_last_features_classic_index(void) { - assert(readable); - return last_features_classic_page_index; -} - -static const bt_device_features_t *get_features_ble(void) { - assert(readable); - assert(ble_supported); - return &features_ble; -} - -static const uint8_t *get_ble_supported_states(void) { - assert(readable); - assert(ble_supported); - return ble_supported_states; -} - -static bool supports_simple_pairing(void) { - assert(readable); - return simple_pairing_supported; -} - -static bool supports_secure_connections(void) { - assert(readable); - return secure_connections_supported; -} - -static bool supports_simultaneous_le_bredr(void) { - assert(readable); - return HCI_SIMUL_LE_BREDR_SUPPORTED(features_classic[0].as_array); -} - -static bool supports_reading_remote_extended_features(void) { - assert(readable); - return HCI_READ_REMOTE_EXT_FEATURES_SUPPORTED(supported_commands); -} - -static bool supports_interlaced_inquiry_scan(void) { - assert(readable); - return HCI_LMP_INTERLACED_INQ_SCAN_SUPPORTED(features_classic[0].as_array); -} - -static bool supports_rssi_with_inquiry_results(void) { - assert(readable); - return HCI_LMP_INQ_RSSI_SUPPORTED(features_classic[0].as_array); -} - -static bool supports_extended_inquiry_response(void) { - assert(readable); - return HCI_EXT_INQ_RSP_SUPPORTED(features_classic[0].as_array); -} - -static bool supports_master_slave_role_switch(void) { - assert(readable); - return HCI_SWITCH_SUPPORTED(features_classic[0].as_array); -} - -static bool supports_ble(void) { - assert(readable); - return ble_supported; -} - -static bool supports_ble_privacy(void) { - assert(readable); - assert(ble_supported); - return HCI_LE_ENHANCED_PRIVACY_SUPPORTED(features_ble.as_array); -} - -static bool supports_ble_packet_extension(void) { - assert(readable); - assert(ble_supported); - return HCI_LE_DATA_LEN_EXT_SUPPORTED(features_ble.as_array); -} - -static bool supports_ble_connection_parameters_request(void) { - assert(readable); - assert(ble_supported); - return HCI_LE_CONN_PARAM_REQ_SUPPORTED(features_ble.as_array); -} - -static uint16_t get_acl_data_size_classic(void) { - assert(readable); - return acl_data_size_classic; -} - -static uint16_t get_acl_data_size_ble(void) { - assert(readable); - assert(ble_supported); - return acl_data_size_ble; -} - -static uint16_t get_acl_packet_size_classic(void) { - assert(readable); - return acl_data_size_classic + HCI_DATA_PREAMBLE_SIZE; -} - -static uint16_t get_acl_packet_size_ble(void) { - assert(readable); - return acl_data_size_ble + HCI_DATA_PREAMBLE_SIZE; -} - -static uint16_t get_ble_suggested_default_data_length(void) { - assert(readable); - assert(ble_supported); - return ble_suggested_default_data_length; -} - -static uint16_t get_acl_buffer_count_classic(void) { - assert(readable); - return acl_buffer_count_classic; -} - -static uint8_t get_acl_buffer_count_ble(void) { - assert(readable); - assert(ble_supported); - return acl_buffer_count_ble; -} - -static uint8_t get_ble_white_list_size(void) { - assert(readable); - assert(ble_supported); - return ble_white_list_size; -} - -static uint8_t get_ble_resolving_list_max_size(void) { - assert(readable); - assert(ble_supported); - return ble_resolving_list_max_size; -} - -static void set_ble_resolving_list_max_size(int resolving_list_max_size) { - assert(readable); - assert(ble_supported); - ble_resolving_list_max_size = resolving_list_max_size; -} - -static const controller_t interface = { - start_up, - shut_down, - get_is_ready, - - get_address, - get_bt_version, - - get_features_classic, - get_last_features_classic_index, - - get_features_ble, - get_ble_supported_states, - - supports_simple_pairing, - supports_secure_connections, - supports_simultaneous_le_bredr, - supports_reading_remote_extended_features, - supports_interlaced_inquiry_scan, - supports_rssi_with_inquiry_results, - supports_extended_inquiry_response, - supports_master_slave_role_switch, - - supports_ble, - supports_ble_packet_extension, - supports_ble_connection_parameters_request, - supports_ble_privacy, - - get_acl_data_size_classic, - get_acl_data_size_ble, - - get_acl_packet_size_classic, - get_acl_packet_size_ble, - get_ble_suggested_default_data_length, - - get_acl_buffer_count_classic, - get_acl_buffer_count_ble, - - get_ble_white_list_size, - - get_ble_resolving_list_max_size, - set_ble_resolving_list_max_size -}; - -const controller_t *controller_get_interface() { - static bool loaded = false; - if (!loaded) { - loaded = true; - - hci = hci_layer_get_interface(); - packet_factory = hci_packet_factory_get_interface(); - packet_parser = hci_packet_parser_get_interface(); - } - - return &interface; -} - +/****************************************************************************** + * + * Copyright (C) 2014 Google, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + ******************************************************************************/ +#include +#include "bt_trace.h" +#include "bdaddr.h" +#include "bt_types.h" +#include "controller.h" +#include "event_mask.h" +#include "hcimsgs.h" +#include "hci_layer.h" +#include "hci_packet_factory.h" +#include "hci_packet_parser.h" +#include "btm_ble_api.h" +#include "version.h" +#include "future.h" + +const bt_event_mask_t BLE_EVENT_MASK = { "\x00\x00\x00\x00\x00\x00\x06\x7f" }; + +#if (BLE_INCLUDED) +const bt_event_mask_t CLASSIC_EVENT_MASK = { HCI_DUMO_EVENT_MASK_EXT }; +#else +const bt_event_mask_t CLASSIC_EVENT_MASK = { HCI_LISBON_EVENT_MASK_EXT }; +#endif + +// TODO(zachoverflow): factor out into common module +const uint8_t SCO_HOST_BUFFER_SIZE = 0xff; + +#define HCI_SUPPORTED_COMMANDS_ARRAY_SIZE 64 +#define MAX_FEATURES_CLASSIC_PAGE_COUNT 3 +#define BLE_SUPPORTED_STATES_SIZE 8 +#define BLE_SUPPORTED_FEATURES_SIZE 8 + +static const hci_t *hci; +static const hci_packet_factory_t *packet_factory; +static const hci_packet_parser_t *packet_parser; + +static bt_bdaddr_t address; +static bt_version_t bt_version; + +static uint8_t supported_commands[HCI_SUPPORTED_COMMANDS_ARRAY_SIZE]; +static bt_device_features_t features_classic[MAX_FEATURES_CLASSIC_PAGE_COUNT]; +static uint8_t last_features_classic_page_index; + +static uint16_t acl_data_size_classic; +static uint16_t acl_data_size_ble; +static uint16_t acl_buffer_count_classic; +static uint8_t acl_buffer_count_ble; + +static uint8_t ble_white_list_size; +static uint8_t ble_resolving_list_max_size; +static uint8_t ble_supported_states[BLE_SUPPORTED_STATES_SIZE]; +static bt_device_features_t features_ble; +static uint16_t ble_suggested_default_data_length; + +static bool readable; +static bool ble_supported; +static bool simple_pairing_supported; +static bool secure_connections_supported; + +#define AWAIT_COMMAND(command) future_await(hci->transmit_command_futured(command)) + +// Module lifecycle functions + +static void start_up(void) { + BT_HDR *response; + + // Send the initial reset command + response = AWAIT_COMMAND(packet_factory->make_reset()); + packet_parser->parse_generic_command_complete(response); + + // Request the classic buffer size next + response = AWAIT_COMMAND(packet_factory->make_read_buffer_size()); + packet_parser->parse_read_buffer_size_response( + response, &acl_data_size_classic, &acl_buffer_count_classic); + + // Tell the controller about our buffer sizes and buffer counts next + // TODO(zachoverflow): factor this out. eww l2cap contamination. And why just a hardcoded 10? + response = AWAIT_COMMAND( + packet_factory->make_host_buffer_size( + L2CAP_MTU_SIZE, + SCO_HOST_BUFFER_SIZE, + L2CAP_HOST_FC_ACL_BUFS, + 10 + ) + ); + + packet_parser->parse_generic_command_complete(response); + + // Read the local version info off the controller next, including + // information such as manufacturer and supported HCI version + response = AWAIT_COMMAND(packet_factory->make_read_local_version_info()); + packet_parser->parse_read_local_version_info_response(response, &bt_version); + + // Read the bluetooth address off the controller next + response = AWAIT_COMMAND(packet_factory->make_read_bd_addr()); + packet_parser->parse_read_bd_addr_response(response, &address); + + // Request the controller's supported commands next + response = AWAIT_COMMAND(packet_factory->make_read_local_supported_commands()); + packet_parser->parse_read_local_supported_commands_response( + response, + supported_commands, + HCI_SUPPORTED_COMMANDS_ARRAY_SIZE + ); + + // Read page 0 of the controller features next + uint8_t page_number = 0; + response = AWAIT_COMMAND(packet_factory->make_read_local_extended_features(page_number)); + packet_parser->parse_read_local_extended_features_response( + response, + &page_number, + &last_features_classic_page_index, + features_classic, + MAX_FEATURES_CLASSIC_PAGE_COUNT + ); + + assert(page_number == 0); + page_number++; + + // Inform the controller what page 0 features we support, based on what + // it told us it supports. We need to do this first before we request the + // next page, because the controller's response for page 1 may be + // dependent on what we configure from page 0 + simple_pairing_supported = HCI_SIMPLE_PAIRING_SUPPORTED(features_classic[0].as_array); + if (simple_pairing_supported) { + response = AWAIT_COMMAND(packet_factory->make_write_simple_pairing_mode(HCI_SP_MODE_ENABLED)); + packet_parser->parse_generic_command_complete(response); + } + +#if (BLE_INCLUDED == TRUE) + if (HCI_LE_SPT_SUPPORTED(features_classic[0].as_array)) { + uint8_t simultaneous_le_host = HCI_SIMUL_LE_BREDR_SUPPORTED(features_classic[0].as_array) ? BTM_BLE_SIMULTANEOUS_HOST : 0; + response = AWAIT_COMMAND( + packet_factory->make_ble_write_host_support(BTM_BLE_HOST_SUPPORT, simultaneous_le_host) + ); + + packet_parser->parse_generic_command_complete(response); + } +#endif + + // Done telling the controller about what page 0 features we support + // Request the remaining feature pages + while (page_number <= last_features_classic_page_index && + page_number < MAX_FEATURES_CLASSIC_PAGE_COUNT) { + response = AWAIT_COMMAND(packet_factory->make_read_local_extended_features(page_number)); + packet_parser->parse_read_local_extended_features_response( + response, + &page_number, + &last_features_classic_page_index, + features_classic, + MAX_FEATURES_CLASSIC_PAGE_COUNT + ); + + page_number++; + } + +#if (SC_MODE_INCLUDED == TRUE) + secure_connections_supported = HCI_SC_CTRLR_SUPPORTED(features_classic[2].as_array); + if (secure_connections_supported) { + response = AWAIT_COMMAND(packet_factory->make_write_secure_connections_host_support(HCI_SC_MODE_ENABLED)); + packet_parser->parse_generic_command_complete(response); + } +#endif + +#if (BLE_INCLUDED == TRUE) + ble_supported = last_features_classic_page_index >= 1 && HCI_LE_HOST_SUPPORTED(features_classic[1].as_array); + if (ble_supported) { + // Request the ble white list size next + response = AWAIT_COMMAND(packet_factory->make_ble_read_white_list_size()); + packet_parser->parse_ble_read_white_list_size_response(response, &ble_white_list_size); + + // Request the ble buffer size next + response = AWAIT_COMMAND(packet_factory->make_ble_read_buffer_size()); + packet_parser->parse_ble_read_buffer_size_response( + response, + &acl_data_size_ble, + &acl_buffer_count_ble + ); + + // Response of 0 indicates ble has the same buffer size as classic + if (acl_data_size_ble == 0) + acl_data_size_ble = acl_data_size_classic; + + // Request the ble supported states next + response = AWAIT_COMMAND(packet_factory->make_ble_read_supported_states()); + packet_parser->parse_ble_read_supported_states_response( + response, + ble_supported_states, + sizeof(ble_supported_states) + ); + + // Request the ble supported features next + response = AWAIT_COMMAND(packet_factory->make_ble_read_local_supported_features()); + packet_parser->parse_ble_read_local_supported_features_response( + response, + &features_ble + ); + + if (HCI_LE_ENHANCED_PRIVACY_SUPPORTED(features_ble.as_array)) { + response = AWAIT_COMMAND(packet_factory->make_ble_read_resolving_list_size()); + packet_parser->parse_ble_read_resolving_list_size_response( + response, + &ble_resolving_list_max_size); + } + + if (HCI_LE_DATA_LEN_EXT_SUPPORTED(features_ble.as_array)) { + response = AWAIT_COMMAND(packet_factory->make_ble_read_suggested_default_data_length()); + packet_parser->parse_ble_read_suggested_default_data_length_response( + response, + &ble_suggested_default_data_length); + } + + // Set the ble event mask next + response = AWAIT_COMMAND(packet_factory->make_ble_set_event_mask(&BLE_EVENT_MASK)); + packet_parser->parse_generic_command_complete(response); + } +#endif + + if (simple_pairing_supported) { + response = AWAIT_COMMAND(packet_factory->make_set_event_mask(&CLASSIC_EVENT_MASK)); + packet_parser->parse_generic_command_complete(response); + } + + readable = true; + // return future_new_immediate(FUTURE_SUCCESS); + return; +} + +static void shut_down(void) { + readable = false; +} + +static bool get_is_ready(void) { + return readable; +} + +static const bt_bdaddr_t *get_address(void) { + assert(readable); + return &address; +} + +static const bt_version_t *get_bt_version(void) { + assert(readable); + return &bt_version; +} + +// TODO(zachoverflow): hide inside, move decoder inside too +static const bt_device_features_t *get_features_classic(int index) { + assert(readable); + assert(index < MAX_FEATURES_CLASSIC_PAGE_COUNT); + return &features_classic[index]; +} + +static uint8_t get_last_features_classic_index(void) { + assert(readable); + return last_features_classic_page_index; +} + +static const bt_device_features_t *get_features_ble(void) { + assert(readable); + assert(ble_supported); + return &features_ble; +} + +static const uint8_t *get_ble_supported_states(void) { + assert(readable); + assert(ble_supported); + return ble_supported_states; +} + +static bool supports_simple_pairing(void) { + assert(readable); + return simple_pairing_supported; +} + +static bool supports_secure_connections(void) { + assert(readable); + return secure_connections_supported; +} + +static bool supports_simultaneous_le_bredr(void) { + assert(readable); + return HCI_SIMUL_LE_BREDR_SUPPORTED(features_classic[0].as_array); +} + +static bool supports_reading_remote_extended_features(void) { + assert(readable); + return HCI_READ_REMOTE_EXT_FEATURES_SUPPORTED(supported_commands); +} + +static bool supports_interlaced_inquiry_scan(void) { + assert(readable); + return HCI_LMP_INTERLACED_INQ_SCAN_SUPPORTED(features_classic[0].as_array); +} + +static bool supports_rssi_with_inquiry_results(void) { + assert(readable); + return HCI_LMP_INQ_RSSI_SUPPORTED(features_classic[0].as_array); +} + +static bool supports_extended_inquiry_response(void) { + assert(readable); + return HCI_EXT_INQ_RSP_SUPPORTED(features_classic[0].as_array); +} + +static bool supports_master_slave_role_switch(void) { + assert(readable); + return HCI_SWITCH_SUPPORTED(features_classic[0].as_array); +} + +static bool supports_ble(void) { + assert(readable); + return ble_supported; +} + +static bool supports_ble_privacy(void) { + assert(readable); + assert(ble_supported); + return HCI_LE_ENHANCED_PRIVACY_SUPPORTED(features_ble.as_array); +} + +static bool supports_ble_packet_extension(void) { + assert(readable); + assert(ble_supported); + return HCI_LE_DATA_LEN_EXT_SUPPORTED(features_ble.as_array); +} + +static bool supports_ble_connection_parameters_request(void) { + assert(readable); + assert(ble_supported); + return HCI_LE_CONN_PARAM_REQ_SUPPORTED(features_ble.as_array); +} + +static uint16_t get_acl_data_size_classic(void) { + assert(readable); + return acl_data_size_classic; +} + +static uint16_t get_acl_data_size_ble(void) { + assert(readable); + assert(ble_supported); + return acl_data_size_ble; +} + +static uint16_t get_acl_packet_size_classic(void) { + assert(readable); + return acl_data_size_classic + HCI_DATA_PREAMBLE_SIZE; +} + +static uint16_t get_acl_packet_size_ble(void) { + assert(readable); + return acl_data_size_ble + HCI_DATA_PREAMBLE_SIZE; +} + +static uint16_t get_ble_suggested_default_data_length(void) { + assert(readable); + assert(ble_supported); + return ble_suggested_default_data_length; +} + +static uint16_t get_acl_buffer_count_classic(void) { + assert(readable); + return acl_buffer_count_classic; +} + +static uint8_t get_acl_buffer_count_ble(void) { + assert(readable); + assert(ble_supported); + return acl_buffer_count_ble; +} + +static uint8_t get_ble_white_list_size(void) { + assert(readable); + assert(ble_supported); + return ble_white_list_size; +} + +static uint8_t get_ble_resolving_list_max_size(void) { + assert(readable); + assert(ble_supported); + return ble_resolving_list_max_size; +} + +static void set_ble_resolving_list_max_size(int resolving_list_max_size) { + assert(readable); + assert(ble_supported); + ble_resolving_list_max_size = resolving_list_max_size; +} + +static const controller_t interface = { + start_up, + shut_down, + get_is_ready, + + get_address, + get_bt_version, + + get_features_classic, + get_last_features_classic_index, + + get_features_ble, + get_ble_supported_states, + + supports_simple_pairing, + supports_secure_connections, + supports_simultaneous_le_bredr, + supports_reading_remote_extended_features, + supports_interlaced_inquiry_scan, + supports_rssi_with_inquiry_results, + supports_extended_inquiry_response, + supports_master_slave_role_switch, + + supports_ble, + supports_ble_packet_extension, + supports_ble_connection_parameters_request, + supports_ble_privacy, + + get_acl_data_size_classic, + get_acl_data_size_ble, + + get_acl_packet_size_classic, + get_acl_packet_size_ble, + get_ble_suggested_default_data_length, + + get_acl_buffer_count_classic, + get_acl_buffer_count_ble, + + get_ble_white_list_size, + + get_ble_resolving_list_max_size, + set_ble_resolving_list_max_size +}; + +const controller_t *controller_get_interface() { + static bool loaded = false; + if (!loaded) { + loaded = true; + + hci = hci_layer_get_interface(); + packet_factory = hci_packet_factory_get_interface(); + packet_parser = hci_packet_parser_get_interface(); + } + + return &interface; +} + diff --git a/components/bt/bluedroid/include/bt_defs.h b/components/bt/bluedroid/include/bt_defs.h index 556123632b..96071af100 100755 --- a/components/bt/bluedroid/include/bt_defs.h +++ b/components/bt/bluedroid/include/bt_defs.h @@ -14,7 +14,7 @@ #define UNUSED(x) (void)(x) #ifndef SIZE_MAX -#define SIZE_MAX 128 +#define SIZE_MAX 254 #endif /*Timer Related Defination*/ diff --git a/components/bt/bluedroid/osi/future.c b/components/bt/bluedroid/osi/future.c index 7c816f9e4d..79f64974b2 100644 --- a/components/bt/bluedroid/osi/future.c +++ b/components/bt/bluedroid/osi/future.c @@ -1,100 +1,100 @@ -/****************************************************************************** - * - * Copyright (C) 2014 Google, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - ******************************************************************************/ - -// #define LOG_TAG "bt_osi_future" -// #include -#include "bt_trace.h" - -#include "allocator.h" -#include "future.h" -#include "osi.h" -//#include "osi/include/log.h" -#include "osi_arch.h" - -struct future_t { - bool ready_can_be_called; - osi_sem_t semaphore; // NULL semaphore means immediate future - void *result; -}; - -static void future_free(future_t *future); - -future_t *future_new(void) { - future_t *ret = osi_calloc(sizeof(future_t)); - if (!ret) { - LOG_ERROR("%s unable to allocate memory for return value.", __func__); - goto error; - } - - if (osi_sem_new(&ret->semaphore, 1, 0)!=0) { - LOG_ERROR("%s unable to allocate memory for the semaphore.", __func__); - goto error; - } - - ret->ready_can_be_called = true; - return ret; -error:; - future_free(ret); - return NULL; -} - -future_t *future_new_immediate(void *value) { - future_t *ret = osi_calloc(sizeof(future_t)); - if (!ret) { - LOG_ERROR("%s unable to allocate memory for return value.", __func__); - goto error; - } - - ret->result = value; - ret->ready_can_be_called = false; - return ret; -error:; - future_free(ret); - return NULL; -} - -void future_ready(future_t *future, void *value) { - assert(future != NULL); - assert(future->ready_can_be_called); - - future->ready_can_be_called = false; - future->result = value; - osi_sem_signal(&future->semaphore); -} - -void *future_await(future_t *future) { - assert(future != NULL); - - // If the future is immediate, it will not have a semaphore - if (future->semaphore) - osi_sem_wait(&future->semaphore, 0); - - void *result = future->result; - future_free(future); - return result; -} - -static void future_free(future_t *future) { - if (!future) - return; - - if (!future->semaphore) - osi_sem_free(&future->semaphore); - - osi_free(future); -} +/****************************************************************************** + * + * Copyright (C) 2014 Google, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + ******************************************************************************/ + +// #define LOG_TAG "bt_osi_future" +// #include +#include "bt_trace.h" + +#include "allocator.h" +#include "future.h" +#include "osi.h" +//#include "osi/include/log.h" +#include "osi_arch.h" + +struct future_t { + bool ready_can_be_called; + osi_sem_t semaphore; // NULL semaphore means immediate future + void *result; +}; + +static void future_free(future_t *future); + +future_t *future_new(void) { + future_t *ret = osi_calloc(sizeof(future_t)); + if (!ret) { + LOG_ERROR("%s unable to allocate memory for return value.", __func__); + goto error; + } + + if (osi_sem_new(&ret->semaphore, 1, 0)!=0) { + LOG_ERROR("%s unable to allocate memory for the semaphore.", __func__); + goto error; + } + + ret->ready_can_be_called = true; + return ret; +error:; + future_free(ret); + return NULL; +} + +future_t *future_new_immediate(void *value) { + future_t *ret = osi_calloc(sizeof(future_t)); + if (!ret) { + LOG_ERROR("%s unable to allocate memory for return value.", __func__); + goto error; + } + + ret->result = value; + ret->ready_can_be_called = false; + return ret; +error:; + future_free(ret); + return NULL; +} + +void future_ready(future_t *future, void *value) { + assert(future != NULL); + assert(future->ready_can_be_called); + + future->ready_can_be_called = false; + future->result = value; + osi_sem_signal(&future->semaphore); +} + +void *future_await(future_t *future) { + assert(future != NULL); + + // If the future is immediate, it will not have a semaphore + if (future->semaphore) + osi_sem_wait(&future->semaphore, 0); + + void *result = future->result; + future_free(future); + return result; +} + +static void future_free(future_t *future) { + if (!future) + return; + + if (!future->semaphore) + osi_sem_free(&future->semaphore); + + osi_free(future); +} diff --git a/components/bt/bluedroid/osi/include/future.h b/components/bt/bluedroid/osi/include/future.h index d4601a93f1..f2d6a1cc27 100644 --- a/components/bt/bluedroid/osi/include/future.h +++ b/components/bt/bluedroid/osi/include/future.h @@ -1,45 +1,45 @@ -/****************************************************************************** - * - * Copyright (C) 2014 Google, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - ******************************************************************************/ - -#ifndef __FUTURE_H__ -#define __FUTURE_H__ -// #pragma once - -typedef struct future_t future_t; - -#define FUTURE_SUCCESS ((void *)1) -#define FUTURE_FAIL ((void *)0) - -// Constructs a new future_t object. Returns NULL on failure. -future_t *future_new(void); - -// Constructs a new future_t object with an immediate |value|. No waiting will -// occur in the call to |future_await| because the value is already present. -// Returns NULL on failure. -future_t *future_new_immediate(void *value); - -// Signals that the |future| is ready, passing |value| back to the context -// waiting for the result. Must only be called once for every future. -// |future| may not be NULL. -void future_ready(future_t *future, void *value); - -// Waits for the |future| to be ready. Returns the value set in |future_ready|. -// Frees the future before return. |future| may not be NULL. -void *future_await(future_t *async_result); - -#endif /* __FUTURE_H__ */ +/****************************************************************************** + * + * Copyright (C) 2014 Google, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + ******************************************************************************/ + +#ifndef __FUTURE_H__ +#define __FUTURE_H__ +// #pragma once + +typedef struct future_t future_t; + +#define FUTURE_SUCCESS ((void *)1) +#define FUTURE_FAIL ((void *)0) + +// Constructs a new future_t object. Returns NULL on failure. +future_t *future_new(void); + +// Constructs a new future_t object with an immediate |value|. No waiting will +// occur in the call to |future_await| because the value is already present. +// Returns NULL on failure. +future_t *future_new_immediate(void *value); + +// Signals that the |future| is ready, passing |value| back to the context +// waiting for the result. Must only be called once for every future. +// |future| may not be NULL. +void future_ready(future_t *future, void *value); + +// Waits for the |future| to be ready. Returns the value set in |future_ready|. +// Frees the future before return. |future| may not be NULL. +void *future_await(future_t *async_result); + +#endif /* __FUTURE_H__ */ diff --git a/components/bt/bluedroid/profiles/core/bt_prf_task.c b/components/bt/bluedroid/profiles/core/bt_prf_task.c index c92d4dc282..bf5ca4e7e7 100644 --- a/components/bt/bluedroid/profiles/core/bt_prf_task.c +++ b/components/bt/bluedroid/profiles/core/bt_prf_task.c @@ -54,17 +54,17 @@ } void bt_prf_task_post(uint32_t sig) -{ - TaskEvt_t *evt = (TaskEvt_t *)osi_malloc(sizeof(TaskEvt_t)); - if (evt == NULL) - return; - - evt->sig = sig; - evt->par = 0; - +{ + TaskEvt_t *evt = (TaskEvt_t *)osi_malloc(sizeof(TaskEvt_t)); + if (evt == NULL) + return; + + evt->sig = sig; + evt->par = 0; + if (xQueueSend(xProfileQueue, &evt, 10/portTICK_RATE_MS) != pdTRUE) { ets_printf("xProfileQueue failed\n"); - } + } } void bt_profile_msg_ready(fixed_queue_t *queue) { diff --git a/components/bt/bluedroid/profiles/esp/ble_button/button_pro.c b/components/bt/bluedroid/profiles/esp/ble_button/button_pro.c index 70976ccf3c..9fa1c9aeda 100644 --- a/components/bt/bluedroid/profiles/esp/ble_button/button_pro.c +++ b/components/bt/bluedroid/profiles/esp/ble_button/button_pro.c @@ -70,7 +70,7 @@ static void button_profile_cb(tBTA_GATTS_EVT event, tBTA_GATTS *p_data) LOG_ERROR("button profile cb event = %x\n",event); switch(event) { - case BTA_GATTS_REG_EVT: + case BTA_GATTS_REG_EVT: LOG_ERROR("p_data->reg_oper.status = %x\n",p_data->reg_oper.status); LOG_ERROR("(p_data->reg_oper.uuid.uu.uuid16=%x\n",p_data->reg_oper.uuid.uu.uuid16); @@ -212,7 +212,7 @@ void Button_CreateService(void) { tBTA_GATTS_IF server_if ; tBT_UUID uuid = {LEN_UUID_16, {ATT_SVC_BUTTON}}; - UINT16 num_handle = KEY_IDX_NB; + UINT16 num_handle = KEY_IDX_NB; UINT8 inst = 0x00; server_if = button_cb_env.gatt_if; button_cb_env.inst_id = inst; @@ -220,7 +220,7 @@ void Button_CreateService(void) //{ // LOG_ERROR("button service added error."); //} - BTA_GATTS_CreateService(server_if,&uuid,inst,num_handle,true); + BTA_GATTS_CreateService(server_if,&uuid,inst,num_handle,true); } @@ -340,7 +340,7 @@ tGATT_STATUS button_init (tBU_CBACK *call_back) } - /* register the button profile to the BTA_GATTS module*/ + /* register the button profile to the BTA_GATTS module*/ BTA_GATTS_AppRegister(&app_uuid,button_profile_cb); button_cb_env.enabled = TRUE; diff --git a/components/bt/bluedroid/profiles/std/hid_le/hid_le_prf.c b/components/bt/bluedroid/profiles/std/hid_le/hid_le_prf.c index f80f211172..2b903c62d5 100644 --- a/components/bt/bluedroid/profiles/std/hid_le/hid_le_prf.c +++ b/components/bt/bluedroid/profiles/std/hid_le/hid_le_prf.c @@ -252,12 +252,12 @@ void hidd_le_CreateService(BOOLEAN is_primary) tBTA_GATTS_IF server_if ; tBT_UUID uuid = {LEN_UUID_16, {ATT_SVC_HID}}; //the number of the hid device attributes in the hid service. - UINT16 num_handle = HIDD_LE_IDX_NB; + UINT16 num_handle = HIDD_LE_IDX_NB; UINT8 inst = 0x00; server_if = hidd_le_env.gatt_if; hidd_le_env.inst_id = inst; //start create the hid device service - BTA_GATTS_CreateService(server_if,&uuid,inst,num_handle,is_primary); + BTA_GATTS_CreateService(server_if,&uuid,inst,num_handle,is_primary); } @@ -285,7 +285,7 @@ tGATT_STATUS hidd_le_init (void) } - /* register the hid deivce profile to the BTA_GATTS module*/ + /* register the hid deivce profile to the BTA_GATTS module*/ BTA_GATTS_AppRegister(&app_uuid,hidd_le_profile_cb); hidd_le_env.enabled = TRUE; diff --git a/components/bt/bluedroid/stack/btm/btm_acl.c b/components/bt/bluedroid/stack/btm/btm_acl.c index 0e1d475dd0..575e560a26 100755 --- a/components/bt/bluedroid/stack/btm/btm_acl.c +++ b/components/bt/bluedroid/stack/btm/btm_acl.c @@ -105,7 +105,7 @@ tACL_CONN *btm_bda_to_acl (BD_ADDR bda, tBT_TRANSPORT transport) #endif ) { - BTM_TRACE_DEBUG ("btm_bda_to_acl found"); + BTM_TRACE_DEBUG ("btm_bda_to_acl found\n"); return(p); } } diff --git a/components/bt/bluedroid/stack/btu/btu_init.c b/components/bt/bluedroid/stack/btu/btu_init.c index 85a8c8a589..cd0af18ad8 100755 --- a/components/bt/bluedroid/stack/btu/btu_init.c +++ b/components/bt/bluedroid/stack/btu/btu_init.c @@ -56,19 +56,19 @@ extern fixed_queue_t *btu_hci_msg_queue; fixed_queue_t *btu_general_alarm_queue; hash_map_t *btu_general_alarm_hash_map; pthread_mutex_t btu_general_alarm_lock; -static const size_t BTU_GENERAL_ALARM_HASH_MAP_SIZE = 17; +static const size_t BTU_GENERAL_ALARM_HASH_MAP_SIZE = 34; // Oneshot timer queue. fixed_queue_t *btu_oneshot_alarm_queue; hash_map_t *btu_oneshot_alarm_hash_map; pthread_mutex_t btu_oneshot_alarm_lock; -static const size_t BTU_ONESHOT_ALARM_HASH_MAP_SIZE = 17; +static const size_t BTU_ONESHOT_ALARM_HASH_MAP_SIZE = 34; // l2cap timer queue. fixed_queue_t *btu_l2cap_alarm_queue; hash_map_t *btu_l2cap_alarm_hash_map; pthread_mutex_t btu_l2cap_alarm_lock; -static const size_t BTU_L2CAP_ALARM_HASH_MAP_SIZE = 17; +static const size_t BTU_L2CAP_ALARM_HASH_MAP_SIZE = 34; //thread_t *bt_workqueue_thread; //static const char *BT_WORKQUEUE_NAME = "bt_workqueue"; @@ -193,7 +193,7 @@ void BTU_StartUp(void) if (btu_l2cap_alarm_queue == NULL) goto error_exit; - xBtuQueue = xQueueCreate(15, sizeof(void *)); + xBtuQueue = xQueueCreate(60, sizeof(void *)); xTaskCreate(btu_task_thread_handler, "BtuT", 8192, NULL, configMAX_PRIORITIES - 1, &xBtuTaskHandle); btu_task_post(SIG_BTU_START_UP); /* diff --git a/components/bt/bluedroid/stack/l2cap/l2c_main.c b/components/bt/bluedroid/stack/l2cap/l2c_main.c index 7181fe1c04..4e5d8a21fa 100755 --- a/components/bt/bluedroid/stack/l2cap/l2c_main.c +++ b/components/bt/bluedroid/stack/l2cap/l2c_main.c @@ -192,7 +192,7 @@ void l2c_rcv_acl_data (BT_HDR *p_msg) /* only process fixed channel data as channel open indication when link is not in disconnecting mode */ l2cble_notify_le_connection(p_lcb->remote_bd_addr); #endif - + L2CAP_TRACE_WARNING ("L2CAP - rcv_cid CID: 0x%04x\n", rcv_cid); /* Find the CCB for this CID */ if (rcv_cid >= L2CAP_BASE_APPL_CID) { diff --git a/components/bt/bluedroid/stack/smp/smp_act.c b/components/bt/bluedroid/stack/smp/smp_act.c index a17b1c5a08..f7b7ce24c1 100755 --- a/components/bt/bluedroid/stack/smp/smp_act.c +++ b/components/bt/bluedroid/stack/smp/smp_act.c @@ -69,7 +69,7 @@ static bool lmp_version_below(BD_ADDR bda, uint8_t version) *******************************************************************************/ static void smp_update_key_mask (tSMP_CB *p_cb, UINT8 key_type, BOOLEAN recv) { - SMP_TRACE_DEBUG("%s before update role=%d recv=%d local_i_key = %02x, local_r_key = %02x", + SMP_TRACE_DEBUG("%s before update role=%d recv=%d local_i_key = %02x, local_r_key = %02x\n", __func__, p_cb->role, recv, p_cb->local_i_key, p_cb->local_r_key); if (((p_cb->le_secure_connections_mode_is_used) || @@ -97,7 +97,7 @@ static void smp_update_key_mask (tSMP_CB *p_cb, UINT8 key_type, BOOLEAN recv) p_cb->local_i_key &= ~key_type; } - SMP_TRACE_DEBUG("updated local_i_key = %02x, local_r_key = %02x", p_cb->local_i_key, + SMP_TRACE_DEBUG("updated local_i_key = %02x, local_r_key = %02x\n", p_cb->local_i_key, p_cb->local_r_key); } @@ -109,7 +109,7 @@ void smp_send_app_cback(tSMP_CB *p_cb, tSMP_INT_DATA *p_data) { tSMP_EVT_DATA cb_data; tSMP_STATUS callback_rc; - SMP_TRACE_DEBUG("%s p_cb->cb_evt=%d", __func__, p_cb->cb_evt); + SMP_TRACE_DEBUG("%s p_cb->cb_evt=%d\n", __func__, p_cb->cb_evt); if (p_cb->p_callback && p_cb->cb_evt != 0) { switch (p_cb->cb_evt) @@ -149,7 +149,7 @@ void smp_send_app_cback(tSMP_CB *p_cb, tSMP_INT_DATA *p_data) callback_rc = (*p_cb->p_callback)(p_cb->cb_evt, p_cb->pairing_bda, &cb_data); - SMP_TRACE_DEBUG("callback_rc=%d p_cb->cb_evt=%d",callback_rc, p_cb->cb_evt ); + SMP_TRACE_DEBUG("callback_rc=%d p_cb->cb_evt=%d\n",callback_rc, p_cb->cb_evt ); if (callback_rc == SMP_SUCCESS) { @@ -172,7 +172,7 @@ void smp_send_app_cback(tSMP_CB *p_cb, tSMP_INT_DATA *p_data) SMP_TRACE_WARNING ( "rcvd auth_req: 0x%02x, io_cap: %d \ loc_oob_flag: %d loc_enc_size: %d," - "local_i_key: 0x%02x, local_r_key: 0x%02x", + "local_i_key: 0x%02x, local_r_key: 0x%02x\n", p_cb->loc_auth_req, p_cb->local_io_capability, p_cb->loc_oob_flag, p_cb->loc_enc_size, p_cb->local_i_key, p_cb->local_r_key); @@ -194,7 +194,7 @@ void smp_send_app_cback(tSMP_CB *p_cb, tSMP_INT_DATA *p_data) p_cb->local_r_key &= ~SMP_SEC_KEY_TYPE_LK; } - SMP_TRACE_WARNING("set auth_req: 0x%02x, local_i_key: 0x%02x, local_r_key: 0x%02x", + SMP_TRACE_WARNING("set auth_req: 0x%02x, local_i_key: 0x%02x, local_r_key: 0x%02x\n", p_cb->loc_auth_req, p_cb->local_i_key, p_cb->local_r_key); smp_sm_event(p_cb, SMP_IO_RSP_EVT, NULL); @@ -209,7 +209,7 @@ void smp_send_app_cback(tSMP_CB *p_cb, tSMP_INT_DATA *p_data) p_cb->local_r_key &= ~SMP_SEC_KEY_TYPE_LK; SMP_TRACE_WARNING ( "for SMP over BR max_key_size: 0x%02x,\ - local_i_key: 0x%02x, local_r_key: 0x%02x", + local_i_key: 0x%02x, local_r_key: 0x%02x\n", p_cb->loc_enc_size, p_cb->local_i_key, p_cb->local_r_key); smp_br_state_machine_event(p_cb, SMP_BR_KEYS_RSP_EVT, NULL); @@ -224,7 +224,7 @@ void smp_send_app_cback(tSMP_CB *p_cb, tSMP_INT_DATA *p_data) smp_sm_event(p_cb, SMP_DISCARD_SEC_REQ_EVT, NULL); } - SMP_TRACE_DEBUG("%s return", __func__); + SMP_TRACE_DEBUG("%s return\n", __func__); } /******************************************************************************* @@ -252,7 +252,7 @@ void smp_send_pair_fail(tSMP_CB *p_cb, tSMP_INT_DATA *p_data) void smp_send_pair_req(tSMP_CB *p_cb, tSMP_INT_DATA *p_data) { tBTM_SEC_DEV_REC *p_dev_rec = btm_find_dev (p_cb->pairing_bda); - SMP_TRACE_DEBUG("%s", __func__); + SMP_TRACE_DEBUG("%s\n", __func__); /* erase all keys when master sends pairing req*/ if (p_dev_rec) @@ -268,7 +268,7 @@ void smp_send_pair_req(tSMP_CB *p_cb, tSMP_INT_DATA *p_data) *******************************************************************************/ void smp_send_pair_rsp(tSMP_CB *p_cb, tSMP_INT_DATA *p_data) { - SMP_TRACE_DEBUG("%s", __func__); + SMP_TRACE_DEBUG("%s\n", __func__); p_cb->local_i_key &= p_cb->peer_i_key; p_cb->local_r_key &= p_cb->peer_r_key; @@ -288,7 +288,7 @@ void smp_send_pair_rsp(tSMP_CB *p_cb, tSMP_INT_DATA *p_data) *******************************************************************************/ void smp_send_confirm(tSMP_CB *p_cb, tSMP_INT_DATA *p_data) { - SMP_TRACE_DEBUG("%s", __func__); + SMP_TRACE_DEBUG("%s\n", __func__); smp_send_cmd(SMP_OPCODE_CONFIRM, p_cb); } @@ -298,7 +298,7 @@ void smp_send_confirm(tSMP_CB *p_cb, tSMP_INT_DATA *p_data) *******************************************************************************/ void smp_send_init(tSMP_CB *p_cb, tSMP_INT_DATA *p_data) { - SMP_TRACE_DEBUG("%s", __func__); + SMP_TRACE_DEBUG("%s\n", __func__); smp_send_cmd(SMP_OPCODE_INIT, p_cb); } @@ -308,7 +308,7 @@ void smp_send_init(tSMP_CB *p_cb, tSMP_INT_DATA *p_data) *******************************************************************************/ void smp_send_rand(tSMP_CB *p_cb, tSMP_INT_DATA *p_data) { - SMP_TRACE_DEBUG("%s", __func__); + SMP_TRACE_DEBUG("%s\n", __func__); smp_send_cmd(SMP_OPCODE_RAND, p_cb); } @@ -318,7 +318,7 @@ void smp_send_rand(tSMP_CB *p_cb, tSMP_INT_DATA *p_data) *******************************************************************************/ void smp_send_pair_public_key(tSMP_CB *p_cb, tSMP_INT_DATA *p_data) { - SMP_TRACE_DEBUG("%s", __func__); + SMP_TRACE_DEBUG("%s\n", __func__); smp_send_cmd(SMP_OPCODE_PAIR_PUBLIC_KEY, p_cb); } @@ -360,7 +360,7 @@ void smp_send_enc_info(tSMP_CB *p_cb, tSMP_INT_DATA *p_data) { tBTM_LE_LENC_KEYS le_key; - SMP_TRACE_DEBUG("%s p_cb->loc_enc_size = %d", __func__, p_cb->loc_enc_size); + SMP_TRACE_DEBUG("%s p_cb->loc_enc_size = %d\n", __func__, p_cb->loc_enc_size); smp_update_key_mask (p_cb, SMP_SEC_KEY_TYPE_ENC, FALSE); smp_send_cmd(SMP_OPCODE_ENCRYPT_INFO, p_cb); @@ -376,7 +376,7 @@ void smp_send_enc_info(tSMP_CB *p_cb, tSMP_INT_DATA *p_data) btm_sec_save_le_key(p_cb->pairing_bda, BTM_LE_KEY_LENC, (tBTM_LE_KEY_VALUE *)&le_key, TRUE); - SMP_TRACE_WARNING ("%s", __func__); + SMP_TRACE_WARNING ("%s\n", __func__); smp_key_distribution(p_cb, NULL); } @@ -388,7 +388,7 @@ void smp_send_enc_info(tSMP_CB *p_cb, tSMP_INT_DATA *p_data) void smp_send_id_info(tSMP_CB *p_cb, tSMP_INT_DATA *p_data) { tBTM_LE_KEY_VALUE le_key; - SMP_TRACE_DEBUG("%s", __func__); + SMP_TRACE_DEBUG("%s\n", __func__); smp_update_key_mask (p_cb, SMP_SEC_KEY_TYPE_ID, FALSE); smp_send_cmd(SMP_OPCODE_IDENTITY_INFO, p_cb); @@ -398,7 +398,7 @@ void smp_send_id_info(tSMP_CB *p_cb, tSMP_INT_DATA *p_data) btm_sec_save_le_key(p_cb->pairing_bda, BTM_LE_KEY_LID, &le_key, TRUE); - SMP_TRACE_WARNING ("%s", __func__); + SMP_TRACE_WARNING ("%s\n", __func__); smp_key_distribution_by_transport(p_cb, NULL); } @@ -409,7 +409,7 @@ void smp_send_id_info(tSMP_CB *p_cb, tSMP_INT_DATA *p_data) void smp_send_csrk_info(tSMP_CB *p_cb, tSMP_INT_DATA *p_data) { tBTM_LE_LCSRK_KEYS key; - SMP_TRACE_DEBUG("%s", __func__); + SMP_TRACE_DEBUG("%s\n", __func__); smp_update_key_mask (p_cb, SMP_SEC_KEY_TYPE_CSRK, FALSE); if (smp_send_cmd(SMP_OPCODE_SIGN_INFO, p_cb)) @@ -529,7 +529,7 @@ void smp_proc_pair_cmd(tSMP_CB *p_cb, tSMP_INT_DATA *p_data) UINT8 reason = SMP_ENC_KEY_SIZE; tBTM_SEC_DEV_REC *p_dev_rec = btm_find_dev (p_cb->pairing_bda); - SMP_TRACE_DEBUG("%s", __func__); + SMP_TRACE_DEBUG("%s\n", __func__); /* erase all keys if it is slave proc pairing req*/ if (p_dev_rec && (p_cb->role == HCI_ROLE_SLAVE)) btm_sec_clear_ble_keys(p_dev_rec); @@ -623,7 +623,7 @@ void smp_proc_confirm(tSMP_CB *p_cb, tSMP_INT_DATA *p_data) UINT8 *p = (UINT8 *)p_data; UINT8 reason = SMP_INVALID_PARAMETERS; - SMP_TRACE_DEBUG("%s", __func__); + SMP_TRACE_DEBUG("%s\n", __func__); if (smp_command_has_invalid_parameters(p_cb)) { @@ -670,7 +670,7 @@ void smp_proc_rand(tSMP_CB *p_cb, tSMP_INT_DATA *p_data) UINT8 *p = (UINT8 *)p_data; UINT8 reason = SMP_INVALID_PARAMETERS; - SMP_TRACE_DEBUG("%s", __func__); + SMP_TRACE_DEBUG("%s\n", __func__); if (smp_command_has_invalid_parameters(p_cb)) { @@ -953,7 +953,7 @@ void smp_proc_enc_info(tSMP_CB *p_cb, tSMP_INT_DATA *p_data) { UINT8 *p = (UINT8 *)p_data; - SMP_TRACE_DEBUG("%s", __func__); + SMP_TRACE_DEBUG("%s\n", __func__); STREAM_TO_ARRAY(p_cb->ltk, p, BT_OCTET16_LEN); smp_key_distribution(p_cb, NULL); @@ -967,7 +967,8 @@ void smp_proc_master_id(tSMP_CB *p_cb, tSMP_INT_DATA *p_data) UINT8 *p = (UINT8 *)p_data; tBTM_LE_PENC_KEYS le_key; - SMP_TRACE_DEBUG("%s", __func__); + SMP_TRACE_DEBUG("%s\np_cb->peer_auth_req = %d,p_cb->loc_auth_req= %d\n", __func__, + p_cb->peer_auth_req,p_cb->loc_auth_req); smp_update_key_mask (p_cb, SMP_SEC_KEY_TYPE_ENC, TRUE); STREAM_TO_UINT16(le_key.ediv, p); @@ -1058,7 +1059,7 @@ void smp_proc_compare(tSMP_CB *p_cb, tSMP_INT_DATA *p_data) { UINT8 reason; - SMP_TRACE_DEBUG("%s", __func__); + SMP_TRACE_DEBUG("%s\n", __func__); if (!memcmp(p_cb->rconfirm, p_data->key.p_data, BT_OCTET16_LEN)) { /* compare the max encryption key size, and save the smaller one for the link */ @@ -1092,7 +1093,7 @@ void smp_proc_sl_key(tSMP_CB *p_cb, tSMP_INT_DATA *p_data) { UINT8 key_type = p_data->key.key_type; - SMP_TRACE_DEBUG("%s", __func__); + SMP_TRACE_DEBUG("%s\n", __func__); if (key_type == SMP_KEY_TYPE_TK) { smp_generate_srand_mrand_confirm(p_cb, NULL); @@ -1115,7 +1116,7 @@ void smp_start_enc(tSMP_CB *p_cb, tSMP_INT_DATA *p_data) tBTM_STATUS cmd; UINT8 reason = SMP_ENC_FAIL; - SMP_TRACE_DEBUG("%s", __func__); + SMP_TRACE_DEBUG("%s\n", __func__); if (p_data != NULL) cmd = btm_ble_start_encrypt(p_cb->pairing_bda, TRUE, p_data->key.p_data); else @@ -1131,7 +1132,7 @@ void smp_start_enc(tSMP_CB *p_cb, tSMP_INT_DATA *p_data) *******************************************************************************/ void smp_proc_discard(tSMP_CB *p_cb, tSMP_INT_DATA *p_data) { - SMP_TRACE_DEBUG("%s", __func__); + SMP_TRACE_DEBUG("%s\n", __func__); if (!(p_cb->flags & SMP_PAIR_FLAGS_WE_STARTED_DD)) smp_reset_control_value(p_cb); } @@ -1145,7 +1146,7 @@ void smp_enc_cmpl(tSMP_CB *p_cb, tSMP_INT_DATA *p_data) UINT8 enc_enable = *(UINT8 *)p_data; UINT8 reason = enc_enable ? SMP_SUCCESS : SMP_ENC_FAIL; - SMP_TRACE_DEBUG("%s", __func__); + SMP_TRACE_DEBUG("%s\n", __func__); smp_sm_event(p_cb, SMP_AUTH_CMPL_EVT, &reason); } @@ -1159,7 +1160,7 @@ void smp_check_auth_req(tSMP_CB *p_cb, tSMP_INT_DATA *p_data) UINT8 reason = enc_enable ? SMP_SUCCESS : SMP_ENC_FAIL; SMP_TRACE_DEBUG("%s rcvs enc_enable=%d i_keys=0x%x r_keys=0x%x " - "(i-initiator r-responder)", + "(i-initiator r-responder)\n", __func__, enc_enable, p_cb->local_i_key, p_cb->local_r_key); if (enc_enable == 1) { @@ -1192,7 +1193,7 @@ void smp_check_auth_req(tSMP_CB *p_cb, tSMP_INT_DATA *p_data) p_cb->local_r_key &= ~SMP_SEC_KEY_TYPE_LK; } SMP_TRACE_DEBUG("%s rcvs upgrades: i_keys=0x%x r_keys=0x%x " - "(i-initiator r-responder)", + "(i-initiator r-responder)\n", __func__, p_cb->local_i_key, p_cb->local_r_key); if (/*((p_cb->peer_auth_req & SMP_AUTH_BOND) || @@ -1227,14 +1228,14 @@ void smp_key_pick_key(tSMP_CB *p_cb, tSMP_INT_DATA *p_data) UINT8 key_to_dist = (p_cb->role == HCI_ROLE_SLAVE) ? p_cb->local_r_key : p_cb->local_i_key; UINT8 i = 0; - SMP_TRACE_DEBUG("%s key_to_dist=0x%x", __func__, key_to_dist); + SMP_TRACE_DEBUG("%s key_to_dist=0x%x\n", __func__, key_to_dist); while (i < SMP_KEY_DIST_TYPE_MAX) { - SMP_TRACE_DEBUG("key to send = %02x, i = %d", key_to_dist, i); + SMP_TRACE_DEBUG("key to send = %02x, i = %d\n", key_to_dist, i); if (key_to_dist & (1 << i)) { - SMP_TRACE_DEBUG("smp_distribute_act[%d]", i); + SMP_TRACE_DEBUG("smp_distribute_act[%d]\n", i); (* smp_distribute_act[i])(p_cb, p_data); break; } @@ -1248,7 +1249,7 @@ void smp_key_pick_key(tSMP_CB *p_cb, tSMP_INT_DATA *p_data) void smp_key_distribution(tSMP_CB *p_cb, tSMP_INT_DATA *p_data) { UINT8 reason = SMP_SUCCESS; - SMP_TRACE_DEBUG("%s role=%d (0-master) r_keys=0x%x i_keys=0x%x", + SMP_TRACE_DEBUG("\n%s role=%d (0-master) r_keys=0x%x i_keys=0x%x\n", __func__, p_cb->role, p_cb->local_r_key, p_cb->local_i_key); if (p_cb->role == HCI_ROLE_SLAVE || @@ -1289,7 +1290,7 @@ void smp_decide_association_model(tSMP_CB *p_cb, tSMP_INT_DATA *p_data) tSMP_KEY key; tSMP_INT_DATA *p = NULL; - SMP_TRACE_DEBUG("%s Association Model = %d", __func__, p_cb->selected_association_model); + SMP_TRACE_DEBUG("%s Association Model = %d\n", __func__, p_cb->selected_association_model); switch (p_cb->selected_association_model) { @@ -1298,7 +1299,7 @@ void smp_decide_association_model(tSMP_CB *p_cb, tSMP_INT_DATA *p_data) ((p_cb->peer_auth_req & SMP_AUTH_YN_BIT) != 0) && ((p_cb->loc_auth_req & SMP_AUTH_YN_BIT) == 0)) { - SMP_TRACE_ERROR ("IO capability does not meet authentication requirement"); + SMP_TRACE_ERROR ("IO capability does not meet authentication requirement\n"); failure = SMP_PAIR_AUTH_FAIL; p = (tSMP_INT_DATA *)&failure; int_evt = SMP_AUTH_CMPL_EVT; @@ -1306,7 +1307,7 @@ void smp_decide_association_model(tSMP_CB *p_cb, tSMP_INT_DATA *p_data) else { p_cb->sec_level = SMP_SEC_UNAUTHENTICATE; - SMP_TRACE_EVENT ("p_cb->sec_level =%d (SMP_SEC_UNAUTHENTICATE) ", p_cb->sec_level ); + SMP_TRACE_EVENT ("p_cb->sec_level =%d (SMP_SEC_UNAUTHENTICATE) \n", p_cb->sec_level ); key.key_type = SMP_KEY_TYPE_TK; key.p_data = p_cb->tk; @@ -1320,16 +1321,16 @@ void smp_decide_association_model(tSMP_CB *p_cb, tSMP_INT_DATA *p_data) case SMP_MODEL_PASSKEY: p_cb->sec_level = SMP_SEC_AUTHENTICATED; - SMP_TRACE_EVENT ("p_cb->sec_level =%d (SMP_SEC_AUTHENTICATED) ", p_cb->sec_level ); + SMP_TRACE_EVENT ("p_cb->sec_level =%d (SMP_SEC_AUTHENTICATED) \n", p_cb->sec_level ); p_cb->cb_evt = SMP_PASSKEY_REQ_EVT; int_evt = SMP_TK_REQ_EVT; break; case SMP_MODEL_OOB: - SMP_TRACE_ERROR ("Association Model = SMP_MODEL_OOB"); + SMP_TRACE_ERROR ("Association Model = SMP_MODEL_OOB\n"); p_cb->sec_level = SMP_SEC_AUTHENTICATED; - SMP_TRACE_EVENT ("p_cb->sec_level =%d (SMP_SEC_AUTHENTICATED) ", p_cb->sec_level ); + SMP_TRACE_EVENT ("p_cb->sec_level =%d (SMP_SEC_AUTHENTICATED) \n", p_cb->sec_level ); p_cb->cb_evt = SMP_OOB_REQ_EVT; int_evt = SMP_TK_REQ_EVT; @@ -1337,7 +1338,7 @@ void smp_decide_association_model(tSMP_CB *p_cb, tSMP_INT_DATA *p_data) case SMP_MODEL_KEY_NOTIF: p_cb->sec_level = SMP_SEC_AUTHENTICATED; - SMP_TRACE_DEBUG("Need to generate Passkey"); + SMP_TRACE_DEBUG("Need to generate Passkey\n"); /* generate passkey and notify application */ smp_generate_passkey(p_cb, NULL); @@ -1352,19 +1353,19 @@ void smp_decide_association_model(tSMP_CB *p_cb, tSMP_INT_DATA *p_data) break; case SMP_MODEL_OUT_OF_RANGE: - SMP_TRACE_ERROR("Association Model = SMP_MODEL_OUT_OF_RANGE (failed)"); + SMP_TRACE_ERROR("Association Model = SMP_MODEL_OUT_OF_RANGE (failed)\n"); p = (tSMP_INT_DATA *)&failure; int_evt = SMP_AUTH_CMPL_EVT; break; default: - SMP_TRACE_ERROR("Association Model = %d (SOMETHING IS WRONG WITH THE CODE)", + SMP_TRACE_ERROR("Association Model = %d (SOMETHING IS WRONG WITH THE CODE)\n", p_cb->selected_association_model); p = (tSMP_INT_DATA *)&failure; int_evt = SMP_AUTH_CMPL_EVT; } - SMP_TRACE_EVENT ("sec_level=%d ", p_cb->sec_level ); + SMP_TRACE_EVENT ("sec_level=%d \n", p_cb->sec_level ); if (int_evt) smp_sm_event(p_cb, int_evt, p); } @@ -1377,7 +1378,7 @@ void smp_process_io_response(tSMP_CB *p_cb, tSMP_INT_DATA *p_data) { uint8_t reason = SMP_PAIR_AUTH_FAIL; - SMP_TRACE_DEBUG("%s", __func__); + SMP_TRACE_DEBUG("%s\n", __func__); if (p_cb->flags & SMP_PAIR_FLAGS_WE_STARTED_DD) { /* pairing started by local (slave) Security Request */ @@ -1394,7 +1395,7 @@ void smp_process_io_response(tSMP_CB *p_cb, tSMP_INT_DATA *p_data) (p_cb->selected_association_model == SMP_MODEL_SEC_CONN_JUSTWORKS))) { SMP_TRACE_ERROR ("Slave requires secure connection only mode \ - but it can't be provided -> Slave fails pairing"); + but it can't be provided -> Slave fails pairing\n"); smp_sm_event(p_cb, SMP_AUTH_CMPL_EVT, &reason); return; } @@ -1423,7 +1424,7 @@ void smp_br_process_slave_keys_response(tSMP_CB *p_cb, tSMP_INT_DATA *p_data) *******************************************************************************/ void smp_br_send_pair_response(tSMP_CB *p_cb, tSMP_INT_DATA *p_data) { - SMP_TRACE_DEBUG("%s", __func__); + SMP_TRACE_DEBUG("%s\n", __func__); p_cb->local_i_key &= p_cb->peer_i_key; p_cb->local_r_key &= p_cb->peer_r_key; @@ -1454,7 +1455,7 @@ void smp_pairing_cmpl(tSMP_CB *p_cb, tSMP_INT_DATA *p_data) *******************************************************************************/ void smp_pair_terminate(tSMP_CB *p_cb, tSMP_INT_DATA *p_data) { - SMP_TRACE_DEBUG("%s", __func__); + SMP_TRACE_DEBUG("%s\n", __func__); p_cb->status = SMP_CONN_TOUT; smp_proc_pairing_cmpl(p_cb); } @@ -1468,7 +1469,7 @@ void smp_idle_terminate(tSMP_CB *p_cb, tSMP_INT_DATA *p_data) { if (p_cb->flags & SMP_PAIR_FLAGS_WE_STARTED_DD) { - SMP_TRACE_DEBUG("Pairing terminated at IDLE state."); + SMP_TRACE_DEBUG("Pairing terminated at IDLE state.\n"); p_cb->status = SMP_FAIL; smp_proc_pairing_cmpl(p_cb); } @@ -1495,7 +1496,7 @@ void smp_fast_conn_param(tSMP_CB *p_cb, tSMP_INT_DATA *p_data) *******************************************************************************/ void smp_both_have_public_keys(tSMP_CB *p_cb, tSMP_INT_DATA *p_data) { - SMP_TRACE_DEBUG("%s",__func__); + SMP_TRACE_DEBUG("%s\n",__func__); /* invokes DHKey computation */ smp_compute_dhkey(p_cb); @@ -1515,17 +1516,17 @@ void smp_both_have_public_keys(tSMP_CB *p_cb, tSMP_INT_DATA *p_data) *******************************************************************************/ void smp_start_secure_connection_phase1(tSMP_CB *p_cb, tSMP_INT_DATA *p_data) { - SMP_TRACE_DEBUG("%s", __func__); + SMP_TRACE_DEBUG("%s\n", __func__); if (p_cb->selected_association_model == SMP_MODEL_SEC_CONN_JUSTWORKS) { p_cb->sec_level = SMP_SEC_UNAUTHENTICATE; - SMP_TRACE_EVENT ("p_cb->sec_level =%d (SMP_SEC_UNAUTHENTICATE) ", p_cb->sec_level ); + SMP_TRACE_EVENT ("p_cb->sec_level =%d (SMP_SEC_UNAUTHENTICATE)\n ", p_cb->sec_level ); } else { p_cb->sec_level = SMP_SEC_AUTHENTICATED; - SMP_TRACE_EVENT ("p_cb->sec_level =%d (SMP_SEC_AUTHENTICATED) ", p_cb->sec_level ); + SMP_TRACE_EVENT ("p_cb->sec_level =%d (SMP_SEC_AUTHENTICATED)\n ", p_cb->sec_level ); } switch(p_cb->selected_association_model) @@ -1542,7 +1543,7 @@ void smp_start_secure_connection_phase1(tSMP_CB *p_cb, tSMP_INT_DATA *p_data) break; case SMP_MODEL_SEC_CONN_PASSKEY_DISP: /* passkey has to be provided to user */ - SMP_TRACE_DEBUG("Need to generate SC Passkey"); + SMP_TRACE_DEBUG("Need to generate SC Passkey\n"); smp_generate_passkey(p_cb, NULL); break; case SMP_MODEL_SEC_CONN_OOB: @@ -1550,7 +1551,7 @@ void smp_start_secure_connection_phase1(tSMP_CB *p_cb, tSMP_INT_DATA *p_data) smp_process_secure_connection_oob_data(p_cb, NULL); break; default: - SMP_TRACE_ERROR ("Association Model = %d is not used in LE SC", + SMP_TRACE_ERROR ("Association Model = %d is not used in LE SC\n", p_cb->selected_association_model); break; } @@ -1564,7 +1565,7 @@ void smp_start_secure_connection_phase1(tSMP_CB *p_cb, tSMP_INT_DATA *p_data) *******************************************************************************/ void smp_process_local_nonce(tSMP_CB *p_cb, tSMP_INT_DATA *p_data) { - SMP_TRACE_DEBUG("%s", __func__); + SMP_TRACE_DEBUG("%s\n", __func__); switch(p_cb->selected_association_model) { @@ -1584,7 +1585,7 @@ void smp_process_local_nonce(tSMP_CB *p_cb, tSMP_INT_DATA *p_data) { /* slave commitment is already received, send local nonce, wait for remote nonce*/ SMP_TRACE_DEBUG("master in assoc mode = %d \ - already rcvd slave commitment - race condition", + already rcvd slave commitment - race condition\n", p_cb->selected_association_model); p_cb->flags &= ~SMP_PAIR_FLAG_HAVE_PEER_COMM; smp_send_rand(p_cb, NULL); @@ -1619,7 +1620,7 @@ void smp_process_local_nonce(tSMP_CB *p_cb, tSMP_INT_DATA *p_data) smp_set_state(SMP_STATE_WAIT_NONCE); break; default: - SMP_TRACE_ERROR ("Association Model = %d is not used in LE SC", + SMP_TRACE_ERROR ("Association Model = %d is not used in LE SC\n", p_cb->selected_association_model); break; } @@ -1636,7 +1637,7 @@ void smp_process_peer_nonce(tSMP_CB *p_cb, tSMP_INT_DATA *p_data) { UINT8 reason; - SMP_TRACE_DEBUG("%s start ", __func__); + SMP_TRACE_DEBUG("%s start \n", __func__); switch(p_cb->selected_association_model) { @@ -1702,12 +1703,12 @@ void smp_process_peer_nonce(tSMP_CB *p_cb, tSMP_INT_DATA *p_data) smp_sm_event(p_cb, SMP_SC_PHASE1_CMPLT_EVT, NULL); break; default: - SMP_TRACE_ERROR ("Association Model = %d is not used in LE SC", + SMP_TRACE_ERROR ("Association Model = %d is not used in LE SC\n", p_cb->selected_association_model); break; } - SMP_TRACE_DEBUG("%s end ",__FUNCTION__); + SMP_TRACE_DEBUG("%s end\n ",__FUNCTION__); } /******************************************************************************* @@ -1719,17 +1720,17 @@ void smp_match_dhkey_checks(tSMP_CB *p_cb, tSMP_INT_DATA *p_data) { UINT8 reason = SMP_DHKEY_CHK_FAIL; - SMP_TRACE_DEBUG("%s", __func__); + SMP_TRACE_DEBUG("%s\n", __func__); if (memcmp(p_data->key.p_data, p_cb->remote_dhkey_check, BT_OCTET16_LEN)) { - SMP_TRACE_WARNING ("dhkey chcks do no match"); + SMP_TRACE_WARNING ("dhkey chcks do no match\n"); p_cb->failure = reason; smp_sm_event(p_cb, SMP_AUTH_CMPL_EVT, &reason); return; } - SMP_TRACE_EVENT ("dhkey chcks match"); + SMP_TRACE_EVENT ("dhkey chcks match\n"); /* compare the max encryption key size, and save the smaller one for the link */ if (p_cb->peer_enc_size < p_cb->loc_enc_size) @@ -1757,7 +1758,7 @@ void smp_match_dhkey_checks(tSMP_CB *p_cb, tSMP_INT_DATA *p_data) *******************************************************************************/ void smp_move_to_secure_connections_phase2(tSMP_CB *p_cb, tSMP_INT_DATA *p_data) { - SMP_TRACE_DEBUG("%s",__func__); + SMP_TRACE_DEBUG("%s\n",__func__); smp_sm_event(p_cb, SMP_SC_PHASE1_CMPLT_EVT, NULL); } @@ -1770,7 +1771,7 @@ void smp_move_to_secure_connections_phase2(tSMP_CB *p_cb, tSMP_INT_DATA *p_data) *******************************************************************************/ void smp_phase_2_dhkey_checks_are_present(tSMP_CB *p_cb, tSMP_INT_DATA *p_data) { - SMP_TRACE_DEBUG("%s",__func__); + SMP_TRACE_DEBUG("%s\n",__func__); if (p_cb->flags & SMP_PAIR_FLAG_HAVE_PEER_DHK_CHK) smp_sm_event(p_cb, SMP_SC_2_DHCK_CHKS_PRES_EVT, NULL); @@ -1786,7 +1787,7 @@ void smp_phase_2_dhkey_checks_are_present(tSMP_CB *p_cb, tSMP_INT_DATA *p_data) *******************************************************************************/ void smp_wait_for_both_public_keys(tSMP_CB *p_cb, tSMP_INT_DATA *p_data) { - SMP_TRACE_DEBUG("%s",__func__); + SMP_TRACE_DEBUG("%s\n",__func__); if ((p_cb->flags & SMP_PAIR_FLAG_HAVE_PEER_PUBL_KEY) && (p_cb->flags & SMP_PAIR_FLAG_HAVE_LOCAL_PUBL_KEY)) @@ -1808,7 +1809,7 @@ void smp_start_passkey_verification(tSMP_CB *p_cb, tSMP_INT_DATA *p_data) { UINT8 *p = NULL; - SMP_TRACE_DEBUG("%s", __func__); + SMP_TRACE_DEBUG("%s\n", __func__); p = p_cb->local_random; UINT32_TO_STREAM(p, p_data->passkey); @@ -1825,7 +1826,7 @@ void smp_start_passkey_verification(tSMP_CB *p_cb, tSMP_INT_DATA *p_data) *******************************************************************************/ void smp_process_secure_connection_oob_data(tSMP_CB *p_cb, tSMP_INT_DATA *p_data) { - SMP_TRACE_DEBUG("%s", __func__); + SMP_TRACE_DEBUG("%s\n", __func__); tSMP_SC_OOB_DATA *p_sc_oob_data = &p_cb->sc_oob_data; if (p_sc_oob_data->loc_oob_data.present) @@ -1835,13 +1836,13 @@ void smp_process_secure_connection_oob_data(tSMP_CB *p_cb, tSMP_INT_DATA *p_data } else { - SMP_TRACE_EVENT ("local OOB randomizer is absent"); + SMP_TRACE_EVENT ("local OOB randomizer is absent\n"); memset(p_cb->local_random, 0, sizeof (p_cb->local_random)); } if (!p_sc_oob_data->peer_oob_data.present) { - SMP_TRACE_EVENT ("peer OOB data is absent"); + SMP_TRACE_EVENT ("peer OOB data is absent\n"); memset(p_cb->peer_random, 0, sizeof (p_cb->peer_random)); } else @@ -1863,7 +1864,7 @@ void smp_process_secure_connection_oob_data(tSMP_CB *p_cb, tSMP_INT_DATA *p_data if (p_cb->peer_oob_flag != SMP_OOB_PRESENT) { /* the peer doesn't have local randomiser */ - SMP_TRACE_EVENT ("peer didn't receive local OOB data, set local randomizer to 0"); + SMP_TRACE_EVENT ("peer didn't receive local OOB data, set local randomizer to 0\n"); memset(p_cb->local_random, 0, sizeof (p_cb->local_random)); } } @@ -1881,7 +1882,7 @@ void smp_process_secure_connection_oob_data(tSMP_CB *p_cb, tSMP_INT_DATA *p_data *******************************************************************************/ void smp_set_local_oob_keys(tSMP_CB *p_cb, tSMP_INT_DATA *p_data) { - SMP_TRACE_DEBUG("%s", __func__); + SMP_TRACE_DEBUG("%s\n", __func__); memcpy(p_cb->sc_oob_data.loc_oob_data.private_key_used, p_cb->private_key, BT_OCTET32_LEN); @@ -1896,7 +1897,7 @@ void smp_set_local_oob_keys(tSMP_CB *p_cb, tSMP_INT_DATA *p_data) *******************************************************************************/ void smp_set_local_oob_random_commitment(tSMP_CB *p_cb, tSMP_INT_DATA *p_data) { - SMP_TRACE_DEBUG("%s", __func__); + SMP_TRACE_DEBUG("%s\n", __func__); memcpy(p_cb->sc_oob_data.loc_oob_data.randomizer, p_cb->rand, BT_OCTET16_LEN); @@ -1907,7 +1908,7 @@ void smp_set_local_oob_random_commitment(tSMP_CB *p_cb, tSMP_INT_DATA *p_data) #if SMP_DEBUG == TRUE UINT8 *p_print = NULL; - SMP_TRACE_DEBUG("local SC OOB data set:"); + SMP_TRACE_DEBUG("local SC OOB data set:\n"); p_print = (UINT8*) &p_cb->sc_oob_data.loc_oob_data.addr_sent_to; smp_debug_print_nbyte_little_endian (p_print, (const UINT8 *)"addr_sent_to", sizeof(tBLE_BD_ADDR)); @@ -1952,7 +1953,7 @@ void smp_link_encrypted(BD_ADDR bda, UINT8 encr_enable) { tSMP_CB *p_cb = &smp_cb; - SMP_TRACE_DEBUG("%s encr_enable=%d", __func__, encr_enable); + SMP_TRACE_DEBUG("%s encr_enable=%d\n", __func__, encr_enable); if (memcmp(&smp_cb.pairing_bda[0], bda, BD_ADDR_LEN) == 0) { @@ -1980,7 +1981,7 @@ void smp_link_encrypted(BD_ADDR bda, UINT8 encr_enable) *******************************************************************************/ BOOLEAN smp_proc_ltk_request(BD_ADDR bda) { - SMP_TRACE_DEBUG("%s state = %d", __func__, smp_cb.state); + SMP_TRACE_DEBUG("%s state = %d\n", __func__, smp_cb.state); BOOLEAN match = FALSE; if (!memcmp(bda, smp_cb.pairing_bda, BD_ADDR_LEN)) @@ -2021,7 +2022,7 @@ void smp_process_secure_connection_long_term_key(void) { tSMP_CB *p_cb = &smp_cb; - SMP_TRACE_DEBUG("%s", __func__); + SMP_TRACE_DEBUG("%s\n", __func__); smp_save_secure_connections_long_term_key(p_cb); smp_update_key_mask (p_cb, SMP_SEC_KEY_TYPE_ENC, FALSE); @@ -2041,7 +2042,7 @@ void smp_process_secure_connection_long_term_key(void) *******************************************************************************/ void smp_set_derive_link_key(tSMP_CB *p_cb, tSMP_INT_DATA *p_data) { - SMP_TRACE_DEBUG ("%s", __func__); + SMP_TRACE_DEBUG ("%s\n", __func__); p_cb->derive_lk = TRUE; smp_update_key_mask (p_cb, SMP_SEC_KEY_TYPE_LK, FALSE); smp_key_distribution(p_cb, NULL); @@ -2060,10 +2061,10 @@ void smp_derive_link_key_from_long_term_key(tSMP_CB *p_cb, tSMP_INT_DATA *p_data { tSMP_STATUS status = SMP_PAIR_FAIL_UNKNOWN; - SMP_TRACE_DEBUG("%s", __func__); + SMP_TRACE_DEBUG("%s\n", __func__); if (!smp_calculate_link_key_from_long_term_key(p_cb)) { - SMP_TRACE_ERROR("%s failed", __FUNCTION__); + SMP_TRACE_ERROR("%s failed\n", __FUNCTION__); smp_sm_event(p_cb, SMP_AUTH_CMPL_EVT, &status); return; } @@ -2084,15 +2085,15 @@ void smp_br_process_link_key(tSMP_CB *p_cb, tSMP_INT_DATA *p_data) { tSMP_STATUS status = SMP_PAIR_FAIL_UNKNOWN; - SMP_TRACE_DEBUG("%s", __func__); + SMP_TRACE_DEBUG("%s\n", __func__); if (!smp_calculate_long_term_key_from_link_key(p_cb)) { - SMP_TRACE_ERROR ("%s failed",__FUNCTION__); + SMP_TRACE_ERROR ("%s failed\n",__FUNCTION__); smp_sm_event(p_cb, SMP_BR_AUTH_CMPL_EVT, &status); return; } - SMP_TRACE_DEBUG("%s: LTK derivation from LK successfully completed", __FUNCTION__); + SMP_TRACE_DEBUG("%s: LTK derivation from LK successfully completed\n", __FUNCTION__); smp_save_secure_connections_long_term_key(p_cb); smp_update_key_mask (p_cb, SMP_SEC_KEY_TYPE_ENC, FALSE); smp_br_select_next_key(p_cb, NULL); @@ -2105,7 +2106,7 @@ void smp_br_process_link_key(tSMP_CB *p_cb, tSMP_INT_DATA *p_data) *******************************************************************************/ void smp_key_distribution_by_transport(tSMP_CB *p_cb, tSMP_INT_DATA *p_data) { - SMP_TRACE_DEBUG("%s", __func__); + SMP_TRACE_DEBUG("%s\n", __func__); if (p_cb->smp_over_br) { smp_br_select_next_key(p_cb, NULL); @@ -2123,7 +2124,7 @@ void smp_key_distribution_by_transport(tSMP_CB *p_cb, tSMP_INT_DATA *p_data) *******************************************************************************/ void smp_br_pairing_complete(tSMP_CB *p_cb, tSMP_INT_DATA *p_data) { - SMP_TRACE_DEBUG("%s", __func__); + SMP_TRACE_DEBUG("%s\n", __func__); if (p_cb->total_tx_unacked == 0) { diff --git a/components/bt/bluedroid/stack/smp/smp_api.c b/components/bt/bluedroid/stack/smp/smp_api.c index a96e653df3..c4b1e2be8c 100755 --- a/components/bt/bluedroid/stack/smp/smp_api.c +++ b/components/bt/bluedroid/stack/smp/smp_api.c @@ -132,7 +132,7 @@ tSMP_STATUS SMP_Pair (BD_ADDR bd_addr) tSMP_CB *p_cb = &smp_cb; UINT8 status = SMP_PAIR_INTERNAL_ERR; - SMP_TRACE_EVENT ("%s state=%d br_state=%d flag=0x%x ", + SMP_TRACE_EVENT ("%s state=%d br_state=%d flag=0x%x \n", __FUNCTION__, p_cb->state, p_cb->br_state, p_cb->flags); if (p_cb->state != SMP_STATE_IDLE || p_cb->flags & SMP_PAIR_FLAGS_WE_STARTED_DD || p_cb->smp_over_br) @@ -148,7 +148,7 @@ tSMP_STATUS SMP_Pair (BD_ADDR bd_addr) if (!L2CA_ConnectFixedChnl (L2CAP_SMP_CID, bd_addr)) { - SMP_TRACE_ERROR("%s: L2C connect fixed channel failed.", __FUNCTION__); + SMP_TRACE_ERROR("%s: L2C connect fixed channel failed.\n", __FUNCTION__); smp_sm_event(p_cb, SMP_AUTH_CMPL_EVT, &status); return status; } diff --git a/components/bt/bluedroid/stack/smp/smp_keys.c b/components/bt/bluedroid/stack/smp/smp_keys.c index 4a73392de5..5f93950d9a 100755 --- a/components/bt/bluedroid/stack/smp/smp_keys.c +++ b/components/bt/bluedroid/stack/smp/smp_keys.c @@ -82,7 +82,7 @@ void smp_debug_print_nbyte_little_endian(UINT8 *p, const UINT8 *key_name, UINT8 int row_count; UINT8 p_buf[512]; - SMP_TRACE_WARNING("%s(LSB ~ MSB):", key_name); + SMP_TRACE_WARNING("%s(LSB ~ MSB):\n", key_name); memset(p_buf, 0, sizeof(p_buf)); row_count = len % col_count ? len / col_count + 1: len / col_count; @@ -145,16 +145,16 @@ BOOLEAN smp_encrypt_data (UINT8 *key, UINT8 key_len, UINT8 *p_rev_key = NULL; /* input key in big endilan format */ UINT8 *p_rev_output = NULL; /* encrypted output in big endilan format */ - SMP_TRACE_DEBUG ("%s", __func__); + SMP_TRACE_DEBUG ("%s\n", __func__); if ( (p_out == NULL ) || (key_len != SMP_ENCRYT_KEY_SIZE) ) { - SMP_TRACE_ERROR ("%s failed", __func__); + SMP_TRACE_ERROR ("%s failed\n", __func__); return FALSE; } if ((p_start = (UINT8 *)GKI_getbuf((SMP_ENCRYT_DATA_SIZE*4))) == NULL) { - SMP_TRACE_ERROR ("%s failed unable to allocate buffer", __func__); + SMP_TRACE_ERROR ("%s failed unable to allocate buffer\n", __func__); return FALSE; } @@ -277,7 +277,7 @@ void smp_generate_stk(tSMP_CB *p_cb, tSMP_INT_DATA *p_data) tSMP_ENC output; tSMP_STATUS status = SMP_PAIR_FAIL_UNKNOWN; - SMP_TRACE_DEBUG ("%s", __func__); + SMP_TRACE_DEBUG ("%s\n", __func__); if (p_cb->le_secure_connections_mode_is_used) { @@ -312,7 +312,7 @@ void smp_generate_srand_mrand_confirm(tSMP_CB *p_cb, tSMP_INT_DATA *p_data) { UNUSED(p_data); - SMP_TRACE_DEBUG ("%s", __func__); + SMP_TRACE_DEBUG ("%s\n", __func__); p_cb->rand_enc_proc_state = SMP_GEN_SRAND_MRAND; /* generate MRand or SRand */ if (!btsnd_hcic_ble_rand((void *)smp_rand_back)) @@ -333,7 +333,7 @@ void smp_generate_rand_cont(tSMP_CB *p_cb, tSMP_INT_DATA *p_data) { UNUSED(p_data); - SMP_TRACE_DEBUG ("%s", __func__); + SMP_TRACE_DEBUG ("%s\n", __func__); p_cb->rand_enc_proc_state = SMP_GEN_SRAND_MRAND_CONT; /* generate 64 MSB of MRand or SRand */ if (!btsnd_hcic_ble_rand((void *)smp_rand_back)) @@ -360,7 +360,7 @@ void smp_generate_ltk(tSMP_CB *p_cb, tSMP_INT_DATA *p_data) UNUSED(p_data); BOOLEAN div_status; - SMP_TRACE_DEBUG ("%s", __FUNCTION__); + SMP_TRACE_DEBUG ("%s\n", __FUNCTION__); if (smp_get_br_state() == SMP_BR_STATE_BOND_PENDING) { smp_br_process_link_key(p_cb, NULL); @@ -380,7 +380,7 @@ void smp_generate_ltk(tSMP_CB *p_cb, tSMP_INT_DATA *p_data) } else { - SMP_TRACE_DEBUG ("Generate DIV for LTK"); + SMP_TRACE_DEBUG ("Generate DIV for LTK\n"); p_cb->rand_enc_proc_state = SMP_GEN_DIV_LTK; /* generate MRand or SRand */ if (!btsnd_hcic_ble_rand((void *)smp_rand_back)) @@ -409,7 +409,7 @@ void smp_compute_csrk(tSMP_CB *p_cb, tSMP_INT_DATA *p_data) tSMP_ENC output; tSMP_STATUS status = SMP_PAIR_FAIL_UNKNOWN; - SMP_TRACE_DEBUG ("smp_compute_csrk div=%x", p_cb->div); + SMP_TRACE_DEBUG ("smp_compute_csrk div=%x\n", p_cb->div); BTM_GetDeviceEncRoot(er); /* CSRK = d1(ER, DIV, 1) */ UINT16_TO_STREAM(p, p_cb->div); @@ -417,7 +417,7 @@ void smp_compute_csrk(tSMP_CB *p_cb, tSMP_INT_DATA *p_data) if (!SMP_Encrypt(er, BT_OCTET16_LEN, buffer, 4, &output)) { - SMP_TRACE_ERROR("smp_generate_csrk failed"); + SMP_TRACE_ERROR("smp_generate_csrk failed\n"); if (p_cb->smp_over_br) { smp_br_state_machine_event(p_cb, SMP_BR_AUTH_CMPL_EVT, &status); @@ -475,7 +475,7 @@ void smp_concatenate_local( tSMP_CB *p_cb, UINT8 **p_data, UINT8 op_code) { UINT8 *p = *p_data; - SMP_TRACE_DEBUG ("%s", __func__); + SMP_TRACE_DEBUG ("%s\n", __func__); UINT8_TO_STREAM(p, op_code); UINT8_TO_STREAM(p, p_cb->local_io_capability); UINT8_TO_STREAM(p, p_cb->loc_oob_flag); @@ -495,7 +495,7 @@ void smp_concatenate_peer( tSMP_CB *p_cb, UINT8 **p_data, UINT8 op_code) { UINT8 *p = *p_data; - SMP_TRACE_DEBUG ("smp_concatenate_peer "); + SMP_TRACE_DEBUG ("smp_concatenate_peer \n"); UINT8_TO_STREAM(p, op_code); UINT8_TO_STREAM(p, p_cb->peer_io_caps); UINT8_TO_STREAM(p, p_cb->peer_oob_flag); @@ -523,11 +523,11 @@ void smp_gen_p1_4_confirm( tSMP_CB *p_cb, BT_OCTET16 p1) tBLE_ADDR_TYPE addr_type = 0; BD_ADDR remote_bda; - SMP_TRACE_DEBUG ("smp_gen_p1_4_confirm"); + SMP_TRACE_DEBUG ("smp_gen_p1_4_confirm\n"); if (!BTM_ReadRemoteConnectionAddr(p_cb->pairing_bda, remote_bda, &addr_type)) { - SMP_TRACE_ERROR("can not generate confirm for unknown device"); + SMP_TRACE_ERROR("can not generate confirm for unknown device\n"); return; } @@ -556,7 +556,7 @@ void smp_gen_p1_4_confirm( tSMP_CB *p_cb, BT_OCTET16 p1) smp_concatenate_local(p_cb, &p, SMP_OPCODE_PAIRING_RSP); } #if SMP_DEBUG == TRUE - SMP_TRACE_DEBUG("p1 = pres || preq || rat' || iat'"); + SMP_TRACE_DEBUG("p1 = pres || preq || rat' || iat'\n"); smp_debug_print_nbyte_little_endian ((UINT8 *)p1, (const UINT8 *)"P1", 16); #endif } @@ -576,14 +576,14 @@ void smp_gen_p2_4_confirm( tSMP_CB *p_cb, BT_OCTET16 p2) UINT8 *p = (UINT8 *)p2; BD_ADDR remote_bda; tBLE_ADDR_TYPE addr_type = 0; - + SMP_TRACE_DEBUG ("smp_gen_p2_4_confirm\n"); if (!BTM_ReadRemoteConnectionAddr(p_cb->pairing_bda, remote_bda, &addr_type)) { - SMP_TRACE_ERROR("can not generate confirm p2 for unknown device"); + SMP_TRACE_ERROR("can not generate confirm p2 for unknown device\n"); return; } - SMP_TRACE_DEBUG ("smp_gen_p2_4_confirm"); + SMP_TRACE_DEBUG ("smp_gen_p2_4_confirm\n"); memset(p, 0, sizeof(BT_OCTET16)); @@ -624,7 +624,7 @@ void smp_calculate_comfirm (tSMP_CB *p_cb, BT_OCTET16 rand, BD_ADDR bda) tSMP_ENC output; tSMP_STATUS status = SMP_PAIR_FAIL_UNKNOWN; - SMP_TRACE_DEBUG ("smp_calculate_comfirm "); + SMP_TRACE_DEBUG ("smp_calculate_comfirm \n"); /* generate p1 = pres || preq || rat' || iat' */ smp_gen_p1_4_confirm(p_cb, p1); @@ -661,9 +661,9 @@ static void smp_calculate_comfirm_cont(tSMP_CB *p_cb, tSMP_ENC *p) tSMP_ENC output; tSMP_STATUS status = SMP_PAIR_FAIL_UNKNOWN; - SMP_TRACE_DEBUG ("smp_calculate_comfirm_cont "); + SMP_TRACE_DEBUG ("smp_calculate_comfirm_cont \n"); #if SMP_DEBUG == TRUE - SMP_TRACE_DEBUG("Confirm step 1 p1' = e(k, r XOR p1) Generated"); + SMP_TRACE_DEBUG("Confirm step 1 p1' = e(k, r XOR p1) Generated\n"); smp_debug_print_nbyte_little_endian (p->param_buf, (const UINT8 *)"C1", 16); #endif @@ -676,11 +676,12 @@ static void smp_calculate_comfirm_cont(tSMP_CB *p_cb, tSMP_ENC *p) /* calculate: Confirm = E(k, p1' XOR p2) */ if (!SMP_Encrypt(p_cb->tk, BT_OCTET16_LEN, p2, BT_OCTET16_LEN, &output)) { - SMP_TRACE_ERROR("smp_calculate_comfirm_cont failed"); + SMP_TRACE_ERROR("smp_calculate_comfirm_cont failed\n"); smp_sm_event(p_cb, SMP_AUTH_CMPL_EVT, &status); } else { + SMP_TRACE_DEBUG("p_cb->rand_enc_proc_state=%d\n",p_cb->rand_enc_proc_state); switch (p_cb->rand_enc_proc_state) { case SMP_GEN_CONFIRM: @@ -708,7 +709,7 @@ static void smp_generate_confirm(tSMP_CB *p_cb, tSMP_INT_DATA *p_data) { UNUSED(p_data); - SMP_TRACE_DEBUG ("%s", __func__); + SMP_TRACE_DEBUG ("%s\n", __func__); p_cb->rand_enc_proc_state = SMP_GEN_CONFIRM; smp_debug_print_nbyte_little_endian ((UINT8 *)p_cb->rand, (const UINT8 *)"local rand", 16); smp_calculate_comfirm(p_cb, p_cb->rand, p_cb->pairing_bda); @@ -729,7 +730,7 @@ void smp_generate_compare (tSMP_CB *p_cb, tSMP_INT_DATA *p_data) { UNUSED(p_data); - SMP_TRACE_DEBUG ("smp_generate_compare "); + SMP_TRACE_DEBUG ("smp_generate_compare \n"); p_cb->rand_enc_proc_state = SMP_GEN_COMPARE; smp_debug_print_nbyte_little_endian ((UINT8 *)p_cb->rrand, (const UINT8 *)"peer rand", 16); smp_calculate_comfirm(p_cb, p_cb->rrand, p_cb->local_bda); @@ -749,7 +750,7 @@ static void smp_process_confirm(tSMP_CB *p_cb, tSMP_ENC *p) { tSMP_KEY key; - SMP_TRACE_DEBUG ("%s", __FUNCTION__); + SMP_TRACE_DEBUG ("%s\n", __FUNCTION__); memcpy(p_cb->confirm, p->param_buf, BT_OCTET16_LEN); #if (SMP_DEBUG == TRUE) @@ -759,7 +760,9 @@ static void smp_process_confirm(tSMP_CB *p_cb, tSMP_ENC *p) key.key_type = SMP_KEY_TYPE_CFM; key.p_data = p->param_buf; + smp_sm_event(p_cb, SMP_KEY_READY_EVT, &key); + } /******************************************************************************* @@ -776,14 +779,14 @@ static void smp_process_compare(tSMP_CB *p_cb, tSMP_ENC *p) { tSMP_KEY key; - SMP_TRACE_DEBUG ("smp_process_compare "); + SMP_TRACE_DEBUG ("smp_process_compare \n"); #if (SMP_DEBUG == TRUE) - SMP_TRACE_DEBUG("Compare Generated"); + SMP_TRACE_DEBUG("Compare Generated\n"); smp_debug_print_nbyte_little_endian (p->param_buf, (const UINT8 *)"Compare", 16); #endif key.key_type = SMP_KEY_TYPE_CMP; key.p_data = p->param_buf; - + //smp_set_state(SMP_STATE_CONFIRM); smp_sm_event(p_cb, SMP_KEY_READY_EVT, &key); } @@ -830,14 +833,14 @@ static void smp_generate_ltk_cont(tSMP_CB *p_cb, tSMP_INT_DATA *p_data) tSMP_ENC output; tSMP_STATUS status = SMP_PAIR_FAIL_UNKNOWN; - SMP_TRACE_DEBUG ("%s", __func__); + SMP_TRACE_DEBUG ("%s\n", __func__); BTM_GetDeviceEncRoot(er); /* LTK = d1(ER, DIV, 0)= e(ER, DIV)*/ if (!SMP_Encrypt(er, BT_OCTET16_LEN, (UINT8 *)&p_cb->div, sizeof(UINT16), &output)) { - SMP_TRACE_ERROR("%s failed", __func__); + SMP_TRACE_ERROR("%s failed\n", __func__); smp_sm_event(p_cb, SMP_AUTH_CMPL_EVT, &status); } else @@ -867,7 +870,7 @@ static void smp_generate_y(tSMP_CB *p_cb, tSMP_INT_DATA *p) tSMP_STATUS status = SMP_PAIR_FAIL_UNKNOWN; - SMP_TRACE_DEBUG ("smp_generate_y "); + SMP_TRACE_DEBUG ("smp_generate_y \n"); BTM_GetDeviceDHK(dhk); if (!SMP_Encrypt(dhk, BT_OCTET16_LEN, p_cb->enc_rand, @@ -898,7 +901,7 @@ static void smp_generate_rand_vector (tSMP_CB *p_cb, tSMP_INT_DATA *p) /* generate EDIV and rand now */ /* generate random vector */ - SMP_TRACE_DEBUG ("smp_generate_rand_vector "); + SMP_TRACE_DEBUG ("smp_generate_rand_vector\n"); p_cb->rand_enc_proc_state = SMP_GEN_RAND_V; if (!btsnd_hcic_ble_rand((void *)smp_rand_back)) smp_rand_back(NULL); @@ -946,7 +949,7 @@ BOOLEAN smp_calculate_legacy_short_term_key(tSMP_CB *p_cb, tSMP_ENC *output) BT_OCTET16 ptext; UINT8 *p = ptext; - SMP_TRACE_DEBUG ("%s", __func__); + SMP_TRACE_DEBUG ("%s\n", __func__); memset(p, 0, BT_OCTET16_LEN); if (p_cb->role == HCI_ROLE_MASTER) { @@ -964,7 +967,7 @@ BOOLEAN smp_calculate_legacy_short_term_key(tSMP_CB *p_cb, tSMP_ENC *output) encrypted = SMP_Encrypt( p_cb->tk, BT_OCTET16_LEN, ptext, BT_OCTET16_LEN, output); if (!encrypted) { - SMP_TRACE_ERROR("%s failed", __func__); + SMP_TRACE_ERROR("%s failed\n", __func__); } return encrypted; } @@ -1007,19 +1010,19 @@ void smp_create_private_key(tSMP_CB *p_cb, tSMP_INT_DATA *p_data) *******************************************************************************/ void smp_use_oob_private_key(tSMP_CB *p_cb, tSMP_INT_DATA *p_data) { - SMP_TRACE_DEBUG ("%s req_oob_type: %d, role: %d", + SMP_TRACE_DEBUG ("%s req_oob_type: %d, role: %d\n", __func__, p_cb->req_oob_type, p_cb->role); switch (p_cb->req_oob_type) { case SMP_OOB_BOTH: case SMP_OOB_LOCAL: - SMP_TRACE_DEBUG("%s restore secret key", __func__) + SMP_TRACE_DEBUG("%s restore secret key\n", __func__); memcpy(p_cb->private_key, p_cb->sc_oob_data.loc_oob_data.private_key_used, BT_OCTET32_LEN); smp_process_private_key(p_cb); break; default: - SMP_TRACE_DEBUG("%s create secret key anew", __func__); + SMP_TRACE_DEBUG("%s create secret key anew\n", __func__); smp_set_state(SMP_STATE_PAIR_REQ_RSP); smp_decide_association_model(p_cb, NULL); break; @@ -1038,7 +1041,7 @@ void smp_use_oob_private_key(tSMP_CB *p_cb, tSMP_INT_DATA *p_data) void smp_continue_private_key_creation (tSMP_CB *p_cb, tBTM_RAND_ENC *p) { UINT8 state = p_cb->rand_enc_proc_state & ~0x80; - SMP_TRACE_DEBUG ("%s state=0x%x", __func__, state); + SMP_TRACE_DEBUG ("%s state=0x%x\n", __func__, state); switch (state) { @@ -1125,7 +1128,7 @@ void smp_compute_dhkey (tSMP_CB *p_cb) Point peer_publ_key, new_publ_key; BT_OCTET32 private_key; - SMP_TRACE_DEBUG ("%s", __FUNCTION__); + SMP_TRACE_DEBUG ("%s\n", __FUNCTION__); memcpy(private_key, p_cb->private_key, BT_OCTET32_LEN); memcpy(peer_publ_key.x, p_cb->peer_publ_key.x, BT_OCTET32_LEN); @@ -1161,7 +1164,7 @@ void smp_calculate_local_commitment(tSMP_CB *p_cb) { UINT8 random_input; - SMP_TRACE_DEBUG("%s", __FUNCTION__); + SMP_TRACE_DEBUG("%s\n", __FUNCTION__); switch (p_cb->selected_association_model) { @@ -1169,7 +1172,7 @@ void smp_calculate_local_commitment(tSMP_CB *p_cb) case SMP_MODEL_SEC_CONN_NUM_COMP: if (p_cb->role == HCI_ROLE_MASTER) SMP_TRACE_WARNING ("local commitment calc on master is not expected \ - for Just Works/Numeric Comparison models"); + for Just Works/Numeric Comparison models\n"); smp_calculate_f4(p_cb->loc_publ_key.x, p_cb->peer_publ_key.x, p_cb->rand, 0, p_cb->commitment); break; @@ -1180,12 +1183,12 @@ void smp_calculate_local_commitment(tSMP_CB *p_cb) random_input, p_cb->commitment); break; case SMP_MODEL_SEC_CONN_OOB: - SMP_TRACE_WARNING ("local commitment calc is expected for OOB model BEFORE pairing"); + SMP_TRACE_WARNING ("local commitment calc is expected for OOB model BEFORE pairing\n"); smp_calculate_f4(p_cb->loc_publ_key.x, p_cb->loc_publ_key.x, p_cb->local_random, 0, p_cb->commitment); break; default: - SMP_TRACE_ERROR("Association Model = %d is not used in LE SC", + SMP_TRACE_ERROR("Association Model = %d is not used in LE SC\n", p_cb->selected_association_model); return; } @@ -1215,7 +1218,7 @@ void smp_calculate_peer_commitment(tSMP_CB *p_cb, BT_OCTET16 output_buf) case SMP_MODEL_SEC_CONN_NUM_COMP: if (p_cb->role == HCI_ROLE_SLAVE) SMP_TRACE_WARNING ("peer commitment calc on slave is not expected \ - for Just Works/Numeric Comparison models"); + for Just Works/Numeric Comparison models\n"); smp_calculate_f4(p_cb->peer_publ_key.x, p_cb->loc_publ_key.x, p_cb->rrand, 0, output_buf); break; @@ -1230,12 +1233,12 @@ void smp_calculate_peer_commitment(tSMP_CB *p_cb, BT_OCTET16 output_buf) output_buf); break; default: - SMP_TRACE_ERROR("Association Model = %d is not used in LE SC", + SMP_TRACE_ERROR("Association Model = %d is not used in LE SC\n", p_cb->selected_association_model); return; } - SMP_TRACE_EVENT ("peer commitment calculation is completed"); + SMP_TRACE_EVENT ("peer commitment calculation is completed\n"); } /******************************************************************************* @@ -1386,7 +1389,7 @@ UINT32 smp_calculate_g2(UINT8 *u, UINT8 *v, UINT8 *x, UINT8 *y) UINT8 *p_prnt = NULL; #endif - SMP_TRACE_DEBUG ("%s", __FUNCTION__); + SMP_TRACE_DEBUG ("%s\n", __FUNCTION__); p = msg; ARRAY_TO_STREAM(p, y, BT_OCTET16_LEN); diff --git a/components/bt/bluedroid/stack/smp/smp_l2c.c b/components/bt/bluedroid/stack/smp/smp_l2c.c index 6f97742c5e..0aa5ee095d 100755 --- a/components/bt/bluedroid/stack/smp/smp_l2c.c +++ b/components/bt/bluedroid/stack/smp/smp_l2c.c @@ -93,14 +93,14 @@ static void smp_connect_callback (UINT16 channel, BD_ADDR bd_addr, BOOLEAN conne tSMP_INT_DATA int_data; BD_ADDR dummy_bda = {0}; - SMP_TRACE_EVENT ("SMDBG l2c %s", __FUNCTION__); + SMP_TRACE_EVENT ("SMDBG l2c %s\n", __FUNCTION__); if (transport == BT_TRANSPORT_BR_EDR || memcmp(bd_addr, dummy_bda, BD_ADDR_LEN) == 0) return; if (memcmp(bd_addr, p_cb->pairing_bda, BD_ADDR_LEN) == 0) { - SMP_TRACE_EVENT ("%s() for pairing BDA: %08x%04x Event: %s", + SMP_TRACE_EVENT ("%s() for pairing BDA: %08x%04x Event: %s\n", __FUNCTION__, (bd_addr[0]<<24)+(bd_addr[1]<<16)+(bd_addr[2]<<8) + bd_addr[3], (bd_addr[4]<<8)+bd_addr[5], @@ -146,14 +146,14 @@ static void smp_data_received(UINT16 channel, BD_ADDR bd_addr, BT_HDR *p_buf) tSMP_CB *p_cb = &smp_cb; UINT8 *p = (UINT8 *)(p_buf + 1) + p_buf->offset; UINT8 cmd ; - SMP_TRACE_EVENT ("SMDBG l2c %s", __FUNCTION__); + SMP_TRACE_EVENT ("\nSMDBG l2c %s\n", __FUNCTION__); STREAM_TO_UINT8(cmd, p); /* sanity check */ if ((SMP_OPCODE_MAX < cmd) || (SMP_OPCODE_MIN > cmd)) { - SMP_TRACE_WARNING( "Ignore received command with RESERVED code 0x%02x", cmd); + SMP_TRACE_WARNING( "Ignore received command with RESERVED code 0x%02x\n", cmd); GKI_freebuf (p_buf); return; } @@ -184,7 +184,7 @@ static void smp_data_received(UINT16 channel, BD_ADDR bd_addr, BT_HDR *p_buf) if (cmd == SMP_OPCODE_CONFIRM) { SMP_TRACE_DEBUG ("in %s cmd = 0x%02x, peer_auth_req = 0x%02x," - "loc_auth_req = 0x%02x", + "loc_auth_req = 0x%02x\n", __FUNCTION__, cmd, p_cb->peer_auth_req, p_cb->loc_auth_req); if ((p_cb->peer_auth_req & SMP_SC_SUPPORT_BIT) && diff --git a/components/bt/bluedroid/stack/smp/smp_main.c b/components/bt/bluedroid/stack/smp/smp_main.c index 2d80343a6f..e9b3775207 100755 --- a/components/bt/bluedroid/stack/smp/smp_main.c +++ b/components/bt/bluedroid/stack/smp/smp_main.c @@ -442,7 +442,7 @@ static const UINT8 smp_slave_entry_map[][SMP_STATE_MAX] = { /* state name: Idle WaitApp SecReq Pair Wait Confirm Rand PublKey SCPhs1 Wait Wait SCPhs2 Wait DHKChk Enc Bond CrLocSc Rsp Pend ReqRsp Cfm Exch Strt Cmtm Nonce Strt DHKChk Pend Pend OobData */ -/* PAIR_REQ */{ 2, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, +/* PAIR_REQ */{ 2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* PAIR_RSP */{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* CONFIRM */{ 0, 4, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* RAND */{ 0, 0, 0, 0, 0, 1, 2, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0 }, @@ -491,7 +491,7 @@ static const UINT8 smp_slave_idle_table[][SMP_SM_NUM_COLS] = /* PAIR_REQ */ {SMP_PROC_PAIR_CMD, SMP_SEND_APP_CBACK, SMP_STATE_WAIT_APP_RSP} /* CR_LOC_SC_OOB_DATA */ ,{SMP_CREATE_PRIVATE_KEY, SMP_SM_NO_ACTION, SMP_STATE_CREATE_LOCAL_SEC_CONN_OOB_DATA} }; - + static const UINT8 smp_slave_wait_for_app_response_table [][SMP_SM_NUM_COLS] = { /* Event Action Next State */ @@ -525,7 +525,6 @@ static const UINT8 smp_slave_pair_request_response_table[][SMP_SM_NUM_COLS] = /* Event Action Next State */ /* CONFIRM */ {SMP_PROC_CONFIRM, SMP_SM_NO_ACTION, SMP_STATE_CONFIRM}, /* TK_REQ */ {SMP_SEND_APP_CBACK, SMP_SM_NO_ACTION, SMP_STATE_WAIT_APP_RSP}, - /* TK/Confirm ready */ /* KEY_READY */{SMP_PROC_SL_KEY, SMP_SM_NO_ACTION, SMP_STATE_PAIR_REQ_RSP} /* PUBL_KEY_EXCH_REQ */,{ SMP_CREATE_PRIVATE_KEY, SMP_SM_NO_ACTION, SMP_STATE_PUBLIC_KEY_EXCH}, @@ -772,15 +771,15 @@ void smp_sm_event(tSMP_CB *p_cb, tSMP_EVENT event, void *p_data) UINT8 action, entry, i; tSMP_ENTRY_TBL entry_table = smp_entry_table[p_cb->role]; - SMP_TRACE_EVENT("main smp_sm_event"); + SMP_TRACE_EVENT("main smp_sm_event\n"); if (curr_state >= SMP_STATE_MAX) { - SMP_TRACE_DEBUG( "Invalid state: %d", curr_state) ; + SMP_TRACE_DEBUG( "Invalid state: %d\n", curr_state) ; return; } SMP_TRACE_DEBUG( "SMP Role: %s State: [%s (%d)], Event: [%s (%d)]",\ - (p_cb->role == 0x01) ?"Slave" : "Master", smp_get_state_name( p_cb->state), + (p_cb->role == 0x01) ?"Slave" : "Master\n", smp_get_state_name( p_cb->state), p_cb->state, smp_get_event_name(event), event) ; /* look up the state table for the current state */ @@ -799,7 +798,7 @@ void smp_sm_event(tSMP_CB *p_cb, tSMP_EVENT event, void *p_data) } else { - SMP_TRACE_DEBUG( "Ignore event [%s (%d)] in state [%s (%d)]", + SMP_TRACE_DEBUG( "Ignore event [%s (%d)] in state [%s (%d)]\n", smp_get_event_name(event), event, smp_get_state_name(curr_state), curr_state); return; @@ -825,7 +824,7 @@ void smp_sm_event(tSMP_CB *p_cb, tSMP_EVENT event, void *p_data) break; } } - SMP_TRACE_DEBUG( "result state = %s", smp_get_state_name( p_cb->state ) ) ; + SMP_TRACE_DEBUG( "result state = %s\n", smp_get_state_name( p_cb->state ) ) ; } /******************************************************************************* diff --git a/components/bt/bluedroid/stack/smp/smp_utils.c b/components/bt/bluedroid/stack/smp/smp_utils.c index a3809115ec..4d988bad46 100755 --- a/components/bt/bluedroid/stack/smp/smp_utils.c +++ b/components/bt/bluedroid/stack/smp/smp_utils.c @@ -314,7 +314,7 @@ BOOLEAN smp_send_cmd(UINT8 cmd_code, tSMP_CB *p_cb) BT_HDR *p_buf; BOOLEAN sent = FALSE; UINT8 failure = SMP_PAIR_INTERNAL_ERR; - SMP_TRACE_EVENT("smp_send_cmd on l2cap cmd_code=0x%x", cmd_code); + SMP_TRACE_EVENT("smp_send_cmd on l2cap cmd_code=0x%x\n", cmd_code); if ( cmd_code <= (SMP_OPCODE_MAX + 1 /* for SMP_OPCODE_PAIR_COMMITM */) && smp_cmd_build_act[cmd_code] != NULL) { @@ -418,7 +418,7 @@ static BT_HDR * smp_build_confirm_cmd(UINT8 cmd_code, tSMP_CB *p_cb) UINT8 *p; UNUSED(cmd_code); - SMP_TRACE_EVENT("smp_build_confirm_cmd"); + SMP_TRACE_EVENT("smp_build_confirm_cmd\n"); if ((p_buf = (BT_HDR *)GKI_getbuf(sizeof(BT_HDR) + SMP_CONFIRM_CMD_SIZE + L2CAP_MIN_OFFSET)) != NULL) { p = (UINT8 *)(p_buf + 1) + L2CAP_MIN_OFFSET; @@ -445,7 +445,7 @@ static BT_HDR * smp_build_rand_cmd(UINT8 cmd_code, tSMP_CB *p_cb) UINT8 *p; UNUSED(cmd_code); - SMP_TRACE_EVENT("%s", __func__); + SMP_TRACE_EVENT("%s\n", __func__); if ((p_buf = (BT_HDR *)GKI_getbuf(sizeof(BT_HDR) + SMP_RAND_CMD_SIZE + L2CAP_MIN_OFFSET)) != NULL) { @@ -473,7 +473,7 @@ static BT_HDR * smp_build_encrypt_info_cmd(UINT8 cmd_code, tSMP_CB *p_cb) UINT8 *p; UNUSED(cmd_code); - SMP_TRACE_EVENT("smp_build_encrypt_info_cmd"); + SMP_TRACE_EVENT("smp_build_encrypt_info_cmd\n"); if ((p_buf = (BT_HDR *)GKI_getbuf(sizeof(BT_HDR) + SMP_ENC_INFO_SIZE + L2CAP_MIN_OFFSET)) != NULL) { p = (UINT8 *)(p_buf + 1) + L2CAP_MIN_OFFSET; @@ -501,7 +501,7 @@ static BT_HDR * smp_build_master_id_cmd(UINT8 cmd_code, tSMP_CB *p_cb) UINT8 *p; UNUSED(cmd_code); - SMP_TRACE_EVENT("%s", __func__); + SMP_TRACE_EVENT("%s\n", __func__); if ((p_buf = (BT_HDR *)GKI_getbuf(sizeof(BT_HDR) + SMP_MASTER_ID_SIZE + L2CAP_MIN_OFFSET)) != NULL) { @@ -533,7 +533,7 @@ static BT_HDR * smp_build_identity_info_cmd(UINT8 cmd_code, tSMP_CB *p_cb) UNUSED(cmd_code); UNUSED(p_cb); - SMP_TRACE_EVENT("smp_build_identity_info_cmd"); + SMP_TRACE_EVENT("smp_build_identity_info_cmd\n"); if ((p_buf = (BT_HDR *)GKI_getbuf(sizeof(BT_HDR) + SMP_ID_INFO_SIZE + L2CAP_MIN_OFFSET)) != NULL) { p = (UINT8 *)(p_buf + 1) + L2CAP_MIN_OFFSET; @@ -564,7 +564,7 @@ static BT_HDR * smp_build_id_addr_cmd(UINT8 cmd_code, tSMP_CB *p_cb) UNUSED(cmd_code); UNUSED(p_cb); - SMP_TRACE_EVENT("smp_build_id_addr_cmd"); + SMP_TRACE_EVENT("smp_build_id_addr_cmd\n"); if ((p_buf = (BT_HDR *)GKI_getbuf(sizeof(BT_HDR) + SMP_ID_ADDR_SIZE + L2CAP_MIN_OFFSET)) != NULL) { p = (UINT8 *)(p_buf + 1) + L2CAP_MIN_OFFSET; @@ -593,7 +593,7 @@ static BT_HDR * smp_build_signing_info_cmd(UINT8 cmd_code, tSMP_CB *p_cb) UINT8 *p; UNUSED(cmd_code); - SMP_TRACE_EVENT("smp_build_signing_info_cmd"); + SMP_TRACE_EVENT("smp_build_signing_info_cmd\n"); if ((p_buf = (BT_HDR *)GKI_getbuf(sizeof(BT_HDR) + SMP_SIGN_INFO_SIZE + L2CAP_MIN_OFFSET)) != NULL) { p = (UINT8 *)(p_buf + 1) + L2CAP_MIN_OFFSET; @@ -621,7 +621,7 @@ static BT_HDR * smp_build_pairing_fail(UINT8 cmd_code, tSMP_CB *p_cb) UINT8 *p; UNUSED(cmd_code); - SMP_TRACE_EVENT("%s", __func__); + SMP_TRACE_EVENT("%s\n", __func__); if ((p_buf = (BT_HDR *)GKI_getbuf(sizeof(BT_HDR) + SMP_PAIR_FAIL_SIZE + L2CAP_MIN_OFFSET)) != NULL) { p = (UINT8 *)(p_buf + 1) + L2CAP_MIN_OFFSET; @@ -649,7 +649,7 @@ static BT_HDR *smp_build_security_request(UINT8 cmd_code, tSMP_CB *p_cb) UINT8 *p; UNUSED(cmd_code); - SMP_TRACE_EVENT("%s", __func__); + SMP_TRACE_EVENT("%s\n", __func__); if ((p_buf = (BT_HDR *)GKI_getbuf(sizeof(BT_HDR) + 2 + L2CAP_MIN_OFFSET)) != NULL) { p = (UINT8 *)(p_buf + 1) + L2CAP_MIN_OFFSET; @@ -682,7 +682,7 @@ static BT_HDR *smp_build_pair_public_key_cmd(UINT8 cmd_code, tSMP_CB *p_cb) UINT8 *p_publ_key = publ_key; UNUSED(cmd_code); - SMP_TRACE_EVENT("%s", __FUNCTION__); + SMP_TRACE_EVENT("%s\n", __FUNCTION__); memcpy(p_publ_key, p_cb->loc_publ_key.x, BT_OCTET32_LEN); memcpy(p_publ_key + BT_OCTET32_LEN, p_cb->loc_publ_key.y, BT_OCTET32_LEN); @@ -715,7 +715,7 @@ static BT_HDR *smp_build_pairing_commitment_cmd(UINT8 cmd_code, tSMP_CB *p_cb) UINT8 *p; UNUSED(cmd_code); - SMP_TRACE_EVENT("%s", __func__); + SMP_TRACE_EVENT("%s\n", __func__); if ((p_buf = (BT_HDR *)GKI_getbuf(sizeof(BT_HDR) + SMP_PAIR_COMMITM_SIZE + L2CAP_MIN_OFFSET)) != NULL) { @@ -744,7 +744,7 @@ static BT_HDR *smp_build_pair_dhkey_check_cmd(UINT8 cmd_code, tSMP_CB *p_cb) UINT8 *p; UNUSED(cmd_code); - SMP_TRACE_EVENT("%s", __FUNCTION__); + SMP_TRACE_EVENT("%s\n", __FUNCTION__); if ((p_buf = (BT_HDR *)GKI_getbuf(sizeof(BT_HDR) + SMP_PAIR_DHKEY_CHECK_SIZE + L2CAP_MIN_OFFSET)) != NULL) { @@ -773,7 +773,7 @@ static BT_HDR * smp_build_pairing_keypress_notification_cmd(UINT8 cmd_code, tSMP UINT8 *p; UNUSED(cmd_code); - SMP_TRACE_EVENT("%s", __FUNCTION__); + SMP_TRACE_EVENT("%s\n", __FUNCTION__); if ((p_buf = (BT_HDR *)GKI_getbuf(sizeof(BT_HDR)\ + SMP_PAIR_KEYPR_NOTIF_SIZE + L2CAP_MIN_OFFSET)) != NULL) { @@ -804,7 +804,7 @@ void smp_convert_string_to_tk(BT_OCTET16 tk, UINT32 passkey) { UINT8 *p = tk; tSMP_KEY key; - SMP_TRACE_EVENT("smp_convert_string_to_tk"); + SMP_TRACE_EVENT("smp_convert_string_to_tk\n"); UINT32_TO_STREAM(p, passkey); key.key_type = SMP_KEY_TYPE_TK; @@ -826,7 +826,7 @@ void smp_convert_string_to_tk(BT_OCTET16 tk, UINT32 passkey) *******************************************************************************/ void smp_mask_enc_key(UINT8 loc_enc_size, UINT8 * p_data) { - SMP_TRACE_EVENT("smp_mask_enc_key"); + SMP_TRACE_EVENT("smp_mask_enc_key\n"); if (loc_enc_size < BT_OCTET16_LEN) { for (; loc_enc_size < BT_OCTET16_LEN; loc_enc_size ++) @@ -849,7 +849,7 @@ void smp_xor_128(BT_OCTET16 a, BT_OCTET16 b) { UINT8 i, *aa = a, *bb = b; - SMP_TRACE_EVENT("smp_xor_128"); + SMP_TRACE_EVENT("smp_xor_128\n"); for (i = 0; i < BT_OCTET16_LEN; i++) { aa[i] = aa[i] ^ bb[i]; @@ -870,7 +870,7 @@ void smp_cb_cleanup(tSMP_CB *p_cb) tSMP_CALLBACK *p_callback = p_cb->p_callback; UINT8 trace_level = p_cb->trace_level; - SMP_TRACE_EVENT("smp_cb_cleanup"); + SMP_TRACE_EVENT("smp_cb_cleanup\n"); memset(p_cb, 0, sizeof(tSMP_CB)); p_cb->p_callback = p_callback; @@ -888,7 +888,7 @@ void smp_cb_cleanup(tSMP_CB *p_cb) *******************************************************************************/ void smp_remove_fixed_channel(tSMP_CB *p_cb) { - SMP_TRACE_DEBUG("%s", __func__); + SMP_TRACE_DEBUG("%s\n", __func__); if (p_cb->smp_over_br) L2CA_RemoveFixedChnl (L2CAP_SMP_BR_CID, p_cb->pairing_bda); @@ -909,7 +909,7 @@ void smp_remove_fixed_channel(tSMP_CB *p_cb) *******************************************************************************/ void smp_reset_control_value(tSMP_CB *p_cb) { - SMP_TRACE_EVENT("smp_reset_control_value"); + SMP_TRACE_EVENT("smp_reset_control_value\n"); btu_stop_timer (&p_cb->rsp_timer_ent); p_cb->flags = 0; /* set the link idle timer to drop the link when pairing is done @@ -939,7 +939,7 @@ void smp_proc_pairing_cmpl(tSMP_CB *p_cb) tSMP_CALLBACK *p_callback = p_cb->p_callback; BD_ADDR pairing_bda; - SMP_TRACE_DEBUG ("smp_proc_pairing_cmpl "); + SMP_TRACE_DEBUG ("smp_proc_pairing_cmpl \n"); evt_data.cmplt.reason = p_cb->status; evt_data.cmplt.smp_over_br = p_cb->smp_over_br; @@ -953,7 +953,7 @@ void smp_proc_pairing_cmpl(tSMP_CB *p_cb) evt_data.cmplt.is_pair_cancel = TRUE; - SMP_TRACE_DEBUG ("send SMP_COMPLT_EVT reason=0x%0x sec_level=0x%0x", + SMP_TRACE_DEBUG ("send SMP_COMPLT_EVT reason=0x%0x sec_level=0x%0x\n", evt_data.cmplt.reason, evt_data.cmplt.sec_level ); @@ -981,12 +981,12 @@ BOOLEAN smp_command_has_invalid_parameters(tSMP_CB *p_cb) { UINT8 cmd_code = p_cb->rcvd_cmd_code; - SMP_TRACE_DEBUG("%s for cmd code 0x%02x", __func__, cmd_code); + SMP_TRACE_DEBUG("%s for cmd code 0x%02x\n", __func__, cmd_code); if ((cmd_code > (SMP_OPCODE_MAX + 1 /* for SMP_OPCODE_PAIR_COMMITM */)) || (cmd_code < SMP_OPCODE_MIN)) { - SMP_TRACE_WARNING("Somehow received command with the RESERVED code 0x%02x", cmd_code); + SMP_TRACE_WARNING("Somehow received command with the RESERVED code 0x%02x\n", cmd_code); return TRUE; } @@ -1014,12 +1014,12 @@ BOOLEAN smp_command_has_valid_fixed_length(tSMP_CB *p_cb) { UINT8 cmd_code = p_cb->rcvd_cmd_code; - SMP_TRACE_DEBUG("%s for cmd code 0x%02x", __func__, cmd_code); + SMP_TRACE_DEBUG("%s for cmd code 0x%02x\n", __func__, cmd_code); if (p_cb->rcvd_cmd_len != smp_cmd_size_per_spec[cmd_code]) { SMP_TRACE_WARNING("Rcvd from the peer cmd 0x%02x with invalid length\ - 0x%02x (per spec the length is 0x%02x).", + 0x%02x (per spec the length is 0x%02x).\n", cmd_code, p_cb->rcvd_cmd_len, smp_cmd_size_per_spec[cmd_code]); return FALSE; } @@ -1048,12 +1048,12 @@ BOOLEAN smp_pairing_request_response_parameters_are_valid(tSMP_CB *p_cb) UINT8 bond_flag = p_cb->peer_auth_req & 0x03; //0x03 is gen bond with appropriate mask UINT8 enc_size = p_cb->peer_enc_size; - SMP_TRACE_DEBUG("%s for cmd code 0x%02x", __func__, p_cb->rcvd_cmd_code); + SMP_TRACE_DEBUG("%s for cmd code 0x%02x\n", __func__, p_cb->rcvd_cmd_code); if (io_caps >= BTM_IO_CAP_MAX) { SMP_TRACE_WARNING("Rcvd from the peer cmd 0x%02x with IO Capabilty \ - value (0x%02x) out of range).", + value (0x%02x) out of range).\n", p_cb->rcvd_cmd_code, io_caps); return FALSE; } @@ -1061,7 +1061,7 @@ BOOLEAN smp_pairing_request_response_parameters_are_valid(tSMP_CB *p_cb) if (!((oob_flag == SMP_OOB_NONE) || (oob_flag == SMP_OOB_PRESENT))) { SMP_TRACE_WARNING("Rcvd from the peer cmd 0x%02x with OOB data flag value \ - (0x%02x) out of range).", + (0x%02x) out of range).\n", p_cb->rcvd_cmd_code, oob_flag); return FALSE; } @@ -1069,7 +1069,7 @@ BOOLEAN smp_pairing_request_response_parameters_are_valid(tSMP_CB *p_cb) if (!((bond_flag == SMP_AUTH_NO_BOND) || (bond_flag == SMP_AUTH_BOND))) { SMP_TRACE_WARNING("Rcvd from the peer cmd 0x%02x with Bonding_Flags value (0x%02x)\ - out of range).", + out of range).\n", p_cb->rcvd_cmd_code, bond_flag); return FALSE; } @@ -1077,7 +1077,7 @@ BOOLEAN smp_pairing_request_response_parameters_are_valid(tSMP_CB *p_cb) if ((enc_size < SMP_ENCR_KEY_SIZE_MIN) || (enc_size > SMP_ENCR_KEY_SIZE_MAX)) { SMP_TRACE_WARNING("Rcvd from the peer cmd 0x%02x with Maximum Encryption \ - Key value (0x%02x) out of range).", + Key value (0x%02x) out of range).\n", p_cb->rcvd_cmd_code, enc_size); return FALSE; } @@ -1098,12 +1098,12 @@ BOOLEAN smp_pairing_keypress_notification_is_valid(tSMP_CB *p_cb) { tBTM_SP_KEY_TYPE keypress_notification = p_cb->peer_keypress_notification; - SMP_TRACE_DEBUG("%s for cmd code 0x%02x", __func__, p_cb->rcvd_cmd_code); + SMP_TRACE_DEBUG("%s for cmd code 0x%02x\n", __func__, p_cb->rcvd_cmd_code); if (keypress_notification >= BTM_SP_KEY_OUT_OF_RANGE) { SMP_TRACE_WARNING("Rcvd from the peer cmd 0x%02x with Pairing Keypress \ - Notification value (0x%02x) out of range).", + Notification value (0x%02x) out of range).\n", p_cb->rcvd_cmd_code, keypress_notification); return FALSE; } @@ -1150,7 +1150,7 @@ void smp_reject_unexpected_pairing_command(BD_ADDR bd_addr) BT_HDR *p_buf; UINT8 *p; - SMP_TRACE_DEBUG ("%s", __FUNCTION__); + SMP_TRACE_DEBUG ("%s\n", __FUNCTION__); if ((p_buf = (BT_HDR *)GKI_getbuf(sizeof(BT_HDR) +\ SMP_PAIR_FAIL_SIZE + L2CAP_MIN_OFFSET)) != NULL) @@ -1188,14 +1188,14 @@ tSMP_ASSO_MODEL smp_select_association_model(tSMP_CB *p_cb) tSMP_ASSO_MODEL model = SMP_MODEL_OUT_OF_RANGE; p_cb->le_secure_connections_mode_is_used = FALSE; - SMP_TRACE_EVENT("%s", __FUNCTION__); - SMP_TRACE_DEBUG("%s p_cb->peer_io_caps = %d p_cb->local_io_capability = %d", + SMP_TRACE_EVENT("%s\n", __FUNCTION__); + SMP_TRACE_DEBUG("%s p_cb->peer_io_caps = %d p_cb->local_io_capability = %d\n", __FUNCTION__, p_cb->peer_io_caps, p_cb->local_io_capability); - SMP_TRACE_DEBUG("%s p_cb->peer_oob_flag = %d p_cb->loc_oob_flag = %d", + SMP_TRACE_DEBUG("%s p_cb->peer_oob_flag = %d p_cb->loc_oob_flag = %d\n", __FUNCTION__, p_cb->peer_oob_flag, p_cb->loc_oob_flag); - SMP_TRACE_DEBUG("%s p_cb->peer_auth_req = 0x%02x p_cb->loc_auth_req = 0x%02x", + SMP_TRACE_DEBUG("%s p_cb->peer_auth_req = 0x%02x p_cb->loc_auth_req = 0x%02x\n", __FUNCTION__, p_cb->peer_auth_req, p_cb->loc_auth_req); - SMP_TRACE_DEBUG("%s p_cb->secure_connections_only_mode_required = %s", + SMP_TRACE_DEBUG("%s p_cb->secure_connections_only_mode_required = %s\n", __FUNCTION__, p_cb->secure_connections_only_mode_required ? "TRUE" : "FALSE"); @@ -1204,7 +1204,7 @@ tSMP_ASSO_MODEL smp_select_association_model(tSMP_CB *p_cb) p_cb->le_secure_connections_mode_is_used = TRUE; } - SMP_TRACE_DEBUG("use_sc_process = %d", p_cb->le_secure_connections_mode_is_used); + SMP_TRACE_DEBUG("use_sc_process = %d\n", p_cb->le_secure_connections_mode_is_used); if (p_cb->le_secure_connections_mode_is_used) { @@ -1228,7 +1228,7 @@ tSMP_ASSO_MODEL smp_select_legacy_association_model(tSMP_CB *p_cb) { tSMP_ASSO_MODEL model = SMP_MODEL_OUT_OF_RANGE; - SMP_TRACE_DEBUG("%s", __func__); + SMP_TRACE_DEBUG("%s\n", __func__); /* if OOB data is present on both devices, then use OOB association model */ if (p_cb->peer_oob_flag == SMP_OOB_PRESENT && p_cb->loc_oob_flag == SMP_OOB_PRESENT) return SMP_MODEL_OOB; @@ -1266,7 +1266,7 @@ tSMP_ASSO_MODEL smp_select_association_model_secure_connections(tSMP_CB *p_cb) { tSMP_ASSO_MODEL model = SMP_MODEL_OUT_OF_RANGE; - SMP_TRACE_DEBUG("%s", __func__); + SMP_TRACE_DEBUG("%s\n", __func__); /* if OOB data is present on at least one device, then use OOB association model */ if (p_cb->peer_oob_flag == SMP_OOB_PRESENT || p_cb->loc_oob_flag == SMP_OOB_PRESENT) return SMP_MODEL_SEC_CONN_OOB; @@ -1303,7 +1303,7 @@ void smp_reverse_array(UINT8 *arr, UINT8 len) { UINT8 i =0, tmp; - SMP_TRACE_DEBUG("smp_reverse_array"); + SMP_TRACE_DEBUG("smp_reverse_array\n"); for (i = 0; i < len/2; i ++) { @@ -1330,9 +1330,9 @@ UINT8 smp_calculate_random_input(UINT8 *random, UINT8 round) UINT8 j = round%8; UINT8 ri; - SMP_TRACE_DEBUG("random: 0x%02x, round: %d, i: %d, j: %d", random[i], round, i, j); + SMP_TRACE_DEBUG("random: 0x%02x, round: %d, i: %d, j: %d\n", random[i], round, i, j); ri = ((random[i] >> j) & 1) | 0x80; - SMP_TRACE_DEBUG("%s ri=0x%02x", __func__, ri); + SMP_TRACE_DEBUG("%s ri=0x%02x\n", __func__, ri); return ri; } @@ -1347,7 +1347,7 @@ UINT8 smp_calculate_random_input(UINT8 *random, UINT8 round) *******************************************************************************/ void smp_collect_local_io_capabilities(UINT8 *iocap, tSMP_CB *p_cb) { - SMP_TRACE_DEBUG("%s", __func__); + SMP_TRACE_DEBUG("%s\n", __func__); iocap[0] = p_cb->local_io_capability; iocap[1] = p_cb->loc_oob_flag; @@ -1365,7 +1365,7 @@ void smp_collect_local_io_capabilities(UINT8 *iocap, tSMP_CB *p_cb) *******************************************************************************/ void smp_collect_peer_io_capabilities(UINT8 *iocap, tSMP_CB *p_cb) { - SMP_TRACE_DEBUG("%s", __func__); + SMP_TRACE_DEBUG("%s\n", __func__); iocap[0] = p_cb->peer_io_caps; iocap[1] = p_cb->peer_oob_flag; @@ -1388,7 +1388,7 @@ void smp_collect_local_ble_address(UINT8 *le_addr, tSMP_CB *p_cb) BD_ADDR bda; UINT8 *p = le_addr; - SMP_TRACE_DEBUG("%s", __func__); + SMP_TRACE_DEBUG("%s\n", __func__); BTM_ReadConnectionAddr( p_cb->pairing_bda, bda, &addr_type); BDADDR_TO_STREAM(p, bda); @@ -1411,11 +1411,11 @@ void smp_collect_peer_ble_address(UINT8 *le_addr, tSMP_CB *p_cb) BD_ADDR bda; UINT8 *p = le_addr; - SMP_TRACE_DEBUG("%s", __func__); + SMP_TRACE_DEBUG("%s\n", __func__); if (!BTM_ReadRemoteConnectionAddr(p_cb->pairing_bda, bda, &addr_type)) { - SMP_TRACE_ERROR("can not collect peer le addr information for unknown device"); + SMP_TRACE_ERROR("can not collect peer le addr information for unknown device\n"); return; } @@ -1438,7 +1438,7 @@ BOOLEAN smp_check_commitment(tSMP_CB *p_cb) { BT_OCTET16 expected; - SMP_TRACE_DEBUG("%s", __func__); + SMP_TRACE_DEBUG("%s\n", __func__); smp_calculate_peer_commitment(p_cb, expected); print128(expected, (const UINT8 *)"calculated peer commitment"); @@ -1446,11 +1446,11 @@ BOOLEAN smp_check_commitment(tSMP_CB *p_cb) if (memcmp(p_cb->remote_commitment, expected, BT_OCTET16_LEN)) { - SMP_TRACE_WARNING("Commitment check fails"); + SMP_TRACE_WARNING("Commitment check fails\n"); return FALSE; } - SMP_TRACE_DEBUG("Commitment check succeeds"); + SMP_TRACE_DEBUG("Commitment check succeeds\n"); return TRUE; } @@ -1469,14 +1469,14 @@ void smp_save_secure_connections_long_term_key(tSMP_CB *p_cb) tBTM_LE_LENC_KEYS lle_key; tBTM_LE_PENC_KEYS ple_key; - SMP_TRACE_DEBUG("%s-Save LTK as local LTK key", __func__); + SMP_TRACE_DEBUG("%s-Save LTK as local LTK key\n", __func__); memcpy(lle_key.ltk, p_cb->ltk, BT_OCTET16_LEN); lle_key.div = 0; lle_key.key_size = p_cb->loc_enc_size; lle_key.sec_level = p_cb->sec_level; btm_sec_save_le_key(p_cb->pairing_bda, BTM_LE_KEY_LENC, (tBTM_LE_KEY_VALUE *)&lle_key, TRUE); - SMP_TRACE_DEBUG("%s-Save LTK as peer LTK key", __func__); + SMP_TRACE_DEBUG("%s-Save LTK as peer LTK key\n", __func__); ple_key.ediv = 0; memset(ple_key.rand, 0, BT_OCTET8_LEN); memcpy(ple_key.ltk, p_cb->ltk, BT_OCTET16_LEN); @@ -1504,7 +1504,7 @@ BOOLEAN smp_calculate_f5_mackey_and_long_term_key(tSMP_CB *p_cb) UINT8 *p_na; UINT8 *p_nb; - SMP_TRACE_DEBUG("%s", __func__); + SMP_TRACE_DEBUG("%s\n", __func__); if (p_cb->role == HCI_ROLE_MASTER) { @@ -1523,11 +1523,11 @@ BOOLEAN smp_calculate_f5_mackey_and_long_term_key(tSMP_CB *p_cb) if(!smp_calculate_f5(p_cb->dhkey, p_na, p_nb, a, b, p_cb->mac_key, p_cb->ltk)) { - SMP_TRACE_ERROR("%s failed", __func__); + SMP_TRACE_ERROR("%s failed\n", __func__); return FALSE; } - SMP_TRACE_EVENT ("%s is completed", __func__); + SMP_TRACE_EVENT ("%s is completed\n", __func__); return TRUE; } @@ -1545,7 +1545,7 @@ BOOLEAN smp_request_oob_data(tSMP_CB *p_cb) { tSMP_OOB_DATA_TYPE req_oob_type = SMP_OOB_INVALID_TYPE; - SMP_TRACE_DEBUG("%s", __func__); + SMP_TRACE_DEBUG("%s\n", __func__); if (p_cb->peer_oob_flag == SMP_OOB_PRESENT && p_cb->loc_oob_flag == SMP_OOB_PRESENT) { @@ -1562,7 +1562,7 @@ BOOLEAN smp_request_oob_data(tSMP_CB *p_cb) req_oob_type = SMP_OOB_PEER; } - SMP_TRACE_DEBUG("req_oob_type = %d", req_oob_type); + SMP_TRACE_DEBUG("req_oob_type = %d\n", req_oob_type); if (req_oob_type == SMP_OOB_INVALID_TYPE) return FALSE; diff --git a/components/bt/bt.c b/components/bt/bt.c index 23f8aea92e..051a45d8fd 100644 --- a/components/bt/bt.c +++ b/components/bt/bt.c @@ -1,134 +1,134 @@ -// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at - -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include -#include -#include - -#include "freertos/FreeRTOS.h" -#include "freertos/task.h" -#include "freertos/queue.h" -#include "freertos/semphr.h" -#include "freertos/xtensa_api.h" -#include "freertos/portmacro.h" -#include "esp_types.h" -#include "esp_system.h" -#include "esp_task.h" -#include "esp_intr.h" -#include "esp_attr.h" -#include "bt.h" - -#if CONFIG_BT_ENABLED - -/* not for user call, so don't put to include file */ -extern void btdm_osi_funcs_register(void *osi_funcs); -extern void btdm_controller_init(void); - - -#define BT_DEBUG(...) -#define BT_API_CALL_CHECK(info, api_call, ret) \ -do{\ - esp_err_t __err = (api_call);\ - if ((ret) != __err) {\ - BT_DEBUG("%s %d %s ret=%d\n", __FUNCTION__, __LINE__, (info), __err);\ - return __err;\ - }\ -} while(0) - -struct osi_funcs_t { - xt_handler (*_set_isr)(int n, xt_handler f, void *arg); - void (*_ints_on)(unsigned int mask); - void (*_interrupt_disable)(void); - void (*_interrupt_restore)(void); - void (*_task_yield)(void); - void *(*_semphr_create)(uint32_t max, uint32_t init); - int32_t (*_semphr_give_from_isr)(void *semphr, void *hptw); - int32_t (*_semphr_take)(void *semphr, uint32_t block_time_ms); - void *(*_mutex_create)(void); - int32_t (*_mutex_lock)(void *mutex); - int32_t (*_mutex_unlock)(void *mutex); - esp_err_t (* _read_efuse_mac)(uint8_t mac[6]); -}; - -static portMUX_TYPE global_int_mux = portMUX_INITIALIZER_UNLOCKED; - -static void IRAM_ATTR interrupt_disable(void) -{ - portENTER_CRITICAL(&global_int_mux); -} - -static void IRAM_ATTR interrupt_restore(void) -{ - portEXIT_CRITICAL(&global_int_mux); -} - -static void * IRAM_ATTR semphr_create_wrapper(uint32_t max, uint32_t init) -{ - return (void *)xSemaphoreCreateCounting(max, init); -} - -static int32_t IRAM_ATTR semphr_give_from_isr_wrapper(void *semphr, void *hptw) -{ - return (int32_t)xSemaphoreGiveFromISR(semphr, hptw); -} - -static int32_t IRAM_ATTR semphr_take_wrapper(void *semphr, uint32_t block_time_ms) -{ - return (int32_t)xSemaphoreTake(semphr, block_time_ms / portTICK_RATE_MS); -} - -static void * IRAM_ATTR mutex_create_wrapper(void) -{ - return (void *)xSemaphoreCreateMutex(); -} - -static int32_t IRAM_ATTR mutex_lock_wrapper(void *mutex) -{ - return (int32_t)xSemaphoreTake(mutex, portMAX_DELAY); -} - -static int32_t IRAM_ATTR mutex_unlock_wrapper(void *mutex) -{ - return (int32_t)xSemaphoreGive(mutex); -} - -static struct osi_funcs_t osi_funcs = { - ._set_isr = xt_set_interrupt_handler, - ._ints_on = xt_ints_on, - ._interrupt_disable = interrupt_disable, - ._interrupt_restore = interrupt_restore, - ._task_yield = vPortYield, - ._semphr_create = semphr_create_wrapper, - ._semphr_give_from_isr = semphr_give_from_isr_wrapper, - ._semphr_take = semphr_take_wrapper, - ._mutex_create = mutex_create_wrapper, - ._mutex_lock = mutex_lock_wrapper, - ._mutex_unlock = mutex_unlock_wrapper, - ._read_efuse_mac = system_efuse_read_mac, -}; - -static void bt_controller_task(void *pvParam) -{ - btdm_osi_funcs_register(&osi_funcs); - btdm_controller_init(); -} - -void bt_controller_init() -{ - xTaskCreatePinnedToCore(bt_controller_task, "btController", - ESP_TASK_BT_CONTROLLER_STACK, NULL, - ESP_TASK_BT_CONTROLLER_PRIO, NULL, 0); -} - -#endif +// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at + +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include +#include +#include + +#include "freertos/FreeRTOS.h" +#include "freertos/task.h" +#include "freertos/queue.h" +#include "freertos/semphr.h" +#include "freertos/xtensa_api.h" +#include "freertos/portmacro.h" +#include "esp_types.h" +#include "esp_system.h" +#include "esp_task.h" +#include "esp_intr.h" +#include "esp_attr.h" +#include "bt.h" + +#if CONFIG_BT_ENABLED + +/* not for user call, so don't put to include file */ +extern void btdm_osi_funcs_register(void *osi_funcs); +extern void btdm_controller_init(void); + + +#define BT_DEBUG(...) +#define BT_API_CALL_CHECK(info, api_call, ret) \ +do{\ + esp_err_t __err = (api_call);\ + if ((ret) != __err) {\ + BT_DEBUG("%s %d %s ret=%d\n", __FUNCTION__, __LINE__, (info), __err);\ + return __err;\ + }\ +} while(0) + +struct osi_funcs_t { + xt_handler (*_set_isr)(int n, xt_handler f, void *arg); + void (*_ints_on)(unsigned int mask); + void (*_interrupt_disable)(void); + void (*_interrupt_restore)(void); + void (*_task_yield)(void); + void *(*_semphr_create)(uint32_t max, uint32_t init); + int32_t (*_semphr_give_from_isr)(void *semphr, void *hptw); + int32_t (*_semphr_take)(void *semphr, uint32_t block_time_ms); + void *(*_mutex_create)(void); + int32_t (*_mutex_lock)(void *mutex); + int32_t (*_mutex_unlock)(void *mutex); + esp_err_t (* _read_efuse_mac)(uint8_t mac[6]); +}; + +static portMUX_TYPE global_int_mux = portMUX_INITIALIZER_UNLOCKED; + +static void IRAM_ATTR interrupt_disable(void) +{ + portENTER_CRITICAL(&global_int_mux); +} + +static void IRAM_ATTR interrupt_restore(void) +{ + portEXIT_CRITICAL(&global_int_mux); +} + +static void * IRAM_ATTR semphr_create_wrapper(uint32_t max, uint32_t init) +{ + return (void *)xSemaphoreCreateCounting(max, init); +} + +static int32_t IRAM_ATTR semphr_give_from_isr_wrapper(void *semphr, void *hptw) +{ + return (int32_t)xSemaphoreGiveFromISR(semphr, hptw); +} + +static int32_t IRAM_ATTR semphr_take_wrapper(void *semphr, uint32_t block_time_ms) +{ + return (int32_t)xSemaphoreTake(semphr, block_time_ms / portTICK_RATE_MS); +} + +static void * IRAM_ATTR mutex_create_wrapper(void) +{ + return (void *)xSemaphoreCreateMutex(); +} + +static int32_t IRAM_ATTR mutex_lock_wrapper(void *mutex) +{ + return (int32_t)xSemaphoreTake(mutex, portMAX_DELAY); +} + +static int32_t IRAM_ATTR mutex_unlock_wrapper(void *mutex) +{ + return (int32_t)xSemaphoreGive(mutex); +} + +static struct osi_funcs_t osi_funcs = { + ._set_isr = xt_set_interrupt_handler, + ._ints_on = xt_ints_on, + ._interrupt_disable = interrupt_disable, + ._interrupt_restore = interrupt_restore, + ._task_yield = vPortYield, + ._semphr_create = semphr_create_wrapper, + ._semphr_give_from_isr = semphr_give_from_isr_wrapper, + ._semphr_take = semphr_take_wrapper, + ._mutex_create = mutex_create_wrapper, + ._mutex_lock = mutex_lock_wrapper, + ._mutex_unlock = mutex_unlock_wrapper, + ._read_efuse_mac = system_efuse_read_mac, +}; + +static void bt_controller_task(void *pvParam) +{ + btdm_osi_funcs_register(&osi_funcs); + btdm_controller_init(); +} + +void bt_controller_init() +{ + xTaskCreatePinnedToCore(bt_controller_task, "btController", + ESP_TASK_BT_CONTROLLER_STACK, NULL, + ESP_TASK_BT_CONTROLLER_PRIO, NULL, 0); +} + +#endif