Skip to content

Commit c872f72

Browse files
authored
Merge branch 'ripplebiz:dev' into dev
2 parents 001b996 + fe0234d commit c872f72

File tree

13 files changed

+183
-35
lines changed

13 files changed

+183
-35
lines changed

src/helpers/ESP32Board.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,15 @@ class ESP32Board : public mesh::MainBoard {
5151
void onAfterTransmit() override {
5252
digitalWrite(P_LORA_TX_LED, LOW); // turn TX LED off
5353
}
54+
#elif defined(P_LORA_TX_NEOPIXEL_LED)
55+
#define NEOPIXEL_BRIGHTNESS 64 // white brightness (max 255)
56+
57+
void onBeforeTransmit() override {
58+
neopixelWrite(P_LORA_TX_NEOPIXEL_LED, NEOPIXEL_BRIGHTNESS, NEOPIXEL_BRIGHTNESS, NEOPIXEL_BRIGHTNESS); // turn TX neopixel on (White)
59+
}
60+
void onAfterTransmit() override {
61+
neopixelWrite(P_LORA_TX_NEOPIXEL_LED, 0, 0, 0); // turn TX neopixel off
62+
}
5463
#endif
5564

5665
uint16_t getBattMilliVolts() override {

src/helpers/esp32/TBeamBoard.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#if defined(TBEAM_SUPREME_SX1262) || defined(TBEAM_SX1262) || defined(TBEAM_SX1276)
2+
13
#include <Arduino.h>
24
#include "TBeamBoard.h"
35
//#include <RadioLib.h>
@@ -343,4 +345,6 @@ bool TBeamBoard::power_init()
343345

344346

345347
// }
346-
#pragma endregion
348+
#pragma endregion
349+
350+
#endif

src/helpers/esp32/TBeamBoard.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#pragma once
22

3+
#if defined(TBEAM_SUPREME_SX1262) || defined(TBEAM_SX1262) || defined(TBEAM_SX1276)
4+
35
#include <Wire.h>
46
#include <Arduino.h>
57
#include "XPowersLib.h"
@@ -162,3 +164,5 @@ bool power_init();
162164
return "LilyGo T-Beam";
163165
}
164166
};
167+
168+
#endif

src/helpers/nrf52/RAK4631Board.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ bool RAK4631Board::startOTAUpdate(const char* id, char reply[]) {
8484
memset(mac_addr, 0, sizeof(mac_addr));
8585
Bluefruit.getAddr(mac_addr);
8686
sprintf(reply, "OK - mac: %02X:%02X:%02X:%02X:%02X:%02X",
87-
mac_addr[0], mac_addr[1], mac_addr[2], mac_addr[3], mac_addr[4], mac_addr[5]);
87+
mac_addr[5], mac_addr[4], mac_addr[3], mac_addr[2], mac_addr[1], mac_addr[0]);
8888

8989
return true;
9090
}

src/helpers/stm32/STM32Board.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@ class STM32Board : public mesh::MainBoard {
2323
}
2424

2525
void reboot() override {
26+
NVIC_SystemReset();
27+
}
28+
29+
void powerOff() override {
30+
HAL_PWREx_DisableInternalWakeUpLine();
31+
__disable_irq();
32+
HAL_PWREx_EnterSHUTDOWNMode();
2633
}
2734

2835
#if defined(P_LORA_TX_LED)

variants/rak3x72/platformio.ini

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,15 @@ build_flags = ${stm32_base.build_flags}
77
-D WRAPPER_CLASS=CustomSTM32WLxWrapper
88
-D SPI_INTERFACES_COUNT=0
99
-D RX_BOOSTED_GAIN=true
10+
; -D STM32WL_TCXO_VOLTAGE=1.6 ; defaults to 0 if undef
11+
; -D LORA_TX_POWER=14 ; Defaults to 22 for HP, 14 is for LP version
1012
-I variants/rak3x72
1113
build_src_filter = ${stm32_base.build_src_filter}
1214
+<../variants/rak3x72>
1315

1416
[env:rak3x72-repeater]
1517
extends = rak3x72
1618
build_flags = ${rak3x72.build_flags}
17-
-D LORA_TX_POWER=22
1819
-D ADVERT_NAME='"RAK3x72 Repeater"'
1920
-D ADMIN_PASSWORD='"password"'
2021
build_src_filter = ${rak3x72.build_src_filter}
@@ -24,7 +25,6 @@ build_src_filter = ${rak3x72.build_src_filter}
2425
extends = rak3x72
2526
build_flags = ${rak3x72.build_flags}
2627
; -D FORMAT_FS=true
27-
-D LORA_TX_POWER=22
2828
-D MAX_CONTACTS=100
2929
-D MAX_GROUP_CHANNELS=8
3030
build_src_filter = ${rak3x72.build_src_filter}

variants/rak3x72/target.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,21 @@ SensorManager sensors;
2424
#define LORA_CR 5
2525
#endif
2626

