mirror of
https://github.com/meshcore-dev/MeshCore.git
synced 2026-04-22 19:45:45 +00:00
Compare commits
16 Commits
room-serve
...
dev
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5372388e6e | ||
|
|
dc548578ff | ||
|
|
d3b457681a | ||
|
|
f1f1361fd5 | ||
|
|
bdae60498c | ||
|
|
66fe9ac2db | ||
|
|
cc6139bc23 | ||
|
|
d516cd8a9e | ||
|
|
07671cf1fe | ||
|
|
d532481f34 | ||
|
|
28b1586fd7 | ||
|
|
3d982711a6 | ||
|
|
db7baa7bd7 | ||
|
|
e8907a3108 | ||
|
|
a5ae89aac0 | ||
|
|
c0252ab82c |
4
.github/workflows/pr-build-check.yml
vendored
4
.github/workflows/pr-build-check.yml
vendored
@@ -39,6 +39,10 @@ jobs:
|
||||
- wio-e5-mini_repeater
|
||||
# ESP32-C6
|
||||
- LilyGo_Tlora_C6_repeater_
|
||||
# LR1110 (nRF52)
|
||||
- wio_wm1110_repeater
|
||||
# SX1276 (ESP32)
|
||||
- Tbeam_SX1276_repeater
|
||||
|
||||
steps:
|
||||
- name: Clone Repo
|
||||
|
||||
@@ -53,11 +53,14 @@
|
||||
"protocols": [
|
||||
"jlink",
|
||||
"nrfjprog",
|
||||
"nrfutil",
|
||||
"stlink",
|
||||
"cmsis-dap",
|
||||
"blackmagic"
|
||||
]
|
||||
],
|
||||
"use_1200bps_touch": true,
|
||||
"wait_for_upload_port": true
|
||||
},
|
||||
"url": "https://os.mbed.com/platforms/Nordic-nRF52840-DK/",
|
||||
"vendor": "Nordic"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include "CommonCLI.h"
|
||||
#include "TxtDataHelpers.h"
|
||||
#include "AdvertDataHelpers.h"
|
||||
#include "TxtDataHelpers.h"
|
||||
#include <RTClib.h>
|
||||
|
||||
#ifndef BRIDGE_MAX_BAUD
|
||||
@@ -285,7 +286,8 @@ void CommonCLI::handleCommand(uint32_t sender_timestamp, char* command, char* re
|
||||
// change admin password
|
||||
StrHelper::strncpy(_prefs->password, &command[9], sizeof(_prefs->password));
|
||||
savePrefs();
|
||||
sprintf(reply, "password now: %s", _prefs->password); // echo back just to let admin know for sure!!
|
||||
sprintf(reply, "password now: ");
|
||||
StrHelper::strncpy(&reply[14], _prefs->password, 160-15); // echo back just to let admin know for sure!!
|
||||
} else if (memcmp(command, "clear stats", 11) == 0) {
|
||||
_callbacks->clearStats();
|
||||
strcpy(reply, "(OK - stats reset)");
|
||||
@@ -726,7 +728,8 @@ void CommonCLI::handleSetCmd(uint32_t sender_timestamp, char* command, char* rep
|
||||
strcpy(reply, "Error: unsupported by this board");
|
||||
};
|
||||
} else {
|
||||
sprintf(reply, "unknown config: %s", config);
|
||||
strcpy(reply, "unknown config: ");
|
||||
StrHelper::strncpy(&reply[16], config, 160-17);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -784,10 +787,11 @@ void CommonCLI::handleGetCmd(uint32_t sender_timestamp, char* command, char* rep
|
||||
} else if (memcmp(config, "direct.txdelay", 14) == 0) {
|
||||
sprintf(reply, "> %s", StrHelper::ftoa(_prefs->direct_tx_delay_factor));
|
||||
} else if (memcmp(config, "owner.info", 10) == 0) {
|
||||
auto start = reply;
|
||||
*reply++ = '>';
|
||||
*reply++ = ' ';
|
||||
const char* sp = _prefs->owner_info;
|
||||
while (*sp) {
|
||||
while (*sp && reply - start < 159) {
|
||||
*reply++ = (*sp == '\n') ? '|' : *sp; // translate newline back to orig '|'
|
||||
sp++;
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ void LoRaFEMControl::init(void)
|
||||
pinMode(P_LORA_KCT8103L_PA_CSD, OUTPUT);
|
||||
digitalWrite(P_LORA_KCT8103L_PA_CSD, HIGH);
|
||||
pinMode(P_LORA_KCT8103L_PA_CTX, OUTPUT);
|
||||
digitalWrite(P_LORA_KCT8103L_PA_CTX, HIGH);
|
||||
digitalWrite(P_LORA_KCT8103L_PA_CTX, lna_enabled ? LOW : HIGH);
|
||||
setLnaCanControl(true);
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,6 @@ class LoRaFEMControl
|
||||
void setLnaCanControl(bool can_control) { lna_can_control = can_control; }
|
||||
|
||||
private:
|
||||
bool lna_enabled = false;
|
||||
bool lna_enabled = true;
|
||||
bool lna_can_control = false;
|
||||
};
|
||||
|
||||
@@ -14,7 +14,7 @@ void LoRaFEMControl::init(void)
|
||||
pinMode(P_LORA_KCT8103L_PA_CSD, OUTPUT);
|
||||
digitalWrite(P_LORA_KCT8103L_PA_CSD, HIGH);
|
||||
pinMode(P_LORA_KCT8103L_PA_CTX, OUTPUT);
|
||||
digitalWrite(P_LORA_KCT8103L_PA_CTX, HIGH);
|
||||
digitalWrite(P_LORA_KCT8103L_PA_CTX, lna_enabled ? LOW : HIGH);
|
||||
setLnaCanControl(true);
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,6 @@ class LoRaFEMControl
|
||||
void setLnaCanControl(bool can_control) { lna_can_control = can_control; }
|
||||
|
||||
private:
|
||||
bool lna_enabled = false;
|
||||
bool lna_enabled = true;
|
||||
bool lna_can_control = false;
|
||||
};
|
||||
|
||||
@@ -73,7 +73,7 @@ void HeltecV4Board::begin() {
|
||||
|
||||
digitalWrite(PIN_ADC_CTRL, LOW);
|
||||
|
||||
return (5.42 * (3.3 / 1024.0) * raw) * 1000;
|
||||
return (adc_mult * (3.3 / 1024.0) * raw) * 1000;
|
||||
}
|
||||
|
||||
const char* HeltecV4Board::getManufacturerName() const {
|
||||
|
||||
@@ -5,8 +5,16 @@
|
||||
#include <helpers/ESP32Board.h>
|
||||
#include <driver/rtc_io.h>
|
||||
#include "LoRaFEMControl.h"
|
||||
|
||||
#ifndef ADC_MULTIPLIER
|
||||
#define ADC_MULTIPLIER 5.42
|
||||
#endif
|
||||
|
||||
class HeltecV4Board : public ESP32Board {
|
||||
|
||||
protected:
|
||||
float adc_mult = ADC_MULTIPLIER;
|
||||
|
||||
public:
|
||||
RefCountedDigitalPin periph_power;
|
||||
LoRaFEMControl loRaFEMControl;
|
||||
@@ -18,6 +26,14 @@ public:
|
||||
void enterDeepSleep(uint32_t secs, int pin_wake_btn = -1);
|
||||
void powerOff() override;
|
||||
uint16_t getBattMilliVolts() override;
|
||||
const char* getManufacturerName() const override ;
|
||||
|
||||
bool setAdcMultiplier(float multiplier) override {
|
||||
if (multiplier == 0.0f) {
|
||||
adc_mult = ADC_MULTIPLIER;
|
||||
} else {
|
||||
adc_mult = multiplier;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
float getAdcMultiplier() const override { return adc_mult; }
|
||||
const char* getManufacturerName() const override;
|
||||
};
|
||||
|
||||
@@ -8,24 +8,47 @@
|
||||
void TechoBoard::begin() {
|
||||
NRF52Board::begin();
|
||||
|
||||
// Configure battery measurement control BEFORE Wire.begin()
|
||||
// to ensure P0.02 is not claimed by another peripheral
|
||||
pinMode(PIN_VBAT_MEAS_EN, OUTPUT);
|
||||
digitalWrite(PIN_VBAT_MEAS_EN, LOW);
|
||||
pinMode(PIN_VBAT_READ, INPUT);
|
||||
|
||||
Wire.begin();
|
||||
|
||||
pinMode(SX126X_POWER_EN, OUTPUT);
|
||||
digitalWrite(SX126X_POWER_EN, HIGH);
|
||||
delay(10); // give sx1262 some time to power up
|
||||
delay(10);
|
||||
}
|
||||
|
||||
uint16_t TechoBoard::getBattMilliVolts() {
|
||||
int adcvalue = 0;
|
||||
|
||||
// Use LilyGo's exact ADC configuration
|
||||
analogReference(AR_INTERNAL_3_0);
|
||||
analogReadResolution(12);
|
||||
delay(10);
|
||||
|
||||
// ADC range is 0..3000mV and resolution is 12-bit (0..4095)
|
||||
adcvalue = analogRead(PIN_VBAT_READ);
|
||||
// Convert the raw value to compensated mv, taking the resistor-
|
||||
// divider into account (providing the actual LIPO voltage)
|
||||
return (uint16_t)((float)adcvalue * REAL_VBAT_MV_PER_LSB);
|
||||
// Enable battery voltage divider (MOSFET gate on P0.31)
|
||||
pinMode(PIN_VBAT_MEAS_EN, OUTPUT);
|
||||
digitalWrite(PIN_VBAT_MEAS_EN, HIGH);
|
||||
|
||||
// Reclaim P0.02 for analog input (in case another peripheral touched it)
|
||||
pinMode(PIN_VBAT_READ, INPUT);
|
||||
delay(10); // let divider + ADC settle
|
||||
|
||||
// Read and average (matching LilyGo's approach)
|
||||
uint32_t sum = 0;
|
||||
for (int i = 0; i < 8; i++) {
|
||||
sum += analogRead(PIN_VBAT_READ);
|
||||
delayMicroseconds(100);
|
||||
}
|
||||
uint16_t adc = sum / 8;
|
||||
|
||||
// Disable divider to save power
|
||||
digitalWrite(PIN_VBAT_MEAS_EN, LOW);
|
||||
|
||||
// LilyGo's exact formula: adc * (3000.0 / 4096.0) * 2.0
|
||||
// = adc * 0.73242188 * 2.0 = adc * 1.46484375
|
||||
uint16_t millivolts = (uint16_t)((float)adc * (3000.0f / 4096.0f) * 2.0f);
|
||||
|
||||
return millivolts;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
@@ -4,14 +4,12 @@
|
||||
#include <Arduino.h>
|
||||
#include <helpers/NRF52Board.h>
|
||||
|
||||
// built-ins
|
||||
#define VBAT_MV_PER_LSB (0.73242188F) // 3.0V ADC range and 12-bit ADC resolution = 3000mV/4096
|
||||
|
||||
#define VBAT_DIVIDER (0.5F) // 150K + 150K voltage divider on VBAT
|
||||
#define VBAT_DIVIDER_COMP (2.0F) // Compensation factor for the VBAT divider
|
||||
|
||||
#define PIN_VBAT_READ (4)
|
||||
#define REAL_VBAT_MV_PER_LSB (VBAT_DIVIDER_COMP * VBAT_MV_PER_LSB)
|
||||
// ============================================================
|
||||
// T-Echo Lite battery pins — hardcoded from LilyGo t_echo_lite_config.h
|
||||
// NOT using any defines from variant.h for battery measurement
|
||||
// ============================================================
|
||||
#define PIN_VBAT_READ _PINNUM(0, 2) // BATTERY_ADC_DATA
|
||||
#define PIN_VBAT_MEAS_EN _PINNUM(0, 31) // BATTERY_MEASUREMENT_CONTROL
|
||||
|
||||
class TechoBoard : public NRF52BoardDCDC {
|
||||
public:
|
||||
@@ -20,10 +18,11 @@ public:
|
||||
uint16_t getBattMilliVolts() override;
|
||||
|
||||
const char* getManufacturerName() const override {
|
||||
return "LilyGo T-Echo";
|
||||
return "LilyGo T-Echo Lite";
|
||||
}
|
||||
|
||||
void powerOff() override {
|
||||
digitalWrite(PIN_VBAT_MEAS_EN, LOW);
|
||||
#ifdef LED_RED
|
||||
digitalWrite(LED_RED, LOW);
|
||||
#endif
|
||||
@@ -41,4 +40,4 @@ public:
|
||||
#endif
|
||||
sd_power_system_off();
|
||||
}
|
||||
};
|
||||
};
|
||||
@@ -96,3 +96,47 @@ build_src_filter = ${LilyGo_T-Echo-Lite.build_src_filter}
|
||||
lib_deps =
|
||||
${LilyGo_T-Echo-Lite.lib_deps}
|
||||
densaugeo/base64 @ ~1.4.0
|
||||
|
||||
[env:LilyGo_T-Echo-Lite_non_shell_companion_radio_ble]
|
||||
extends = LilyGo_T-Echo-Lite
|
||||
upload_protocol = nrfutil
|
||||
board_build.ldscript = boards/nrf52840_s140_v6_extrafs.ld
|
||||
board_upload.maximum_size = 712704
|
||||
build_flags =
|
||||
${nrf52_base.build_flags}
|
||||
-I variants/lilygo_techo_lite
|
||||
-I src/helpers/nrf52
|
||||
-I lib/nrf52/s140_nrf52_6.1.1_API/include
|
||||
-I lib/nrf52/s140_nrf52_6.1.1_API/include/nrf52
|
||||
-I src/helpers/ui
|
||||
-I examples/companion_radio/ui-new
|
||||
-D LILYGO_TECHO
|
||||
-D RADIO_CLASS=CustomSX1262
|
||||
-D WRAPPER_CLASS=CustomSX1262Wrapper
|
||||
-D LORA_TX_POWER=22
|
||||
-D SX126X_POWER_EN=30
|
||||
-D SX126X_CURRENT_LIMIT=140
|
||||
-D SX126X_RX_BOOSTED_GAIN=1
|
||||
-D P_LORA_TX_LED=LED_GREEN
|
||||
-D DISABLE_DIAGNOSTIC_OUTPUT
|
||||
-D ENV_INCLUDE_GPS=1
|
||||
-D GPS_BAUD_RATE=9600
|
||||
-D PIN_GPS_EN=GPS_EN
|
||||
-D AUTO_OFF_MILLIS=0
|
||||
-D MAX_CONTACTS=350
|
||||
-D MAX_GROUP_CHANNELS=40
|
||||
-D BLE_PIN_CODE=123456
|
||||
-D OFFLINE_QUEUE_SIZE=256
|
||||
-D UI_RECENT_LIST_SIZE=9
|
||||
-D AUTO_SHUTDOWN_MILLIVOLTS=3300
|
||||
build_src_filter = ${nrf52_base.build_src_filter}
|
||||
+<helpers/*.cpp>
|
||||
+<TechoBoard.cpp>
|
||||
+<helpers/sensors/EnvironmentSensorManager.cpp>
|
||||
+<helpers/ui/MomentaryButton.cpp>
|
||||
+<../variants/lilygo_techo_lite>
|
||||
+<helpers/nrf52/SerialBLEInterface.cpp>
|
||||
+<../examples/companion_radio/*.cpp>
|
||||
lib_deps =
|
||||
${LilyGo_T-Echo-Lite.lib_deps}
|
||||
densaugeo/base64 @ ~1.4.0
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
#define PIN_PWR_EN _PINNUM(0, 30) // RT9080_EN
|
||||
|
||||
#define BATTERY_PIN _PINNUM(0, 2)
|
||||
#define ADC_MULTIPLIER (4.90F)
|
||||
#define ADC_MULTIPLIER (2.0F)
|
||||
|
||||
#define ADC_RESOLUTION (14)
|
||||
#define BATTERY_SENSE_RES (12)
|
||||
@@ -47,13 +47,13 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// I2C pin definition
|
||||
|
||||
#define PIN_WIRE_SDA _PINNUM(0, 4) // (SDA)
|
||||
#define PIN_WIRE_SCL _PINNUM(0, 2) // (SCL)
|
||||
#define PIN_WIRE_SDA _PINNUM(1, 4) // (SDA) - per LilyGo IIC_1_SDA
|
||||
#define PIN_WIRE_SCL _PINNUM(1, 2) // (SCL) - per LilyGo IIC_1_SCL
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// SPI pin definition
|
||||
|
||||
#define SPI_INTERFACES_COUNT _PINNUM(0, 2)
|
||||
#define SPI_INTERFACES_COUNT (2)
|
||||
|
||||
#define PIN_SPI_MISO _PINNUM(0, 17) // (MISO)
|
||||
#define PIN_SPI_MOSI _PINNUM(0, 15) // (MOSI)
|
||||
@@ -149,10 +149,11 @@ extern const int SCK;
|
||||
#define PIN_DISPLAY_BUSY DISP_BUSY
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// GPS
|
||||
// GPS — per LilyGo t_echo_lite_config.h
|
||||
// PIN_GPS_TX/RX named from GPS module's perspective
|
||||
|
||||
#define PIN_GPS_RX _PINNUM(1, 13) // RXD
|
||||
#define PIN_GPS_TX _PINNUM(1, 15) // TXD
|
||||
#define GPS_EN _PINNUM(1, 11) // POWER_RT9080_EN
|
||||
#define PIN_GPS_STANDBY _PINNUM(1, 10)
|
||||
#define PIN_GPS_PPS _PINNUM(0, 29) // 1PPS
|
||||
#define PIN_GPS_TX _PINNUM(0, 29) // GPS UART TX → MCU RX
|
||||
#define PIN_GPS_RX _PINNUM(1, 10) // GPS UART RX ← MCU TX
|
||||
#define GPS_EN _PINNUM(1, 11) // GPS RT9080 power enable
|
||||
#define PIN_GPS_STANDBY _PINNUM(1, 13) // GPS wake-up
|
||||
#define PIN_GPS_PPS _PINNUM(1, 15) // GPS 1PPS
|
||||
@@ -14,9 +14,12 @@ const PowerMgtConfig power_config = {
|
||||
|
||||
void R1NeoBoard::initiateShutdown(uint8_t reason) {
|
||||
// Disable LoRa module power before shutdown
|
||||
MESH_DEBUG_PRINTLN("R1Neo: shutting down");
|
||||
digitalWrite(SX126X_POWER_EN, LOW);
|
||||
|
||||
// Signal IO controller that MCU is off, then release DCDC latch
|
||||
digitalWrite(PIN_SOFT_SHUTDOWN, LOW);
|
||||
digitalWrite(PIN_DCDC_EN_MCU_HOLD, LOW);
|
||||
|
||||
if (reason == SHUTDOWN_REASON_LOW_VOLTAGE ||
|
||||
reason == SHUTDOWN_REASON_BOOT_PROTECT) {
|
||||
configureVoltageWake(power_config.lpcomp_ain_channel, power_config.lpcomp_refsel);
|
||||
|
||||
@@ -18,6 +18,12 @@ public:
|
||||
R1NeoBoard() : NRF52Board("R1NEO_OTA") {}
|
||||
void begin();
|
||||
|
||||
#ifdef NRF52_POWER_MANAGEMENT
|
||||
void powerOff() override {
|
||||
initiateShutdown(SHUTDOWN_REASON_USER);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(P_LORA_TX_LED)
|
||||
void onBeforeTransmit() override {
|
||||
digitalWrite(P_LORA_TX_LED, HIGH); // turn TX LED on
|
||||
|
||||
@@ -147,7 +147,7 @@ extern "C"
|
||||
// LoRa radio module pins for RAK4631
|
||||
#define P_LORA_DIO_1 (47)
|
||||
#define P_LORA_NSS (42)
|
||||
#define P_LORA_RESET (-1)
|
||||
#define P_LORA_RESET (38)
|
||||
#define P_LORA_BUSY (46)
|
||||
#define P_LORA_SCLK (43)
|
||||
#define P_LORA_MISO (45)
|
||||
|
||||
Reference in New Issue
Block a user