From 6648ff427cfa41f23c232731bdd132272e961d43 Mon Sep 17 00:00:00 2001 From: Tian Hao Date: Thu, 16 Feb 2017 14:10:44 +0800 Subject: [PATCH] component/bt : fix connection bug of Iphone7 10.0.2 This connection error caused by iPhone, it think that TX data length must large than 27 when slave support EXTEND_DATA_LENGTH. But this should be allow. Besides, the problem cannot be found on higher version of Iphone7, apple seemed to have fixed it. Actually maybe other BLE device have the same problem. --- components/bt/bluedroid/device/controller.c | 4 ++++ components/bt/bluedroid/hci/hci_packet_factory.c | 12 ++++++++++++ .../bt/bluedroid/hci/include/hci_packet_factory.h | 1 + 3 files changed, 17 insertions(+) diff --git a/components/bt/bluedroid/device/controller.c b/components/bt/bluedroid/device/controller.c index c7fc98d6c8..08564052d8 100644 --- a/components/bt/bluedroid/device/controller.c +++ b/components/bt/bluedroid/device/controller.c @@ -221,6 +221,10 @@ static void start_up(void) } if (HCI_LE_DATA_LEN_EXT_SUPPORTED(features_ble.as_array)) { + /* set default tx data length to MAX 251 */ + response = AWAIT_COMMAND(packet_factory->make_ble_write_suggested_default_data_length(BTM_BLE_DATA_SIZE_MAX, BTM_BLE_DATA_TX_TIME_MAX)); + packet_parser->parse_generic_command_complete(response); + response = AWAIT_COMMAND(packet_factory->make_ble_read_suggested_default_data_length()); packet_parser->parse_ble_read_suggested_default_data_length_response( response, diff --git a/components/bt/bluedroid/hci/hci_packet_factory.c b/components/bt/bluedroid/hci/hci_packet_factory.c index 6d5592b758..c4bb96b162 100644 --- a/components/bt/bluedroid/hci/hci_packet_factory.c +++ b/components/bt/bluedroid/hci/hci_packet_factory.c @@ -154,6 +154,17 @@ static BT_HDR *make_ble_read_suggested_default_data_length(void) return make_command_no_params(HCI_BLE_READ_DEFAULT_DATA_LENGTH); } +static BT_HDR *make_ble_write_suggested_default_data_length(uint16_t SuggestedMaxTxOctets, uint16_t SuggestedMaxTxTime) +{ + uint8_t *stream; + uint8_t parameter_size = sizeof(uint16_t) + sizeof(uint16_t); + BT_HDR *packet = make_command(HCI_BLE_WRITE_DEFAULT_DATA_LENGTH, parameter_size, &stream); + + UINT16_TO_STREAM(stream, SuggestedMaxTxOctets); + UINT16_TO_STREAM(stream, SuggestedMaxTxTime); + return packet; +} + static BT_HDR *make_ble_set_event_mask(const bt_event_mask_t *event_mask) { uint8_t *stream; @@ -215,6 +226,7 @@ static const hci_packet_factory_t interface = { make_ble_read_local_supported_features, make_ble_read_resolving_list_size, make_ble_read_suggested_default_data_length, + make_ble_write_suggested_default_data_length, make_ble_set_event_mask }; diff --git a/components/bt/bluedroid/hci/include/hci_packet_factory.h b/components/bt/bluedroid/hci/include/hci_packet_factory.h index 879962c2fc..11f0053a58 100644 --- a/components/bt/bluedroid/hci/include/hci_packet_factory.h +++ b/components/bt/bluedroid/hci/include/hci_packet_factory.h @@ -40,6 +40,7 @@ typedef struct { BT_HDR *(*make_ble_read_local_supported_features)(void); BT_HDR *(*make_ble_read_resolving_list_size)(void); BT_HDR *(*make_ble_read_suggested_default_data_length)(void); + BT_HDR *(*make_ble_write_suggested_default_data_length)(uint16_t SuggestedMaxTxOctets, uint16_t SuggestedMaxTxTime); BT_HDR *(*make_ble_set_event_mask)(const bt_event_mask_t *event_mask); } hci_packet_factory_t;