esp32-snippets
esp32-snippets copied to clipboard
Arduino: how can BLE Client detecting RSSI in Connecting with server,not only for scan?
I connect two esp32s through the BLE server to the Client, when i use
int ble_rssi = myDevice->getRSSI(); Serial.println(ble_rssi);
in the loop function, become the same value which got in the Scan
I want the Client to always test the signal strength of the server. Is this possible?
thank you in advance
what is myDevice? BLEClient, BLEServer, BLEAdvertisedDevice?
@chegewara hello, it's BLEAdertisedDevice.
myDevice = new BLEAdvertisedDevice(advertisedDevice);
I want the client to keep detecting RSSI of the server while it is connected, but I failed. Is this possible?
thank you in advance
https://github.com/nkolban/esp32-snippets/blob/810aeb810a15ff6cf8742080ea5a413447cd0b92/cpp_utils/BLEClient.cpp#L366
You need to use it on connected client. At least in this library.
myDevice = new BLEAdvertisedDevice(advertisedDevice);
is static structure of data, never updated.
This esp-idf function is in gap layer, so in thoery it shouldnt be tied to BLEClient or BLEServer class and maybe moved to BLEDevice. The thing is that you could use it in BLEScan, but most peripheral devices allow only one connection at time and dont advertise when is connected.
PS this code can be cloned to BLEServer, or like i mentioned above moved to BLEDevice
I am using ble_client in the example. It uses BLEDevice. https://github.com/nkolban/ESP32_BLE_Arduino/blob/master/examples/BLE_client/BLE_client.ino How can this Code be cloned from BLEClient to BLEDevice. I am a beginner and im not very clear how to do it. Can someone help me. thanks
@chegewara Thank you for your reply
i want to try it in loop();
BLEClient* pClient = BLEDevice::createClient(); int rssi= pClient->getRssi(); Serial.println("RSSI Value is :" + rssi);
Use only this in loop:
int rssi= pClient->getRssi();
Serial.println("RSSI Value is :" + rssi);
@chegewara Thank you I was successful I defined it globally BLEClient* pClient, and use in loop: if (connected) {
int rssi = pClient->getRssi();
Serial.println(rssi);
}
hey im doing a senior design and im in the same boat i need my rssi to read consistent values. What do you mean you globally defined BLEClient*pClient = BLEDevice::createClient();
@DeJason-lsng What he meant with globally defined is he declared the object outside of the loop and setup. This enables a global access for every call/use on it. Ps. Sorry, Im not so good on what they are called.