Skip to content

Commit

Permalink
NRF: getAddress(1) returns the current BLE address
Browse files Browse the repository at this point in the history
  • Loading branch information
bobrippling committed May 24, 2024
1 parent 52352ef commit 8c3a58e
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions libs/bluetooth/jswrap_bluetooth.c
Original file line number Diff line number Diff line change
Expand Up @@ -707,14 +707,20 @@ 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)) {
return jsvObjectGetChildIfExists(execInfo.hiddenRoot, BLE_NAME_MAC_ADDRESS);
}
#ifdef NRF5X
uint32_t addr0 = NRF_FICR->DEVICEADDR[0];
uint32_t addr1 = NRF_FICR->DEVICEADDR[1];
Expand Down

0 comments on commit 8c3a58e

Please sign in to comment.