Skip to content

Commit 5e5591f

Browse files
committed
Update NimBLE core to esp-nimble @3df0d20.
1 parent b52f2f5 commit 5e5591f

File tree

9 files changed

+347
-63
lines changed

9 files changed

+347
-63
lines changed

src/nimble/nimble/host/include/host/ble_gap.h

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1162,6 +1162,38 @@ int ble_gap_adv_rsp_set_fields(const struct ble_hs_adv_fields *rsp_fields);
11621162
int ble_hs_hci_util_set_data_len(uint16_t conn_handle, uint16_t tx_octets,
11631163
uint16_t tx_time);
11641164

1165+
/**
1166+
* Read host's suggested values for the controller's maximum transmitted number of payload octets
1167+
* and maximum packet transmission time (OGF = 0x08, OCF = 0x0024).
1168+
*
1169+
* @param out_sugg_max_tx_octets The Host's suggested value for the Controller's maximum transmitted
1170+
* number of payload octets in LL Data PDUs to be used for new
1171+
* connections. (Range 0x001B-0x00FB).
1172+
* @param out_sugg_max_tx_time The Host's suggested value for the Controller's maximum packet
1173+
* transmission time for packets containing LL Data PDUs to be used
1174+
* for new connections. (Range 0x0148-0x4290).
1175+
*
1176+
* @return 0 on success,
1177+
* other error code on failure.
1178+
*/
1179+
int ble_hs_hci_util_read_sugg_def_data_len(uint16_t *out_sugg_max_tx_octets,
1180+
uint16_t *out_sugg_max_tx_time);
1181+
/**
1182+
* Configure host's suggested maximum transmitted number of payload octets and maximum packet
1183+
* transmission time in controller (OGF = 0x08, OCF = 0x0024).
1184+
*
1185+
* @param sugg_max_tx_octets The Host's suggested value for the Controller's maximum transmitted
1186+
* number of payload octets in LL Data PDUs to be used for new
1187+
* connections. (Range 0x001B-0x00FB).
1188+
* @param sugg_max_tx_time The Host's suggested value for the Controller's maximum packet
1189+
* transmission time for packets containing LL Data PDUs to be used
1190+
* for new connections. (Range 0x0148-0x4290).
1191+
*
1192+
* @return 0 on success,
1193+
* other error code on failure.
1194+
*/
1195+
int ble_hs_hci_util_write_sugg_def_data_len(uint16_t sugg_max_tx_octets, uint16_t sugg_max_tx_time);
1196+
11651197
#if MYNEWT_VAL(BLE_EXT_ADV)
11661198
/** @brief Extended advertising parameters */
11671199
struct ble_gap_ext_adv_params {
@@ -1843,6 +1875,37 @@ int ble_gap_update_params(uint16_t conn_handle,
18431875
*/
18441876
int ble_gap_set_data_len(uint16_t conn_handle, uint16_t tx_octets, uint16_t tx_time);
18451877

1878+
/**
1879+
* Read LE Suggested Default Data Length in controller (OGF = 0x08, OCF = 0x0024).
1880+
*
1881+
* @param out_sugg_max_tx_octets The Host's suggested value for the Controller's maximum transmitted
1882+
* number of payload octets in LL Data PDUs to be used for new
1883+
* connections. (Range 0x001B-0x00FB).
1884+
* @param out_sugg_max_tx_time The Host's suggested value for the Controller's maximum packet
1885+
* transmission time for packets containing LL Data PDUs to be used
1886+
* for new connections. (Range 0x0148-0x4290).
1887+
*
1888+
* @return 0 on success,
1889+
* other error code on failure.
1890+
*/
1891+
int ble_gap_read_sugg_def_data_len(uint16_t *out_sugg_max_tx_octets,
1892+
uint16_t *out_sugg_max_tx_time);
1893+
1894+
/**
1895+
* Configure LE Suggested Default Data Length in controller (OGF = 0x08, OCF = 0x0024).
1896+
*
1897+
* @param sugg_max_tx_octets The Host's suggested value for the Controller's maximum transmitted
1898+
* number of payload octets in LL Data PDUs to be used for new
1899+
* connections. (Range 0x001B-0x00FB).
1900+
* @param sugg_max_tx_time The Host's suggested value for the Controller's maximum packet
1901+
* transmission time for packets containing LL Data PDUs to be used
1902+
* for new connections. (Range 0x0148-0x4290).
1903+
*
1904+
* @return 0 on success,
1905+
* other error code on failure.
1906+
*/
1907+
int ble_gap_write_sugg_def_data_len(uint16_t sugg_max_tx_octets, uint16_t sugg_max_tx_time);
1908+
18461909
/**
18471910
* Initiates the GAP security procedure.
18481911
*

src/nimble/nimble/host/src/ble_gap.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5860,6 +5860,16 @@ int ble_gap_set_data_len(uint16_t conn_handle, uint16_t tx_octets, uint16_t tx_t
58605860
return ble_hs_hci_util_set_data_len(conn_handle, tx_octets, tx_time);
58615861
}
58625862

5863+
int ble_gap_read_sugg_def_data_len(uint16_t *out_sugg_max_tx_octets, uint16_t *out_sugg_max_tx_time)
5864+
{
5865+
return ble_hs_hci_util_read_sugg_def_data_len(out_sugg_max_tx_octets, out_sugg_max_tx_time);
5866+
}
5867+
5868+
int ble_gap_write_sugg_def_data_len(uint16_t sugg_max_tx_octets, uint16_t sugg_max_tx_time)
5869+
{
5870+
return ble_hs_hci_util_write_sugg_def_data_len(sugg_max_tx_octets, sugg_max_tx_time);
5871+
}
5872+
58635873
/*****************************************************************************
58645874
* $security *
58655875
*****************************************************************************/

src/nimble/nimble/host/src/ble_hs_hci_util.c

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,60 @@ ble_hs_hci_util_set_data_len(uint16_t conn_handle, uint16_t tx_octets,
157157
return 0;
158158
}
159159

160+
int
161+
ble_hs_hci_util_read_sugg_def_data_len(uint16_t *out_sugg_max_tx_octets,
162+
uint16_t *out_sugg_max_tx_time)
163+
{
164+
struct ble_hci_le_rd_sugg_def_data_len_rp rsp;
165+
int rc;
166+
167+
rc = ble_hs_hci_cmd_tx(BLE_HCI_OP(BLE_HCI_OGF_LE,
168+
BLE_HCI_OCF_LE_RD_SUGG_DEF_DATA_LEN),
169+
NULL, 0, &rsp, sizeof(rsp));
170+
if (rc != 0) {
171+
return rc;
172+
}
173+
174+
*out_sugg_max_tx_octets = le16toh(rsp.max_tx_octets);
175+
*out_sugg_max_tx_time = le16toh(rsp.max_tx_time);
176+
177+
if (*out_sugg_max_tx_octets < BLE_HCI_SUGG_DEF_DATALEN_TX_OCTETS_MIN ||
178+
*out_sugg_max_tx_octets > BLE_HCI_SUGG_DEF_DATALEN_TX_OCTETS_MAX) {
179+
BLE_HS_LOG(WARN, "received suggested maximum tx octets is out of range\n");
180+
}
181+
182+
if (*out_sugg_max_tx_time < BLE_HCI_SUGG_DEF_DATALEN_TX_TIME_MIN ||
183+
*out_sugg_max_tx_time > BLE_HCI_SUGG_DEF_DATALEN_TX_TIME_MAX) {
184+
BLE_HS_LOG(WARN, "received suggested maximum tx time is out of range\n");
185+
}
186+
187+
return 0;
188+
}
189+
190+
int
191+
ble_hs_hci_util_write_sugg_def_data_len(uint16_t sugg_max_tx_octets,
192+
uint16_t sugg_max_tx_time)
193+
{
194+
struct ble_hci_le_wr_sugg_def_data_len_cp cmd;
195+
196+
if (sugg_max_tx_octets < BLE_HCI_SUGG_DEF_DATALEN_TX_OCTETS_MIN ||
197+
sugg_max_tx_octets > BLE_HCI_SUGG_DEF_DATALEN_TX_OCTETS_MAX) {
198+
return BLE_HS_EINVAL;
199+
}
200+
201+
if (sugg_max_tx_time < BLE_HCI_SUGG_DEF_DATALEN_TX_TIME_MIN ||
202+
sugg_max_tx_time > BLE_HCI_SUGG_DEF_DATALEN_TX_TIME_MAX) {
203+
return BLE_HS_EINVAL;
204+
}
205+
206+
cmd.max_tx_octets = htole16(sugg_max_tx_octets);
207+
cmd.max_tx_time = htole16(sugg_max_tx_time);
208+
209+
return ble_hs_hci_cmd_tx(BLE_HCI_OP(BLE_HCI_OGF_LE,
210+
BLE_HCI_OCF_LE_WR_SUGG_DEF_DATA_LEN),
211+
&cmd, sizeof(cmd), NULL, 0);
212+
}
213+
160214
int
161215
ble_hs_hci_util_data_hdr_strip(struct os_mbuf *om,
162216
struct hci_data_hdr *out_hdr)

src/nimble/nimble/host/src/ble_hs_periodic_sync.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ ble_hs_periodic_sync_alloc(void)
4343
memset(psync, 0, sizeof(*psync));
4444
}
4545

46-
ble_npl_event_init(&psync->lost_ev, ble_gap_npl_sync_lost, psync);
4746
return psync;
4847
}
4948

