Skip to content

Commit

Permalink
Merge pull request #2503 from bobrippling/feat/nrf-address-current
Browse files Browse the repository at this point in the history
NRF: `getAddress(1)` returns the current BLE address
  • Loading branch information
gfwilliams authored Jun 17, 2024
2 parents 6f91a26 + 521ca36 commit 51baa11
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions libs/bluetooth/jswrap_bluetooth.c
Original file line number Diff line number Diff line change
Expand Up @@ -707,14 +707,21 @@ void jswrap_ble_eraseBonds() {
"class" : "NRF",
"name" : "getAddress",
"generate" : "jswrap_ble_getAddress",
"params" : [
["current", "JsVar", "If true, return the current address rather than the default"]
],
"return" : ["JsVar", "MAC address - a string of the form 'aa:bb:cc:dd:ee:ff'" ]
}
Get this device's default Bluetooth MAC address.
Get this device's default or current Bluetooth MAC address.
For Puck.js, the last 5 characters of this (e.g. `ee:ff`) are used in the
device's advertised Bluetooth name.
*/
JsVar *jswrap_ble_getAddress() {
JsVar *jswrap_ble_getAddress(JsVar *current) {
if (jsvGetBool(current)) {
JsVar *addr = jsvObjectGetChildIfExists(execInfo.hiddenRoot, BLE_NAME_MAC_ADDRESS);
if (addr) return addr;
}
#ifdef NRF5X
uint32_t addr0 = NRF_FICR->DEVICEADDR[0];
uint32_t addr1 = NRF_FICR->DEVICEADDR[1];
Expand Down

0 comments on commit 51baa11

Please sign in to comment.