Skip to content

Commit aa9eac1

Browse files
authored
Merge branch 'ripplebiz:dev' into dev
2 parents 7bcfbd3 + 1295c46 commit aa9eac1

File tree

14 files changed

+307
-49
lines changed

14 files changed

+307
-49
lines changed

examples/companion_radio/MyMesh.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1474,7 +1474,6 @@ void MyMesh::loop() {
14741474

14751475
#ifdef DISPLAY_CLASS
14761476
ui_task.setHasConnection(_serial->isConnected());
1477-
ui_task.loop();
14781477
#endif
14791478
}
14801479

examples/companion_radio/main.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,4 +193,7 @@ void setup() {
193193
void loop() {
194194
the_mesh.loop();
195195
sensors.loop();
196+
#ifdef DISPLAY_CLASS
197+
ui_task.loop();
198+
#endif
196199
}

src/helpers/CommonCLI.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,9 @@ void CommonCLI::handleCommand(uint32_t sender_timestamp, const char* command, ch
144144
uint32_t curr = getRTCClock()->getCurrentTime();
145145
if (sender_timestamp > curr) {
146146
getRTCClock()->setCurrentTime(sender_timestamp + 1);
147-
strcpy(reply, "OK - clock set");
147+
uint32_t now = getRTCClock()->getCurrentTime();
148+
DateTime dt = DateTime(now);
149+
sprintf(reply, "OK - clock set: %02d:%02d - %d/%d/%d UTC", dt.hour(), dt.minute(), dt.day(), dt.month(), dt.year());
148150
} else {
149151
strcpy(reply, "ERR: clock cannot go backwards");
150152
}
@@ -161,7 +163,9 @@ void CommonCLI::handleCommand(uint32_t sender_timestamp, const char* command, ch
161163
uint32_t curr = getRTCClock()->getCurrentTime();
162164
if (secs > curr) {
163165
getRTCClock()->setCurrentTime(secs);
164-
strcpy(reply, "(OK - clock set!)");
166+
uint32_t now = getRTCClock()->getCurrentTime();
167+
DateTime dt = DateTime(now);
168+
sprintf(reply, "OK - clock set: %02d:%02d - %d/%d/%d UTC", dt.hour(), dt.minute(), dt.day(), dt.month(), dt.year());
165169
} else {
166170
strcpy(reply, "(ERR: clock cannot go backwards)");
167171
}
@@ -245,10 +249,8 @@ void CommonCLI::handleCommand(uint32_t sender_timestamp, const char* command, ch
245249
strcpy(reply, "OK");
246250
} else if (memcmp(config, "flood.advert.interval ", 22) == 0) {
247251
int hours = _atoi(&config[22]);
248-
if (hours > 0 && hours < 3) {
249-
sprintf(reply, "Error: min is 3 hours");
250-
} else if (hours > 48) {
251-
strcpy(reply, "Error: max is 48 hours");
252+
if ((hours > 0 && hours < 3) || (hours > 48)) {
253+
strcpy(reply, "Error: interval range is 3-48 hours");
252254
} else {
253255
_prefs->flood_advert_interval = (uint8_t)(hours);
254256
_callbacks->updateFloodAdvertTimer();
@@ -257,10 +259,8 @@ void CommonCLI::handleCommand(uint32_t sender_timestamp, const char* command, ch
257259
}
258260
} else if (memcmp(config, "advert.interval ", 16) == 0) {
259261
int mins = _atoi(&config[16]);
260-
if (mins > 0 && mins < MIN_LOCAL_ADVERT_INTERVAL) {
261-
sprintf(reply, "Error: min is %d mins", MIN_LOCAL_ADVERT_INTERVAL);
262-
} else if (mins > 240) {
263-
strcpy(reply, "Error: max is 240 mins");
262+
if ((mins > 0 && mins < MIN_LOCAL_ADVERT_INTERVAL) || (mins > 240)) {
263+
sprintf(reply, "Error: interval range is %d-240 minutes", MIN_LOCAL_ADVERT_INTERVAL);
264264
} else {
265265
_prefs->advert_interval = (uint8_t)(mins / 2);
266266
_callbacks->updateAdvertTimer();

src/helpers/CustomLLCC68.h

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,76 @@ class CustomLLCC68 : public LLCC68 {
99
public:
1010
CustomLLCC68(Module *mod) : LLCC68(mod) { }
1111

12+
#ifdef RP2040_PLATFORM
13+
bool std_init(SPIClassRP2040* spi = NULL)
14+
#else
15+
bool std_init(SPIClass* spi = NULL)
16+
#endif
17+
{
18+
#ifdef SX126X_DIO3_TCXO_VOLTAGE
19+
float tcxo = SX126X_DIO3_TCXO_VOLTAGE;
20+
#else
21+
float tcxo = 1.6f;
22+
#endif
23+
24+
#ifdef LORA_CR
25+
uint8_t cr = LORA_CR;
26+
#else
27+
uint8_t cr = 5;
28+
#endif
29+
30+
#if defined(P_LORA_SCLK)
31+
#ifdef NRF52_PLATFORM
32+
if (spi) { spi->setPins(P_LORA_MISO, P_LORA_SCLK, P_LORA_MOSI); spi->begin(); }
33+
#elif defined(RP2040_PLATFORM)
34+
if (spi) {
35+
spi->setMISO(P_LORA_MISO);
36+
//spi->setCS(P_LORA_NSS); // Setting CS results in freeze
37+
spi->setSCK(P_LORA_SCLK);
38+
spi->setMOSI(P_LORA_MOSI);
39+
spi->begin();
40+
}
41+
#else
42+
if (spi) spi->begin(P_LORA_SCLK, P_LORA_MISO, P_LORA_MOSI);
43+
#endif
44+
#endif
45+
int status = begin(LORA_FREQ, LORA_BW, LORA_SF, cr, RADIOLIB_SX126X_SYNC_WORD_PRIVATE, LORA_TX_POWER, 8, tcxo);
46+
// if radio init fails with -707/-706, try again with tcxo voltage set to 0.0f
47+
if (status == RADIOLIB_ERR_SPI_CMD_FAILED || status == RADIOLIB_ERR_SPI_CMD_INVALID) {
48+
#define SX126X_DIO3_TCXO_VOLTAGE (0.0f);
49+
tcxo = SX126X_DIO3_TCXO_VOLTAGE;
50+
status = begin(LORA_FREQ, LORA_BW, LORA_SF, cr, RADIOLIB_SX126X_SYNC_WORD_PRIVATE, LORA_TX_POWER, 8, tcxo);
51+
}
52+
if (status != RADIOLIB_ERR_NONE) {
53+
Serial.print("ERROR: radio init failed: ");
54+
Serial.println(status);
55+
return false; // fail
56+
}
57+
58+
setCRC(1);
59+
60+
#ifdef SX126X_CURRENT_LIMIT
61+
setCurrentLimit(SX126X_CURRENT_LIMIT);
62+
#endif
63+
#ifdef SX126X_DIO2_AS_RF_SWITCH
64+
setDio2AsRfSwitch(SX126X_DIO2_AS_RF_SWITCH);
65+
#endif
66+
#ifdef SX126X_RX_BOOSTED_GAIN
67+
setRxBoostedGainMode(SX126X_RX_BOOSTED_GAIN);
68+
#endif
69+
#if defined(SX126X_RXEN) || defined(SX126X_TXEN)
70+
#ifndef SX1262X_RXEN
71+
#define SX1262X_RXEN RADIOLIB_NC
72+
#endif
73+
#ifndef SX1262X_TXEN
74+
#define SX1262X_TXEN RADIOLIB_NC
75+
#endif
76+
setRfSwitchPins(SX126X_RXEN, SX126X_TXEN);
77+
#endif
78+
79+
return true; // success
80+
}
81+
1282
bool isReceiving() {
1383
uint16_t irq = getIrqFlags();
1484
bool detected = (irq & SX126X_IRQ_HEADER_VALID) || (irq & SX126X_IRQ_PREAMBLE_DETECTED);

src/helpers/CustomSX1268.h

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,76 @@ class CustomSX1268 : public SX1268 {
99
public:
1010
CustomSX1268(Module *mod) : SX1268(mod) { }
1111

12+
#ifdef RP2040_PLATFORM
13+
bool std_init(SPIClassRP2040* spi = NULL)
14+
#else
15+
bool std_init(SPIClass* spi = NULL)
16+
#endif
17+
{
18+
#ifdef SX126X_DIO3_TCXO_VOLTAGE
19+
float tcxo = SX126X_DIO3_TCXO_VOLTAGE;
20+
#else
21+
float tcxo = 1.6f;
22+
#endif
23+
24+
#ifdef LORA_CR
25+
uint8_t cr = LORA_CR;
26+
#else
27+
uint8_t cr = 5;
28+
#endif
29+
30+
#if defined(P_LORA_SCLK)
31+
#ifdef NRF52_PLATFORM
32+
if (spi) { spi->setPins(P_LORA_MISO, P_LORA_SCLK, P_LORA_MOSI); spi->begin(); }
33+
#elif defined(RP2040_PLATFORM)
34+
if (spi) {
35+
spi->setMISO(P_LORA_MISO);
36+
//spi->setCS(P_LORA_NSS); // Setting CS results in freeze
37+
spi->setSCK(P_LORA_SCLK);
38+
spi->setMOSI(P_LORA_MOSI);
39+
spi->begin();
40+
}
41+
#else
42+
if (spi) spi->begin(P_LORA_SCLK, P_LORA_MISO, P_LORA_MOSI);
43+
#endif
44+
#endif
45+
int status = begin(LORA_FREQ, LORA_BW, LORA_SF, cr, RADIOLIB_SX126X_SYNC_WORD_PRIVATE, LORA_TX_POWER, 8, tcxo);
46+
// if radio init fails with -707/-706, try again with tcxo voltage set to 0.0f
47+
if (status == RADIOLIB_ERR_SPI_CMD_FAILED || status == RADIOLIB_ERR_SPI_CMD_INVALID) {
48+
#define SX126X_DIO3_TCXO_VOLTAGE (0.0f);
49+
tcxo = SX126X_DIO3_TCXO_VOLTAGE;
50+
status = begin(LORA_FREQ, LORA_BW, LORA_SF, cr, RADIOLIB_SX126X_SYNC_WORD_PRIVATE, LORA_TX_POWER, 8, tcxo);
51+
}
52+
if (status != RADIOLIB_ERR_NONE) {
53+
Serial.print("ERROR: radio init failed: ");
54+
Serial.println(status);
55+
return false; // fail
56+
}
57+
58+
setCRC(1);
59+
60+
#ifdef SX126X_CURRENT_LIMIT
61+
setCurrentLimit(SX126X_CURRENT_LIMIT);
62+
#endif
63+
#ifdef SX126X_DIO2_AS_RF_SWITCH
64+
setDio2AsRfSwitch(SX126X_DIO2_AS_RF_SWITCH);
65+
#endif
66+
#ifdef SX126X_RX_BOOSTED_GAIN
67+
setRxBoostedGainMode(SX126X_RX_BOOSTED_GAIN);
68+
#endif
69+
#if defined(SX126X_RXEN) || defined(SX126X_TXEN)
70+
#ifndef SX1262X_RXEN
71+
#define SX1262X_RXEN RADIOLIB_NC
72+
#endif
73+
#ifndef SX1262X_TXEN
74+
#define SX1262X_TXEN RADIOLIB_NC
75+
#endif
76+
setRfSwitchPins(SX126X_RXEN, SX126X_TXEN);
77+
#endif
78+
79+
return true; // success
80+
}
81+
1282
bool isReceiving() {
1383
uint16_t irq = getIrqFlags();
1484
bool detected = (irq & SX126X_IRQ_HEADER_VALID) || (irq & SX126X_IRQ_PREAMBLE_DETECTED);

src/helpers/HeltecV2Board.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ class HeltecV2Board : public ESP32Board {
6868
}
6969
raw = raw / 8;
7070

71-
return (1.883 * (2 / 1024.0) * raw) * 1000;
71+
return (1.98 * (2 / 1024.0) * raw) * 1000;
7272
}
7373

7474
const char* getManufacturerName() const override {

src/helpers/HeltecV3Board.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ class HeltecV3Board : public ESP32Board {
9999

100100
digitalWrite(PIN_ADC_CTRL, !adc_active_state);
101101

102-
return (5.2 * (3.3 / 1024.0) * raw) * 1000;
102+
return (5.42 * (3.3 / 1024.0) * raw) * 1000;
103103
}
104104

105105
const char* getManufacturerName() const override {

src/helpers/sensors/EnvironmentSensorManager.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ void EnvironmentSensorManager::loop() {
220220
_location->loop();
221221

222222
if (millis() > next_gps_update) {
223-
if (_location->isValid()) {
223+
if (gps_active && _location->isValid()) {
224224
node_lat = ((double)_location->getLatitude())/1000000.;
225225
node_lon = ((double)_location->getLongitude())/1000000.;
226226
MESH_DEBUG_PRINTLN("lat %f lon %f", node_lat, node_lon);

variants/heltec_v3/platformio.ini

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ build_flags =
2121
-D ENV_INCLUDE_BME280=1
2222
-D ENV_INCLUDE_INA3221=1
2323
-D ENV_INCLUDE_INA219=1
24+
-D ENV_INCLUDE_GPS=1
25+
-D PIN_GPS_RX=45
26+
-D PIN_GPS_TX=46
27+
-D PIN_GPS_EN=-1
2428
build_src_filter = ${esp32_base.build_src_filter}
2529
+<../variants/heltec_v3>
2630
+<helpers/sensors>
@@ -30,7 +34,8 @@ lib_deps =
3034
adafruit/Adafruit INA3221 Library @ ^1.0.1
3135
adafruit/Adafruit INA219 @ ^1.2.3
3236
adafruit/Adafruit AHTX0 @ ^2.0.5
33-
adafruit/Adafruit BME280 Library @ ^2.3.0
37+
adafruit/Adafruit BME280 Library @ ^2.3.0
38+
stevemarple/MicroNMEA @ ^2.0.6
3439

3540
[env:Heltec_v3_repeater]
3641
extends = Heltec_lora32_v3

variants/heltec_v3/target.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,14 @@ WRAPPER_CLASS radio_driver(radio, board);
1414

1515
ESP32RTCClock fallback_clock;
1616
AutoDiscoverRTCClock rtc_clock(fallback_clock);
17-
EnvironmentSensorManager sensors;
17+
18+
#if ENV_INCLUDE_GPS
19+
#include <helpers/sensors/MicroNMEALocationProvider.h>
20+
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1);
21+
EnvironmentSensorManager sensors = EnvironmentSensorManager(nmea);
22+
#else
23+
EnvironmentSensorManager sensors;
24+
#endif
1825

1926
#ifdef DISPLAY_CLASS
2027
DISPLAY_CLASS display;

0 commit comments

Comments
 (0)