From 2c5e3d2c4723c0a626220a77646825c4469d96ce Mon Sep 17 00:00:00 2001 From: richonguzman Date: Mon, 9 Oct 2023 22:12:29 -0300 Subject: [PATCH] WIDE and bmp add --- platformio.ini | 3 ++- src/aprs_is_utils.cpp | 2 +- src/bme_utils.cpp | 27 ++++++++++++++++++++++++--- src/bme_utils.h | 7 +++++++ src/lora_utils.cpp | 2 +- src/query_utils.cpp | 2 +- 6 files changed, 36 insertions(+), 7 deletions(-) diff --git a/platformio.ini b/platformio.ini index 650e163..31a7e28 100644 --- a/platformio.ini +++ b/platformio.ini @@ -23,4 +23,5 @@ lib_deps = esphome/AsyncTCP-esphome@^2.0.0 mikalhart/TinyGPSPlus @ 1.0.3 adafruit/Adafruit Unified Sensor@^1.1.9 - adafruit/Adafruit BME280 Library@^2.2.2 \ No newline at end of file + adafruit/Adafruit BME280 Library@^2.2.2 + adafruit/Adafruit BMP280 Library@^2.6.8 \ No newline at end of file diff --git a/src/aprs_is_utils.cpp b/src/aprs_is_utils.cpp index a9c8326..6aba232 100644 --- a/src/aprs_is_utils.cpp +++ b/src/aprs_is_utils.cpp @@ -107,7 +107,7 @@ namespace APRS_IS_Utils { for(int i = Sender.length(); i < 9; i++) { Sender += ' '; } - LoRa_Utils::sendNewPacket("APRS", Config.callsign + ">APLRG1,RFONLY::" + Sender + ":" + ackMessage); + LoRa_Utils::sendNewPacket("APRS", Config.callsign + ">APLRG1,RFONLY,WIDE1-1::" + Sender + ":" + ackMessage); receivedMessage = AddresseeAndMessage.substring(AddresseeAndMessage.indexOf(":")+1, AddresseeAndMessage.indexOf("{")); } else { receivedMessage = AddresseeAndMessage.substring(AddresseeAndMessage.indexOf(":")+1); diff --git a/src/bme_utils.cpp b/src/bme_utils.cpp index 89f0c79..9a60956 100644 --- a/src/bme_utils.cpp +++ b/src/bme_utils.cpp @@ -13,21 +13,33 @@ extern String fifthLine; namespace BME_Utils { +#ifndef BMPSensor Adafruit_BME280 bme; +#else +Adafruit_BMP280 bme; +#endif void setup() { if (Config.bme.active) { bool status; status = bme.begin(0x76); // Don't forget to join pins for righ direction on BME280! if (!status) { - Serial.println("Could not find a valid BME280 sensor, check wiring!"); - show_display("ERROR", "", "BME sensor active", "but no sensor found..."); + Serial.println("Could not find a valid BME280 or BMP280 sensor, check wiring!"); + show_display("ERROR", "", "BME/BMP sensor active", "but no sensor found..."); while (1); // sacar esto para que quede pegado si no encuentra BME280 } else { + #ifndef BMPSensor Serial.println("init : BME280 Module ... done!"); + #else + Serial.println("init : BMP280 Module ... done!"); + #endif } } else { + #ifndef BMPSensor Serial.println("(BME not 'active' in 'igate_conf.json')"); + #else + Serial.println("(BMP not 'active' in 'igate_conf.json')"); + #endif } } @@ -98,7 +110,12 @@ String generatePresString(float bmePress) { String readDataSensor() { String wx, tempStr, humStr, presStr; float newTemp = bme.readTemperature(); - float newHum = bme.readHumidity(); + float newHum; + #ifndef BMPSensor + newHum = bme.readHumidity(); + #else + newHum = 0; + #endif float newPress = (bme.readPressure() / 100.0F); //bme.readAltitude(SEALEVELPRESSURE_HPA) // this is for approximate Altitude Calculation. @@ -110,7 +127,11 @@ String readDataSensor() { return wx; } else { tempStr = generateTempString((newTemp * 1.8) + 32); + #ifndef BMPSensor humStr = generateHumString(newHum); + #else + humStr = "-99"; + #endif presStr = generatePresString(newPress + (HEIGHT_CORRECTION/CORRECTION_FACTOR)); fifthLine = "BME-> " + String(int(newTemp))+"C " + humStr + "% " + presStr.substring(0,4) + "hPa"; wx = ".../...g...t" + tempStr + "r...p...P...h" + humStr + "b" + presStr; diff --git a/src/bme_utils.h b/src/bme_utils.h index 2ce7884..e32c378 100644 --- a/src/bme_utils.h +++ b/src/bme_utils.h @@ -3,7 +3,14 @@ #include #include + +//#define BMPSensor // uncoment this line if BMP280 Module is connected instead of BME280 + +#ifndef BMPSensor #include +#else +#include +#endif namespace BME_Utils { diff --git a/src/lora_utils.cpp b/src/lora_utils.cpp index cbc110b..45bd9fb 100644 --- a/src/lora_utils.cpp +++ b/src/lora_utils.cpp @@ -60,7 +60,7 @@ namespace LoRa_Utils { aprsisPacket.trim(); firstPart = aprsisPacket.substring(0, aprsisPacket.indexOf(",")); messagePart = aprsisPacket.substring(aprsisPacket.indexOf("::")+2); - return firstPart + ",TCPIP," + Config.callsign + "::" + messagePart; + return firstPart + ",TCPIP,WIDE1-1," + Config.callsign + "::" + messagePart; } String receivePacket() { diff --git a/src/query_utils.cpp b/src/query_utils.cpp index ef5e572..4fd2e67 100644 --- a/src/query_utils.cpp +++ b/src/query_utils.cpp @@ -42,7 +42,7 @@ String process(String query, String station, String queryOrigin) { if (queryOrigin == "APRSIS") { return Config.callsign + ">APLRG1,TCPIP,qAC::" + station + ":" + answer + "\n"; } else { //} if (queryOrigin == "LoRa") { - return Config.callsign + ">APLRG1,RFONLY::" + station + ":" + answer; + return Config.callsign + ">APLRG1,RFONLY,WIDE1-1::" + station + ":" + answer; } }