Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

advertisedDevice->getAddress().getNative() Returns MAC Address in Reverse Order #91

Open
camdenmoors opened this issue Jul 7, 2022 · 1 comment

Comments

@camdenmoors
Copy link

camdenmoors commented Jul 7, 2022

Not sure if this intentional.

Example Code:

NimBLEScan *pBLEScan;
class MyAdvertisedDeviceCallbacks : public NimBLEAdvertisedDeviceCallbacks
{
  void onResult(NimBLEAdvertisedDevice *advertisedDevice)
  {
    //    // local variables from bluetooth scan
    uint8_t blueRSSI = (uint8_t)advertisedDevice->getRSSI();
    uint8_t blueMAC_0 = advertisedDevice->getAddress().getNative()[5];
    uint8_t blueMAC_1 = advertisedDevice->getAddress().getNative()[4];
    uint8_t blueMAC_2 = advertisedDevice->getAddress().getNative()[3];
    uint8_t blueMAC_3 = advertisedDevice->getAddress().getNative()[2];
    uint8_t blueMAC_4 = advertisedDevice->getAddress().getNative()[1];
    uint8_t blueMAC_5 = advertisedDevice->getAddress().getNative()[0];
    // MAC will be in the correct order as we went in reverse.
    Serial.printf("%X:%X:%X:%X:%X:%X\n", blueMAC_0, blueMAC_1, blueMAC_2, blueMAC_3, blueMAC_4, blueMAC_5);
  }
}

@h2zero
Copy link
Owner

h2zero commented Jul 7, 2022

This is the way it is represented by the NimBLE stack, thus it is the "native" address. Unfortunately this does cause some confusion for users occasionally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants