diff --git a/.github/workflows/package_amd64.yml b/.github/workflows/package_amd64.yml
index 4f6636712..c11566deb 100644
--- a/.github/workflows/package_amd64.yml
+++ b/.github/workflows/package_amd64.yml
@@ -58,7 +58,7 @@ jobs:
if [ -d .debpkg/usr/share/doc/meshtasticd/web/build ]; then mv .debpkg/usr/share/doc/meshtasticd/web/build/* .debpkg/usr/share/doc/meshtasticd/web/; fi
if [ -d .debpkg/usr/share/doc/meshtasticd/web/build ]; then rmdir .debpkg/usr/share/doc/meshtasticd/web/build; fi
if [ -d .debpkg/usr/share/doc/meshtasticd/web/.DS_Store]; then rm -f .debpkg/usr/share/doc/meshtasticd/web/.DS_Store; fi
- gunzip .debpkg/usr/share/doc/meshtasticd/web/*.gz
+ gunzip .debpkg/usr/share/doc/meshtasticd/web/ -r
cp release/meshtasticd_linux_x86_64 .debpkg/usr/sbin/meshtasticd
cp bin/config-dist.yaml .debpkg/etc/meshtasticd/config.yaml
cp bin/config.d/* .debpkg/etc/meshtasticd/available.d/
diff --git a/.github/workflows/package_raspbian.yml b/.github/workflows/package_raspbian.yml
index d9b12d6da..56b683fdd 100644
--- a/.github/workflows/package_raspbian.yml
+++ b/.github/workflows/package_raspbian.yml
@@ -58,7 +58,7 @@ jobs:
if [ -d .debpkg/usr/share/doc/meshtasticd/web/build ]; then mv .debpkg/usr/share/doc/meshtasticd/web/build/* .debpkg/usr/share/doc/meshtasticd/web/; fi
if [ -d .debpkg/usr/share/doc/meshtasticd/web/build ]; then rmdir .debpkg/usr/share/doc/meshtasticd/web/build; fi
if [ -d .debpkg/usr/share/doc/meshtasticd/web/.DS_Store]; then rm -f .debpkg/usr/share/doc/meshtasticd/web/.DS_Store; fi
- gunzip .debpkg/usr/share/doc/meshtasticd/web/*.gz
+ gunzip .debpkg/usr/share/doc/meshtasticd/web/ -r
cp release/meshtasticd_linux_aarch64 .debpkg/usr/sbin/meshtasticd
cp bin/config-dist.yaml .debpkg/etc/meshtasticd/config.yaml
cp bin/config.d/* .debpkg/etc/meshtasticd/available.d/
diff --git a/.github/workflows/package_raspbian_armv7l.yml b/.github/workflows/package_raspbian_armv7l.yml
index e19df9d17..663903e10 100644
--- a/.github/workflows/package_raspbian_armv7l.yml
+++ b/.github/workflows/package_raspbian_armv7l.yml
@@ -58,7 +58,7 @@ jobs:
if [ -d .debpkg/usr/share/doc/meshtasticd/web/build ]; then mv .debpkg/usr/share/doc/meshtasticd/web/build/* .debpkg/usr/share/doc/meshtasticd/web/; fi
if [ -d .debpkg/usr/share/doc/meshtasticd/web/build ]; then rmdir .debpkg/usr/share/doc/meshtasticd/web/build; fi
if [ -d .debpkg/usr/share/doc/meshtasticd/web/.DS_Store]; then rm -f .debpkg/usr/share/doc/meshtasticd/web/.DS_Store; fi
- gunzip .debpkg/usr/share/doc/meshtasticd/web/*.gz
+ gunzip .debpkg/usr/share/doc/meshtasticd/web/ -r
cp release/meshtasticd_linux_armv7l .debpkg/usr/sbin/meshtasticd
cp bin/config-dist.yaml .debpkg/etc/meshtasticd/config.yaml
cp bin/config.d/* .debpkg/etc/meshtasticd/available.d/
diff --git a/arch/esp32/esp32.ini b/arch/esp32/esp32.ini
index 1f17bc691..d6a756bec 100644
--- a/arch/esp32/esp32.ini
+++ b/arch/esp32/esp32.ini
@@ -46,7 +46,7 @@ lib_deps =
${radiolib_base.lib_deps}
https://github.com/meshtastic/esp32_https_server.git#23665b3adc080a311dcbb586ed5941b5f94d6ea2
h2zero/NimBLE-Arduino@^1.4.2
- https://github.com/dbSuS/libpax.git#7bcd3fcab75037505be9b122ab2b24cc5176b587
+ https://github.com/dbinfrago/libpax.git#3cdc0371c375676a97967547f4065607d4c53fd1
lewisxhe/XPowersLib@^0.2.6
https://github.com/meshtastic/ESP32_Codec2.git#633326c78ac251c059ab3a8c430fcdf25b41672f
rweather/Crypto@^0.4.0
diff --git a/bin/build-native.sh b/bin/build-native.sh
index e8ed61bcf..cda77b064 100755
--- a/bin/build-native.sh
+++ b/bin/build-native.sh
@@ -27,5 +27,4 @@ rm -r $OUTDIR/* || true
platformio pkg update --environment native || platformioFailed
pio run --environment native || platformioFailed
cp .pio/build/native/program "$OUTDIR/meshtasticd_linux_$(uname -m)"
-cp bin/device-install.* $OUTDIR
-cp bin/device-update.* $OUTDIR
+cp bin/native-install.* $OUTDIR
diff --git a/platformio.ini b/platformio.ini
index f7c73c190..cc08b33a0 100644
--- a/platformio.ini
+++ b/platformio.ini
@@ -34,7 +34,6 @@ default_envs = tbeam
;default_envs = radiomaster_900_bandit_nano
;default_envs = radiomaster_900_bandit_micro
;default_envs = radiomaster_900_bandit
-;default_envs = heltec_capsule_sensor_v3
;default_envs = heltec_vision_master_t190
;default_envs = heltec_vision_master_e213
;default_envs = heltec_vision_master_e290
@@ -110,7 +109,6 @@ framework = arduino
lib_deps =
${env.lib_deps}
end2endzone/NonBlockingRTTTL@1.3.0
- https://github.com/meshtastic/SparkFun_ATECCX08a_Arduino_Library.git#5cf62b36c6f30bc72a07bdb2c11fc9a22d1e31da
build_flags = ${env.build_flags} -Os
build_src_filter = ${env.build_src_filter} -
@@ -154,15 +152,11 @@ lib_deps =
sparkfun/SparkFun 9DoF IMU Breakout - ICM 20948 - Arduino Library@1.2.13
ClosedCube OPT3001@1.1.2
emotibit/EmotiBit MLX90632@1.0.8
- dfrobot/DFRobot_RTU@1.0.3
sparkfun/SparkFun MAX3010x Pulse and Proximity Sensor Library@1.1.2
adafruit/Adafruit MLX90614 Library@2.1.5
-
https://github.com/boschsensortec/Bosch-BSEC2-Library#v1.7.2502
boschsensortec/BME68x Sensor Library@1.1.40407
https://github.com/KodinLanewave/INA3221@1.0.1
- lewisxhe/SensorLib@0.2.0
mprograms/QMC5883LCompass@1.2.3
-
- https://github.com/meshtastic/DFRobot_LarkWeatherStation#4de3a9cadef0f6a5220a8a906cf9775b02b0040d
- https://github.com/gjelsoe/STK8xxx-Accelerometer.git#v0.1.1
+ dfrobot/DFRobot_RTU@1.0.3
+ https://github.com/meshtastic/DFRobot_LarkWeatherStation#4de3a9cadef0f6a5220a8a906cf9775b02b0040d
\ No newline at end of file
diff --git a/protobufs b/protobufs
index af7521c3a..02e6576ef 160000
--- a/protobufs
+++ b/protobufs
@@ -1 +1 @@
-Subproject commit af7521c3a77d56eb7a64efae5637a311ac33f76d
+Subproject commit 02e6576efaa2f691be9504b8c1c6261703f7a277
diff --git a/release/latest/.gitignore b/release/latest/.gitignore
deleted file mode 100644
index fff416667..000000000
--- a/release/latest/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-curfirmwareversion.xml
diff --git a/src/PowerFSM.cpp b/src/PowerFSM.cpp
index 00dd6c942..4c4d203c2 100644
--- a/src/PowerFSM.cpp
+++ b/src/PowerFSM.cpp
@@ -19,6 +19,10 @@
#include "sleep.h"
#include "target_specific.h"
+#if HAS_WIFI && !defined(ARCH_PORTDUINO)
+#include "mesh/wifi/WiFiAPClient.h"
+#endif
+
#ifndef SLEEP_TIME
#define SLEEP_TIME 30
#endif
@@ -377,9 +381,9 @@ void PowerFSM_setup()
// We never enter light-sleep or NB states on NRF52 (because the CPU uses so little power normally)
#ifdef ARCH_ESP32
// See: https://github.com/meshtastic/firmware/issues/1071
- // Don't add power saving transitions if we are a power saving tracker or sensor. Sleep will be initiated through the
- // modules
- if ((isRouter || config.power.is_power_saving) && !isTrackerOrSensor) {
+ // Don't add power saving transitions if we are a power saving tracker or sensor or have Wifi enabled. Sleep will be initiated
+ // through the modules
+ if ((isRouter || config.power.is_power_saving) && !isWifiAvailable() && !isTrackerOrSensor) {
powerFSM.add_timed_transition(&stateNB, &stateLS,
Default::getConfiguredOrDefaultMs(config.power.min_wake_secs, default_min_wake_secs), NULL,
"Min wake timeout");
diff --git a/src/configuration.h b/src/configuration.h
index 15912be3f..b5727508d 100644
--- a/src/configuration.h
+++ b/src/configuration.h
@@ -148,6 +148,7 @@ along with this program. If not, see .
#define NAU7802_ADDR 0x2A
#define MAX30102_ADDR 0x57
#define MLX90614_ADDR_DEF 0x5A
+#define CGRADSENS_ADDR 0x66
// -----------------------------------------------------------------------------
// ACCELEROMETER
@@ -170,7 +171,6 @@ along with this program. If not, see .
// -----------------------------------------------------------------------------
// Security
// -----------------------------------------------------------------------------
-#define ATECC608B_ADDR 0x35
// -----------------------------------------------------------------------------
// IO Expander
@@ -361,4 +361,4 @@ along with this program. If not, see .
#endif
#include "DebugConfiguration.h"
-#include "RF95Configuration.h"
+#include "RF95Configuration.h"
\ No newline at end of file
diff --git a/src/detect/ScanI2C.h b/src/detect/ScanI2C.h
index 8591b8433..7fe3aac89 100644
--- a/src/detect/ScanI2C.h
+++ b/src/detect/ScanI2C.h
@@ -12,7 +12,6 @@ class ScanI2C
SCREEN_SH1106,
SCREEN_UNKNOWN, // has the same address as the two above but does not respond to the same commands
SCREEN_ST7567,
- ATECC608B,
RTC_RV3028,
RTC_PCF8563,
CARDKB,
@@ -63,7 +62,8 @@ class ScanI2C
ICM20948,
MAX30102,
TPS65233,
- MPR121KB
+ MPR121KB,
+ CGRADSENS
} DeviceType;
// typedef uint8_t DeviceAddress;
diff --git a/src/detect/ScanI2CTwoWire.cpp b/src/detect/ScanI2CTwoWire.cpp
index ef5e5ee00..d29e5be8e 100644
--- a/src/detect/ScanI2CTwoWire.cpp
+++ b/src/detect/ScanI2CTwoWire.cpp
@@ -7,7 +7,6 @@
#include "linux/LinuxHardwareI2C.h"
#endif
#if !defined(ARCH_PORTDUINO) && !defined(ARCH_STM32WL)
-#include "main.h" // atecc
#include "meshUtils.h" // vformat
#endif
@@ -72,10 +71,10 @@ ScanI2C::DeviceType ScanI2CTwoWire::probeOLED(ScanI2C::DeviceAddress addr) const
r &= 0x0f;
if (r == 0x08 || r == 0x00) {
- LOG_INFO("sh1106 display found");
+ logFoundDevice("SH1106", (uint8_t)addr.address);
o_probe = SCREEN_SH1106; // SH1106
} else if (r == 0x03 || r == 0x04 || r == 0x06 || r == 0x07) {
- LOG_INFO("ssd1306 display found");
+ logFoundDevice("SSD1306", (uint8_t)addr.address);
o_probe = SCREEN_SSD1306; // SSD1306
}
c++;
@@ -84,40 +83,6 @@ ScanI2C::DeviceType ScanI2CTwoWire::probeOLED(ScanI2C::DeviceAddress addr) const
return o_probe;
}
-void ScanI2CTwoWire::printATECCInfo() const
-{
-#if !defined(ARCH_PORTDUINO) && !defined(ARCH_STM32WL)
- atecc.readConfigZone(false);
-
- std::string atecc_numbers = "ATECC608B Serial Number: ";
- for (int i = 0; i < 9; i++) {
- atecc_numbers += vformat("%02x", atecc.serialNumber[i]);
- }
-
- atecc_numbers += ", Rev Number: ";
- for (int i = 0; i < 4; i++) {
- atecc_numbers += vformat("%02x", atecc.revisionNumber[i]);
- }
- LOG_DEBUG(atecc_numbers.c_str());
-
- LOG_DEBUG("ATECC608B Config %s, Data %s, Slot 0 %s", atecc.configLockStatus ? "Locked" : "Unlocked",
- atecc.dataOTPLockStatus ? "Locked" : "Unlocked", atecc.slot0LockStatus ? "Locked" : "Unlocked");
-
- std::string atecc_publickey = "";
- if (atecc.configLockStatus && atecc.dataOTPLockStatus && atecc.slot0LockStatus) {
- if (atecc.generatePublicKey() == false) {
- atecc_publickey += "ATECC608B Error generating public key";
- } else {
- atecc_publickey += "ATECC608B Public Key: ";
- for (int i = 0; i < 64; i++) {
- atecc_publickey += vformat("%02x", atecc.publicKey64Bytes[i]);
- }
- }
- LOG_DEBUG(atecc_publickey.c_str());
- }
-#endif
-}
-
uint16_t ScanI2CTwoWire::getRegisterValue(const ScanI2CTwoWire::RegisterLocation ®isterLocation,
ScanI2CTwoWire::ResponseWidth responseWidth) const
{
@@ -129,7 +94,6 @@ uint16_t ScanI2CTwoWire::getRegisterValue(const ScanI2CTwoWire::RegisterLocation
i2cBus->endTransmission();
delay(20);
i2cBus->requestFrom(registerLocation.i2cAddress.address, responseWidth);
- LOG_DEBUG("Wire.available() = %d", i2cBus->available());
if (i2cBus->available() == 2) {
// Read MSB, then LSB
value = (uint16_t)i2cBus->read() << 8;
@@ -142,7 +106,7 @@ uint16_t ScanI2CTwoWire::getRegisterValue(const ScanI2CTwoWire::RegisterLocation
#define SCAN_SIMPLE_CASE(ADDR, T, ...) \
case ADDR: \
- LOG_INFO(__VA_ARGS__); \
+ logFoundDevice(__VA_ARGS__); \
type = T; \
break;
@@ -184,9 +148,9 @@ void ScanI2CTwoWire::scanPort(I2CPort port, uint8_t *address, uint8_t asize)
for (addr.address = 8; addr.address < 120; addr.address++) {
if (asize != 0) {
- if (!in_array(address, asize, addr.address))
+ if (!in_array(address, asize, (uint8_t)addr.address))
continue;
- LOG_DEBUG("Scan address 0x%x", addr.address);
+ LOG_DEBUG("Scan address 0x%x", (uint8_t)addr.address);
}
i2cBus->beginTransmission(addr.address);
#ifdef ARCH_PORTDUINO
@@ -199,35 +163,16 @@ void ScanI2CTwoWire::scanPort(I2CPort port, uint8_t *address, uint8_t asize)
#endif
type = NONE;
if (err == 0) {
- LOG_DEBUG("I2C device found at address 0x%x", addr.address);
-
switch (addr.address) {
case SSD1306_ADDRESS:
type = probeOLED(addr);
break;
-#if !defined(ARCH_PORTDUINO) && !defined(ARCH_STM32WL)
- case ATECC608B_ADDR:
-#ifdef RP2040_SLOW_CLOCK
- if (atecc.begin(addr.address, Wire, Serial2) == true)
-#else
- if (atecc.begin(addr.address) == true)
-#endif
-
- {
- LOG_INFO("ATECC608B initialized");
- } else {
- LOG_WARN("ATECC608B initialization failed");
- }
- printATECCInfo();
- break;
-#endif
-
#ifdef RV3028_RTC
case RV3028_RTC:
// foundDevices[addr] = RTC_RV3028;
type = RTC_RV3028;
- LOG_INFO("RV3028 RTC found");
+ logFoundDevice("RV3028", (uint8_t)addr.address);
rtc.initI2C(*i2cBus);
rtc.writeToRegister(0x35, 0x07); // no Clkout
rtc.writeToRegister(0x37, 0xB4);
@@ -235,7 +180,7 @@ void ScanI2CTwoWire::scanPort(I2CPort port, uint8_t *address, uint8_t asize)
#endif
#ifdef PCF8563_RTC
- SCAN_SIMPLE_CASE(PCF8563_RTC, RTC_PCF8563, "PCF8563 RTC found")
+ SCAN_SIMPLE_CASE(PCF8563_RTC, RTC_PCF8563, "PCF8563", (uint8_t)addr.address)
#endif
case CARDKB_ADDR:
@@ -243,50 +188,50 @@ void ScanI2CTwoWire::scanPort(I2CPort port, uint8_t *address, uint8_t asize)
registerValue = getRegisterValue(ScanI2CTwoWire::RegisterLocation(addr, 0x04), 1);
if (registerValue == 0x02) {
// KEYPAD_VERSION
- LOG_INFO("RAK14004 found");
+ logFoundDevice("RAK14004", (uint8_t)addr.address);
type = RAK14004;
} else {
- LOG_INFO("m5 cardKB found");
+ logFoundDevice("M5 cardKB", (uint8_t)addr.address);
type = CARDKB;
}
break;
- SCAN_SIMPLE_CASE(TDECK_KB_ADDR, TDECKKB, "T-Deck keyboard found");
- SCAN_SIMPLE_CASE(BBQ10_KB_ADDR, BBQ10KB, "BB Q10 keyboard found");
+ SCAN_SIMPLE_CASE(TDECK_KB_ADDR, TDECKKB, "T-Deck keyboard", (uint8_t)addr.address);
+ SCAN_SIMPLE_CASE(BBQ10_KB_ADDR, BBQ10KB, "BB Q10", (uint8_t)addr.address);
- SCAN_SIMPLE_CASE(ST7567_ADDRESS, SCREEN_ST7567, "st7567 display found");
+ SCAN_SIMPLE_CASE(ST7567_ADDRESS, SCREEN_ST7567, "ST7567", (uint8_t)addr.address);
#ifdef HAS_NCP5623
- SCAN_SIMPLE_CASE(NCP5623_ADDR, NCP5623, "NCP5623 RGB LED found");
+ SCAN_SIMPLE_CASE(NCP5623_ADDR, NCP5623, "NCP5623", (uint8_t)addr.address);
#endif
#ifdef HAS_PMU
- SCAN_SIMPLE_CASE(XPOWERS_AXP192_AXP2101_ADDRESS, PMU_AXP192_AXP2101, "axp192/axp2101 PMU found")
+ SCAN_SIMPLE_CASE(XPOWERS_AXP192_AXP2101_ADDRESS, PMU_AXP192_AXP2101, "AXP192/AXP2101", (uint8_t)addr.address)
#endif
case BME_ADDR:
case BME_ADDR_ALTERNATE:
registerValue = getRegisterValue(ScanI2CTwoWire::RegisterLocation(addr, 0xD0), 1); // GET_ID
switch (registerValue) {
case 0x61:
- LOG_INFO("BME-680 sensor found at address 0x%x", (uint8_t)addr.address);
+ logFoundDevice("BME680", (uint8_t)addr.address);
type = BME_680;
break;
case 0x60:
- LOG_INFO("BME-280 sensor found at address 0x%x", (uint8_t)addr.address);
+ logFoundDevice("BME280", (uint8_t)addr.address);
type = BME_280;
break;
case 0x55:
- LOG_INFO("BMP-085 or BMP-180 sensor found at address 0x%x", (uint8_t)addr.address);
+ logFoundDevice("BMP085/BMP180", (uint8_t)addr.address);
type = BMP_085;
break;
default:
registerValue = getRegisterValue(ScanI2CTwoWire::RegisterLocation(addr, 0x00), 1); // GET_ID
switch (registerValue) {
case 0x50: // BMP-388 should be 0x50
- LOG_INFO("BMP-388 sensor found at address 0x%x", (uint8_t)addr.address);
+ logFoundDevice("BMP-388", (uint8_t)addr.address);
type = BMP_3XX;
break;
case 0x58: // BMP-280 should be 0x58
default:
- LOG_INFO("BMP-280 sensor found at address 0x%x", (uint8_t)addr.address);
+ logFoundDevice("BMP-280", (uint8_t)addr.address);
type = BMP_280;
break;
}
@@ -295,7 +240,7 @@ void ScanI2CTwoWire::scanPort(I2CPort port, uint8_t *address, uint8_t asize)
break;
#ifndef HAS_NCP5623
case AHT10_ADDR:
- LOG_INFO("AHT10 sensor found at address 0x%x", (uint8_t)addr.address);
+ logFoundDevice("AHT10", (uint8_t)addr.address);
type = AHT10;
break;
#endif
@@ -305,41 +250,57 @@ void ScanI2CTwoWire::scanPort(I2CPort port, uint8_t *address, uint8_t asize)
registerValue = getRegisterValue(ScanI2CTwoWire::RegisterLocation(addr, 0xFE), 2);
LOG_DEBUG("Register MFG_UID: 0x%x", registerValue);
if (registerValue == 0x5449) {
- LOG_INFO("INA260 sensor found at address 0x%x", (uint8_t)addr.address);
+ logFoundDevice("INA260", (uint8_t)addr.address);
type = INA260;
} else { // Assume INA219 if INA260 ID is not found
- LOG_INFO("INA219 sensor found at address 0x%x", (uint8_t)addr.address);
+ logFoundDevice("INA219", (uint8_t)addr.address);
type = INA219;
}
break;
case INA3221_ADDR:
registerValue = getRegisterValue(ScanI2CTwoWire::RegisterLocation(addr, 0xFE), 2);
- LOG_DEBUG("Register MFG_UID: 0x%x", registerValue);
+ LOG_DEBUG("Register MFG_UID FE: 0x%x", registerValue);
if (registerValue == 0x5449) {
- LOG_INFO("INA3221 sensor found at address 0x%x", (uint8_t)addr.address);
+ logFoundDevice("INA3221", (uint8_t)addr.address);
type = INA3221;
} else {
- LOG_INFO("DFRobot Lark weather station found at address 0x%x", (uint8_t)addr.address);
- type = DFROBOT_LARK;
+ /* check the first 2 bytes of the 6 byte response register
+ LARK FW 1.0 should return:
+ RESPONSE_STATUS STATUS_SUCCESS (0x53)
+ RESPONSE_CMD CMD_GET_VERSION (0x05)
+ RESPONSE_LEN_L 0x02
+ RESPONSE_LEN_H 0x00
+ RESPONSE_PAYLOAD 0x01
+ RESPONSE_PAYLOAD+1 0x00
+ */
+ registerValue = getRegisterValue(ScanI2CTwoWire::RegisterLocation(addr, 0x05), 2);
+ LOG_DEBUG("Register MFG_UID 05: 0x%x", registerValue);
+ if (registerValue == 0x5305) {
+ logFoundDevice("DFRobot Lark", (uint8_t)addr.address);
+ type = DFROBOT_LARK;
+ }
+ // else: probably a RAK12500/UBLOX GPS on I2C
}
break;
case MCP9808_ADDR:
// We need to check for STK8BAXX first, since register 0x07 is new data flag for the z-axis and can produce some
// weird result. and register 0x00 doesn't seems to be colliding with MCP9808 and LIS3DH chips.
{
+#ifdef HAS_STK8XXX
// Check register 0x00 for 0x8700 response to ID STK8BA53 chip.
registerValue = getRegisterValue(ScanI2CTwoWire::RegisterLocation(addr, 0x00), 2);
if (registerValue == 0x8700) {
type = STK8BAXX;
- LOG_INFO("STK8BAXX accelerometer found");
+ logFoundDevice("STK8BAXX", (uint8_t)addr.address);
break;
}
+#endif
// Check register 0x07 for 0x0400 response to ID MCP9808 chip.
registerValue = getRegisterValue(ScanI2CTwoWire::RegisterLocation(addr, 0x07), 2);
if (registerValue == 0x0400) {
type = MCP9808;
- LOG_INFO("MCP9808 sensor found");
+ logFoundDevice("MCP9808", (uint8_t)addr.address);
break;
}
@@ -347,7 +308,7 @@ void ScanI2CTwoWire::scanPort(I2CPort port, uint8_t *address, uint8_t asize)
registerValue = getRegisterValue(ScanI2CTwoWire::RegisterLocation(addr, 0x0F), 2);
if (registerValue == 0x3300 || registerValue == 0x3333) { // RAK4631 WisBlock has LIS3DH register at 0x3333
type = LIS3DH;
- LOG_INFO("LIS3DH accelerometer found");
+ logFoundDevice("LIS3DH", (uint8_t)addr.address);
}
break;
}
@@ -355,93 +316,92 @@ void ScanI2CTwoWire::scanPort(I2CPort port, uint8_t *address, uint8_t asize)
registerValue = getRegisterValue(ScanI2CTwoWire::RegisterLocation(addr, 0x89), 2);
if (registerValue == 0x11a2 || registerValue == 0x11da || registerValue == 0xe9c) {
type = SHT4X;
- LOG_INFO("SHT4X sensor found");
+ logFoundDevice("SHT4X", (uint8_t)addr.address);
} else if (getRegisterValue(ScanI2CTwoWire::RegisterLocation(addr, 0x7E), 2) == 0x5449) {
type = OPT3001;
- LOG_INFO("OPT3001 light sensor found");
+ logFoundDevice("OPT3001", (uint8_t)addr.address);
} else {
type = SHT31;
- LOG_INFO("SHT31 sensor found");
+ logFoundDevice("SHT31", (uint8_t)addr.address);
}
break;
- SCAN_SIMPLE_CASE(SHTC3_ADDR, SHTC3, "SHTC3 sensor found")
+ SCAN_SIMPLE_CASE(SHTC3_ADDR, SHTC3, "SHTC3", (uint8_t)addr.address)
case RCWL9620_ADDR:
// get MAX30102 PARTID
registerValue = getRegisterValue(ScanI2CTwoWire::RegisterLocation(addr, 0xFF), 1);
if (registerValue == 0x15) {
type = MAX30102;
- LOG_INFO("MAX30102 Health sensor found");
+ logFoundDevice("MAX30102", (uint8_t)addr.address);
break;
} else {
type = RCWL9620;
- LOG_INFO("RCWL9620 sensor found");
+ logFoundDevice("RCWL9620", (uint8_t)addr.address);
}
break;
case LPS22HB_ADDR_ALT:
- SCAN_SIMPLE_CASE(LPS22HB_ADDR, LPS22HB, "LPS22HB sensor found")
-
- SCAN_SIMPLE_CASE(QMC6310_ADDR, QMC6310, "QMC6310 Highrate 3-Axis magnetic sensor found")
+ SCAN_SIMPLE_CASE(LPS22HB_ADDR, LPS22HB, "LPS22HB", (uint8_t)addr.address)
+ SCAN_SIMPLE_CASE(QMC6310_ADDR, QMC6310, "QMC6310", (uint8_t)addr.address)
case QMI8658_ADDR:
registerValue = getRegisterValue(ScanI2CTwoWire::RegisterLocation(addr, 0x0A), 1); // get ID
if (registerValue == 0xC0) {
type = BQ24295;
- LOG_INFO("BQ24295 PMU found");
+ logFoundDevice("BQ24295", (uint8_t)addr.address);
break;
}
registerValue = getRegisterValue(ScanI2CTwoWire::RegisterLocation(addr, 0x0F), 1); // get ID
if (registerValue == 0x6A) {
type = LSM6DS3;
- LOG_INFO("LSM6DS3 accelerometer found at address 0x%x", (uint8_t)addr.address);
+ logFoundDevice("LSM6DS3", (uint8_t)addr.address);
} else {
type = QMI8658;
- LOG_INFO("QMI8658 Highrate 6-Axis inertial measurement sensor found");
+ logFoundDevice("QMI8658", (uint8_t)addr.address);
}
break;
- SCAN_SIMPLE_CASE(QMC5883L_ADDR, QMC5883L, "QMC5883L Highrate 3-Axis magnetic sensor found")
- SCAN_SIMPLE_CASE(HMC5883L_ADDR, HMC5883L, "HMC5883L 3-Axis digital compass found")
+ SCAN_SIMPLE_CASE(QMC5883L_ADDR, QMC5883L, "QMC5883L", (uint8_t)addr.address)
+ SCAN_SIMPLE_CASE(HMC5883L_ADDR, HMC5883L, "HMC5883L", (uint8_t)addr.address)
#ifdef HAS_QMA6100P
- SCAN_SIMPLE_CASE(QMA6100P_ADDR, QMA6100P, "QMA6100P accelerometer found")
+ SCAN_SIMPLE_CASE(QMA6100P_ADDR, QMA6100P, "QMA6100P", (uint8_t)addr.address)
#else
- SCAN_SIMPLE_CASE(PMSA0031_ADDR, PMSA0031, "PMSA0031 air quality sensor found")
+ SCAN_SIMPLE_CASE(PMSA0031_ADDR, PMSA0031, "PMSA0031", (uint8_t)addr.address)
#endif
case BMA423_ADDR: // this can also be LIS3DH_ADDR_ALT
registerValue = getRegisterValue(ScanI2CTwoWire::RegisterLocation(addr, 0x0F), 2);
if (registerValue == 0x3300 || registerValue == 0x3333) { // RAK4631 WisBlock has LIS3DH register at 0x3333
type = LIS3DH;
- LOG_INFO("LIS3DH accelerometer found");
+ logFoundDevice("LIS3DH", (uint8_t)addr.address);
} else {
type = BMA423;
- LOG_INFO("BMA423 accelerometer found");
+ logFoundDevice("BMA423", (uint8_t)addr.address);
}
break;
- SCAN_SIMPLE_CASE(LSM6DS3_ADDR, LSM6DS3, "LSM6DS3 accelerometer found at address 0x%x", (uint8_t)addr.address);
- SCAN_SIMPLE_CASE(TCA9535_ADDR, TCA9535, "TCA9535 I2C expander found");
- SCAN_SIMPLE_CASE(TCA9555_ADDR, TCA9555, "TCA9555 I2C expander found");
- SCAN_SIMPLE_CASE(VEML7700_ADDR, VEML7700, "VEML7700 light sensor found");
- SCAN_SIMPLE_CASE(TSL25911_ADDR, TSL2591, "TSL2591 light sensor found");
- SCAN_SIMPLE_CASE(OPT3001_ADDR, OPT3001, "OPT3001 light sensor found");
- SCAN_SIMPLE_CASE(MLX90632_ADDR, MLX90632, "MLX90632 IR temp sensor found");
- SCAN_SIMPLE_CASE(NAU7802_ADDR, NAU7802, "NAU7802 based scale found");
- SCAN_SIMPLE_CASE(FT6336U_ADDR, FT6336U, "FT6336U touchscreen found");
- SCAN_SIMPLE_CASE(MAX1704X_ADDR, MAX17048, "MAX17048 lipo fuel gauge found");
+ SCAN_SIMPLE_CASE(LSM6DS3_ADDR, LSM6DS3, "LSM6DS3", (uint8_t)addr.address);
+ SCAN_SIMPLE_CASE(TCA9535_ADDR, TCA9535, "TCA9535", (uint8_t)addr.address);
+ SCAN_SIMPLE_CASE(TCA9555_ADDR, TCA9555, "TCA9555", (uint8_t)addr.address);
+ SCAN_SIMPLE_CASE(VEML7700_ADDR, VEML7700, "VEML7700", (uint8_t)addr.address);
+ SCAN_SIMPLE_CASE(TSL25911_ADDR, TSL2591, "TSL2591", (uint8_t)addr.address);
+ SCAN_SIMPLE_CASE(OPT3001_ADDR, OPT3001, "OPT3001", (uint8_t)addr.address);
+ SCAN_SIMPLE_CASE(MLX90632_ADDR, MLX90632, "MLX90632", (uint8_t)addr.address);
+ SCAN_SIMPLE_CASE(NAU7802_ADDR, NAU7802, "NAU7802", (uint8_t)addr.address);
+ SCAN_SIMPLE_CASE(FT6336U_ADDR, FT6336U, "FT6336U", (uint8_t)addr.address);
+ SCAN_SIMPLE_CASE(MAX1704X_ADDR, MAX17048, "MAX17048", (uint8_t)addr.address);
#ifdef HAS_TPS65233
- SCAN_SIMPLE_CASE(TPS65233_ADDR, TPS65233, "TPS65233 BIAS-T found");
+ SCAN_SIMPLE_CASE(TPS65233_ADDR, TPS65233, "TPS65233", (uint8_t)addr.address);
#endif
case MLX90614_ADDR_DEF:
registerValue = getRegisterValue(ScanI2CTwoWire::RegisterLocation(addr, 0x0e), 1);
if (registerValue == 0x5a) {
type = MLX90614;
- LOG_INFO("MLX90614 IR temp sensor found");
+ logFoundDevice("MLX90614", (uint8_t)addr.address);
} else {
type = MPR121KB;
- LOG_INFO("MPR121KB keyboard found");
+ logFoundDevice("MPR121KB", (uint8_t)addr.address);
}
break;
@@ -450,24 +410,34 @@ void ScanI2CTwoWire::scanPort(I2CPort port, uint8_t *address, uint8_t asize)
registerValue = getRegisterValue(ScanI2CTwoWire::RegisterLocation(addr, 0x00), 1);
if (registerValue == 0xEA) {
type = ICM20948;
- LOG_INFO("ICM20948 9-dof motion processor found");
+ logFoundDevice("ICM20948", (uint8_t)addr.address);
break;
} else if (addr.address == BMX160_ADDR) {
type = BMX160;
- LOG_INFO("BMX160 accelerometer found");
+ logFoundDevice("BMX160", (uint8_t)addr.address);
break;
} else {
type = MPU6050;
- LOG_INFO("MPU6050 accelerometer found");
+ logFoundDevice("MPU6050", (uint8_t)addr.address);
+ break;
+ }
+ break;
+
+ case CGRADSENS_ADDR:
+ // Register 0x00 of the RadSens sensor contains is product identifier 0x7D
+ registerValue = getRegisterValue(ScanI2CTwoWire::RegisterLocation(addr, 0x00), 1);
+ if (registerValue == 0x7D) {
+ type = CGRADSENS;
+ logFoundDevice("ClimateGuard RadSens", (uint8_t)addr.address);
break;
}
break;
default:
- LOG_INFO("Device found at address 0x%x was not able to be enumerated", addr.address);
+ LOG_INFO("Device found at address 0x%x was not able to be enumerated", (uint8_t)addr.address);
}
} else if (err == 4) {
- LOG_ERROR("Unknown error at address 0x%x", addr.address);
+ LOG_ERROR("Unknown error at address 0x%x", (uint8_t)addr.address);
}
// Check if a type was found for the enumerated device - save, if so
@@ -500,4 +470,9 @@ size_t ScanI2CTwoWire::countDevices() const
{
return foundDevices.size();
}
+
+void ScanI2CTwoWire::logFoundDevice(const char *device, uint8_t address)
+{
+ LOG_INFO("%s found at address 0x%x", device, address);
+}
#endif
\ No newline at end of file
diff --git a/src/detect/ScanI2CTwoWire.h b/src/detect/ScanI2CTwoWire.h
index c8dd96469..d0af7cde6 100644
--- a/src/detect/ScanI2CTwoWire.h
+++ b/src/detect/ScanI2CTwoWire.h
@@ -53,10 +53,10 @@ class ScanI2CTwoWire : public ScanI2C
concurrency::Lock lock;
- void printATECCInfo() const;
-
uint16_t getRegisterValue(const RegisterLocation &, ResponseWidth) const;
DeviceType probeOLED(ScanI2C::DeviceAddress) const;
+
+ static void logFoundDevice(const char *device, uint8_t address);
};
#endif
\ No newline at end of file
diff --git a/src/gps/GPS.cpp b/src/gps/GPS.cpp
index a6db85950..dcece305a 100644
--- a/src/gps/GPS.cpp
+++ b/src/gps/GPS.cpp
@@ -28,29 +28,43 @@
#define GPS_RESET_MODE HIGH
#endif
+// Not all platforms have std::size().
+template std::size_t array_count(const T (&)[N])
+{
+ return N;
+}
+
#if defined(NRF52840_XXAA) || defined(NRF52833_XXAA) || defined(ARCH_ESP32) || defined(ARCH_PORTDUINO)
HardwareSerial *GPS::_serial_gps = &Serial1;
#elif defined(ARCH_RP2040)
SerialUART *GPS::_serial_gps = &Serial1;
#else
-HardwareSerial *GPS::_serial_gps = NULL;
+HardwareSerial *GPS::_serial_gps = nullptr;
#endif
GPS *gps = nullptr;
-GPSUpdateScheduling scheduling;
+static const char *ACK_SUCCESS_MESSAGE = "Get ack success!";
+
+static GPSUpdateScheduling scheduling;
/// Multiple GPS instances might use the same serial port (in sequence), but we can
/// only init that port once.
static bool didSerialInit;
-struct uBloxGnssModelInfo info;
-uint8_t uBloxProtocolVersion;
+static struct uBloxGnssModelInfo {
+ char swVersion[30];
+ char hwVersion[10];
+ uint8_t extensionNo;
+ char extension[10][30];
+ uint8_t protocol_version;
+} ublox_info;
+
#define GPS_SOL_EXPIRY_MS 5000 // in millis. give 1 second time to combine different sentences. NMEA Frequency isn't higher anyway
#define NMEA_MSG_GXGSA "GNGSA" // GSA message (GPGSA, GNGSA etc)
// For logging
-const char *getGPSPowerStateString(GPSPowerState state)
+static const char *getGPSPowerStateString(GPSPowerState state)
{
switch (state) {
case GPS_ACTIVE:
@@ -69,7 +83,7 @@ const char *getGPSPowerStateString(GPSPowerState state)
}
}
-void GPS::UBXChecksum(uint8_t *message, size_t length)
+static void UBXChecksum(uint8_t *message, size_t length)
{
uint8_t CK_A = 0, CK_B = 0;
@@ -85,7 +99,7 @@ void GPS::UBXChecksum(uint8_t *message, size_t length)
}
// Calculate the checksum for a CAS packet
-void GPS::CASChecksum(uint8_t *message, size_t length)
+static void CASChecksum(uint8_t *message, size_t length)
{
uint32_t cksum = ((uint32_t)message[5] << 24); // Message ID
cksum += ((uint32_t)message[4]) << 16; // Class
@@ -410,6 +424,15 @@ int GPS::getACK(uint8_t *buffer, uint16_t size, uint8_t requestedClass, uint8_t
return 0;
}
+#if GPS_BAUDRATE_FIXED
+// if GPS_BAUDRATE is specified in variant, only try that.
+static const int serialSpeeds[1] = {GPS_BAUDRATE};
+static const int rareSerialSpeeds[1] = {GPS_BAUDRATE};
+#else
+static const int serialSpeeds[3] = {9600, 115200, 38400};
+static const int rareSerialSpeeds[3] = {4800, 57600, GPS_BAUDRATE};
+#endif
+
/**
* @brief Setup the GPS based on the model detected.
* We detect the GPS by cycling through a set of baud rates, first common then rare.
@@ -419,7 +442,6 @@ int GPS::getACK(uint8_t *buffer, uint16_t size, uint8_t requestedClass, uint8_t
*/
bool GPS::setup()
{
-
if (!didSerialInit) {
int msglen = 0;
if (tx_gpio && gnssModel == GNSS_MODEL_UNKNOWN) {
@@ -427,7 +449,7 @@ bool GPS::setup()
LOG_DEBUG("Probe for GPS at %d", serialSpeeds[speedSelect]);
gnssModel = probe(serialSpeeds[speedSelect]);
if (gnssModel == GNSS_MODEL_UNKNOWN) {
- if (++speedSelect == sizeof(serialSpeeds) / sizeof(int)) {
+ if (++speedSelect == array_count(serialSpeeds)) {
speedSelect = 0;
++probeTries;
}
@@ -438,7 +460,7 @@ bool GPS::setup()
LOG_DEBUG("Probe for GPS at %d", rareSerialSpeeds[speedSelect]);
gnssModel = probe(rareSerialSpeeds[speedSelect]);
if (gnssModel == GNSS_MODEL_UNKNOWN) {
- if (++speedSelect == sizeof(rareSerialSpeeds) / sizeof(int)) {
+ if (++speedSelect == array_count(rareSerialSpeeds)) {
LOG_WARN("Give up on GPS probe and set to %d", GPS_BAUDRATE);
return true;
}
@@ -634,7 +656,7 @@ bool GPS::setup()
SEND_UBX_PACKET(0x06, 0x01, _message_RMC, "enable NMEA RMC", 500);
SEND_UBX_PACKET(0x06, 0x01, _message_GGA, "enable NMEA GGA", 500);
- if (uBloxProtocolVersion >= 18) {
+ if (ublox_info.protocol_version >= 18) {
clearBuffer();
SEND_UBX_PACKET(0x06, 0x86, _message_PMS, "enable powersave for GPS", 500);
SEND_UBX_PACKET(0x06, 0x3B, _message_CFG_PM2, "enable powersave details for GPS", 500);
@@ -718,6 +740,7 @@ GPS::~GPS()
// we really should unregister our sleep observer
notifyDeepSleepObserver.unobserve(¬ifyDeepSleep);
}
+
// Put the GPS hardware into a specified state
void GPS::setPowerState(GPSPowerState newState, uint32_t sleepTime)
{
@@ -882,17 +905,17 @@ void GPS::setPowerUBLOX(bool on, uint32_t sleepMs)
if (gnssModel != GNSS_MODEL_UBLOX10) {
// Encode the sleep time in millis into the packet
for (int i = 0; i < 4; i++)
- gps->_message_PMREQ[0 + i] = sleepMs >> (i * 8);
+ _message_PMREQ[0 + i] = sleepMs >> (i * 8);
// Record the message length
- msglen = gps->makeUBXPacket(0x02, 0x41, sizeof(_message_PMREQ), gps->_message_PMREQ);
+ msglen = gps->makeUBXPacket(0x02, 0x41, sizeof(_message_PMREQ), _message_PMREQ);
} else {
// Encode the sleep time in millis into the packet
for (int i = 0; i < 4; i++)
- gps->_message_PMREQ_10[4 + i] = sleepMs >> (i * 8);
+ _message_PMREQ_10[4 + i] = sleepMs >> (i * 8);
// Record the message length
- msglen = gps->makeUBXPacket(0x02, 0x41, sizeof(_message_PMREQ_10), gps->_message_PMREQ_10);
+ msglen = gps->makeUBXPacket(0x02, 0x41, sizeof(_message_PMREQ_10), _message_PMREQ_10);
}
// Send the UBX packet
@@ -1099,17 +1122,19 @@ int GPS::prepareDeepSleep(void *unused)
return 0;
}
-const char *PROBE_MESSAGE = "Trying %s (%s)...";
-const char *DETECTED_MESSAGE = "%s detected, using %s Module";
+static const char *PROBE_MESSAGE = "Trying %s (%s)...";
+static const char *DETECTED_MESSAGE = "%s detected, using %s Module";
#define PROBE_SIMPLE(CHIP, TOWRITE, RESPONSE, DRIVER, TIMEOUT, ...) \
- LOG_DEBUG(PROBE_MESSAGE, TOWRITE, CHIP); \
- clearBuffer(); \
- _serial_gps->write(TOWRITE "\r\n"); \
- if (getACK(RESPONSE, TIMEOUT) == GNSS_RESPONSE_OK) { \
- LOG_INFO(DETECTED_MESSAGE, CHIP, #DRIVER); \
- return DRIVER; \
- }
+ do { \
+ LOG_DEBUG(PROBE_MESSAGE, TOWRITE, CHIP); \
+ clearBuffer(); \
+ _serial_gps->write(TOWRITE "\r\n"); \
+ if (getACK(RESPONSE, TIMEOUT) == GNSS_RESPONSE_OK) { \
+ LOG_INFO(DETECTED_MESSAGE, CHIP, #DRIVER); \
+ return DRIVER; \
+ } \
+ } while (0)
GnssModel_t GPS::probe(int serialSpeed)
{
@@ -1127,7 +1152,7 @@ GnssModel_t GPS::probe(int serialSpeed)
}
#endif
- memset(&info, 0, sizeof(struct uBloxGnssModelInfo));
+ memset(&ublox_info, 0, sizeof(ublox_info));
uint8_t buffer[768] = {0};
delay(100);
@@ -1194,64 +1219,64 @@ GnssModel_t GPS::probe(int serialSpeed)
if (len) {
uint16_t position = 0;
for (int i = 0; i < 30; i++) {
- info.swVersion[i] = buffer[position];
+ ublox_info.swVersion[i] = buffer[position];
position++;
}
for (int i = 0; i < 10; i++) {
- info.hwVersion[i] = buffer[position];
+ ublox_info.hwVersion[i] = buffer[position];
position++;
}
while (len >= position + 30) {
for (int i = 0; i < 30; i++) {
- info.extension[info.extensionNo][i] = buffer[position];
+ ublox_info.extension[ublox_info.extensionNo][i] = buffer[position];
position++;
}
- info.extensionNo++;
- if (info.extensionNo > 9)
+ ublox_info.extensionNo++;
+ if (ublox_info.extensionNo > 9)
break;
}
LOG_DEBUG("Module Info : ");
- LOG_DEBUG("Soft version: %s", info.swVersion);
- LOG_DEBUG("Hard version: %s", info.hwVersion);
- LOG_DEBUG("Extensions:%d", info.extensionNo);
- for (int i = 0; i < info.extensionNo; i++) {
- LOG_DEBUG(" %s", info.extension[i]);
+ LOG_DEBUG("Soft version: %s", ublox_info.swVersion);
+ LOG_DEBUG("Hard version: %s", ublox_info.hwVersion);
+ LOG_DEBUG("Extensions:%d", ublox_info.extensionNo);
+ for (int i = 0; i < ublox_info.extensionNo; i++) {
+ LOG_DEBUG(" %s", ublox_info.extension[i]);
}
memset(buffer, 0, sizeof(buffer));
// tips: extensionNo field is 0 on some 6M GNSS modules
- for (int i = 0; i < info.extensionNo; ++i) {
- if (!strncmp(info.extension[i], "MOD=", 4)) {
- strncpy((char *)buffer, &(info.extension[i][4]), sizeof(buffer));
- } else if (!strncmp(info.extension[i], "PROTVER", 7)) {
+ for (int i = 0; i < ublox_info.extensionNo; ++i) {
+ if (!strncmp(ublox_info.extension[i], "MOD=", 4)) {
+ strncpy((char *)buffer, &(ublox_info.extension[i][4]), sizeof(buffer));
+ } else if (!strncmp(ublox_info.extension[i], "PROTVER", 7)) {
char *ptr = nullptr;
memset(buffer, 0, sizeof(buffer));
- strncpy((char *)buffer, &(info.extension[i][8]), sizeof(buffer));
+ strncpy((char *)buffer, &(ublox_info.extension[i][8]), sizeof(buffer));
LOG_DEBUG("Protocol Version:%s", (char *)buffer);
if (strlen((char *)buffer)) {
- uBloxProtocolVersion = strtoul((char *)buffer, &ptr, 10);
- LOG_DEBUG("ProtVer=%d", uBloxProtocolVersion);
+ ublox_info.protocol_version = strtoul((char *)buffer, &ptr, 10);
+ LOG_DEBUG("ProtVer=%d", ublox_info.protocol_version);
} else {
- uBloxProtocolVersion = 0;
+ ublox_info.protocol_version = 0;
}
}
}
- if (strncmp(info.hwVersion, "00040007", 8) == 0) {
+ if (strncmp(ublox_info.hwVersion, "00040007", 8) == 0) {
LOG_INFO(DETECTED_MESSAGE, "U-blox 6", "6");
return GNSS_MODEL_UBLOX6;
- } else if (strncmp(info.hwVersion, "00070000", 8) == 0) {
+ } else if (strncmp(ublox_info.hwVersion, "00070000", 8) == 0) {
LOG_INFO(DETECTED_MESSAGE, "U-blox 7", "7");
return GNSS_MODEL_UBLOX7;
- } else if (strncmp(info.hwVersion, "00080000", 8) == 0) {
+ } else if (strncmp(ublox_info.hwVersion, "00080000", 8) == 0) {
LOG_INFO(DETECTED_MESSAGE, "U-blox 8", "8");
return GNSS_MODEL_UBLOX8;
- } else if (strncmp(info.hwVersion, "00190000", 8) == 0) {
+ } else if (strncmp(ublox_info.hwVersion, "00190000", 8) == 0) {
LOG_INFO(DETECTED_MESSAGE, "U-blox 9", "9");
return GNSS_MODEL_UBLOX9;
- } else if (strncmp(info.hwVersion, "000A0000", 8) == 0) {
+ } else if (strncmp(ublox_info.hwVersion, "000A0000", 8) == 0) {
LOG_INFO(DETECTED_MESSAGE, "U-blox 10", "10");
return GNSS_MODEL_UBLOX10;
}
@@ -1725,4 +1750,4 @@ void GPS::toggleGpsMode()
enable();
}
}
-#endif // Exclude GPS
+#endif // Exclude GPS
\ No newline at end of file
diff --git a/src/gps/GPS.h b/src/gps/GPS.h
index cd61c5444..74d73e39a 100644
--- a/src/gps/GPS.h
+++ b/src/gps/GPS.h
@@ -16,13 +16,6 @@
#define GPS_EN_ACTIVE 1
#endif
-struct uBloxGnssModelInfo {
- char swVersion[30];
- char hwVersion[10];
- uint8_t extensionNo;
- char extension[10][30];
-};
-
typedef enum {
GNSS_MODEL_ATGM336H,
GNSS_MODEL_MTK,
@@ -54,9 +47,6 @@ enum GPSPowerState : uint8_t {
GPS_OFF // Powered off indefinitely
};
-// Generate a string representation of DOP
-const char *getDOPString(uint32_t dop);
-
/**
* A gps class that only reads from the GPS periodically and keeps the gps powered down except when reading
*
@@ -64,109 +54,7 @@ const char *getDOPString(uint32_t dop);
*/
class GPS : private concurrency::OSThread
{
- TinyGPSPlus reader;
- uint8_t fixQual = 0; // fix quality from GPGGA
- uint32_t lastChecksumFailCount = 0;
-
-#ifndef TINYGPS_OPTION_NO_CUSTOM_FIELDS
- // (20210908) TinyGps++ can only read the GPGSA "FIX TYPE" field
- // via optional feature "custom fields", currently disabled (bug #525)
- TinyGPSCustom gsafixtype; // custom extract fix type from GPGSA
- TinyGPSCustom gsapdop; // custom extract PDOP from GPGSA
- uint8_t fixType = 0; // fix type from GPGSA
-#endif
- private:
-#if GPS_BAUDRATE_FIXED
- // if GPS_BAUDRATE is specified in variant, only try that.
- const int serialSpeeds[1] = {GPS_BAUDRATE};
- const int rareSerialSpeeds[1] = {GPS_BAUDRATE};
-#else
- const int serialSpeeds[3] = {9600, 115200, 38400};
- const int rareSerialSpeeds[3] = {4800, 57600, GPS_BAUDRATE};
-#endif
-
- uint32_t lastWakeStartMsec = 0, lastSleepStartMsec = 0, lastFixStartMsec = 0;
- uint32_t rx_gpio = 0;
- uint32_t tx_gpio = 0;
-
- int speedSelect = 0;
- int probeTries = 0;
-
- /**
- * hasValidLocation - indicates that the position variables contain a complete
- * GPS location, valid and fresh (< gps_update_interval + position_broadcast_secs)
- */
- bool hasValidLocation = false; // default to false, until we complete our first read
-
- bool isInPowersave = false;
-
- bool shouldPublish = false; // If we've changed GPS state, this will force a publish the next loop()
-
- bool hasGPS = false; // Do we have a GPS we are talking to
-
- bool GPSInitFinished = false; // Init thread finished?
- bool GPSInitStarted = false; // Init thread finished?
-
- GPSPowerState powerState = GPS_OFF; // GPS_ACTIVE if we want a location right now
-
- uint8_t numSatellites = 0;
-
- CallbackObserver notifyDeepSleepObserver = CallbackObserver(this, &GPS::prepareDeepSleep);
-
public:
- /** If !NULL we will use this serial port to construct our GPS */
-#if defined(ARCH_RP2040)
- static SerialUART *_serial_gps;
-#else
- static HardwareSerial *_serial_gps;
-#endif
- static uint8_t _message_PMREQ[];
- static uint8_t _message_PMREQ_10[];
- static const uint8_t _message_CFG_RXM_PSM[];
- static const uint8_t _message_CFG_RXM_ECO[];
- static const uint8_t _message_CFG_PM2[];
- static const uint8_t _message_GNSS_7[];
- static const uint8_t _message_GNSS_8[];
- static const uint8_t _message_JAM_6_7[];
- static const uint8_t _message_JAM_8[];
- static const uint8_t _message_NAVX5[];
- static const uint8_t _message_NAVX5_8[];
- static const uint8_t _message_NMEA[];
- static const uint8_t _message_DISABLE_TXT_INFO[];
- static const uint8_t _message_1HZ[];
- static const uint8_t _message_GLL[];
- static const uint8_t _message_GSA[];
- static const uint8_t _message_GSV[];
- static const uint8_t _message_VTG[];
- static const uint8_t _message_RMC[];
- static const uint8_t _message_AID[];
- static const uint8_t _message_GGA[];
- static const uint8_t _message_PMS[];
- static const uint8_t _message_SAVE[];
- static const uint8_t _message_SAVE_10[];
-
- // VALSET Commands for M10
- static const uint8_t _message_VALSET_PM[];
- static const uint8_t _message_VALSET_PM_RAM[];
- static const uint8_t _message_VALSET_PM_BBR[];
- static const uint8_t _message_VALSET_ITFM_RAM[];
- static const uint8_t _message_VALSET_ITFM_BBR[];
- static const uint8_t _message_VALSET_DISABLE_NMEA_RAM[];
- static const uint8_t _message_VALSET_DISABLE_NMEA_BBR[];
- static const uint8_t _message_VALSET_DISABLE_TXT_INFO_RAM[];
- static const uint8_t _message_VALSET_DISABLE_TXT_INFO_BBR[];
- static const uint8_t _message_VALSET_ENABLE_NMEA_RAM[];
- static const uint8_t _message_VALSET_ENABLE_NMEA_BBR[];
- static const uint8_t _message_VALSET_DISABLE_SBAS_RAM[];
- static const uint8_t _message_VALSET_DISABLE_SBAS_BBR[];
-
- // CASIC commands for ATGM336H
- static const uint8_t _message_CAS_CFG_RST_FACTORY[];
- static const uint8_t _message_CAS_CFG_NAVX_CONF[];
- static const uint8_t _message_CAS_CFG_RATE_1HZ[];
-
- const char *ACK_SUCCESS_MESSAGE = "Get ack success!";
-
meshtastic_Position p = meshtastic_Position_init_default;
/** This is normally bound to config.position.gps_en_gpio but some rare boards (like heltec tracker) need more advanced
@@ -176,8 +64,6 @@ class GPS : private concurrency::OSThread
*/
GpioVirtPin *enablePin = NULL;
- GPS() : concurrency::OSThread("GPS") {}
-
virtual ~GPS();
/** We will notify this observable anytime GPS state has changed meaningfully */
@@ -214,21 +100,6 @@ class GPS : private concurrency::OSThread
// Empty the input buffer as quickly as possible
void clearBuffer();
- // Create a ublox packet for editing in memory
- uint8_t makeUBXPacket(uint8_t class_id, uint8_t msg_id, uint8_t payload_size, const uint8_t *msg);
- uint8_t makeCASPacket(uint8_t class_id, uint8_t msg_id, uint8_t payload_size, const uint8_t *msg);
-
- // scratch space for creating ublox packets
- uint8_t UBXscratch[250] = {0};
-
- int rebootsSeen = 0;
-
- int getACK(uint8_t *buffer, uint16_t size, uint8_t requestedClass, uint8_t requestedID, uint32_t waitMillis);
- GPS_RESPONSE getACK(uint8_t c, uint8_t i, uint32_t waitMillis);
- GPS_RESPONSE getACK(const char *message, uint32_t waitMillis);
-
- GPS_RESPONSE getACKCas(uint8_t class_id, uint8_t msg_id, uint32_t waitMillis);
-
virtual bool factoryReset();
// Creates an instance of the GPS class.
@@ -241,20 +112,8 @@ class GPS : private concurrency::OSThread
// Let the GPS hardware save power between updates
void down();
- protected:
- /**
- * Perform any processing that should be done only while the GPS is awake and looking for a fix.
- * Override this method to check for new locations
- *
- * @return true if we've acquired a time
- */
-
- /**
- * Perform any processing that should be done only while the GPS is awake and looking for a fix.
- * Override this method to check for new locations
- *
- * @return true if we've acquired a new location
- */
+ private:
+ GPS() : concurrency::OSThread("GPS") {}
/// Record that we have a GPS
void setConnected();
@@ -281,15 +140,74 @@ class GPS : private concurrency::OSThread
*/
virtual bool lookForLocation();
- private:
+ GnssModel_t gnssModel = GNSS_MODEL_UNKNOWN;
+
+ TinyGPSPlus reader;
+ uint8_t fixQual = 0; // fix quality from GPGGA
+ uint32_t lastChecksumFailCount = 0;
+
+#ifndef TINYGPS_OPTION_NO_CUSTOM_FIELDS
+ // (20210908) TinyGps++ can only read the GPGSA "FIX TYPE" field
+ // via optional feature "custom fields", currently disabled (bug #525)
+ TinyGPSCustom gsafixtype; // custom extract fix type from GPGSA
+ TinyGPSCustom gsapdop; // custom extract PDOP from GPGSA
+ uint8_t fixType = 0; // fix type from GPGSA
+#endif
+
+ uint32_t lastWakeStartMsec = 0, lastSleepStartMsec = 0, lastFixStartMsec = 0;
+ uint32_t rx_gpio = 0;
+ uint32_t tx_gpio = 0;
+
+ int speedSelect = 0;
+ int probeTries = 0;
+
+ /**
+ * hasValidLocation - indicates that the position variables contain a complete
+ * GPS location, valid and fresh (< gps_update_interval + position_broadcast_secs)
+ */
+ bool hasValidLocation = false; // default to false, until we complete our first read
+
+ bool isInPowersave = false;
+
+ bool shouldPublish = false; // If we've changed GPS state, this will force a publish the next loop()
+
+ bool hasGPS = false; // Do we have a GPS we are talking to
+
+ bool GPSInitFinished = false; // Init thread finished?
+ bool GPSInitStarted = false; // Init thread finished?
+
+ GPSPowerState powerState = GPS_OFF; // GPS_ACTIVE if we want a location right now
+
+ uint8_t numSatellites = 0;
+
+ CallbackObserver notifyDeepSleepObserver = CallbackObserver(this, &GPS::prepareDeepSleep);
+
+ /** If !NULL we will use this serial port to construct our GPS */
+#if defined(ARCH_RP2040)
+ static SerialUART *_serial_gps;
+#else
+ static HardwareSerial *_serial_gps;
+#endif
+
+ // Create a ublox packet for editing in memory
+ uint8_t makeUBXPacket(uint8_t class_id, uint8_t msg_id, uint8_t payload_size, const uint8_t *msg);
+ uint8_t makeCASPacket(uint8_t class_id, uint8_t msg_id, uint8_t payload_size, const uint8_t *msg);
+
+ // scratch space for creating ublox packets
+ uint8_t UBXscratch[250] = {0};
+
+ int rebootsSeen = 0;
+
+ int getACK(uint8_t *buffer, uint16_t size, uint8_t requestedClass, uint8_t requestedID, uint32_t waitMillis);
+ GPS_RESPONSE getACK(uint8_t c, uint8_t i, uint32_t waitMillis);
+ GPS_RESPONSE getACK(const char *message, uint32_t waitMillis);
+
+ GPS_RESPONSE getACKCas(uint8_t class_id, uint8_t msg_id, uint32_t waitMillis);
+
/// Prepare the GPS for the cpu entering deep sleep, expect to be gone for at least 100s of msecs
/// always returns 0 to indicate okay to sleep
int prepareDeepSleep(void *unused);
- // Calculate checksum
- void UBXChecksum(uint8_t *message, size_t length);
- void CASChecksum(uint8_t *message, size_t length);
-
/** Set power with EN pin, if relevant
*/
void writePinEN(bool on);
@@ -318,12 +236,7 @@ class GPS : private concurrency::OSThread
// delay counter to allow more sats before fixed position stops GPS thread
uint8_t fixeddelayCtr = 0;
-
- const char *powerStateToString();
-
- protected:
- GnssModel_t gnssModel = GNSS_MODEL_UNKNOWN;
};
extern GPS *gps;
-#endif // Exclude GPS
\ No newline at end of file
+#endif // Exclude GPS
diff --git a/src/gps/GeoCoord.cpp b/src/gps/GeoCoord.cpp
index 5abb25a06..6d1f2da6d 100644
--- a/src/gps/GeoCoord.cpp
+++ b/src/gps/GeoCoord.cpp
@@ -574,3 +574,23 @@ const char *GeoCoord::degreesToBearing(unsigned int degrees)
else
return "N";
}
+
+double GeoCoord::pow_neg(double base, double exponent)
+{
+ if (exponent == 0) {
+ return 1;
+ } else if (exponent > 0) {
+ return pow(base, exponent);
+ }
+ return 1 / pow(base, -exponent);
+}
+
+double GeoCoord::toRadians(double deg)
+{
+ return deg * PI / 180;
+}
+
+double GeoCoord::toDegrees(double r)
+{
+ return r * 180 / PI;
+}
\ No newline at end of file
diff --git a/src/gps/GeoCoord.h b/src/gps/GeoCoord.h
index ecdaf0ec7..658c177b3 100644
--- a/src/gps/GeoCoord.h
+++ b/src/gps/GeoCoord.h
@@ -13,28 +13,6 @@
#define OLC_CODE_LEN 11
#define DEG_CONVERT (180 / PI)
-// Helper functions
-// Raises a number to an exponent, handling negative exponents.
-static inline double pow_neg(double base, double exponent)
-{
- if (exponent == 0) {
- return 1;
- } else if (exponent > 0) {
- return pow(base, exponent);
- }
- return 1 / pow(base, -exponent);
-}
-
-static inline double toRadians(double deg)
-{
- return deg * PI / 180;
-}
-
-static inline double toDegrees(double r)
-{
- return r * 180 / PI;
-}
-
// GeoCoord structs/classes
// A struct to hold the data for a DMS coordinate.
struct DMS {
@@ -120,6 +98,11 @@ class GeoCoord
static unsigned int bearingToDegrees(const char *bearing);
static const char *degreesToBearing(unsigned int degrees);
+ // Raises a number to an exponent, handling negative exponents.
+ static double pow_neg(double base, double exponent);
+ static double toRadians(double deg);
+ static double toDegrees(double r);
+
// Point to point conversions
int32_t distanceTo(const GeoCoord &pointB);
int32_t bearingTo(const GeoCoord &pointB);
@@ -162,4 +145,4 @@ class GeoCoord
// OLC getter
void getOLCCode(char *code) { strncpy(code, _olc.code, OLC_CODE_LEN + 1); } // +1 for null termination
-};
+};
\ No newline at end of file
diff --git a/src/gps/cas.h b/src/gps/cas.h
index 53d75cda9..725fd07b3 100644
--- a/src/gps/cas.h
+++ b/src/gps/cas.h
@@ -21,7 +21,7 @@
// CFG-RST (0x06, 0x02)
// Factory reset
-const uint8_t GPS::_message_CAS_CFG_RST_FACTORY[] = {
+static const uint8_t _message_CAS_CFG_RST_FACTORY[] = {
0xFF, 0x03, // Fields to clear
0x01, // Reset Mode: Controlled Software reset
0x03 // Startup Mode: Factory
@@ -30,7 +30,7 @@ const uint8_t GPS::_message_CAS_CFG_RST_FACTORY[] = {
// CFG_RATE (0x06, 0x01)
// 1HZ update rate, this should always be the case after
// factory reset but update it regardless
-const uint8_t GPS::_message_CAS_CFG_RATE_1HZ[] = {
+static const uint8_t _message_CAS_CFG_RATE_1HZ[] = {
0xE8, 0x03, // Update Rate: 0x03E8 = 1000ms
0x00, 0x00 // Reserved
};
@@ -39,7 +39,7 @@ const uint8_t GPS::_message_CAS_CFG_RATE_1HZ[] = {
// Initial ATGM33H-5N configuration, Updates for Dynamic Mode, Fix Mode, and SV system
// Qwirk: The ATGM33H-5N-31 should only support GPS+BDS, however it will happily enable
// and use GPS+BDS+GLONASS iff the correct CFG_NAVX command is used.
-const uint8_t GPS::_message_CAS_CFG_NAVX_CONF[] = {
+static const uint8_t _message_CAS_CFG_NAVX_CONF[] = {
0x03, 0x01, 0x00, 0x00, // Update Mask: Dynamic Mode, Fix Mode, Nav Settings
0x03, // Dynamic Mode: Automotive
0x03, // Fix Mode: Auto 2D/3D
@@ -60,4 +60,4 @@ const uint8_t GPS::_message_CAS_CFG_NAVX_CONF[] = {
0x00, 0x00, 0x00, 0x00, // Position Accuracy Max
0x00, 0x00, 0x00, 0x00, // Time Accuracy Max
0x00, 0x00, 0x00, 0x00 // Static Hold Threshold
-};
\ No newline at end of file
+};
diff --git a/src/gps/ubx.h b/src/gps/ubx.h
index 551921384..d674bed51 100644
--- a/src/gps/ubx.h
+++ b/src/gps/ubx.h
@@ -1,20 +1,22 @@
-const char *failMessage = "Unable to %s";
+static const char *failMessage = "Unable to %s";
#define SEND_UBX_PACKET(TYPE, ID, DATA, ERRMSG, TIMEOUT) \
- msglen = makeUBXPacket(TYPE, ID, sizeof(DATA), DATA); \
- _serial_gps->write(UBXscratch, msglen); \
- if (getACK(TYPE, ID, TIMEOUT) != GNSS_RESPONSE_OK) { \
- LOG_WARN(failMessage, #ERRMSG); \
- }
+ do { \
+ msglen = makeUBXPacket(TYPE, ID, sizeof(DATA), DATA); \
+ _serial_gps->write(UBXscratch, msglen); \
+ if (getACK(TYPE, ID, TIMEOUT) != GNSS_RESPONSE_OK) { \
+ LOG_WARN(failMessage, #ERRMSG); \
+ } \
+ } while (0)
// Power Management
-uint8_t GPS::_message_PMREQ[] PROGMEM = {
+static uint8_t _message_PMREQ[] PROGMEM = {
0x00, 0x00, 0x00, 0x00, // 4 bytes duration of request task (milliseconds)
0x02, 0x00, 0x00, 0x00 // Bitfield, set backup = 1
};
-uint8_t GPS::_message_PMREQ_10[] PROGMEM = {
+static uint8_t _message_PMREQ_10[] PROGMEM = {
0x00, // version (0 for this version)
0x00, 0x00, 0x00, // Reserved 1
0x00, 0x00, 0x00, 0x00, // 4 bytes duration of request task (milliseconds)
@@ -22,18 +24,18 @@ uint8_t GPS::_message_PMREQ_10[] PROGMEM = {
0x08, 0x00, 0x00, 0x00 // wakeupSources Wake on uartrx
};
-const uint8_t GPS::_message_CFG_RXM_PSM[] PROGMEM = {
+static const uint8_t _message_CFG_RXM_PSM[] PROGMEM = {
0x08, // Reserved
0x01 // Power save mode
};
// only for Neo-6
-const uint8_t GPS::_message_CFG_RXM_ECO[] PROGMEM = {
+static const uint8_t _message_CFG_RXM_ECO[] PROGMEM = {
0x08, // Reserved
0x04 // eco mode
};
-const uint8_t GPS::_message_CFG_PM2[] PROGMEM = {
+static const uint8_t _message_CFG_PM2[] PROGMEM = {
0x01, // version
0x00, // Reserved 1, set to 0x06 by u-Center
0x00, // Reserved 2
@@ -58,7 +60,7 @@ const uint8_t GPS::_message_CFG_PM2[] PROGMEM = {
// Constallation setup, none required for Neo-6
// For Neo-7 GPS & SBAS
-const uint8_t GPS::_message_GNSS_7[] = {
+static const uint8_t _message_GNSS_7[] = {
0x00, // msgVer (0 for this version)
0x00, // numTrkChHw (max number of hardware channels, read only, so it's always 0)
0xff, // numTrkChUse (max number of channels to use, 0xff = max available)
@@ -76,7 +78,7 @@ const uint8_t GPS::_message_GNSS_7[] = {
// There is also a possibility that the module may be GPS-only.
// For M8 GPS, GLONASS, Galileo, SBAS, QZSS
-const uint8_t GPS::_message_GNSS_8[] = {
+static const uint8_t _message_GNSS_8[] = {
0x00, // msgVer (0 for this version)
0x00, // numTrkChHw (max number of hardware channels, read only, so it's always 0)
0xff, // numTrkChUse (max number of channels to use, 0xff = max available)
@@ -90,7 +92,7 @@ const uint8_t GPS::_message_GNSS_8[] = {
};
/*
// For M8 GPS, GLONASS, BeiDou, SBAS, QZSS
-const uint8_t GPS::_message_GNSS_8_B[] = {
+static const uint8_t _message_GNSS_8_B[] = {
0x00, // msgVer (0 for this version)
0x00, // numTrkChHw (max number of hardware channels, read only, so it's always 0)
0xff, // numTrkChUse (max number of channels to use, 0xff = max available) read only for protocol >23
@@ -105,7 +107,7 @@ const uint8_t GPS::_message_GNSS_8_B[] = {
*/
// For M8 we want to enable NMEA version 4.10 messages to allow for Galileo and or BeiDou
-const uint8_t GPS::_message_NMEA[]{
+static const uint8_t _message_NMEA[]{
0x00, // filter flags
0x41, // NMEA Version
0x00, // Max number of SVs to report per TaklerId
@@ -121,13 +123,13 @@ const uint8_t GPS::_message_NMEA[]{
// Enable jamming/interference monitor
// For Neo-6, Max-7 and Neo-7
-const uint8_t GPS::_message_JAM_6_7[] = {
+static const uint8_t _message_JAM_6_7[] = {
0xf3, 0xac, 0x62, 0xad, // config1 bbThreshold = 3, cwThreshold = 15, enable = 1, reserved bits 0x16B156
0x1e, 0x03, 0x00, 0x00 // config2 antennaSetting Unknown = 0, reserved 3, = 0x00,0x00, reserved 2 = 0x31E
};
// For M8
-const uint8_t GPS::_message_JAM_8[] = {
+static const uint8_t _message_JAM_8[] = {
0xf3, 0xac, 0x62, 0xad, // config1 bbThreshold = 3, cwThreshold = 15, enable1 = 1, reserved bits 0x16B156
0x1e, 0x43, 0x00, 0x00 // config2 antennaSetting Unknown = 0, enable2 = 1, generalBits = 0x31E
};
@@ -137,7 +139,7 @@ const uint8_t GPS::_message_JAM_8[] = {
// ToDo: check UBX-MON-VER for module type and protocol version
// For the Neo-6
-const uint8_t GPS::_message_NAVX5[] = {
+static const uint8_t _message_NAVX5[] = {
0x00, 0x00, // msgVer (0 for this version)
0x4c, 0x66, // mask1
0x00, 0x00, 0x00, 0x00, // Reserved 0
@@ -166,7 +168,7 @@ const uint8_t GPS::_message_NAVX5[] = {
0x00, 0x00, 0x00, 0x00 // Reserved 4
};
// For the M8
-const uint8_t GPS::_message_NAVX5_8[] = {
+static const uint8_t _message_NAVX5_8[] = {
0x02, 0x00, // msgVer (2 for this version)
0x4c, 0x66, // mask1
0x00, 0x00, 0x00, 0x00, // mask2
@@ -197,7 +199,7 @@ const uint8_t GPS::_message_NAVX5_8[] = {
// Additionally, for some new modules like the M9/M10, an update rate lower than 5Hz
// is recommended to avoid a known issue with satellites disappearing.
// The module defaults for M8, M9, M10 are the same as we use here so no update is necessary
-const uint8_t GPS::_message_1HZ[] = {
+static const uint8_t _message_1HZ[] = {
0xE8, 0x03, // Measurement Rate (1000ms for 1Hz)
0x01, 0x00, // Navigation rate, always 1 in GPS mode
0x01, 0x00 // Time reference
@@ -205,7 +207,7 @@ const uint8_t GPS::_message_1HZ[] = {
// Disable GLL. GLL - Geographic position (latitude and longitude), which provides the current geographical
// coordinates.
-const uint8_t GPS::_message_GLL[] = {
+static const uint8_t _message_GLL[] = {
0xF0, 0x01, // NMEA ID for GLL
0x00, // Rate for DDC
0x00, // Rate for UART1
@@ -217,7 +219,7 @@ const uint8_t GPS::_message_GLL[] = {
// Disable GSA. GSA - GPS DOP and active satellites, used for detailing the satellites used in the positioning and
// the DOP (Dilution of Precision)
-const uint8_t GPS::_message_GSA[] = {
+static const uint8_t _message_GSA[] = {
0xF0, 0x02, // NMEA ID for GSA
0x00, // Rate for DDC
0x00, // Rate for UART1
@@ -228,7 +230,7 @@ const uint8_t GPS::_message_GSA[] = {
};
// Disable GSV. GSV - Satellites in view, details the number and location of satellites in view.
-const uint8_t GPS::_message_GSV[] = {
+static const uint8_t _message_GSV[] = {
0xF0, 0x03, // NMEA ID for GSV
0x00, // Rate for DDC
0x00, // Rate for UART1
@@ -240,7 +242,7 @@ const uint8_t GPS::_message_GSV[] = {
// Disable VTG. VTG - Track made good and ground speed, which provides course and speed information relative to
// the ground.
-const uint8_t GPS::_message_VTG[] = {
+static const uint8_t _message_VTG[] = {
0xF0, 0x05, // NMEA ID for VTG
0x00, // Rate for DDC
0x00, // Rate for UART1
@@ -251,7 +253,7 @@ const uint8_t GPS::_message_VTG[] = {
};
// Enable RMC. RMC - Recommended Minimum data, the essential gps pvt (position, velocity, time) data.
-const uint8_t GPS::_message_RMC[] = {
+static const uint8_t _message_RMC[] = {
0xF0, 0x04, // NMEA ID for RMC
0x00, // Rate for DDC
0x01, // Rate for UART1
@@ -262,7 +264,7 @@ const uint8_t GPS::_message_RMC[] = {
};
// Enable GGA. GGA - Global Positioning System Fix Data, which provides 3D location and accuracy data.
-const uint8_t GPS::_message_GGA[] = {
+static const uint8_t _message_GGA[] = {
0xF0, 0x00, // NMEA ID for GGA
0x00, // Rate for DDC
0x01, // Rate for UART1
@@ -274,7 +276,7 @@ const uint8_t GPS::_message_GGA[] = {
// Disable UBX-AID-ALPSRV as it may confuse TinyGPS. The Neo-6 seems to send this message
// whether the AID Autonomous is enabled or not
-const uint8_t GPS::_message_AID[] = {
+static const uint8_t _message_AID[] = {
0x0B, 0x32, // NMEA ID for UBX-AID-ALPSRV
0x00, // Rate for DDC
0x00, // Rate for UART1
@@ -287,7 +289,7 @@ const uint8_t GPS::_message_AID[] = {
// Turn off TEXT INFO Messages for all but M10 series
// B5 62 06 02 0A 00 01 00 00 00 03 03 00 03 03 00 1F 20
-const uint8_t GPS::_message_DISABLE_TXT_INFO[] = {
+static const uint8_t _message_DISABLE_TXT_INFO[] = {
0x01, // Protocol ID for NMEA
0x00, 0x00, 0x00, // Reserved
0x03, // I2C
@@ -310,7 +312,7 @@ const uint8_t GPS::_message_DISABLE_TXT_INFO[] = {
// and must be smaller than the period. It is only valid when the powerSetupValue is set to Interval; otherwise,
// it must be set to '0'.
// This command applies to M8 products
-const uint8_t GPS::_message_PMS[] = {
+static const uint8_t _message_PMS[] = {
0x00, // Version (0)
0x03, // Power setup value 3 = Agresssive 1Hz
0x00, 0x00, // period: not applicable, set to 0
@@ -318,14 +320,14 @@ const uint8_t GPS::_message_PMS[] = {
0x00, 0x00 // reserved, generated by u-center
};
-const uint8_t GPS::_message_SAVE[] = {
+static const uint8_t _message_SAVE[] = {
0x00, 0x00, 0x00, 0x00, // clearMask: no sections cleared
0xFF, 0xFF, 0x00, 0x00, // saveMask: save all sections
0x00, 0x00, 0x00, 0x00, // loadMask: no sections loaded
0x17 // deviceMask: BBR, Flash, EEPROM, and SPI Flash
};
-const uint8_t GPS::_message_SAVE_10[] = {
+static const uint8_t _message_SAVE_10[] = {
0x00, 0x00, 0x00, 0x00, // clearMask: no sections cleared
0xFF, 0xFF, 0x00, 0x00, // saveMask: save all sections
0x00, 0x00, 0x00, 0x00, // loadMask: no sections loaded
@@ -375,12 +377,12 @@ LIMITPEAKCURRENT L 1
// b5 62 06 8a 26 00 00 02 00 00 01 00 d0 20 02 02 00 d0 40 05 00 00 00 05 00 d0 30 01 00 08 00 d0 10 01 09 00 d0 10 01 10 00 d0
// 10 01 8c 03
*/
-const uint8_t GPS::_message_VALSET_PM_RAM[] = {0x00, 0x01, 0x00, 0x00, 0x01, 0x00, 0xd0, 0x20, 0x02, 0x02, 0x00, 0xd0, 0x40,
- 0x05, 0x00, 0x00, 0x00, 0x05, 0x00, 0xd0, 0x30, 0x01, 0x00, 0x08, 0x00, 0xd0,
- 0x10, 0x01, 0x09, 0x00, 0xd0, 0x10, 0x01, 0x10, 0x00, 0xd0, 0x10, 0x01};
-const uint8_t GPS::_message_VALSET_PM_BBR[] = {0x00, 0x02, 0x00, 0x00, 0x01, 0x00, 0xd0, 0x20, 0x02, 0x02, 0x00, 0xd0, 0x40,
- 0x05, 0x00, 0x00, 0x00, 0x05, 0x00, 0xd0, 0x30, 0x01, 0x00, 0x08, 0x00, 0xd0,
- 0x10, 0x01, 0x09, 0x00, 0xd0, 0x10, 0x01, 0x10, 0x00, 0xd0, 0x10, 0x01};
+static const uint8_t _message_VALSET_PM_RAM[] = {0x00, 0x01, 0x00, 0x00, 0x01, 0x00, 0xd0, 0x20, 0x02, 0x02, 0x00, 0xd0, 0x40,
+ 0x05, 0x00, 0x00, 0x00, 0x05, 0x00, 0xd0, 0x30, 0x01, 0x00, 0x08, 0x00, 0xd0,
+ 0x10, 0x01, 0x09, 0x00, 0xd0, 0x10, 0x01, 0x10, 0x00, 0xd0, 0x10, 0x01};
+static const uint8_t _message_VALSET_PM_BBR[] = {0x00, 0x02, 0x00, 0x00, 0x01, 0x00, 0xd0, 0x20, 0x02, 0x02, 0x00, 0xd0, 0x40,
+ 0x05, 0x00, 0x00, 0x00, 0x05, 0x00, 0xd0, 0x30, 0x01, 0x00, 0x08, 0x00, 0xd0,
+ 0x10, 0x01, 0x09, 0x00, 0xd0, 0x10, 0x01, 0x10, 0x00, 0xd0, 0x10, 0x01};
/*
CFG-ITFM replaced by 5 valset messages which can be combined into one for RAM and one for BBR
@@ -394,10 +396,10 @@ CFG-ITFM replaced by 5 valset messages which can be combined into one for RAM an
b5 62 06 8a 0e 00 00 01 00 00 0d 00 41 10 01 13 00 41 10 01 63 c6
*/
-const uint8_t GPS::_message_VALSET_ITFM_RAM[] = {0x00, 0x01, 0x00, 0x00, 0x0d, 0x00, 0x41,
- 0x10, 0x01, 0x13, 0x00, 0x41, 0x10, 0x01};
-const uint8_t GPS::_message_VALSET_ITFM_BBR[] = {0x00, 0x02, 0x00, 0x00, 0x0d, 0x00, 0x41,
- 0x10, 0x01, 0x13, 0x00, 0x41, 0x10, 0x01};
+static const uint8_t _message_VALSET_ITFM_RAM[] = {0x00, 0x01, 0x00, 0x00, 0x0d, 0x00, 0x41,
+ 0x10, 0x01, 0x13, 0x00, 0x41, 0x10, 0x01};
+static const uint8_t _message_VALSET_ITFM_BBR[] = {0x00, 0x02, 0x00, 0x00, 0x0d, 0x00, 0x41,
+ 0x10, 0x01, 0x13, 0x00, 0x41, 0x10, 0x01};
// Turn off all NMEA messages:
// Ram layer config message:
@@ -407,13 +409,13 @@ const uint8_t GPS::_message_VALSET_ITFM_BBR[] = {0x00, 0x02, 0x00, 0x00, 0x0d, 0
// BBR layer config message:
// b5 62 06 8a 13 00 00 02 00 00 ca 00 91 20 00 c5 00 91 20 00 b1 00 91 20 00 f8 4e
-const uint8_t GPS::_message_VALSET_DISABLE_NMEA_RAM[] = {
+static const uint8_t _message_VALSET_DISABLE_NMEA_RAM[] = {
/*0x00, 0x01, 0x00, 0x00, 0xca, 0x00, 0x91, 0x20, 0x00, 0xc5, 0x00, 0x91, 0x20, 0x00, 0xb1, 0x00, 0x91, 0x20, 0x00 */
0x00, 0x01, 0x00, 0x00, 0xc0, 0x00, 0x91, 0x20, 0x00, 0xca, 0x00, 0x91, 0x20, 0x00, 0xc5, 0x00, 0x91,
0x20, 0x00, 0xac, 0x00, 0x91, 0x20, 0x00, 0xb1, 0x00, 0x91, 0x20, 0x00, 0xbb, 0x00, 0x91, 0x20, 0x00};
-const uint8_t GPS::_message_VALSET_DISABLE_NMEA_BBR[] = {0x00, 0x02, 0x00, 0x00, 0xca, 0x00, 0x91, 0x20, 0x00, 0xc5,
- 0x00, 0x91, 0x20, 0x00, 0xb1, 0x00, 0x91, 0x20, 0x00};
+static const uint8_t _message_VALSET_DISABLE_NMEA_BBR[] = {0x00, 0x02, 0x00, 0x00, 0xca, 0x00, 0x91, 0x20, 0x00, 0xc5,
+ 0x00, 0x91, 0x20, 0x00, 0xb1, 0x00, 0x91, 0x20, 0x00};
// Turn off text info messages:
// Ram layer config message:
@@ -432,17 +434,17 @@ const uint8_t GPS::_message_VALSET_DISABLE_NMEA_BBR[] = {0x00, 0x02, 0x00, 0x00,
// b5 62 06 8a 0e 00 00 04 00 00 bb 00 91 20 01 ac 00 91 20 01 6d b6
// Doing this for the FLASH layer isn't really required since we save the config to flash later
-const uint8_t GPS::_message_VALSET_DISABLE_TXT_INFO_RAM[] = {0x00, 0x01, 0x00, 0x00, 0x07, 0x00, 0x92, 0x20, 0x03};
-const uint8_t GPS::_message_VALSET_DISABLE_TXT_INFO_BBR[] = {0x00, 0x02, 0x00, 0x00, 0x07, 0x00, 0x92, 0x20, 0x03};
+static const uint8_t _message_VALSET_DISABLE_TXT_INFO_RAM[] = {0x00, 0x01, 0x00, 0x00, 0x07, 0x00, 0x92, 0x20, 0x03};
+static const uint8_t _message_VALSET_DISABLE_TXT_INFO_BBR[] = {0x00, 0x02, 0x00, 0x00, 0x07, 0x00, 0x92, 0x20, 0x03};
-const uint8_t GPS::_message_VALSET_ENABLE_NMEA_RAM[] = {0x00, 0x01, 0x00, 0x00, 0xbb, 0x00, 0x91,
- 0x20, 0x01, 0xac, 0x00, 0x91, 0x20, 0x01};
-const uint8_t GPS::_message_VALSET_ENABLE_NMEA_BBR[] = {0x00, 0x02, 0x00, 0x00, 0xbb, 0x00, 0x91,
- 0x20, 0x01, 0xac, 0x00, 0x91, 0x20, 0x01};
-const uint8_t GPS::_message_VALSET_DISABLE_SBAS_RAM[] = {0x00, 0x01, 0x00, 0x00, 0x20, 0x00, 0x31,
- 0x10, 0x00, 0x05, 0x00, 0x31, 0x10, 0x00};
-const uint8_t GPS::_message_VALSET_DISABLE_SBAS_BBR[] = {0x00, 0x02, 0x00, 0x00, 0x20, 0x00, 0x31,
- 0x10, 0x00, 0x05, 0x00, 0x31, 0x10, 0x00};
+static const uint8_t _message_VALSET_ENABLE_NMEA_RAM[] = {0x00, 0x01, 0x00, 0x00, 0xbb, 0x00, 0x91,
+ 0x20, 0x01, 0xac, 0x00, 0x91, 0x20, 0x01};
+static const uint8_t _message_VALSET_ENABLE_NMEA_BBR[] = {0x00, 0x02, 0x00, 0x00, 0xbb, 0x00, 0x91,
+ 0x20, 0x01, 0xac, 0x00, 0x91, 0x20, 0x01};
+static const uint8_t _message_VALSET_DISABLE_SBAS_RAM[] = {0x00, 0x01, 0x00, 0x00, 0x20, 0x00, 0x31,
+ 0x10, 0x00, 0x05, 0x00, 0x31, 0x10, 0x00};
+static const uint8_t _message_VALSET_DISABLE_SBAS_BBR[] = {0x00, 0x02, 0x00, 0x00, 0x20, 0x00, 0x31,
+ 0x10, 0x00, 0x05, 0x00, 0x31, 0x10, 0x00};
/*
Operational issues with the M10:
@@ -475,4 +477,4 @@ b5 62 06 8a 0e 00 00 01 00 00 20 00 31 10 00 05 00 31 10 00 46 87
BBR layer config message:
b5 62 06 8a 0e 00 00 02 00 00 20 00 31 10 00 05 00 31 10 00 47 94
-*/
\ No newline at end of file
+*/
diff --git a/src/graphics/Screen.cpp b/src/graphics/Screen.cpp
index a875c11d6..dfef162ba 100644
--- a/src/graphics/Screen.cpp
+++ b/src/graphics/Screen.cpp
@@ -1420,7 +1420,7 @@ static void drawNodeInfo(OLEDDisplay *display, OLEDDisplayUiState *state, int16_
}
bool hasNodeHeading = false;
- if (ourNode && (hasValidPosition(ourNode) || screen->hasHeading())) {
+ if (ourNode && (nodeDB->hasValidPosition(ourNode) || screen->hasHeading())) {
const meshtastic_PositionLite &op = ourNode->position;
float myHeading;
if (screen->hasHeading())
@@ -1429,7 +1429,7 @@ static void drawNodeInfo(OLEDDisplay *display, OLEDDisplayUiState *state, int16_
myHeading = screen->estimatedHeading(DegD(op.latitude_i), DegD(op.longitude_i));
screen->drawCompassNorth(display, compassX, compassY, myHeading);
- if (hasValidPosition(node)) {
+ if (nodeDB->hasValidPosition(node)) {
// display direction toward node
hasNodeHeading = true;
const meshtastic_PositionLite &p = node->position;
@@ -2757,4 +2757,4 @@ int Screen::handleAdminMessage(const meshtastic_AdminMessage *arg)
} // namespace graphics
#else
graphics::Screen::Screen(ScanI2C::DeviceAddress, meshtastic_Config_DisplayConfig_OledType, OLEDDISPLAY_GEOMETRY) {}
-#endif // HAS_SCREEN
+#endif // HAS_SCREEN
\ No newline at end of file
diff --git a/src/main.cpp b/src/main.cpp
index b66d237f1..61db9672e 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -150,10 +150,6 @@ ScanI2C::DeviceAddress accelerometer_found = ScanI2C::ADDRESS_NONE;
// The I2C address of the RGB LED (if found)
ScanI2C::FoundDevice rgb_found = ScanI2C::FoundDevice(ScanI2C::DeviceType::NONE, ScanI2C::ADDRESS_NONE);
-#if !defined(ARCH_PORTDUINO) && !defined(ARCH_STM32WL)
-ATECCX08A atecc;
-#endif
-
#ifdef T_WATCH_S3
Adafruit_DRV2605 drv;
#endif
@@ -572,48 +568,37 @@ void setup()
LOG_DEBUG("acc_info = %i", acc_info.type);
#endif
-#define STRING(S) #S
-
-#define SCANNER_TO_SENSORS_MAP(SCANNER_T, PB_T) \
- { \
- auto found = i2cScanner->find(SCANNER_T); \
- if (found.type != ScanI2C::DeviceType::NONE) { \
- nodeTelemetrySensorsMap[PB_T].first = found.address.address; \
- nodeTelemetrySensorsMap[PB_T].second = i2cScanner->fetchI2CBus(found.address); \
- LOG_DEBUG("found i2c sensor %s", STRING(PB_T)); \
- } \
- }
-
- SCANNER_TO_SENSORS_MAP(ScanI2C::DeviceType::BME_680, meshtastic_TelemetrySensorType_BME680)
- SCANNER_TO_SENSORS_MAP(ScanI2C::DeviceType::BME_280, meshtastic_TelemetrySensorType_BME280)
- SCANNER_TO_SENSORS_MAP(ScanI2C::DeviceType::BMP_280, meshtastic_TelemetrySensorType_BMP280)
- SCANNER_TO_SENSORS_MAP(ScanI2C::DeviceType::BMP_3XX, meshtastic_TelemetrySensorType_BMP3XX)
- SCANNER_TO_SENSORS_MAP(ScanI2C::DeviceType::BMP_085, meshtastic_TelemetrySensorType_BMP085)
- SCANNER_TO_SENSORS_MAP(ScanI2C::DeviceType::INA260, meshtastic_TelemetrySensorType_INA260)
- SCANNER_TO_SENSORS_MAP(ScanI2C::DeviceType::INA219, meshtastic_TelemetrySensorType_INA219)
- SCANNER_TO_SENSORS_MAP(ScanI2C::DeviceType::INA3221, meshtastic_TelemetrySensorType_INA3221)
- SCANNER_TO_SENSORS_MAP(ScanI2C::DeviceType::MAX17048, meshtastic_TelemetrySensorType_MAX17048)
- SCANNER_TO_SENSORS_MAP(ScanI2C::DeviceType::MCP9808, meshtastic_TelemetrySensorType_MCP9808)
- SCANNER_TO_SENSORS_MAP(ScanI2C::DeviceType::MCP9808, meshtastic_TelemetrySensorType_MCP9808)
- SCANNER_TO_SENSORS_MAP(ScanI2C::DeviceType::SHT31, meshtastic_TelemetrySensorType_SHT31)
- SCANNER_TO_SENSORS_MAP(ScanI2C::DeviceType::SHTC3, meshtastic_TelemetrySensorType_SHTC3)
- SCANNER_TO_SENSORS_MAP(ScanI2C::DeviceType::LPS22HB, meshtastic_TelemetrySensorType_LPS22)
- SCANNER_TO_SENSORS_MAP(ScanI2C::DeviceType::QMC6310, meshtastic_TelemetrySensorType_QMC6310)
- SCANNER_TO_SENSORS_MAP(ScanI2C::DeviceType::QMI8658, meshtastic_TelemetrySensorType_QMI8658)
- SCANNER_TO_SENSORS_MAP(ScanI2C::DeviceType::QMC5883L, meshtastic_TelemetrySensorType_QMC5883L)
- SCANNER_TO_SENSORS_MAP(ScanI2C::DeviceType::HMC5883L, meshtastic_TelemetrySensorType_QMC5883L)
- SCANNER_TO_SENSORS_MAP(ScanI2C::DeviceType::PMSA0031, meshtastic_TelemetrySensorType_PMSA003I)
- SCANNER_TO_SENSORS_MAP(ScanI2C::DeviceType::RCWL9620, meshtastic_TelemetrySensorType_RCWL9620)
- SCANNER_TO_SENSORS_MAP(ScanI2C::DeviceType::VEML7700, meshtastic_TelemetrySensorType_VEML7700)
- SCANNER_TO_SENSORS_MAP(ScanI2C::DeviceType::TSL2591, meshtastic_TelemetrySensorType_TSL25911FN)
- SCANNER_TO_SENSORS_MAP(ScanI2C::DeviceType::OPT3001, meshtastic_TelemetrySensorType_OPT3001)
- SCANNER_TO_SENSORS_MAP(ScanI2C::DeviceType::MLX90632, meshtastic_TelemetrySensorType_MLX90632)
- SCANNER_TO_SENSORS_MAP(ScanI2C::DeviceType::MLX90614, meshtastic_TelemetrySensorType_MLX90614)
- SCANNER_TO_SENSORS_MAP(ScanI2C::DeviceType::SHT4X, meshtastic_TelemetrySensorType_SHT4X)
- SCANNER_TO_SENSORS_MAP(ScanI2C::DeviceType::AHT10, meshtastic_TelemetrySensorType_AHT10)
- SCANNER_TO_SENSORS_MAP(ScanI2C::DeviceType::DFROBOT_LARK, meshtastic_TelemetrySensorType_DFROBOT_LARK)
- SCANNER_TO_SENSORS_MAP(ScanI2C::DeviceType::ICM20948, meshtastic_TelemetrySensorType_ICM20948)
- SCANNER_TO_SENSORS_MAP(ScanI2C::DeviceType::MAX30102, meshtastic_TelemetrySensorType_MAX30102)
+ scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::BME_680, meshtastic_TelemetrySensorType_BME680);
+ scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::BME_280, meshtastic_TelemetrySensorType_BME280);
+ scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::BMP_280, meshtastic_TelemetrySensorType_BMP280);
+ scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::BMP_3XX, meshtastic_TelemetrySensorType_BMP3XX);
+ scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::BMP_085, meshtastic_TelemetrySensorType_BMP085);
+ scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::INA260, meshtastic_TelemetrySensorType_INA260);
+ scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::INA219, meshtastic_TelemetrySensorType_INA219);
+ scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::INA3221, meshtastic_TelemetrySensorType_INA3221);
+ scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::MAX17048, meshtastic_TelemetrySensorType_MAX17048);
+ scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::MCP9808, meshtastic_TelemetrySensorType_MCP9808);
+ scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::MCP9808, meshtastic_TelemetrySensorType_MCP9808);
+ scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::SHT31, meshtastic_TelemetrySensorType_SHT31);
+ scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::SHTC3, meshtastic_TelemetrySensorType_SHTC3);
+ scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::LPS22HB, meshtastic_TelemetrySensorType_LPS22);
+ scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::QMC6310, meshtastic_TelemetrySensorType_QMC6310);
+ scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::QMI8658, meshtastic_TelemetrySensorType_QMI8658);
+ scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::QMC5883L, meshtastic_TelemetrySensorType_QMC5883L);
+ scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::HMC5883L, meshtastic_TelemetrySensorType_QMC5883L);
+ scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::PMSA0031, meshtastic_TelemetrySensorType_PMSA003I);
+ scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::RCWL9620, meshtastic_TelemetrySensorType_RCWL9620);
+ scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::VEML7700, meshtastic_TelemetrySensorType_VEML7700);
+ scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::TSL2591, meshtastic_TelemetrySensorType_TSL25911FN);
+ scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::OPT3001, meshtastic_TelemetrySensorType_OPT3001);
+ scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::MLX90632, meshtastic_TelemetrySensorType_MLX90632);
+ scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::MLX90614, meshtastic_TelemetrySensorType_MLX90614);
+ scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::SHT4X, meshtastic_TelemetrySensorType_SHT4X);
+ scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::AHT10, meshtastic_TelemetrySensorType_AHT10);
+ scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::DFROBOT_LARK, meshtastic_TelemetrySensorType_DFROBOT_LARK);
+ scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::ICM20948, meshtastic_TelemetrySensorType_ICM20948);
+ scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::MAX30102, meshtastic_TelemetrySensorType_MAX30102);
+ scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::CGRADSENS, meshtastic_TelemetrySensorType_RADSENS);
i2cScanner.reset();
#endif
@@ -1191,6 +1176,19 @@ extern meshtastic_DeviceMetadata getDeviceMetadata()
#endif
return deviceMetadata;
}
+
+#if !MESHTASTIC_EXCLUDE_I2C
+void scannerToSensorsMap(const std::unique_ptr &i2cScanner, ScanI2C::DeviceType deviceType,
+ meshtastic_TelemetrySensorType sensorType)
+{
+ auto found = i2cScanner->find(deviceType);
+ if (found.type != ScanI2C::DeviceType::NONE) {
+ nodeTelemetrySensorsMap[sensorType].first = found.address.address;
+ nodeTelemetrySensorsMap[sensorType].second = i2cScanner->fetchI2CBus(found.address);
+ }
+}
+#endif
+
#ifndef PIO_UNIT_TESTING
void loop()
{
diff --git a/src/main.h b/src/main.h
index 5722f7cf0..b3f58ae4b 100644
--- a/src/main.h
+++ b/src/main.h
@@ -10,9 +10,6 @@
#include "mesh/generated/meshtastic/telemetry.pb.h"
#include
#include