Skip to content

Commit

Permalink
nRF52840: setScan({... phy:"both"}) now means coded+1mbps (ref #2465)
Browse files Browse the repository at this point in the history
  • Loading branch information
gfwilliams committed Feb 23, 2024
1 parent 76d2b57 commit c3f31b1
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
g.wrapString fix issues wrapping long words in UTF8 strings over multiple lines
Bangle.js2: Fix parsing of UTF8 strings containing char codes 0xF5..0xFF (which are not valid UTF8)
nRF52: Added window/interval arguments to NRF.setScan (default was 100ms)
nRF52840: setScan({... phy:"both"}) now means coded+1mbps (ref #2465)

2v21 : nRF52: free up 800b more flash by removing vector table padding
Throw Exception when a Promise tries to resolve with another Promise (#2450)
Expand Down
8 changes: 6 additions & 2 deletions libs/bluetooth/jswrap_bluetooth.c
Original file line number Diff line number Diff line change
Expand Up @@ -3277,8 +3277,12 @@ a match is found. e.g. `NRF.requestDevice({ timeout:2000, filters: [ ... ] })`
* `active` - whether to perform active scanning (requesting 'scan response'
packets from any devices that are found). e.g. `NRF.requestDevice({ active:true,
filters: [ ... ] })`
* `phy` - (NRF52833/NRF52840 only) use the long-range coded phy (`"1mbps"` default, can
be `"1mbps/2mbps/both/coded"`)
* `phy` - (NRF52833/NRF52840 only) the type of Bluetooth signals to scan for (can
be `"1mbps/coded/both/2mbps"`)
* `1mbps` (default) - standard Bluetooth LE advertising
* `coded` - long range
* `both` - standard and long range
* `2mbps` - high speed 2mbps (not working)
* `extended` - (NRF52833/NRF52840 only) support receiving extended-length advertising
packets (default=true if phy isn't `"1mbps"`)
* `extended` - (NRF52833/NRF52840 only) support receiving extended-length advertising
Expand Down
3 changes: 2 additions & 1 deletion targets/nrf5x/bluetooth.c
Original file line number Diff line number Diff line change
Expand Up @@ -2996,12 +2996,13 @@ uint32_t jsble_set_scanning(bool enabled, JsVar *options) {
m_scan_param.scan_phys = BLE_GAP_PHY_2MBPS;
m_scan_param.extended = 1;
} else if (jsvIsStringEqual(advPhy,"both")) {
m_scan_param.scan_phys = BLE_GAP_PHYS_SUPPORTED;
m_scan_param.scan_phys = BLE_GAP_PHY_1MBPS|BLE_GAP_PHY_CODED;
m_scan_param.extended = 1;
} else if (jsvIsStringEqual(advPhy,"coded")) {
m_scan_param.scan_phys = BLE_GAP_PHY_CODED;
m_scan_param.extended = 1;
} else jsWarn("Unknown phy %q\n", advPhy);
// BLE_GAP_PHYS_SUPPORTED (all 3) doesn't appear to work - see https://github.com/espruino/Espruino/issues/2465
jsvUnLock(advPhy);
#endif
uint32_t scan_window = MSEC_TO_UNITS(jsvObjectGetIntegerChild(options, "window"), UNIT_0_625_MS);
Expand Down

0 comments on commit c3f31b1

Please sign in to comment.