esp32-snippets
esp32-snippets copied to clipboard
Rssi returns zero form server(Esp32)
I tried getting the rssi of a connected device form the sever but it only returns zeros. please how can i go about this
here is the code:
// notify changed value
if (deviceConnected) {
int rssi = pClient->getRssi();
Serial.println(rssi);
if (rssi > RSSI_THRESHOLD)
digitalWrite(LED_BUILTIN, HIGH);
else
digitalWrite(LED_BUILTIN, LOW);
pCharacteristic->setValue((uint8_t*)&value, 4);
pCharacteristic->notify();
value++;
}
delay(1000); // bluetooth stack will go into congestion, if too many packets are sent, in 6 hours test i was able to go as low as 3ms
// disconnecting
if (!deviceConnected && oldDeviceConnected) {
delay(500); // give the bluetooth stack the chance to get things ready
pServer->startAdvertising(); // restart advertising
Serial.println("start advertising");
oldDeviceConnected = deviceConnected;
}
// connecting
if (deviceConnected && !oldDeviceConnected) {
// do stuff here on connecting
oldDeviceConnected = deviceConnected;
}
}```