Skip to content

Commit 6efdd8c

Browse files
committed
nRF52: Add 'slaveLatency' option to BluetoothRemoteGATTServer.connect, default changed from 2 to 4
1 parent 9bb9641 commit 6efdd8c

File tree

3 files changed

+5
-1
lines changed

3 files changed

+5
-1
lines changed

ChangeLog

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
: Add `E.internal` as a way to access the 'hidden root' containing Espruino internal variables that previously needed `global["\xff"]`
22
Bangle.js: Fix back handler not removed when using E.setUI with a back button but without widgets (#2636)
3+
nRF52: Add 'slaveLatency' option to BluetoothRemoteGATTServer.connect, default changed from 2 to 4
34

45
2v27 : nRF5x: Ensure Bluetooth notifications work correctly when two separate connections use the same handle for their characteristics
56
nRF5x: Remove handlers from our handlers array when a device is disconnected

libs/bluetooth/jswrap_bluetooth.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4044,6 +4044,7 @@ See [`NRF.requestDevice`](/Reference#l_NRF_requestDevice) for usage examples.
40444044
{
40454045
minInterval // min connection interval in milliseconds, 7.5 ms to 4 s
40464046
maxInterval // max connection interval in milliseconds, 7.5 ms to 4 s
4047+
slaveLatency : int // (2v28+) number of connection intervals missed before connection is closed, default 4 (or 2 if pre-2v28)
40474048
phy : "1mbps/coded/both/2mbps"
40484049
// (2v26+, NRF52833/NRF52840 only) the type of Bluetooth signals to scan for
40494050
// `1mbps` (default) - standard Bluetooth LE advertising

targets/nrf5x/bluetooth.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ __ALIGN(4) static ble_gap_lesc_dhkey_t m_lesc_dhkey; /**< LESC ECC DH Key*/
124124
#define CONN_SUP_TIMEOUT MSEC_TO_UNITS(4000, UNIT_10_MS) /**< Connection Supervision Timeout in 10 ms units, see @ref BLE_GAP_CP_LIMITS.*/
125125
// Slave latency - the number of missed responses to BLE requests we're happy to put up with - see BLE_GAP_CP_LIMITS
126126
#define SLAVE_LATENCY 0 // latency for *us* - we want to respond on every event
127-
#define SLAVE_LATENCY_CENTRAL 2 // when connecting to something else, be willing to put up with some lack of response
127+
#define SLAVE_LATENCY_CENTRAL 4 // when connecting to something else, be willing to put up with some lack of response
128128

129129
#if NRF_BLE_MAX_MTU_SIZE != GATT_MTU_SIZE_DEFAULT
130130
#define EXTENSIBLE_MTU // The MTU can be extended past the default of 23
@@ -3512,6 +3512,8 @@ void jsble_central_connect(ble_gap_addr_t peer_addr, JsVar *options) {
35123512
if (!isnan(v)) gap_conn_params.min_conn_interval = (uint16_t)(MSEC_TO_UNITS(v, UNIT_1_25_MS)+0.5);
35133513
v = jsvObjectGetFloatChild(options,"maxInterval");
35143514
if (!isnan(v)) gap_conn_params.max_conn_interval = (uint16_t)(MSEC_TO_UNITS(v, UNIT_1_25_MS)+0.5);
3515+
int vi = jsvObjectGetIntegerChild(options,"slaveLatency");
3516+
if (vi>0) gap_conn_params.slave_latency = vi;
35153517
}
35163518
/* From NRF SDK: If both conn_sup_timeout and max_conn_interval are specified, then the following constraint applies:
35173519
conn_sup_timeout * 4 > (1 + slave_latency) * max_conn_interval

0 commit comments

Comments
 (0)