Skip to content

Commit

Permalink
raw RSSI
Browse files Browse the repository at this point in the history
  • Loading branch information
bertmelis committed May 27, 2024
1 parent de0868d commit 949452d
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 28 deletions.
8 changes: 4 additions & 4 deletions examples/simple-esp32/simple-esp32.ino
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ void loop() {
static uint32_t lastMillis = 0;
if (millis() - lastMillis > 10000) {
lastMillis = millis();
uint8_t signalQuality = espMqttManagerHelpers::signalQuality();
char sqStr[4];
snprintf(sqStr, sizeof(sqStr), "%d", signalQuality);
espMqttManager::mqttClient.publish("test/topic", 0, false, sqStr);
int8_t signalQuality = WiFi.RSSI();
char buf[5];
snprintf(buf, sizeof(buf), "%d", signalQuality);
espMqttManager::mqttClient.publish("test/topic", 0, false, buf);
}
espMqttManager::loop();
}
8 changes: 4 additions & 4 deletions examples/simple-esp8266/simple-esp8266.ino
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ void loop() {
static uint32_t lastMillis = 0;
if (millis() - lastMillis > 10000) {
lastMillis = millis();
uint8_t signalQuality = espMqttManagerHelpers::signalQuality();
char sqStr[4];
snprintf(sqStr, sizeof(sqStr), "%d", signalQuality);
espMqttManager::mqttClient.publish("test/topic", 0, false, sqStr);
int8_t signalQuality = WiFi.RSSI();
char buf[5];
snprintf(buf, sizeof(buf), "%d", signalQuality);
espMqttManager::mqttClient.publish("test/topic", 0, false, buf);
}
espMqttManager::loop();
}
8 changes: 4 additions & 4 deletions examples/tls-esp32/tls-esp32.ino
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ void loop() {
static uint32_t lastMillis = 0;
if (millis() - lastMillis > 10000) {
lastMillis = millis();
uint8_t signalQuality = espMqttManagerHelpers::signalQuality();
char sqStr[4];
snprintf(sqStr, sizeof(sqStr), "%d", signalQuality);
espMqttManager::mqttClient.publish("test/topic", 0, false, sqStr);
int8_t signalQuality = WiFi.RSSI();
char buf[5];
snprintf(buf, sizeof(buf), "%d", signalQuality);
espMqttManager::mqttClient.publish("test/topic", 0, false, buf);
}
espMqttManager::loop();
}
13 changes: 0 additions & 13 deletions src/Helpers/Helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,6 @@ the LICENSE file.

namespace espMqttManagerHelpers {

uint8_t signalQuality() {
uint8_t signal = 0;
int32_t rssi = WiFi.RSSI();
if (rssi <= -100) {
signal = 0;
} else if (rssi >= -50) {
signal = 100;
} else {
signal = 2 * (rssi + 100);
}
return signal;
}

bool updated = false;

void handleUpdate(const uint8_t* payload, size_t length, size_t index, size_t total) {
Expand Down
3 changes: 0 additions & 3 deletions src/Helpers/Helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,15 @@ the LICENSE file.

#include <Arduino.h> // millis()
#if defined(ARDUINO_ARCH_ESP8266)
#include <ESP8266WiFi.h> // WiFi.RSSI()
#include <Updater.h>
#elif defined(ARDUINO_ARCH_ESP32)
#include <WiFi.h>
#include <Update.h>
#else
#error Platform not supported
#endif

namespace espMqttManagerHelpers {

uint8_t signalQuality();
void handleUpdate(const uint8_t* payload, size_t length, size_t index, size_t total);
extern bool updated;

Expand Down

0 comments on commit 949452d

Please sign in to comment.