This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How to include mac address in advertisement packet name?

Hello, I am using sdk 12.2.2 and pca10040. I want to include the mac address in adv packet name. I am not aware of the api used to get mac address. I used sd_ble_gap_address_get(&m_devAddress); but it didn't work. Can I get help related to this challenge? Thanks, Shailav

  • Despite fact that MAC is indeed in every BLE PDU including all forms of ADV packets (so why would you include it in payload data?) you can indeed put whatever you want into certain AD objects like Manufacturer Specific data. If you are using Nordic Soft Device then function sd_ble_gap_address_get is the right one to get actual 6-byte value. If you have any problem while calling it please be very specific about how you define/init parameters of the function, what error/status code is returned by the function, what is in returned structure/pointer vs. what you see as current MAC address on the air (e.g. through any observer/scanner app like Nordic nRF Connect on the phone).

  • By default the advertisement address (MAC ID) is part of the payload. Same as in WiFi or even 802.3 wired ethernet, it has to be there in order for the receiver to identify the source. If you use any BLE scanner you will see that it knows the MAC ID's of the transmitters.

    There is insufficient room to also include it in a standard advertisement. A BLE advert has up to 31 bytes available and the UUID takes a big chunk of it. If you use a non-standard advertisement structure then you could include it, but you wouldn't be able to take advantage of the API's built into most operating systems to screen standard BLE advert structures (eg, eddystone, ibeacon, etc.) Through the Nordic API's you can choose different advertisement types such as random, random private resoveable, etc. These styles are discussed at length in the bluetooth spec.

    To get the mac id you do the following. Once you have it in the struct you can place it where you wish:

    	ble_gap_addr_t ble_addr;
        err_code = sd_ble_gap_address_get(&ble_addr);
    APP_ERROR_CHECK(err_code);
    
  • Hi, I tried your suggestions but unfortunately I am getting error as "._build\nrf52832_xxaa.axf: Error: L6218E: Undefined symbol sd_ble_gap_address_get (referred from main.o)." Am I missing some files here? I am attaching my main.c file in question above. Thanks for you help.

  • Hi,

    It was renamed to sd_ble_gap_addr_get() in SDK 12.

  • Hi Sigurd, That worked. Thanks,

Related