27+
#ifndef STM32WL_TCXO_VOLTAGE
28+
// TCXO set to 0 for RAK3172
29+
#define STM32WL_TCXO_VOLTAGE 0
30+
#endif
31+
32+
#ifndef LORA_TX_POWER
33+
#define LORA_TX_POWER 22
34+
#endif
35+
2736
bool radio_init() {
2837
// rtc_clock.begin(Wire);
2938

3039
radio.setRfSwitchTable(rfswitch_pins, rfswitch_table);
3140

32-
int status = radio.begin(LORA_FREQ, LORA_BW, LORA_SF, LORA_CR, RADIOLIB_SX126X_SYNC_WORD_PRIVATE, LORA_TX_POWER, 8, 0, 0); // TCXO set to 0 for RAK3172
41+
int status = radio.begin(LORA_FREQ, LORA_BW, LORA_SF, LORA_CR, RADIOLIB_SX126X_SYNC_WORD_PRIVATE, LORA_TX_POWER, 8, STM32WL_TCXO_VOLTAGE, 0);
3342

3443
if (status != RADIOLIB_ERR_NONE) {
3544
Serial.print("ERROR: radio init failed: ");

variants/rak3x72/target.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,12 @@ class RAK3x72Board : public STM32Board {
1818
}
1919

2020
uint16_t getBattMilliVolts() override {
21-
uint32_t raw = analogRead(PIN_VBAT_READ);
22-
return (ADC_MULTIPLIER * raw) / 1024;
21+
analogReadResolution(12);
22+
uint32_t raw = 0;
23+
for (int i=0; i<8;i++) {
24+
raw += analogRead(PIN_VBAT_READ);
25+
}
26+
return ((double)raw) * ADC_MULTIPLIER / 8 / 4096;
2327
}
2428
};
2529

variants/station_g2/platformio.ini

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ build_flags =
77
-D STATION_G2
88
-D RADIO_CLASS=CustomSX1262
99
-D WRAPPER_CLASS=CustomSX1262Wrapper
10-
-D LORA_TX_POWER=7
10+
-D LORA_TX_POWER=19
1111
; -D P_LORA_TX_LED=35
1212
-D PIN_BOARD_SDA=5
1313
-D PIN_BOARD_SCL=6
@@ -16,9 +16,9 @@ build_flags =
1616
-D SX126X_DIO3_TCXO_VOLTAGE=1.8
1717
-D SX126X_CURRENT_LIMIT=140
1818
; -D SX126X_RX_BOOSTED_GAIN=1 - DO NOT ENABLE THIS!
19+
; https://wiki.uniteng.com/en/meshtastic/station-g2#impact-of-lora-node-dense-areashigh-noise-environments-on-rf-performance
1920
-I src/helpers/ui
2021
-D DISPLAY_CLASS=SH1106Display
21-
; https://wiki.uniteng.com/en/meshtastic/station-g2#impact-of-lora-node-dense-areashigh-noise-environments-on-rf-performance
2222
build_src_filter = ${esp32_base.build_src_filter}
2323
+<../variants/station_g2>
2424
+<helpers/ui/SH1106Display.cpp>

variants/station_g2/target.cpp

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -27,36 +27,13 @@ SensorManager sensors;
2727
bool radio_init() {
2828
fallback_clock.begin();
2929
rtc_clock.begin(Wire);
30-
31-
#ifdef SX126X_DIO3_TCXO_VOLTAGE
32-
float tcxo = SX126X_DIO3_TCXO_VOLTAGE;
33-
#else
34-
float tcxo = 1.6f;
35-
#endif
3630

3731
#if defined(P_LORA_SCLK)
3832
spi.begin(P_LORA_SCLK, P_LORA_MISO, P_LORA_MOSI);
33+
return radio.std_init(&spi);
34+
#else
35+
return radio.std_init();
3936
#endif
40-
int status = radio.begin(LORA_FREQ, LORA_BW, LORA_SF, LORA_CR, RADIOLIB_SX126X_SYNC_WORD_PRIVATE, LORA_TX_POWER, 8, tcxo);
41-
if (status != RADIOLIB_ERR_NONE) {
42-
Serial.print("ERROR: radio init failed: ");
43-
Serial.println(status);
44-
return false; // fail
45-
}
46-
47-
radio.setCRC(1);
48-
49-
#ifdef SX126X_CURRENT_LIMIT
50-
radio.setCurrentLimit(SX126X_CURRENT_LIMIT);
51-
#endif
52-
#ifdef SX126X_DIO2_AS_RF_SWITCH
53-
radio.setDio2AsRfSwitch(SX126X_DIO2_AS_RF_SWITCH);
54-
#endif
55-
#ifdef SX126X_RX_BOOSTED_GAIN
56-
radio.setRxBoostedGainMode(SX126X_RX_BOOSTED_GAIN);
57-
#endif
58-
59-
return true; // success
6037
}
6138

6239
uint32_t radio_get_rng_seed() {

0 commit comments

Comments
 (0)