mirror of https://github.com/meshcore-dev/MeshCore
committed by
GitHub
164 changed files with 2686 additions and 706 deletions
@ -1,9 +0,0 @@ |
|||||
{ |
|
||||
"recommendations": [ |
|
||||
"pioarduino.pioarduino-ide", |
|
||||
"platformio.platformio-ide" |
|
||||
], |
|
||||
"unwantedRecommendations": [ |
|
||||
"ms-vscode.cpptools-extension-pack" |
|
||||
] |
|
||||
} |
|
||||
@ -0,0 +1,61 @@ |
|||||
|
{ |
||||
|
"build": { |
||||
|
"arduino": { |
||||
|
"ldscript": "nrf52840_s140_v6.ld" |
||||
|
}, |
||||
|
"core": "nRF5", |
||||
|
"cpu": "cortex-m4", |
||||
|
"extra_flags": "-DNRF52840_XXAA", |
||||
|
"f_cpu": "64000000L", |
||||
|
"hwids": [ |
||||
|
["0x239A","0x4405"], |
||||
|
["0x239A","0x0029"], |
||||
|
["0x239A","0x002A"], |
||||
|
["0x239A","0x0071"] |
||||
|
], |
||||
|
"usb_product": "HT-n5262", |
||||
|
"mcu": "nrf52840", |
||||
|
"variant": "heltec_tower_v2", |
||||
|
"bsp": { |
||||
|
"name": "adafruit" |
||||
|
}, |
||||
|
"softdevice": { |
||||
|
"sd_flags": "-DS140", |
||||
|
"sd_name": "s140", |
||||
|
"sd_version": "6.1.1", |
||||
|
"sd_fwid": "0x00B6" |
||||
|
}, |
||||
|
"bootloader": { |
||||
|
"settings_addr": "0xFF000" |
||||
|
} |
||||
|
}, |
||||
|
"connectivity": [ |
||||
|
"bluetooth" |
||||
|
], |
||||
|
"debug": { |
||||
|
"jlink_device": "nRF52840_xxAA", |
||||
|
"svd_path": "nrf52840.svd", |
||||
|
"openocd_target": "nrf52.cfg" |
||||
|
}, |
||||
|
"frameworks": [ |
||||
|
"arduino" |
||||
|
], |
||||
|
"name": "Heltec Tower V2 Board", |
||||
|
"upload": { |
||||
|
"maximum_ram_size": 235520, |
||||
|
"maximum_size": 815104, |
||||
|
"speed": 115200, |
||||
|
"protocol": "nrfutil", |
||||
|
"protocols": [ |
||||
|
"jlink", |
||||
|
"nrfjprog", |
||||
|
"nrfutil", |
||||
|
"stlink" |
||||
|
], |
||||
|
"use_1200bps_touch": true, |
||||
|
"require_upload_port": true, |
||||
|
"wait_for_upload_port": true |
||||
|
}, |
||||
|
"url": "https://heltec.org/", |
||||
|
"vendor": "Heltec" |
||||
|
} |
||||
@ -0,0 +1,42 @@ |
|||||
|
{ |
||||
|
"build": { |
||||
|
"arduino": { |
||||
|
"ldscript": "esp32s3_out.ld", |
||||
|
"memory_type": "qio_opi" |
||||
|
}, |
||||
|
"core": "esp32", |
||||
|
"extra_flags": [ |
||||
|
"-D BOARD_HAS_PSRAM", |
||||
|
"-D ARDUINO_USB_CDC_ON_BOOT=0", |
||||
|
"-D ARDUINO_USB_MODE=0", |
||||
|
"-D ARDUINO_RUNNING_CORE=1", |
||||
|
"-D ARDUINO_EVENT_RUNNING_CORE=0" |
||||
|
], |
||||
|
"f_cpu": "240000000L", |
||||
|
"f_flash": "80000000L", |
||||
|
"flash_mode": "qio", |
||||
|
"psram_type": "qio_opi", |
||||
|
"hwids": [["0x303A", "0x1001"]], |
||||
|
"mcu": "esp32s3", |
||||
|
"variant": "ELECROW-ThinkNode-M7" |
||||
|
}, |
||||
|
"connectivity": ["wifi", "bluetooth", "lora"], |
||||
|
"debug": { |
||||
|
"default_tool": "esp-builtin", |
||||
|
"onboard_tools": ["esp-builtin"], |
||||
|
"openocd_target": "esp32s3.cfg" |
||||
|
}, |
||||
|
"frameworks": ["arduino", "espidf"], |
||||
|
"name": "ELECROW ThinkNode M7", |
||||
|
"upload": { |
||||
|
"flash_size": "8MB", |
||||
|
"maximum_ram_size": 524288, |
||||
|
"maximum_size": 8388608, |
||||
|
"use_1200bps_touch": true, |
||||
|
"wait_for_upload_port": true, |
||||
|
"require_upload_port": true, |
||||
|
"speed": 921600 |
||||
|
}, |
||||
|
"url": "https://www.elecrow.com", |
||||
|
"vendor": "ELECROW" |
||||
|
} |
||||
@ -0,0 +1,57 @@ |
|||||
|
{ |
||||
|
"build": { |
||||
|
"arduino": { |
||||
|
"ldscript": "esp32s3_out.ld", |
||||
|
"memory_type": "qio_opi", |
||||
|
"partitions": "default_16MB.csv" |
||||
|
}, |
||||
|
"core": "esp32", |
||||
|
"extra_flags": [ |
||||
|
"-DBOARD_HAS_PSRAM", |
||||
|
"-DARDUINO_USB_CDC_ON_BOOT=0", |
||||
|
"-DARDUINO_USB_MODE=0", |
||||
|
"-DARDUINO_RUNNING_CORE=1", |
||||
|
"-DARDUINO_EVENT_RUNNING_CORE=0" |
||||
|
], |
||||
|
"f_cpu": "240000000L", |
||||
|
"f_flash": "80000000L", |
||||
|
"flash_mode": "qio", |
||||
|
"psram_type": "qio_opi", |
||||
|
"hwids": [ |
||||
|
[ |
||||
|
"0x303A", |
||||
|
"0x1001" |
||||
|
] |
||||
|
], |
||||
|
"mcu": "esp32s3", |
||||
|
"variant": "ELECROW-ThinkNode-M9" |
||||
|
}, |
||||
|
"connectivity": [ |
||||
|
"wifi", |
||||
|
"bluetooth", |
||||
|
"lora" |
||||
|
], |
||||
|
"debug": { |
||||
|
"default_tool": "esp-builtin", |
||||
|
"onboard_tools": [ |
||||
|
"esp-builtin" |
||||
|
], |
||||
|
"openocd_target": "esp32s3.cfg" |
||||
|
}, |
||||
|
"frameworks": [ |
||||
|
"arduino", |
||||
|
"espidf" |
||||
|
], |
||||
|
"name": "elecrow-thinknode-m9", |
||||
|
"upload": { |
||||
|
"flash_size": "16MB", |
||||
|
"maximum_ram_size": 524288, |
||||
|
"maximum_size": 16777216, |
||||
|
"use_1200bps_touch": true, |
||||
|
"wait_for_upload_port": true, |
||||
|
"require_upload_port": true, |
||||
|
"speed": 921600 |
||||
|
}, |
||||
|
"url": "https://www.elecrow.com/thinknode-m1-meshtastic-lora-signal-transceiver-powered-by-nrf52840-with-154-screen-support-gps.html", |
||||
|
"vendor": "ELECROW" |
||||
|
} |
||||
@ -1,11 +1,12 @@ |
|||||
{ pkgs ? import <nixpkgs> {} }: |
{pkgs ? import <nixpkgs> {}}: let |
||||
let |
|
||||
in |
in |
||||
pkgs.mkShell { |
pkgs.mkShell { |
||||
buildInputs = [ |
buildInputs = [ |
||||
pkgs.platformio |
pkgs.platformio |
||||
pkgs.python3 |
pkgs.python3 |
||||
|
pkgs.gcc |
||||
|
pkgs.gtest |
||||
# optional: needed as a programmer i.e. for esp32 |
# optional: needed as a programmer i.e. for esp32 |
||||
pkgs.avrdude |
pkgs.avrdude |
||||
]; |
]; |
||||
} |
} |
||||
|
|||||
@ -17,6 +17,7 @@ Once you have a working app/project, you need to be able to demonstrate it exist |
|||||
| 0000 - 00FF | -reserved for internal use- | | |
| 0000 - 00FF | -reserved for internal use- | | |
||||
| 0100 | MeshCore Open | [email protected] — https://github.com/zjs81/meshcore-open | |
| 0100 | MeshCore Open | [email protected] — https://github.com/zjs81/meshcore-open | |
||||
| 0110 - 011F | Ripple | [email protected] — https://buymeacoffee.com/ripplebiz | |
| 0110 - 011F | Ripple | [email protected] — https://buymeacoffee.com/ripplebiz | |
||||
|
| 0120 | MCO Advanced | [email protected] — https://hdden.ru/MCOa/ | |
||||
| FF00 - FFFF | -reserved for testing/dev- | | |
| FF00 - FFFF | -reserved for testing/dev- | | |
||||
|
|
||||
(add rows, inside the range 0100 - FEFF for custom apps) |
(add rows, inside the range 0100 - FEFF for custom apps) |
||||
|
|||||
@ -0,0 +1,12 @@ |
|||||
|
#pragma once |
||||
|
|
||||
|
class ExternalWatchdogManager { |
||||
|
protected: |
||||
|
unsigned long last_feed_watchdog; |
||||
|
public: |
||||
|
ExternalWatchdogManager() { last_feed_watchdog = 0; } |
||||
|
virtual bool begin() { return false; } |
||||
|
virtual void loop() { } |
||||
|
virtual unsigned long getIntervalMs() const { return 0; } |
||||
|
virtual void feed() { } |
||||
|
}; |
||||
@ -0,0 +1,103 @@ |
|||||
|
#include <gtest/gtest.h> |
||||
|
#include "helpers/SimpleMeshTables.h" |
||||
|
|
||||
|
using namespace mesh; |
||||
|
|
||||
|
// Build a packet that calculatePacketHash() distinguishes by payload content.
|
||||
|
// header selects ROUTE_TYPE_FLOOD so isRouteDirect() returns false.
|
||||
|
static Packet makeFloodPacket(uint8_t seed) { |
||||
|
Packet p; |
||||
|
p.header = ROUTE_TYPE_FLOOD | (PAYLOAD_TYPE_ACK << PH_TYPE_SHIFT); |
||||
|
p.payload[0] = seed; |
||||
|
p.payload_len = 1; |
||||
|
p.path_len = 0; |
||||
|
return p; |
||||
|
} |
||||
|
|
||||
|
static Packet makeDirectPacket(uint8_t seed) { |
||||
|
Packet p; |
||||
|
p.header = ROUTE_TYPE_DIRECT | (PAYLOAD_TYPE_ACK << PH_TYPE_SHIFT); |
||||
|
p.payload[0] = seed; |
||||
|
p.payload_len = 1; |
||||
|
p.path_len = 0; |
||||
|
return p; |
||||
|
} |
||||
|
|
||||
|
// ── wasSeen: pure query ───────────────────────────────────────────────────────
|
||||
|
|
||||
|
TEST(SimpleMeshTables, WasSeen_ReturnsFalseForUnseen) { |
||||
|
SimpleMeshTables t; |
||||
|
Packet p = makeFloodPacket(0x01); |
||||
|
EXPECT_FALSE(t.wasSeen(&p)); |
||||
|
} |
||||
|
|
||||
|
// wasSeen shouldn't change state
|
||||
|
TEST(SimpleMeshTables, WasSeen_IsPureQuery_DoesNotInsert) { |
||||
|
SimpleMeshTables t; |
||||
|
Packet p = makeFloodPacket(0x01); |
||||
|
EXPECT_FALSE(t.wasSeen(&p)); |
||||
|
EXPECT_FALSE(t.wasSeen(&p)); |
||||
|
} |
||||
|
|
||||
|
// ── markSeen + wasSeen ───────────────────────────────────────────────────────
|
||||
|
|
||||
|
TEST(SimpleMeshTables, MarkSeen_MakesWasSeenReturnTrue) { |
||||
|
SimpleMeshTables t; |
||||
|
Packet p = makeFloodPacket(0x01); |
||||
|
t.markSeen(&p); |
||||
|
EXPECT_TRUE(t.wasSeen(&p)); |
||||
|
} |
||||
|
|
||||
|
TEST(SimpleMeshTables, MarkSeen_DoesNotAffectOtherPackets) { |
||||
|
SimpleMeshTables t; |
||||
|
Packet p1 = makeFloodPacket(0x01); |
||||
|
Packet p2 = makeFloodPacket(0x02); |
||||
|
t.markSeen(&p1); |
||||
|
EXPECT_FALSE(t.wasSeen(&p2)); |
||||
|
} |
||||
|
|
||||
|
// Canonical pattern used at every onRecvPacket call site:
|
||||
|
// if (!wasSeen(pkt)) { markSeen(pkt); process(pkt); }
|
||||
|
TEST(SimpleMeshTables, QueryThenMark_WorksCorrectly) { |
||||
|
SimpleMeshTables t; |
||||
|
Packet p = makeFloodPacket(0x01); |
||||
|
EXPECT_FALSE(t.wasSeen(&p)); |
||||
|
t.markSeen(&p); |
||||
|
EXPECT_TRUE(t.wasSeen(&p)); |
||||
|
} |
||||
|
|
||||
|
// ── dup stats ────────────────────────────────────────────────────────────────
|
||||
|
|
||||
|
TEST(SimpleMeshTables, WasSeen_IncrementsFloodDupStat) { |
||||
|
SimpleMeshTables t; |
||||
|
Packet p = makeFloodPacket(0x01); |
||||
|
t.markSeen(&p); |
||||
|
t.wasSeen(&p); |
||||
|
EXPECT_EQ(1u, t.getNumFloodDups()); |
||||
|
EXPECT_EQ(0u, t.getNumDirectDups()); |
||||
|
} |
||||
|
|
||||
|
TEST(SimpleMeshTables, WasSeen_IncrementsDirectDupStat) { |
||||
|
SimpleMeshTables t; |
||||
|
Packet p = makeDirectPacket(0x01); |
||||
|
t.markSeen(&p); |
||||
|
t.wasSeen(&p); |
||||
|
EXPECT_EQ(0u, t.getNumFloodDups()); |
||||
|
EXPECT_EQ(1u, t.getNumDirectDups()); |
||||
|
} |
||||
|
|
||||
|
// ── clear ────────────────────────────────────────────────────────────────────
|
||||
|
|
||||
|
TEST(SimpleMeshTables, Clear_RemovesSeenPacket) { |
||||
|
SimpleMeshTables t; |
||||
|
Packet p = makeFloodPacket(0x01); |
||||
|
t.markSeen(&p); |
||||
|
ASSERT_TRUE(t.wasSeen(&p)); |
||||
|
t.clear(&p); |
||||
|
EXPECT_FALSE(t.wasSeen(&p)); |
||||
|
} |
||||
|
|
||||
|
int main(int argc, char** argv) { |
||||
|
::testing::InitGoogleTest(&argc, argv); |
||||
|
return RUN_ALL_TESTS(); |
||||
|
} |
||||
@ -0,0 +1,103 @@ |
|||||
|
#include "HeltecTowerV2Board.h" |
||||
|
|
||||
|
#include <Arduino.h> |
||||
|
#include <Wire.h> |
||||
|
|
||||
|
extern void variant_shutdown(); |
||||
|
|
||||
|
#ifdef NRF52_POWER_MANAGEMENT |
||||
|
const PowerMgtConfig power_config = { |
||||
|
.lpcomp_ain_channel = PWRMGT_LPCOMP_AIN, |
||||
|
.lpcomp_refsel = PWRMGT_LPCOMP_REFSEL, |
||||
|
.voltage_bootlock = PWRMGT_VOLTAGE_BOOTLOCK |
||||
|
}; |
||||
|
|
||||
|
void HeltecTowerV2Board::initiateShutdown(uint8_t reason) { |
||||
|
pinMode(PIN_GPS_EN, OUTPUT); |
||||
|
digitalWrite(PIN_GPS_EN, !PIN_GPS_EN_ACTIVE); |
||||
|
pinMode(PIN_GPS_STANDBY, OUTPUT); |
||||
|
digitalWrite(PIN_GPS_STANDBY, LOW); |
||||
|
pinMode(PIN_GPS_RESET, OUTPUT); |
||||
|
digitalWrite(PIN_GPS_RESET, GPS_RESET_MODE); |
||||
|
loRaFEMControl.setSleepModeEnable(); |
||||
|
|
||||
|
bool enable_lpcomp = (reason == SHUTDOWN_REASON_LOW_VOLTAGE || |
||||
|
reason == SHUTDOWN_REASON_BOOT_PROTECT); |
||||
|
pinMode(PIN_BAT_CTL, OUTPUT); |
||||
|
digitalWrite(PIN_BAT_CTL, enable_lpcomp ? HIGH : LOW); |
||||
|
|
||||
|
if (enable_lpcomp) { |
||||
|
configureVoltageWake(power_config.lpcomp_ain_channel, power_config.lpcomp_refsel); |
||||
|
} |
||||
|
|
||||
|
variant_shutdown(); |
||||
|
enterSystemOff(reason); |
||||
|
} |
||||
|
#endif |
||||
|
|
||||
|
void HeltecTowerV2Board::begin() { |
||||
|
NRF52Board::begin(); |
||||
|
|
||||
|
pinMode(P_LORA_TX_LED, OUTPUT); |
||||
|
digitalWrite(P_LORA_TX_LED, !LED_STATE_ON); |
||||
|
|
||||
|
pinMode(PIN_BAT_CTL, OUTPUT); |
||||
|
digitalWrite(PIN_BAT_CTL, LOW); |
||||
|
|
||||
|
#ifdef NRF52_POWER_MANAGEMENT |
||||
|
checkBootVoltage(&power_config); |
||||
|
#endif |
||||
|
|
||||
|
Wire.setPins(PIN_BOARD_SDA, PIN_BOARD_SCL); |
||||
|
Wire.begin(); |
||||
|
|
||||
|
pinMode(PIN_GPS_EN, OUTPUT); |
||||
|
digitalWrite(PIN_GPS_EN, !PIN_GPS_EN_ACTIVE); |
||||
|
pinMode(PIN_GPS_RESET, OUTPUT); |
||||
|
digitalWrite(PIN_GPS_RESET, GPS_RESET_MODE); |
||||
|
pinMode(PIN_GPS_STANDBY, OUTPUT); |
||||
|
digitalWrite(PIN_GPS_STANDBY, HIGH); |
||||
|
loRaFEMControl.init(); |
||||
|
} |
||||
|
|
||||
|
void HeltecTowerV2Board::onBeforeTransmit() { |
||||
|
digitalWrite(P_LORA_TX_LED, LED_STATE_ON); |
||||
|
loRaFEMControl.setTxModeEnable(); |
||||
|
} |
||||
|
|
||||
|
void HeltecTowerV2Board::onAfterTransmit() { |
||||
|
digitalWrite(P_LORA_TX_LED, !LED_STATE_ON); |
||||
|
loRaFEMControl.setRxModeEnable(); |
||||
|
} |
||||
|
|
||||
|
uint16_t HeltecTowerV2Board::getBattMilliVolts() { |
||||
|
analogReadResolution(12); |
||||
|
analogReference(VBAT_AR_INTERNAL); |
||||
|
pinMode(PIN_VBAT_READ, INPUT); |
||||
|
pinMode(PIN_BAT_CTL, OUTPUT); |
||||
|
digitalWrite(PIN_BAT_CTL, HIGH); |
||||
|
|
||||
|
delay(10); |
||||
|
int adcvalue = analogRead(PIN_VBAT_READ); |
||||
|
digitalWrite(PIN_BAT_CTL, LOW); |
||||
|
|
||||
|
return (uint16_t)((float)adcvalue * MV_LSB * ADC_MULTIPLIER); |
||||
|
} |
||||
|
|
||||
|
const char* HeltecTowerV2Board::getManufacturerName() const { |
||||
|
return "Heltec Tower V2"; |
||||
|
} |
||||
|
|
||||
|
void HeltecTowerV2Board::powerOff() { |
||||
|
pinMode(PIN_GPS_EN, OUTPUT); |
||||
|
digitalWrite(PIN_GPS_EN, !PIN_GPS_EN_ACTIVE); |
||||
|
pinMode(PIN_GPS_STANDBY, OUTPUT); |
||||
|
digitalWrite(PIN_GPS_STANDBY, LOW); |
||||
|
pinMode(PIN_GPS_RESET, OUTPUT); |
||||
|
digitalWrite(PIN_GPS_RESET, GPS_RESET_MODE); |
||||
|
loRaFEMControl.setSleepModeEnable(); |
||||
|
pinMode(PIN_BAT_CTL, OUTPUT); |
||||
|
digitalWrite(PIN_BAT_CTL, LOW); |
||||
|
variant_shutdown(); |
||||
|
sd_power_system_off(); |
||||
|
} |
||||
@ -0,0 +1,24 @@ |
|||||
|
#pragma once |
||||
|
|
||||
|
#include <Arduino.h> |
||||
|
#include <MeshCore.h> |
||||
|
#include <helpers/NRF52Board.h> |
||||
|
#include "LoRaFEMControl.h" |
||||
|
|
||||
|
class HeltecTowerV2Board : public NRF52BoardDCDC { |
||||
|
protected: |
||||
|
#ifdef NRF52_POWER_MANAGEMENT |
||||
|
void initiateShutdown(uint8_t reason) override; |
||||
|
#endif |
||||
|
|
||||
|
public: |
||||
|
LoRaFEMControl loRaFEMControl; |
||||
|
|
||||
|
HeltecTowerV2Board() : NRF52Board("TOWER_V2_OTA") {} |
||||
|
void begin(); |
||||
|
void onBeforeTransmit() override; |
||||
|
void onAfterTransmit() override; |
||||
|
uint16_t getBattMilliVolts() override; |
||||
|
const char* getManufacturerName() const override; |
||||
|
void powerOff() override; |
||||
|
}; |
||||
@ -0,0 +1,40 @@ |
|||||
|
#include "LoRaFEMControl.h" |
||||
|
|
||||
|
#include <Arduino.h> |
||||
|
#include "variant.h" |
||||
|
|
||||
|
static void enableFEMPower() { |
||||
|
bool wasOff = digitalRead(LORA_KCT8103L_EN) != HIGH; |
||||
|
digitalWrite(LORA_KCT8103L_EN, HIGH); |
||||
|
if (wasOff) { |
||||
|
delay(5); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
void LoRaFEMControl::init() { |
||||
|
pinMode(LORA_KCT8103L_EN, OUTPUT); |
||||
|
digitalWrite(LORA_KCT8103L_EN, HIGH); |
||||
|
delay(1); |
||||
|
pinMode(LORA_KCT8103L_TX_RX, OUTPUT); |
||||
|
digitalWrite(LORA_KCT8103L_TX_RX, LOW); |
||||
|
} |
||||
|
|
||||
|
void LoRaFEMControl::setSleepModeEnable() { |
||||
|
pinMode(LORA_KCT8103L_EN, OUTPUT); |
||||
|
digitalWrite(LORA_KCT8103L_EN, LOW); |
||||
|
} |
||||
|
|
||||
|
void LoRaFEMControl::setTxModeEnable() { |
||||
|
enableFEMPower(); |
||||
|
digitalWrite(LORA_KCT8103L_TX_RX, HIGH); |
||||
|
} |
||||
|
|
||||
|
void LoRaFEMControl::setRxModeEnable() { |
||||
|
enableFEMPower(); |
||||
|
digitalWrite(LORA_KCT8103L_TX_RX, LOW); |
||||
|
} |
||||
|
|
||||
|
void LoRaFEMControl::setRxModeEnableWhenMCUSleep() { |
||||
|
enableFEMPower(); |
||||
|
digitalWrite(LORA_KCT8103L_TX_RX, LOW); |
||||
|
} |
||||
@ -0,0 +1,13 @@ |
|||||
|
#pragma once |
||||
|
|
||||
|
class LoRaFEMControl { |
||||
|
public: |
||||
|
LoRaFEMControl() {} |
||||
|
virtual ~LoRaFEMControl() {} |
||||
|
|
||||
|
void init(); |
||||
|
void setSleepModeEnable(); |
||||
|
void setTxModeEnable(); |
||||
|
void setRxModeEnable(); |
||||
|
void setRxModeEnableWhenMCUSleep(); |
||||
|
}; |
||||
@ -0,0 +1,104 @@ |
|||||
|
[Heltec_tower_v2] |
||||
|
extends = nrf52_base |
||||
|
board = heltec_tower_v2 |
||||
|
board_build.ldscript = boards/nrf52840_s140_v6.ld |
||||
|
build_flags = ${nrf52_base.build_flags} |
||||
|
-D ENV_INCLUDE_GPS=1 |
||||
|
-I lib/nrf52/s140_nrf52_6.1.1_API/include |
||||
|
-I lib/nrf52/s140_nrf52_6.1.1_API/include/nrf52 |
||||
|
-I variants/heltec_tower_v2 |
||||
|
-D HELTEC_TOWER_V2 |
||||
|
-D NRF52_POWER_MANAGEMENT |
||||
|
-D RADIO_CLASS=CustomSX1262 |
||||
|
-D WRAPPER_CLASS=CustomSX1262Wrapper |
||||
|
-D LORA_TX_POWER=12 |
||||
|
-D MAX_LORA_TX_POWER=22 ; Max SX1262 output -> ~29dBm at antenna |
||||
|
-D SX126X_CURRENT_LIMIT=140 |
||||
|
-D SX126X_RX_BOOSTED_GAIN=1 |
||||
|
build_src_filter = ${nrf52_base.build_src_filter} |
||||
|
+<helpers/*.cpp> |
||||
|
+<helpers/sensors> |
||||
|
+<../variants/heltec_tower_v2> |
||||
|
lib_deps = |
||||
|
${nrf52_base.lib_deps} |
||||
|
stevemarple/MicroNMEA @ ^2.0.6 |
||||
|
debug_tool = jlink |
||||
|
upload_protocol = nrfutil |
||||
|
|
||||
|
[env:Heltec_tower_v2_repeater] |
||||
|
extends = Heltec_tower_v2 |
||||
|
build_src_filter = ${Heltec_tower_v2.build_src_filter} |
||||
|
+<../examples/simple_repeater> |
||||
|
build_flags = |
||||
|
${Heltec_tower_v2.build_flags} |
||||
|
-D ADVERT_NAME='"Heltec_Tower_V2 Repeater"' |
||||
|
-D ADVERT_LAT=0.0 |
||||
|
-D ADVERT_LON=0.0 |
||||
|
-D ADMIN_PASSWORD='"password"' |
||||
|
-D MAX_NEIGHBOURS=50 |
||||
|
; -D MESH_PACKET_LOGGING=1 |
||||
|
; -D MESH_DEBUG=1 |
||||
|
|
||||
|
[env:Heltec_tower_v2_room_server] |
||||
|
extends = Heltec_tower_v2 |
||||
|
build_src_filter = ${Heltec_tower_v2.build_src_filter} |
||||
|
+<../examples/simple_room_server> |
||||
|
build_flags = |
||||
|
${Heltec_tower_v2.build_flags} |
||||
|
-D ADVERT_NAME='"Heltec_Tower_V2 Room"' |
||||
|
-D ADVERT_LAT=0.0 |
||||
|
-D ADVERT_LON=0.0 |
||||
|
-D ADMIN_PASSWORD='"password"' |
||||
|
-D ROOM_PASSWORD='"hello"' |
||||
|
; -D MESH_PACKET_LOGGING=1 |
||||
|
; -D MESH_DEBUG=1 |
||||
|
|
||||
|
[env:Heltec_tower_v2_companion_radio_ble] |
||||
|
extends = Heltec_tower_v2 |
||||
|
board_build.ldscript = boards/nrf52840_s140_v6_extrafs.ld |
||||
|
board_upload.maximum_size = 712704 |
||||
|
build_flags = |
||||
|
${Heltec_tower_v2.build_flags} |
||||
|
-I examples/companion_radio/ui-new |
||||
|
-D DISPLAY_CLASS=NullDisplayDriver |
||||
|
-D MAX_CONTACTS=350 |
||||
|
-D MAX_GROUP_CHANNELS=40 |
||||
|
-D BLE_PIN_CODE=123456 |
||||
|
; -D BLE_DEBUG_LOGGING=1 |
||||
|
-D OFFLINE_QUEUE_SIZE=256 |
||||
|
; -D MESH_PACKET_LOGGING=1 |
||||
|
; -D MESH_DEBUG=1 |
||||
|
build_src_filter = ${Heltec_tower_v2.build_src_filter} |
||||
|
+<helpers/nrf52/SerialBLEInterface.cpp> |
||||
|
+<../examples/companion_radio/*.cpp> |
||||
|
+<../examples/companion_radio/ui-new/*.cpp> |
||||
|
lib_deps = |
||||
|
${Heltec_tower_v2.lib_deps} |
||||
|
densaugeo/base64 @ ~1.4.0 |
||||
|
|
||||
|
[env:Heltec_tower_v2_companion_radio_usb] |
||||
|
extends = Heltec_tower_v2 |
||||
|
board_build.ldscript = boards/nrf52840_s140_v6_extrafs.ld |
||||
|
board_upload.maximum_size = 712704 |
||||
|
build_flags = |
||||
|
${Heltec_tower_v2.build_flags} |
||||
|
-I examples/companion_radio/ui-new |
||||
|
-D DISPLAY_CLASS=NullDisplayDriver |
||||
|
-D MAX_CONTACTS=350 |
||||
|
-D MAX_GROUP_CHANNELS=40 |
||||
|
; -D BLE_PIN_CODE=123456 |
||||
|
; -D BLE_DEBUG_LOGGING=1 |
||||
|
; -D MESH_PACKET_LOGGING=1 |
||||
|
; -D MESH_DEBUG=1 |
||||
|
build_src_filter = ${Heltec_tower_v2.build_src_filter} |
||||
|
+<helpers/nrf52/*.cpp> |
||||
|
+<../examples/companion_radio/*.cpp> |
||||
|
+<../examples/companion_radio/ui-new/*.cpp> |
||||
|
lib_deps = |
||||
|
${Heltec_tower_v2.lib_deps} |
||||
|
densaugeo/base64 @ ~1.4.0 |
||||
|
|
||||
|
[env:Heltec_tower_v2_kiss_modem] |
||||
|
extends = Heltec_tower_v2 |
||||
|
build_src_filter = ${Heltec_tower_v2.build_src_filter} |
||||
|
+<../examples/kiss_modem/> |
||||
@ -0,0 +1,64 @@ |
|||||
|
#include "target.h" |
||||
|
|
||||
|
#include <Arduino.h> |
||||
|
#include <helpers/ArduinoHelpers.h> |
||||
|
#include <helpers/sensors/MicroNMEALocationProvider.h> |
||||
|
|
||||
|
HeltecTowerV2Board board; |
||||
|
|
||||
|
RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY, SPI); |
||||
|
|
||||
|
WRAPPER_CLASS radio_driver(radio, board); |
||||
|
|
||||
|
VolatileRTCClock fallback_clock; |
||||
|
AutoDiscoverRTCClock rtc_clock(fallback_clock); |
||||
|
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1, &rtc_clock); |
||||
|
EnvironmentSensorManager sensors = EnvironmentSensorManager(nmea); |
||||
|
TowerV2ExternalWatchdog external_watchdog; |
||||
|
|
||||
|
#ifdef DISPLAY_CLASS |
||||
|
DISPLAY_CLASS display; |
||||
|
MomentaryButton user_btn(PIN_USER_BTN, 1000, true); |
||||
|
#endif |
||||
|
|
||||
|
bool radio_init() { |
||||
|
rtc_clock.begin(Wire); |
||||
|
return radio.std_init(&SPI); |
||||
|
} |
||||
|
|
||||
|
mesh::LocalIdentity radio_new_identity() { |
||||
|
RadioNoiseListener rng(radio); |
||||
|
return mesh::LocalIdentity(&rng); |
||||
|
} |
||||
|
|
||||
|
bool TowerV2ExternalWatchdog::begin() { |
||||
|
last_feed_watchdog = 0; |
||||
|
pinMode(EXTERNAL_WATCHDOG_WAKE_PIN, INPUT); |
||||
|
pinMode(EXTERNAL_WATCHDOG_DONE_PIN, OUTPUT); |
||||
|
delay(1); |
||||
|
digitalWrite(EXTERNAL_WATCHDOG_DONE_PIN, LOW); |
||||
|
delay(1); |
||||
|
feed(); |
||||
|
return true; |
||||
|
} |
||||
|
|
||||
|
void TowerV2ExternalWatchdog::loop() { |
||||
|
if (millis() - last_feed_watchdog >= EXTERNAL_WATCHDOG_FEED_INTERVAL_MS) { |
||||
|
feed(); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
unsigned long TowerV2ExternalWatchdog::getIntervalMs() const { |
||||
|
unsigned long elapsed_ms = millis() - last_feed_watchdog; |
||||
|
if (elapsed_ms >= EXTERNAL_WATCHDOG_FEED_INTERVAL_MS) { |
||||
|
return 0; |
||||
|
} |
||||
|
return EXTERNAL_WATCHDOG_FEED_INTERVAL_MS - elapsed_ms; |
||||
|
} |
||||
|
|
||||
|
void TowerV2ExternalWatchdog::feed() { |
||||
|
digitalWrite(EXTERNAL_WATCHDOG_DONE_PIN, HIGH); |
||||
|
delay(1); |
||||
|
digitalWrite(EXTERNAL_WATCHDOG_DONE_PIN, LOW); |
||||
|
last_feed_watchdog = millis(); |
||||
|
} |
||||
@ -0,0 +1,39 @@ |
|||||
|
#pragma once |
||||
|
|
||||
|
#define RADIOLIB_STATIC_ONLY 1 |
||||
|
#include <RadioLib.h> |
||||
|
#include <HeltecTowerV2Board.h> |
||||
|
#include <helpers/AutoDiscoverRTCClock.h> |
||||
|
#include <helpers/radiolib/CustomSX1262Wrapper.h> |
||||
|
#include <helpers/radiolib/RadioLibWrappers.h> |
||||
|
#include <helpers/sensors/EnvironmentSensorManager.h> |
||||
|
#include <helpers/sensors/LocationProvider.h> |
||||
|
#include <helpers/ExternalWatchdogManager.h> |
||||
|
|
||||
|
#ifdef DISPLAY_CLASS |
||||
|
#include <helpers/ui/MomentaryButton.h> |
||||
|
#include "helpers/ui/NullDisplayDriver.h" |
||||
|
#endif |
||||
|
|
||||
|
class TowerV2ExternalWatchdog : public ExternalWatchdogManager { |
||||
|
public: |
||||
|
TowerV2ExternalWatchdog() {} |
||||
|
bool begin() override; |
||||
|
void loop() override; |
||||
|
unsigned long getIntervalMs() const override; |
||||
|
void feed() override; |
||||
|
}; |
||||
|
|
||||
|
extern HeltecTowerV2Board board; |
||||
|
extern WRAPPER_CLASS radio_driver; |
||||
|
extern AutoDiscoverRTCClock rtc_clock; |
||||
|
extern EnvironmentSensorManager sensors; |
||||
|
extern TowerV2ExternalWatchdog external_watchdog; |
||||
|
|
||||
|
#ifdef DISPLAY_CLASS |
||||
|
extern DISPLAY_CLASS display; |
||||
|
extern MomentaryButton user_btn; |
||||
|
#endif |
||||
|
|
||||
|
bool radio_init(); |
||||
|
mesh::LocalIdentity radio_new_identity(); |
||||
@ -0,0 +1,42 @@ |
|||||
|
#include "variant.h" |
||||
|
|
||||
|
#include "Arduino.h" |
||||
|
#include "nrf.h" |
||||
|
#include "wiring_constants.h" |
||||
|
#include "wiring_digital.h" |
||||
|
|
||||
|
const uint32_t g_ADigitalPinMap[] = { |
||||
|
0xff, 0xff, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, |
||||
|
14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, |
||||
|
27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, |
||||
|
40, 41, 42, 43, 44, 45, 46, 47 |
||||
|
}; |
||||
|
|
||||
|
void initVariant() |
||||
|
{ |
||||
|
|
||||
|
} |
||||
|
|
||||
|
void variant_shutdown() |
||||
|
{ |
||||
|
nrf_gpio_cfg_default(PIN_GPS_EN); |
||||
|
nrf_gpio_cfg_default(PIN_GPS_PPS); |
||||
|
nrf_gpio_cfg_default(PIN_GPS_RESET); |
||||
|
nrf_gpio_cfg_default(PIN_GPS_STANDBY); |
||||
|
nrf_gpio_cfg_default(GPS_RX_PIN); |
||||
|
nrf_gpio_cfg_default(GPS_TX_PIN); |
||||
|
pinMode(LORA_KCT8103L_EN, OUTPUT); |
||||
|
digitalWrite(LORA_KCT8103L_EN, LOW); |
||||
|
nrf_gpio_cfg_default(LORA_KCT8103L_TX_RX); |
||||
|
nrf_gpio_cfg_default(RF_PA_DETECT_PIN); |
||||
|
nrf_gpio_cfg_default(SX126X_CS); |
||||
|
nrf_gpio_cfg_default(SX126X_DIO1); |
||||
|
nrf_gpio_cfg_default(SX126X_BUSY); |
||||
|
nrf_gpio_cfg_default(SX126X_RESET); |
||||
|
nrf_gpio_cfg_default(PIN_SPI_MISO); |
||||
|
nrf_gpio_cfg_default(PIN_SPI_MOSI); |
||||
|
nrf_gpio_cfg_default(PIN_SPI_SCK); |
||||
|
nrf_gpio_cfg_default(PIN_LED); |
||||
|
detachInterrupt(PIN_GPS_PPS); |
||||
|
detachInterrupt(PIN_BUTTON1); |
||||
|
} |
||||
@ -0,0 +1,108 @@ |
|||||
|
#pragma once |
||||
|
|
||||
|
#include "WVariant.h" |
||||
|
|
||||
|
#define USE_LFXO |
||||
|
#define VARIANT_MCK (64000000ul) |
||||
|
|
||||
|
#define PINS_COUNT (48) |
||||
|
#define NUM_DIGITAL_PINS (48) |
||||
|
#define NUM_ANALOG_INPUTS (1) |
||||
|
#define NUM_ANALOG_OUTPUTS (0) |
||||
|
|
||||
|
#define WIRE_INTERFACES_COUNT (1) |
||||
|
#define PIN_WIRE_SDA (0 + 30) |
||||
|
#define PIN_WIRE_SCL (0 + 5) |
||||
|
#define PIN_BOARD_SDA PIN_WIRE_SDA |
||||
|
#define PIN_BOARD_SCL PIN_WIRE_SCL |
||||
|
|
||||
|
#define SPI_INTERFACES_COUNT (1) |
||||
|
#define PIN_SPI_MISO (0 + 23) |
||||
|
#define PIN_SPI_MOSI (0 + 22) |
||||
|
#define PIN_SPI_SCK (0 + 19) |
||||
|
#define PIN_SPI_NSS LORA_CS |
||||
|
|
||||
|
#define LED_BUILTIN (32 + 15) |
||||
|
#define PIN_LED LED_BUILTIN |
||||
|
#define LED_RED (-1) |
||||
|
#define LED_GREEN (-1) |
||||
|
#define LED_BLUE (-1) |
||||
|
#define LED_PIN (-1) |
||||
|
#define P_LORA_TX_LED LED_BUILTIN |
||||
|
#define LED_STATE_ON LOW |
||||
|
|
||||
|
#define PIN_BUTTON1 (32 + 10) |
||||
|
#define BUTTON_PIN PIN_BUTTON1 |
||||
|
#define PIN_USER_BTN BUTTON_PIN |
||||
|
|
||||
|
#define USE_SX1262 |
||||
|
#define SX126X_CS (0 + 24) |
||||
|
#define LORA_CS SX126X_CS |
||||
|
#define SX126X_DIO1 (0 + 20) |
||||
|
#define SX126X_BUSY (0 + 17) |
||||
|
#define SX126X_RESET (0 + 25) |
||||
|
#define SX126X_DIO2_AS_RF_SWITCH |
||||
|
#define SX126X_DIO3_TCXO_VOLTAGE 1.8 |
||||
|
|
||||
|
#define P_LORA_NSS LORA_CS |
||||
|
#define P_LORA_DIO_1 SX126X_DIO1 |
||||
|
#define P_LORA_BUSY SX126X_BUSY |
||||
|
#define P_LORA_RESET SX126X_RESET |
||||
|
#define P_LORA_MISO PIN_SPI_MISO |
||||
|
#define P_LORA_MOSI PIN_SPI_MOSI |
||||
|
#define P_LORA_SCLK PIN_SPI_SCK |
||||
|
|
||||
|
#define USE_KCT8103L_PA_ONLY |
||||
|
#define LORA_KCT8103L_EN (0 + 15) |
||||
|
#define LORA_KCT8103L_TX_RX (0 + 16) |
||||
|
#define LORA_PA_POWER LORA_KCT8103L_EN |
||||
|
#define RF_PA_DETECT_PIN (0 + 13) |
||||
|
#define RF_PA_HIGH_POWER_VALUE HIGH |
||||
|
|
||||
|
#define GPS_L76K |
||||
|
#define GPS_RESET_MODE LOW |
||||
|
#define PIN_GPS_RESET (32 + 6) |
||||
|
#define PIN_GPS_RESET_ACTIVE GPS_RESET_MODE |
||||
|
#define PIN_GPS_EN (0 + 7) |
||||
|
#define PIN_GPS_EN_ACTIVE LOW |
||||
|
#define GPS_EN_ACTIVE PIN_GPS_EN_ACTIVE |
||||
|
#define PIN_GPS_STANDBY (32 + 2) |
||||
|
#define PIN_GPS_PPS (32 + 4) |
||||
|
#define GPS_BAUD_RATE 9600 |
||||
|
|
||||
|
// Upstream names are from the GPS perspective. MeshCore's PIN_GPS_TX is the
|
||||
|
// CPU RX pin because EnvironmentSensorManager passes it as Serial1 RX.
|
||||
|
#define GPS_TX_PIN (32 + 7) |
||||
|
#define GPS_RX_PIN (32 + 5) |
||||
|
#define PIN_GPS_TX GPS_RX_PIN |
||||
|
#define PIN_GPS_RX GPS_TX_PIN |
||||
|
|
||||
|
#define PIN_SERIAL1_RX PIN_GPS_TX |
||||
|
#define PIN_SERIAL1_TX PIN_GPS_RX |
||||
|
#define PIN_SERIAL2_RX (-1) |
||||
|
#define PIN_SERIAL2_TX (-1) |
||||
|
|
||||
|
#define HAS_EXTERNAL_WATCHDOG |
||||
|
#define EXTERNAL_WATCHDOG_DONE_PIN (0 + 9) |
||||
|
#define EXTERNAL_WATCHDOG_WAKE_PIN (0 + 10) |
||||
|
#define EXTERNAL_WATCHDOG_FEED_INTERVAL_MS (8 * 60 * 1000) |
||||
|
|
||||
|
#define SERIAL_PRINT_PORT 0 |
||||
|
|
||||
|
#define PIN_BAT_CTL (0 + 21) |
||||
|
#define ADC_CTRL PIN_BAT_CTL |
||||
|
#define ADC_CTRL_ENABLED HIGH |
||||
|
#define BATTERY_PIN (0 + 4) |
||||
|
#define PIN_VBAT_READ BATTERY_PIN |
||||
|
#define ADC_RESOLUTION 14 |
||||
|
#define BATTERY_SENSE_RESOLUTION_BITS 12 |
||||
|
#define BATTERY_SENSE_RESOLUTION 4096.0 |
||||
|
#define AREF_VOLTAGE 3.0 |
||||
|
#define VBAT_AR_INTERNAL AR_INTERNAL_3_0 |
||||
|
#define ADC_MULTIPLIER (4.916F) |
||||
|
#define MV_LSB (3000.0F / 4096.0F) |
||||
|
|
||||
|
#define NRF52_POWER_MANAGEMENT |
||||
|
#define PWRMGT_VOLTAGE_BOOTLOCK 3100 |
||||
|
#define PWRMGT_LPCOMP_AIN 2 |
||||
|
#define PWRMGT_LPCOMP_REFSEL 1 |
||||
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue