This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

ble_gap_addr_t address is not right?

when phone connect to the device, I print the connected address. However, I find that the bluetooth address is not same with the phone bluetooth address. here is the debug infomation: image description

peer_address is:34:40:36:59:18:01, addr_type is:CA

the phone bluetooth address is:18:59:36:40:34:CA

I use SDK9.0.0, SoftDevice8.0.0

how to get the correct bluetooth? Thanks!

Parents
  • I don't know whether it is a bug or not. But you can avoid this problem with modifying your code like this:

    peer_address = p_ble_evt->evt.gap_evt.params.connected.peer_addr;
    
Reply
  • I don't know whether it is a bug or not. But you can avoid this problem with modifying your code like this:

    peer_address = p_ble_evt->evt.gap_evt.params.connected.peer_addr;
    
Children
  • It's not a bug - your code is correct because it gets the correct event type out of the event, his gets the 'scan request' structure out, however what's in there isn't a scan request, so the data is wrong.

  • @RK: I see. Thank you. :)

  • when I chang code to below:

    peer_address =p_ble_evt->evt.gap_evt.params.connected.peer_addr
    

    I got the correct bluetooth address sometimes. sometimes I got wrong address,when I debug peer_address.addr_type, I find out, when peer_address.addr_type=0 , peer_address is same with the phone address, when peer_address.addr_type=1, the address is wong ! how to get the correct address whether peer_address.addr_type is 0 or not? Thanks!

  • The address is right in both cases, when the type is '1' it's a random static address which isn't going to be the same as the public static address, because it's random. In both cases that's the address the link is using.

  • how to set type =0 in android app ? is there an API ??