Author Topic: How to get the local public Bluetooth address?  (Read 582 times)

joao_ts

  • RFduino Newbie
  • *
  • Posts: 2
  • Karma: +0/-0
    • View Profile
How to get the local public Bluetooth address?
« on: June 09, 2016, 06:51:53 AM »
ys to do this?I want to get the local public Bluetooth address of a RFduino connect via USB.
Can I get the address from a RFduino application (sketch) and the send the value using Serial.print? Or are there any better way to do this?
Thank you!

tolson

  • Global Moderator
  • *****
  • Posts: 801
  • Karma: +18/-0
    • View Profile
    • Thomas Olson Consulting
Re: How to get the local public Bluetooth address?
« Reply #1 on: June 09, 2016, 09:22:49 AM »
Yes, you can get the MAC address by reading a couple memory locations.

Code: [Select]
// myMACaddress
// Thomas Olson .com
// teo20140410.2
// nRF Hardware MAC address
// These two registers are suppose to contain the MAC address.
// For some reason I get a different nibble for the last nibble.
// So I cheat and force it to C since that is what it is in all
// the ones I have so far. Needs fixin' of better understanding!

#include <RFduinoBLE.h>
//#include <SimbleeBLE.h>

uint32_t *deviceADDR0 = (uint32_t *)0x100000a4; // location of MAC address
uint32_t *deviceADDR1 = (uint32_t *)0x100000a8;


void setup() {
  Serial.begin(9600);
  RFduinoBLE.begin();
  //SimbleeBLE.begin();
}

void loop(){
  delay(2000);
  Serial.print("\n My MAC ADDRESS: ");
  Serial.print((*deviceADDR1 | 0x0000C000) & 0x0000FFFF, HEX);
  Serial.print(" ");
  Serial.println(*deviceADDR0,HEX); 
}