Capturing BT remoteAddress after connection.

the_nexusComplex
Posts: 1
Joined: Tue Feb 20, 2024 8:06 pm

Capturing BT remoteAddress after connection.

Postby the_nexusComplex » Tue Feb 20, 2024 8:16 pm

This is probably really simple, but I have sure struggled.

scenario:
a lot of BT devices with same name, different locations.
since I know the name, I connect via name - this works fine, just takes awhile. (if I hand enter the mac, connection is immediate).
sometimes, Im connecting to the same device consecutively and would like to mitigate the 20-30 seconds associated with connecting.

connection method:
delay(1);
BTconnected = SerialBT.connect(slaveName);

what I would like to be able to do:
once connected, it would be nice to capture the remote mac address in a variable post connection.
(i will simply save to EEPROM and then call this address on boot up - if it fails(because im now at a different location), then ill call connect via name again - you get the idea.

I cant seem to figure out how to capture the remote address - there has to be a way post connection.

from the BluetoothSerial.h library:
bool connect(String remoteName);
bool connect(uint8_t remoteAddress[], int channel=0, esp_spp_sec_t sec_mask=(ESP_SPP_SEC_ENCRYPT|ESP_SPP_SEC_AUTHENTICATE), esp_spp_role_t role=ESP_SPP_ROLE_MASTER);
bool connect(const BTAddress &remoteAddress, int channel=0, esp_spp_sec_t sec_mask=(ESP_SPP_SEC_ENCRYPT|ESP_SPP_SEC_AUTHENTICATE), esp_spp_role_t role=ESP_SPP_ROLE_MASTER) {
return connect(*remoteAddress.getNative(), channel, sec_mask); };

stands to reason I could capture the remote address?
any help is appreciated!

Who is online

Users browsing this forum: Bing [Bot] and 102 guests