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

sd_ble_gap_addr_get() shows different MAC address in the different example.

Hi, all.

I used sd_ble_gap_addr_get() function to get a MAC address in the different example and the result was different.

I tested this example in SDK v14.2 and v15.0 but I just got the same symptoms in both SDK.

1. /examples/ble_peripheral/ble_app_beacon

You can modify main() function. Red colored is additional code to test.

int main(void)
{
  static ble_gap_addr_t mac_addr;
  uint32_t err_code;

  // Initialize.
  log_init();
  timers_init();
  leds_init();
  power_management_init();
  ble_stack_init();
  advertising_init();

  // Start execution.
  NRF_LOG_INFO("Beacon example started.");
  advertising_start();

  err_code = sd_ble_gap_addr_get(&mac_addr);
  NRF_LOG_INFO("MAC_ADDR: %x:%x:%x:%x:%x:%x\r\n", mac_addr.addr[5], mac_addr.addr[4], mac_addr.addr[3], mac_addr.addr[2], mac_addr.addr[1], mac_addr.addr[0]);

  // Enter main loop.
  for (;; )
  {
    idle_state_handle();
  }

}

With my PCA10040 board, it shows C4:EA:D2:82:33:xx in UART log window. (I hid last bytes) 

2. /examples/iot/coap/ipv6/client

You can modify main() function. Red colored is additional code to test.

int main(void)
{

  uint32_t err_code;
  static ble_gap_addr_t mac_addr;
....

....

....

  // Start execution
  connectable_mode_enter();

  err_code = sd_ble_gap_addr_get(&mac_addr);
  APPL_LOG("MAC_ADDR: %x:%x:%x:%x:%x:%x\r\n", mac_addr.addr[5], mac_addr.addr[4], mac_addr.addr[3], mac_addr.addr[2], mac_addr.addr[1], mac_addr.addr[0]);

  // Enter main loop
  for (;;)
  {
    app_sched_execute();

    if (NRF_LOG_PROCESS() == false)
    {
      // Sleep waiting for an application event.
      err_code = sd_app_evt_wait();
      APP_ERROR_CHECK(err_code);
    }

  }
}

With my PCA10040 board, it shows 0:EA:D2:82:33:xx in UART log window. (I hid last bytes) 

As you know, the first byte value is different.

Which is a right MAC address ? I am very confused.

If you know any other good function to get a MAC address, let me know it.

Thanks.

Parents Reply Children
Related