-
-
Notifications
You must be signed in to change notification settings - Fork 191
Description
Hi,
I tried everything I could think of, but I do not get it working.
I compare devices by MAC to connect and this works flawless.
class scanCallbacks : public NimBLEScanCallbacks // BLEAdvertisedDeviceCallbacks
{
void onResult(const NimBLEAdvertisedDevice* advertisedDevice) override
{
Serial.printf("NimBLE_scan: Discovered Device: %s Type: %d \n", advertisedDevice->toString().c_str(),advertisedDevice->getAddressType());
// Checke for LiFePo4 MAC discovered
if (advertisedDevice->getAddress().equals(MAC_LiPo4))
changing the MAC is where I struggle to get the .equals working
let me show you what I tried
This works:
NimBLEAddress MAC_LiPo4("a4:c1:37:01:22:5f", 0);
and in Setup
NimBLEAddress MAC_LiPo4("38:3b:26:b5:15:a2", 0);
Since I have to change it , I added this at the top (before setup) and this works.
char MAC_lithium[18] = {0x61,0x34,0x3A,0x63,0x31,0x3A,0x33,0x37,0x3A,0x30,0x31,0x3A,0x32,0x32,0x3A,0x35,0x66,0x00};
NimBLEAddress MAC_LiPo4(MAC_lithium, 0);
If I change the MAC_lithium[] in Setup and run
NimBLEAddress MAC_LiPo4(MAC_lithium, 0);
the .equals will always be false.
The snipped looks like this:
char MAC_lithium[18] = {0x61,0x34,0x3A,0x63,0x31,0x3A,0x33,0x37,0x3A,0x30,0x31,0x3A,0x32,0x32,0x3A,0x35,0x66,0x00};
char fake_MAC_lithium[18] = {0x6**4**,0x34,0x3A,0x63,0x31,0x3A,0x33,0x37,0x3A,0x30,0x31,0x3A,0x32,0x32,0x3A,0x35,0x66,0x00};
NimBLEAddress MAC_LiPo4(fake_MAC_lithium, 0); // 0=Public, 1= Random --- BLE_ADDR_PUBLIC (0) BLE_ADDR_RANDOM (1)
void setup(){
NimBLEAddress MAC_LiPo4(MAC_lithium, 0); // 0=Public, 1= Random --- BLE_ADDR_PUBLIC (0) BLE_ADDR_RANDOM (1)
Any help is appreciated