@@ -56,7 +55,9 @@ ble_hs_periodic_sync_free(struct ble_hs_periodic_sync *psync)
5655
return;
5756
}
5857

59-
ble_npl_event_deinit(&psync->lost_ev);
58+
if((psync->lost_ev).event != NULL)
59+
ble_npl_event_deinit(&psync->lost_ev);
60+
6061
#if MYNEWT_VAL(BLE_HS_DEBUG)
6162
memset(psync, 0xff, sizeof *psync);
6263
#endif

src/nimble/nimble/include/nimble/hci_common.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1215,6 +1215,12 @@ struct ble_hci_vs_rd_static_addr_rp {
12151215
#define BLE_HCI_SET_DATALEN_TX_TIME_MIN (0x0148)
12161216
#define BLE_HCI_SET_DATALEN_TX_TIME_MAX (0x4290)
12171217

1218+
/* --- LE read/write suggested default data length (OCF 0x0023 and 0x0024) */
1219+
#define BLE_HCI_SUGG_DEF_DATALEN_TX_OCTETS_MIN (0x001b)
1220+
#define BLE_HCI_SUGG_DEF_DATALEN_TX_OCTETS_MAX (0x00fb)
1221+
#define BLE_HCI_SUGG_DEF_DATALEN_TX_TIME_MIN (0x0148)
1222+
#define BLE_HCI_SUGG_DEF_DATALEN_TX_TIME_MAX (0x4290)
1223+
12181224
/* --- LE read maximum default PHY (OCF 0x0030) */
12191225
#define BLE_HCI_LE_PHY_1M (1)
12201226
#define BLE_HCI_LE_PHY_2M (2)

src/nimble/porting/nimble/include/nimble/nimble_port.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include "nimble/nimble/include/nimble/nimble_npl.h"
2424

2525
#ifdef ESP_PLATFORM
26+
#include "esp_err.h"
2627
#include "nimconfig.h"
2728
#define NIMBLE_CORE (CONFIG_BT_NIMBLE_PINNED_TO_CORE < portNUM_PROCESSORS ? CONFIG_BT_NIMBLE_PINNED_TO_CORE : tskNO_AFFINITY)
2829
#define NIMBLE_HS_STACK_SIZE CONFIG_BT_NIMBLE_HOST_TASK_STACK_SIZE
@@ -45,6 +46,22 @@ void nimble_port_deinit(void);
4546
void nimble_port_run(void);
4647
int nimble_port_stop(void);
4748

49+
#ifdef ESP_PLATFORM
50+
/**
51+
* @brief esp_nimble_init - Initialize the NimBLE host stack
52+
*
53+
* @return esp_err_t
54+
*/
55+
esp_err_t esp_nimble_init(void);
56+
57+
/**
58+
* @brief esp_nimble_deinit - Deinitialize the NimBLE host stack
59+
*
60+
* @return esp_err_t
61+
*/
62+
esp_err_t esp_nimble_deinit(void);
63+
#endif // ESP_PLATFORM
64+
4865
struct ble_npl_eventq *nimble_port_get_dflt_eventq(void);
4966

5067
#if NIMBLE_CFG_CONTROLLER

0 commit comments

Comments
 (0)