MAC address of Smart Phone issue

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

hello...

i have two log files which are collected from the trace debug (please check below screen shot)

  • with 13:24:41 (timed) is paring peripheral to COMPUTER.
  • with 14:26:02 (timed) is paring peripheral to SMART PHONE.

Capture.PNG

this is the code i am using:

1.png

please correct me if i am wrong- after "Load Dev Info:" line - it is Bluetooth MAC address is displayed in both log files.

my question is

  1. where this MAC address (Load Dev Info) are collected? - i am sure its before the connection_up function since i am tracing it by giving "----------->0".
  2. from the COMPUTER log, the address "ea7c3b239468" and i am printing the same by considering bda[0] which is 'ea' . and in connection_up: it is giving same values but reverse order.
  3. from the SMART PHONE log, the address "0effaf792e4d" and i am printing the same by considering bda[0] which is different now that is '00' and as same as that of connection_up: 020100200400. why is this happening here?
  4. where the MAC address of CLIENT (computer / Smart Phone) are stored?

please explain us how this is happening, why its changing its values when connected to smart phone (in bda[]) and is always shows the same address when connected to other phone too and even how it is connecting (connection occurrence)?

thanks in advance

Regards

Sid

0 Likes
1 Solution
Anonymous
Not applicable

Hello.

I looked into this and this is because the addresses from the phone uses RPA ( random public address ).

emconninfo_getPeerPubAddr gives different result depending on the type of the address.

In your first example, the computer probably had the same address because the type of the address is not random address.

You can check the type of the address type using emconninfo_getPeerAddrType().

Regular Public Address is 0

Random Public Address is 1

When you call emconninfo_getPeerPubAddr(), if your address type is

0: you will just the address.

1: you will get non rpa address by using IRK (identity resolving key) info.

This key is generated by the host and is exchanged between the master and the slave when pairing.

However to be honest, I don't know how exactly they get 020100200400.

All I know is that it uses IRK info to give you that number.

If you want the RPA, you can simly call emconninfo_getPeerAdd().

pastedImage_0.png

Does this help with your problem?

James

View solution in original post

0 Likes
9 Replies
MichaelF_56
Moderator
Moderator
Moderator
250 sign-ins 25 comments on blog 10 comments on blog

I've asked jamesle1​ on the Apps team to take a look at this when he is in the office this week Sid.

0 Likes
HeLo_1712431
Level 2
Level 2
First like received First like given

It looks like the SMART PHONE is try to protecting the privacy by using randomly generated MAC address.  See the following link:

Google

0 Likes
Anonymous
Not applicable

yes you are right, some smart phone changes MAC address,

but when i connect to another Master, again it is displaying in bda[] = 020100200400 the same address as that of previous one. (which it should display the MAC of that smart phone)

2.PNG

this is of two different smart phones, you can see theirs respective address in 2nd line (both files) but changes in connection_up, bda[] = 020100200400 (for both address are same)

Regards

Sid

0 Likes
Anonymous
Not applicable

Hello.

I looked into this and this is because the addresses from the phone uses RPA ( random public address ).

emconninfo_getPeerPubAddr gives different result depending on the type of the address.

In your first example, the computer probably had the same address because the type of the address is not random address.

You can check the type of the address type using emconninfo_getPeerAddrType().

Regular Public Address is 0

Random Public Address is 1

When you call emconninfo_getPeerPubAddr(), if your address type is

0: you will just the address.

1: you will get non rpa address by using IRK (identity resolving key) info.

This key is generated by the host and is exchanged between the master and the slave when pairing.

However to be honest, I don't know how exactly they get 020100200400.

All I know is that it uses IRK info to give you that number.

If you want the RPA, you can simly call emconninfo_getPeerAdd().

pastedImage_0.png

Does this help with your problem?

James

0 Likes
Anonymous
Not applicable

thank you very much jamesle1​ for clearing my doubt...

can i get information / where i can get function emconninfo_getPeerPubAddr() in the program (source file)?

and requesting one more suggestion: i want to save (id) of smart phone, when it is connected to Slave for the first time, Slave must know it is his Master(Smart Phone) and then later on, the Slave must authenticate by itself and connect only that smart phone, rejecting if other try to connect it. how can i do it ?

thanking you...

Regards

Sid

0 Likes

Hi rsiddhanth.

Your problem can be solve with a whitelist. The max size of the whitelist is 5 address.

I have the same problem. I'm my case I want create my whitelist manually (I store BLE addressin an external i2c EEPROM). When the connection is done,  I compare the address of the device wich is actually connected and if his address match with one store in EEPROM I autorize connection. At the opposite I disconnect the BLE device with the execution of blecm_disconnect(0x13).

And I have the same problem to get information of the peer address.

If I use emconninfo_getPeerPubAddr() I have an adresse like 020100200400 and I don't what I can do with this.

If I use emconninfo_getPeerAddr() I think I have a random address.

0 Likes
Anonymous
Not applicable

hello julien_horizon

i thought of using Adding and removing master nodes to a whitelist running on a peripheral device , but it could not able to access the MAC address if it is Random MAC . it will be problem....

as heng said all the new Smart phones are using random MAC address for security reasons

Regards

Sid

0 Likes
Anonymous
Not applicable

Hello.

I'm sorry about the late reply.

Did you get to fix this problem?

can i get information / where i can get function emconninfo_getPeerPubAddr() in the program (source file)?

I'm afraid there isn't really anything place where you can get more info about the function,

since there really isn't any documentation and I don't think we are allowed to share the source code.

"and requesting one more suggestion: i want to save (id) of smart phone, when it is connected to Slave for the first time, Slave must know it is his Master(Smart Phone) and then later on, the Slave must authenticate by itself and connect only that smart phone, rejecting if other try to connect it. how can i do it ?"

There is a way to achieve this behavior without having to get the pub address of the paired device.

If you look at hello_sensor, there is authentication code in the connection_up function. You can use this to get the above behavior.

When the slave is has no bonded devices, send a security request when a master tries to connect.

On any subsequent connection tries with any other devices, check if the device is bonded. If it is not, disconnect.

The slave will only stay connect with the device that is bonded.

Here's example of what you might need in connection_up function:

if (emconninfo_deviceBonded()) {

     ble_trace0("device bonded");

} else {

     UINT8 readbyte = bleprofile_ReadNVRAM(BOND_COUNT_ID, sizeof(UINT8), (UINT8 *)&bond_count);

     ble_trace1("NVRAM read for bond count:%04x\n", bond_count);

    if(bond_count != 0) {

         blecm_disconnect(BT_ERROR_CODE_CONNECTION_TERMINATED_BY_LOCAL_HOST);

         return;

    } else {

         ble_trace0("device not bonded");

         lesmp_pinfo->pairingParam.AuthReq  |= LESMP_AUTH_FLAG_BONDING;

         lesmp_sendSecurityRequest();

         bond_count = 1;

         UINT8 writebyte = bleprofile_WriteNVRAM(BOND_COUNT_ID, sizeof(UINT8), (UINT8 *)&bond_count);

         ble_trace1("NVRAM write for bond count:%04x\n", writebyte);

    }

}

One little caveat: make sure you can reset the slave so you can bond again whenever you want.

*side note: You wouldn't be able to do what you want do using the BD address from iphone or any newer Android devices,

because they use random resolvable private addresses. I think they are changed at least every 15 minutes.

I hope this helps.

If you have any follow up questions, please let me know.

James

0 Likes
Anonymous
Not applicable

thank you very much for suggestion  jamesle1

0 Likes