esp32-snippets icon indicating copy to clipboard operation
esp32-snippets copied to clipboard

Rssi returns zero form server(Esp32)

Open vanvicka opened this issue 4 years ago • 0 comments

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;
    }
}```

vanvicka avatar May 05 '21 01:05 vanvicka