merge: upstream/dev into observer-firmware-dev (v1.17.0)
Picks up upstream MeshCore 1.17.0 and the dev commits that followed it. Notable upstream content: - 1.17.0 version/build-date bump in the example MyMesh headers. - anon_req hardening: reply_path_len is now uint8_t with an isValidPathLen() bounds check and a 0xFF sentinel; reply_path_hash_size is gone. - LR2021 support (Meshnology W12, Seeed MeshTracker X1) incl. side detectors, multi-SF and the new `extra.sf` get/set CLI. - CustomLFS 0.2.2 -> 0.2.3 (GD25Q64C support). - kiss_modem envs for several nRF52 variants; ThinkNode M6 GPS/flash fixes. Conflicts resolved: - platformio.ini: took upstream's CustomLFS 0.2.3, kept our lib_ignore for the vendored PsychicMqttClient. - CommonCLI.h: kept both upstream's USE_LR2021 configSideDetectors() hook and our fault-alert callbacks. NodePrefs gains upstream's extra_sf[4], which is not registered with ConfigSerializer, so /prefs.json layout is unchanged. Verified: 275/275 native host tests pass; Heltec_v3_repeater_observer_mqtt, Heltec_v3_repeater and heltec_v4_repeater_observer_mqtt all build.
This commit is contained in:
commit
0c6de45625
46 files changed
+1840
-47
No files matched your search
@@ -0,0 +1,43 @@
|
||||
{
|
||||
"build": {
|
||||
"arduino": {
|
||||
"ldscript": "esp32s3_out.ld",
|
||||
"partitions": "default_16MB.csv",
|
||||
"memory_type": "qio_opi"
|
||||
},
|
||||
"core": "esp32",
|
||||
"extra_flags": [
|
||||
"-DBOARD_HAS_PSRAM",
|
||||
"-DARDUINO_USB_CDC_ON_BOOT=1",
|
||||
"-DARDUINO_USB_MODE=1",
|
||||
"-DARDUINO_RUNNING_CORE=1",
|
||||
"-DARDUINO_EVENT_RUNNING_CORE=1"
|
||||
],
|
||||
"f_cpu": "240000000L",
|
||||
"f_flash": "80000000L",
|
||||
"flash_mode": "qio",
|
||||
"psram_type": "opi",
|
||||
"hwids": [["0x303A", "0x0002"], ["0x303A", "0x1001"]],
|
||||
"mcu": "esp32s3",
|
||||
"variant": "meshnology_w12"
|
||||
},
|
||||
"connectivity": ["wifi", "bluetooth", "lora"],
|
||||
"debug": {
|
||||
"default_tool": "esp-builtin",
|
||||
"onboard_tools": ["esp-builtin"],
|
||||
"openocd_target": "esp32s3.cfg"
|
||||
},
|
||||
"frameworks": ["arduino", "espidf"],
|
||||
"name": "heltec_wifi_lora_32 v5 (16 MB FLASH, 8 MB PSRAM)",
|
||||
"upload": {
|
||||
"flash_size": "16MB",
|
||||
"maximum_ram_size": 327680,
|
||||
"maximum_size": 16777216,
|
||||
"use_1200bps_touch": true,
|
||||
"wait_for_upload_port": true,
|
||||
"require_upload_port": true,
|
||||
"speed": 921600
|
||||
},
|
||||
"url": "https://heltec.org/",
|
||||
"vendor": "heltec"
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
{
|
||||
"build": {
|
||||
"arduino": {
|
||||
"ldscript": "nrf52840_s140_v7.ld"
|
||||
},
|
||||
"core": "nRF5",
|
||||
"cpu": "cortex-m4",
|
||||
"extra_flags": "-DARDUINO_WIO_WM1110 -DNRF52840_XXAA",
|
||||
"f_cpu": "64000000L",
|
||||
"hwids": [
|
||||
["0x239A", "0x8029"],
|
||||
["0x239A", "0x0029"],
|
||||
["0x239A", "0x002A"],
|
||||
["0x239A", "0x802A"],
|
||||
["0x2886", "0x0057"]
|
||||
],
|
||||
"usb_product": "X1-BOOT",
|
||||
"mcu": "nrf52840",
|
||||
"variant": "Seeed_Mesh-Tracker-X1",
|
||||
"bsp": {
|
||||
"name": "adafruit"
|
||||
},
|
||||
"softdevice": {
|
||||
"sd_flags": "-DS140",
|
||||
"sd_name": "s140",
|
||||
"sd_version": "7.3.0",
|
||||
"sd_fwid": "0x0123"
|
||||
},
|
||||
"bootloader": {
|
||||
"settings_addr": "0xFF000"
|
||||
}
|
||||
},
|
||||
"connectivity": ["bluetooth"],
|
||||
"debug": {
|
||||
"jlink_device": "nRF52840_xxAA",
|
||||
"svd_path": "nrf52840.svd",
|
||||
"openocd_target": "nrf52.cfg"
|
||||
},
|
||||
"frameworks": ["arduino"],
|
||||
"name": "Seeed SenseCAP MeshTracker X1",
|
||||
"upload": {
|
||||
"maximum_ram_size": 248832,
|
||||
"maximum_size": 815104,
|
||||
"speed": 115200,
|
||||
"protocol": "nrfutil",
|
||||
"protocols": [
|
||||
"jlink",
|
||||
"nrfjprog",
|
||||
"nrfutil",
|
||||
"stlink",
|
||||
"cmsis-dap",
|
||||
"blackmagic"
|
||||
],
|
||||
"use_1200bps_touch": true,
|
||||
"require_upload_port": true,
|
||||
"wait_for_upload_port": true
|
||||
},
|
||||
"url": "https://www.seeedstudio.com/SenseCAP-MeshTracker-X1-for-Meshtastic-p-6793.html",
|
||||
"vendor": "Seeed Studio"
|
||||
}
|
||||
@@ -37,6 +37,9 @@ $ sh build.sh build-repeater-firmwares
|
||||
Build all chat room server firmwares
|
||||
$ sh build.sh build-room-server-firmwares
|
||||
|
||||
Build all kiss radio firmwares
|
||||
$ sh build.sh build-kiss-radio-firmwares
|
||||
|
||||
Environment Variables:
|
||||
DISABLE_DEBUG=1: Disables all debug logging flags (MESH_DEBUG, MESH_PACKET_LOGGING, etc.)
|
||||
If not set, debug flags from variant platformio.ini files are used.
|
||||
@@ -297,6 +300,17 @@ build_room_server_firmwares() {
|
||||
|
||||
}
|
||||
|
||||
build_kiss_modem_firmwares() {
|
||||
|
||||
# # build specific kiss radio firmwares
|
||||
# build_firmware "Heltec_v3_kiss_modem"
|
||||
# build_firmware "RAK_4631_kiss_modem"
|
||||
|
||||
# build all room server firmwares
|
||||
build_all_firmwares_by_suffix "_kiss_modem"
|
||||
|
||||
}
|
||||
|
||||
build_firmwares() {
|
||||
build_companion_firmwares
|
||||
build_repeater_firmwares
|
||||
@@ -333,6 +347,8 @@ elif [[ $1 == "build-repeater-firmwares" ]]; then
|
||||
build_repeater_firmwares
|
||||
elif [[ $1 == "build-room-server-firmwares" ]]; then
|
||||
build_room_server_firmwares
|
||||
elif [[ $1 == "build-kiss-radio-firmwares" ]]; then
|
||||
build_kiss_modem_firmwares
|
||||
elif [[ $1 == "get-companion-firmwares-to-build" ]]; then
|
||||
get_pio_envs_ending_with_string "_companion_radio_usb"
|
||||
get_pio_envs_ending_with_string "_companion_radio_ble"
|
||||
|
||||
@@ -440,6 +440,8 @@ Byte 0: 0x14
|
||||
- Uses a secret key derived from the channel name
|
||||
- It is the first 16 bytes of `sha256("#test")`
|
||||
- For example hashtag channel `#test` has the key: `9cd8fcf22a47333b591d96a2b848b73f`
|
||||
- Traffic is encrypted on air, but anyone who knows or guesses the channel
|
||||
name can derive the key. Hashtag channels should not be treated as private.
|
||||
- Used as a topic based public group chat, separate from the default public channel
|
||||
3. **Private Channels**
|
||||
- Uses a randomly generated 16-byte secret key
|
||||
|
||||
@@ -236,6 +236,9 @@ txt_type
|
||||
|
||||
The plaintext contained in the ciphertext matches the format described in [plain text message](#plain-text-message). Specifically, it consists of a four byte timestamp, a flags byte, and the message. The flags byte will generally be `0x00` because it is a "plain text message". The message will be of the form `<sender name>: <message body>` (eg., `user123: I'm on my way`).
|
||||
|
||||
The sender name is unverified message text. Group messages contain no sender
|
||||
signature, so any channel-key holder can choose any sender name.
|
||||
|
||||
## Group datagram
|
||||
|
||||
| Field | Size (bytes) | Description |
|
||||
|
||||
@@ -259,7 +259,7 @@ float MyMesh::getAirtimeBudgetFactor() const {
|
||||
}
|
||||
|
||||
bool MyMesh::getCADEnabled() const {
|
||||
return true; // hardware CAD before TX (no CLI toggle on companion; enabled by default)
|
||||
return false; // hardware CAD before TX (disabled by default, until configurable)
|
||||
}
|
||||
|
||||
int MyMesh::getInterferenceThreshold() const {
|
||||
|
||||
@@ -8,11 +8,11 @@
|
||||
#define FIRMWARE_VER_CODE 13
|
||||
|
||||
#ifndef FIRMWARE_BUILD_DATE
|
||||
#define FIRMWARE_BUILD_DATE "6 Jun 2026"
|
||||
#define FIRMWARE_BUILD_DATE "9 Aug 2026"
|
||||
#endif
|
||||
|
||||
#ifndef FIRMWARE_VERSION
|
||||
#define FIRMWARE_VERSION "v1.16.0"
|
||||
#define FIRMWARE_VERSION "v1.17.0"
|
||||
#endif
|
||||
|
||||
#if defined(NRF52_PLATFORM) || defined(STM32_PLATFORM)
|
||||
|
||||
@@ -28,6 +28,7 @@ public:
|
||||
uint32_t ble_pin = 0;
|
||||
uint8_t advert_loc_policy = 0;
|
||||
uint8_t buzzer_quiet = 0;
|
||||
uint8_t vibe_quiet = 0;
|
||||
uint8_t gps_enabled = 0; // GPS enabled flag (0=disabled, 1=enabled)
|
||||
uint32_t gps_interval = 0; // GPS read interval in seconds
|
||||
uint8_t autoadd_config = 0; // bitmask for auto-add contacts config
|
||||
@@ -101,6 +102,7 @@ private:
|
||||
def("defs_key", (void *) _parent->default_scope_key, sizeof(_parent->default_scope_key));
|
||||
def("pin", _parent->ble_pin);
|
||||
def("buzz_q", _parent->buzzer_quiet);
|
||||
def("vibe_q", _parent->vibe_quiet);
|
||||
def("auto_add", _parent->autoadd_config); // bitmask for auto-add contacts config
|
||||
def("man_add", _parent->manual_add_contacts);
|
||||
def("tel_base", _parent->telemetry_mode_base);
|
||||
|
||||
@@ -6,12 +6,19 @@
|
||||
#define AUTO_OFF_MILLIS 15000 // 15 seconds
|
||||
#define BOOT_SCREEN_MILLIS 3000 // 3 seconds
|
||||
|
||||
#ifdef PIN_STATUS_LED
|
||||
#if defined(PIN_STATUS_LED) || defined(PIN_STATUS_LED_R)
|
||||
#define LED_ON_MILLIS 20
|
||||
#define LED_ON_MSG_MILLIS 200
|
||||
#define LED_CYCLE_MILLIS 4000
|
||||
#endif
|
||||
|
||||
#if defined(PIN_STATUS_LED_R) && defined(PIN_STATUS_LED_G) && defined(PIN_STATUS_LED_B)
|
||||
#define STATUS_LED_RGB 1
|
||||
#ifndef LOW_BATT_MILLIVOLTS
|
||||
#define LOW_BATT_MILLIVOLTS 3500
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef USER_BTN_PRESSED
|
||||
#define USER_BTN_PRESSED LOW
|
||||
#endif
|
||||
@@ -60,6 +67,11 @@ void UITask::begin(DisplayDriver* display, SensorManager* sensors, NodePrefs* no
|
||||
buzzer.startup();
|
||||
#endif
|
||||
|
||||
#ifdef HAS_DRV2605
|
||||
vibration.begin();
|
||||
vibration.quiet(_node_prefs->vibe_quiet);
|
||||
#endif
|
||||
|
||||
// Initialize digital button if available
|
||||
#ifdef PIN_USER_BTN
|
||||
_userButton = new Button(PIN_USER_BTN, USER_BTN_PRESSED);
|
||||
@@ -130,6 +142,10 @@ void UITask::clearMsgPreview() {
|
||||
void UITask::newMsg(uint8_t path_len, const char* from_name, const char* text, int msgcount) {
|
||||
_msgcount = msgcount;
|
||||
|
||||
#ifdef HAS_DRV2605
|
||||
vibration.trigger(); // vibrate even while the app is connected (honors quiet + cooldown)
|
||||
#endif
|
||||
|
||||
if (path_len == 0xFF) {
|
||||
sprintf(_origin, "(F) %s", from_name);
|
||||
} else {
|
||||
@@ -260,8 +276,114 @@ void UITask::renderCurrScreen() {
|
||||
_need_refresh = false;
|
||||
}
|
||||
|
||||
#ifdef STATUS_LED_RGB
|
||||
static void statusLedWrite(uint8_t r, uint8_t g, uint8_t b) {
|
||||
analogWrite(PIN_STATUS_LED_R, r);
|
||||
analogWrite(PIN_STATUS_LED_G, g);
|
||||
analogWrite(PIN_STATUS_LED_B, b);
|
||||
}
|
||||
|
||||
static void statusLedWheel(uint8_t pos) { // smooth hue sweep, 0..255
|
||||
if (pos < 85) {
|
||||
statusLedWrite(255 - pos * 3, pos * 3, 0);
|
||||
} else if (pos < 170) {
|
||||
pos -= 85;
|
||||
statusLedWrite(0, 255 - pos * 3, pos * 3);
|
||||
} else {
|
||||
pos -= 170;
|
||||
statusLedWrite(pos * 3, 0, 255 - pos * 3);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void UITask::userLedHandler() {
|
||||
#ifdef PIN_STATUS_LED
|
||||
#ifdef STATUS_LED_RGB
|
||||
static bool booted = false;
|
||||
static bool flourish_active = false;
|
||||
static unsigned long flourish_until = 0;
|
||||
static int prev_msgcount = 0;
|
||||
static int state = 0;
|
||||
static unsigned long next_change = 0;
|
||||
static int last_increment = 0;
|
||||
static unsigned long next_batt_check = 0;
|
||||
static bool low_batt = false;
|
||||
|
||||
unsigned long cur_time = millis();
|
||||
|
||||
if (!booted) { // color sweep on boot
|
||||
booted = true;
|
||||
flourish_until = cur_time + 1200;
|
||||
flourish_active = true;
|
||||
}
|
||||
if (_msgcount > prev_msgcount) { // color sweep when a new message arrives
|
||||
flourish_until = cur_time + 800;
|
||||
flourish_active = true;
|
||||
}
|
||||
prev_msgcount = _msgcount;
|
||||
|
||||
if (flourish_active) {
|
||||
if (cur_time < flourish_until) {
|
||||
statusLedWheel((cur_time % 1200) * 255 / 1200);
|
||||
return;
|
||||
}
|
||||
statusLedWrite(0, 0, 0);
|
||||
flourish_active = false;
|
||||
state = 0;
|
||||
next_change = cur_time;
|
||||
}
|
||||
|
||||
if (cur_time > next_batt_check) { // battery reads are not free, keep them rare
|
||||
low_batt = _board->getBattMilliVolts() < LOW_BATT_MILLIVOLTS;
|
||||
next_batt_check = cur_time + 60000;
|
||||
}
|
||||
|
||||
#ifdef EXT_CHRG_DETECT
|
||||
// charge status display while docked (skipped when messages are waiting,
|
||||
// so the unread indication is never masked)
|
||||
static unsigned long next_pwr_check = 0;
|
||||
static bool ext_powered = false, ext_charging = false;
|
||||
if (cur_time > next_pwr_check) {
|
||||
ext_powered = _board->isExternalPowered();
|
||||
ext_charging = ext_powered && digitalRead(EXT_CHRG_DETECT) == LOW;
|
||||
next_pwr_check = cur_time + 1000;
|
||||
}
|
||||
if (ext_powered && _msgcount == 0) {
|
||||
if (ext_charging) {
|
||||
// amber breathing while charging
|
||||
int ph = cur_time % 2000;
|
||||
int v = ph < 1000 ? ph : 2000 - ph;
|
||||
uint8_t lvl = (uint8_t)(v * 255 / 1000);
|
||||
statusLedWrite(lvl, (uint8_t)(lvl * 35 / 100), 0);
|
||||
} else {
|
||||
statusLedWrite(0, 40, 0); // dim solid green: charge complete
|
||||
}
|
||||
state = 0;
|
||||
next_change = cur_time;
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (cur_time > next_change) {
|
||||
if (state == 0) {
|
||||
state = 1;
|
||||
last_increment = (_msgcount > 0) ? LED_ON_MSG_MILLIS : LED_ON_MILLIS;
|
||||
next_change = cur_time + last_increment;
|
||||
if (low_batt) {
|
||||
statusLedWrite(255, 0, 0); // red: battery low
|
||||
} else if (_msgcount > 0) {
|
||||
statusLedWrite(255, 90, 0); // amber: unread messages
|
||||
} else if (_connected) {
|
||||
statusLedWrite(0, 0, 255); // blue: app connected
|
||||
} else {
|
||||
statusLedWrite(0, 255, 0); // green: heartbeat
|
||||
}
|
||||
} else {
|
||||
state = 0;
|
||||
next_change = cur_time + LED_CYCLE_MILLIS - last_increment;
|
||||
statusLedWrite(0, 0, 0);
|
||||
}
|
||||
}
|
||||
#elif defined(PIN_STATUS_LED)
|
||||
static int state = 0;
|
||||
static int next_change = 0;
|
||||
static int last_increment = 0;
|
||||
@@ -406,8 +528,26 @@ void UITask::handleButtonDoublePress() {
|
||||
|
||||
void UITask::handleButtonTriplePress() {
|
||||
MESH_DEBUG_PRINTLN("UITask: triple press triggered");
|
||||
// Toggle buzzer quiet mode
|
||||
#ifdef PIN_BUZZER
|
||||
#if defined(PIN_BUZZER) && defined(HAS_DRV2605)
|
||||
// cycle alert modes: Buzz+Vibe -> Buzz only -> Vibe only -> Silent
|
||||
int mode = (_node_prefs->buzzer_quiet ? 2 : 0) | (_node_prefs->vibe_quiet ? 1 : 0);
|
||||
mode = (mode + 1) & 3;
|
||||
_node_prefs->buzzer_quiet = (mode & 2) ? 1 : 0;
|
||||
_node_prefs->vibe_quiet = (mode & 1) ? 1 : 0;
|
||||
buzzer.quiet(_node_prefs->buzzer_quiet);
|
||||
vibration.quiet(_node_prefs->vibe_quiet);
|
||||
// audible/tactile confirmation of the new mode (no screen on some boards)
|
||||
if (!_node_prefs->buzzer_quiet) notify(UIEventType::ack);
|
||||
if (!_node_prefs->vibe_quiet) vibration.trigger(true);
|
||||
switch (mode) {
|
||||
case 0: sprintf(_alert, "Alerts: Buzz+Vibe"); break;
|
||||
case 1: sprintf(_alert, "Alerts: Buzz only"); break;
|
||||
case 2: sprintf(_alert, "Alerts: Vibe only"); break;
|
||||
default: sprintf(_alert, "Alerts: Silent"); break;
|
||||
}
|
||||
the_mesh.savePrefs();
|
||||
_need_refresh = true;
|
||||
#elif defined(PIN_BUZZER)
|
||||
if (buzzer.isQuiet()) {
|
||||
buzzer.quiet(false);
|
||||
notify(UIEventType::ack);
|
||||
@@ -419,7 +559,7 @@ void UITask::handleButtonTriplePress() {
|
||||
_node_prefs->buzzer_quiet = buzzer.isQuiet();
|
||||
the_mesh.savePrefs();
|
||||
_need_refresh = true;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
void UITask::handleButtonQuadruplePress() {
|
||||
|
||||
@@ -14,11 +14,18 @@
|
||||
|
||||
#include "Button.h"
|
||||
|
||||
#ifdef HAS_DRV2605
|
||||
#include <helpers/ui/DRV2605Vibration.h>
|
||||
#endif
|
||||
|
||||
class UITask : public AbstractUITask {
|
||||
DisplayDriver* _display;
|
||||
SensorManager* _sensors;
|
||||
#ifdef PIN_BUZZER
|
||||
genericBuzzer buzzer;
|
||||
#endif
|
||||
#ifdef HAS_DRV2605
|
||||
DRV2605Vibration vibration;
|
||||
#endif
|
||||
unsigned long _next_refresh, _auto_off;
|
||||
NodePrefs* _node_prefs;
|
||||
|
||||
@@ -191,11 +191,10 @@ static int cmp_neighbours_weakest_to_strongest(const void* a, const void* b) {
|
||||
uint8_t MyMesh::handleAnonRegionsReq(const mesh::Identity& sender, uint32_t sender_timestamp, const uint8_t* data) {
|
||||
if (anon_limiter.allow(rtc_clock.getCurrentTime())) {
|
||||
// request data has: {reply-path-len}{reply-path}
|
||||
reply_path_len = *data & 63;
|
||||
reply_path_hash_size = (*data >> 6) + 1;
|
||||
data++;
|
||||
reply_path_len = *data++;
|
||||
if (!mesh::Packet::isValidPathLen(reply_path_len)) return 0; // reject - bad encoding
|
||||
|
||||
memcpy(reply_path, data, ((uint8_t)reply_path_len) * reply_path_hash_size);
|
||||
mesh::Packet::writePath(reply_path, data, reply_path_len);
|
||||
// data += (uint8_t)reply_path_len * reply_path_hash_size;
|
||||
|
||||
memcpy(reply_data, &sender_timestamp, 4); // prefix with sender_timestamp, like a tag
|
||||
@@ -210,11 +209,10 @@ uint8_t MyMesh::handleAnonRegionsReq(const mesh::Identity& sender, uint32_t send
|
||||
uint8_t MyMesh::handleAnonOwnerReq(const mesh::Identity& sender, uint32_t sender_timestamp, const uint8_t* data) {
|
||||
if (anon_limiter.allow(rtc_clock.getCurrentTime())) {
|
||||
// request data has: {reply-path-len}{reply-path}
|
||||
reply_path_len = *data & 63;
|
||||
reply_path_hash_size = (*data >> 6) + 1;
|
||||
data++;
|
||||
reply_path_len = *data++;
|
||||
if (!mesh::Packet::isValidPathLen(reply_path_len)) return 0; // reject - bad encoding
|
||||
|
||||
memcpy(reply_path, data, ((uint8_t)reply_path_len) * reply_path_hash_size);
|
||||
mesh::Packet::writePath(reply_path, data, reply_path_len);
|
||||
// data += (uint8_t)reply_path_len * reply_path_hash_size;
|
||||
|
||||
memcpy(reply_data, &sender_timestamp, 4); // prefix with sender_timestamp, like a tag
|
||||
@@ -230,11 +228,10 @@ uint8_t MyMesh::handleAnonOwnerReq(const mesh::Identity& sender, uint32_t sender
|
||||
uint8_t MyMesh::handleAnonClockReq(const mesh::Identity& sender, uint32_t sender_timestamp, const uint8_t* data) {
|
||||
if (anon_limiter.allow(rtc_clock.getCurrentTime())) {
|
||||
// request data has: {reply-path-len}{reply-path}
|
||||
reply_path_len = *data & 63;
|
||||
reply_path_hash_size = (*data >> 6) + 1;
|
||||
data++;
|
||||
reply_path_len = *data++;
|
||||
if (!mesh::Packet::isValidPathLen(reply_path_len)) return 0; // reject - bad encoding
|
||||
|
||||
memcpy(reply_path, data, ((uint8_t)reply_path_len) * reply_path_hash_size);
|
||||
mesh::Packet::writePath(reply_path, data, reply_path_len);
|
||||
// data += (uint8_t)reply_path_len * reply_path_hash_size;
|
||||
|
||||
memcpy(reply_data, &sender_timestamp, 4); // prefix with sender_timestamp, like a tag
|
||||
@@ -665,7 +662,7 @@ void MyMesh::onAnonDataRecv(mesh::Packet *packet, const uint8_t *secret, const m
|
||||
data[len] = 0; // ensure null terminator
|
||||
uint8_t reply_len;
|
||||
|
||||
reply_path_len = -1;
|
||||
reply_path_len = 0xFF;
|
||||
if (data[4] == 0 || data[4] >= ' ') { // is password, ie. a login request
|
||||
reply_len = handleLoginReq(sender, secret, timestamp, &data[4], packet->isRouteFlood());
|
||||
} else if (data[4] == ANON_REQ_TYPE_REGIONS && packet->isRouteDirect()) {
|
||||
@@ -685,13 +682,12 @@ void MyMesh::onAnonDataRecv(mesh::Packet *packet, const uint8_t *secret, const m
|
||||
mesh::Packet* path = createPathReturn(sender, secret, packet->path, packet->path_len,
|
||||
PAYLOAD_TYPE_RESPONSE, reply_data, reply_len);
|
||||
if (path) sendFloodReply(path, SERVER_RESPONSE_DELAY, packet->getPathHashSize());
|
||||
} else if (reply_path_len < 0) {
|
||||
} else if (reply_path_len == 0xFF) {
|
||||
mesh::Packet* reply = createDatagram(PAYLOAD_TYPE_RESPONSE, sender, secret, reply_data, reply_len);
|
||||
if (reply) sendFloodReply(reply, SERVER_RESPONSE_DELAY, packet->getPathHashSize());
|
||||
} else {
|
||||
mesh::Packet* reply = createDatagram(PAYLOAD_TYPE_RESPONSE, sender, secret, reply_data, reply_len);
|
||||
uint8_t path_len = ((reply_path_hash_size - 1) << 6) | (reply_path_len & 63);
|
||||
if (reply) sendDirect(reply, reply_path, path_len, SERVER_RESPONSE_DELAY);
|
||||
if (reply) sendDirect(reply, reply_path, reply_path_len, SERVER_RESPONSE_DELAY);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1319,6 +1315,12 @@ bool MyMesh::setRxBoostedGain(bool enable) {
|
||||
return radio_driver.setRxBoostedGainMode(enable);
|
||||
}
|
||||
|
||||
#if defined(USE_LR2021)
|
||||
bool MyMesh::configSideDetectors(const uint8_t sideDetSFs[], uint8_t num, float bw) {
|
||||
return radio_driver.configSideDetectors(sideDetSFs, num, bw);
|
||||
}
|
||||
#endif
|
||||
|
||||
void MyMesh::formatNeighborsReply(char *reply) {
|
||||
char *dp = reply;
|
||||
|
||||
|
||||
@@ -79,11 +79,11 @@ struct NeighbourInfo {
|
||||
};
|
||||
|
||||
#ifndef FIRMWARE_BUILD_DATE
|
||||
#define FIRMWARE_BUILD_DATE "6 Jun 2026"
|
||||
#define FIRMWARE_BUILD_DATE "9 Aug 2026"
|
||||
#endif
|
||||
|
||||
#ifndef FIRMWARE_VERSION
|
||||
#define FIRMWARE_VERSION "v1.16.0"
|
||||
#define FIRMWARE_VERSION "v1.17.0"
|
||||
#endif
|
||||
|
||||
#define FIRMWARE_ROLE "repeater"
|
||||
@@ -105,8 +105,7 @@ class MyMesh : public mesh::Mesh, public CommonCLICallbacks
|
||||
CommonCLI _cli;
|
||||
uint8_t reply_data[MAX_PACKET_PAYLOAD];
|
||||
uint8_t reply_path[MAX_PATH_SIZE];
|
||||
int8_t reply_path_len;
|
||||
uint8_t reply_path_hash_size;
|
||||
uint8_t reply_path_len;
|
||||
TransportKeyStore key_store;
|
||||
RegionMap region_map, temp_map;
|
||||
RegionEntry* load_stack[8];
|
||||
@@ -499,4 +498,8 @@ public:
|
||||
|
||||
bool setRxBoostedGain(bool enable) override;
|
||||
|
||||
#if defined(USE_LR2021)
|
||||
virtual bool configSideDetectors(const uint8_t sideDetSFs[], uint8_t num, float bw) override;
|
||||
#endif
|
||||
|
||||
};
|
||||
@@ -38,11 +38,11 @@
|
||||
/* ------------------------------ Config -------------------------------- */
|
||||
|
||||
#ifndef FIRMWARE_BUILD_DATE
|
||||
#define FIRMWARE_BUILD_DATE "6 Jun 2026"
|
||||
#define FIRMWARE_BUILD_DATE "9 Aug 2026"
|
||||
#endif
|
||||
|
||||
#ifndef FIRMWARE_VERSION
|
||||
#define FIRMWARE_VERSION "v1.16.0"
|
||||
#define FIRMWARE_VERSION "v1.17.0"
|
||||
#endif
|
||||
|
||||
#ifndef LORA_FREQ
|
||||
|
||||
@@ -34,11 +34,11 @@
|
||||
#define PERM_RECV_ALERTS_HI (1 << 7) // high priority alerts
|
||||
|
||||
#ifndef FIRMWARE_BUILD_DATE
|
||||
#define FIRMWARE_BUILD_DATE "6 Jun 2026"
|
||||
#define FIRMWARE_BUILD_DATE "9 Aug 2026"
|
||||
#endif
|
||||
|
||||
#ifndef FIRMWARE_VERSION
|
||||
#define FIRMWARE_VERSION "v1.16.0"
|
||||
#define FIRMWARE_VERSION "v1.17.0"
|
||||
#endif
|
||||
|
||||
#define FIRMWARE_ROLE "sensor"
|
||||
|
||||
+1
-1
@@ -103,7 +103,7 @@ build_flags = ${arduino_base.build_flags}
|
||||
-D USE_CC310_HW_CRYPTO=1
|
||||
lib_deps =
|
||||
${arduino_base.lib_deps}
|
||||
https://github.com/oltaco/CustomLFS#0.2.2
|
||||
https://github.com/oltaco/CustomLFS#0.2.3
|
||||
; Vendored ESP-IDF MQTT client; the LDF otherwise pulls it into non-ESP builds.
|
||||
lib_ignore = PsychicMqttClient
|
||||
; ----------------- RP2040 ---------------------
|
||||
|
||||
@@ -1451,6 +1451,28 @@ void CommonCLI::handleSetCmd(uint32_t sender_timestamp, char* command, char* rep
|
||||
_prefs->adc_multiplier = 0.0f;
|
||||
strcpy(reply, "Error: unsupported");
|
||||
};
|
||||
#if defined(USE_LR2021)
|
||||
} else if (memcmp(config, "extra.sf ", 9) == 0) {
|
||||
strcpy(tmp, &config[9]);
|
||||
const char *parts[4];
|
||||
uint8_t sideDetSFs[4];
|
||||
int num = mesh::Utils::parseTextParts(tmp, parts, 4);
|
||||
if (num > 3) {
|
||||
sprintf(reply, "Invalid extra SF config");
|
||||
} else {
|
||||
for (int i = 0; i < num; i++) {
|
||||
sideDetSFs[i] = atoi(parts[i]);
|
||||
}
|
||||
sideDetSFs[num] = 0;
|
||||
if (_callbacks->configSideDetectors(sideDetSFs, num, _prefs->bw)) {
|
||||
for (int i = 0; i <= num; i++) _prefs->extra_sf[i] = sideDetSFs[i];
|
||||
savePrefs();
|
||||
sprintf(reply, "OK - extra SFs set");
|
||||
} else {
|
||||
sprintf(reply, "Invalid extra SF config");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
} else {
|
||||
sprintf(reply, "unknown config: %s", config);
|
||||
}
|
||||
@@ -1626,6 +1648,14 @@ void CommonCLI::handleGetCmd(uint32_t sender_timestamp, char* command, char* rep
|
||||
#else
|
||||
strcpy(reply, "ERROR: Power management not supported");
|
||||
#endif
|
||||
} else if (memcmp(config, "extra.sf", 8) == 0) {
|
||||
char* tmp = reply;
|
||||
for (int i = 0; i < 3 && _prefs->extra_sf[i] != 0; i++) {
|
||||
tmp += sprintf(tmp, "%s%d", (i == 0) ? "" : ",", _prefs->extra_sf[i]);
|
||||
}
|
||||
if (tmp == reply) {
|
||||
sprintf(reply, "No extra SF configured");
|
||||
}
|
||||
} else {
|
||||
sprintf(reply, "??: %s", config);
|
||||
}
|
||||
|
||||
@@ -69,6 +69,7 @@ public:
|
||||
uint8_t path_hash_mode = 0; // which path mode to use when sending
|
||||
uint8_t loop_detect = 0;
|
||||
uint8_t cad_enabled = 0; // hardware Channel Activity Detection before TX (boolean)
|
||||
uint8_t extra_sf[4];
|
||||
|
||||
// NOTE: observer settings (MQTT/WiFi/timezone/SNMP/alert) are not in NodePrefs.
|
||||
// They live in MQTTPrefs, persisted separately to /mqtt_prefs, so this struct
|
||||
@@ -314,6 +315,12 @@ public:
|
||||
return false; // CommonCLI reports unsupported if not overridden by wrapper
|
||||
};
|
||||
|
||||
#if defined(USE_LR2021)
|
||||
virtual bool configSideDetectors(const uint8_t sideDetSFs[], uint8_t num, float bw) {
|
||||
return false; // Override in wrapper
|
||||
}
|
||||
#endif
|
||||
|
||||
// Fault-alert channel hooks (see NodePrefs::alert_*). The default no-op
|
||||
// implementations keep CLI commands harmless on builds that don't wire up
|
||||
// an AlertReporter.
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
#pragma once
|
||||
|
||||
#include <RadioLib.h>
|
||||
#include "MeshCore.h"
|
||||
|
||||
class CustomLR2021 : public LR2021 {
|
||||
bool _rx_boosted = false;
|
||||
|
||||
public:
|
||||
CustomLR2021(Module *mod) : LR2021(mod) { irqDioNum = LR2021_IRQ_DIO; }
|
||||
|
||||
bool std_init(SPIClass* spi = NULL)
|
||||
{
|
||||
|
||||
#ifdef LR2021_TCXO_VOLTAGE
|
||||
float tcxo = LR2021_TCXO_VOLTAGE;
|
||||
#else
|
||||
float tcxo = 1.6f;
|
||||
#endif
|
||||
|
||||
#ifdef LORA_CR
|
||||
uint8_t cr = LORA_CR;
|
||||
#else
|
||||
uint8_t cr = 5;
|
||||
#endif
|
||||
|
||||
#if defined(P_LORA_SCLK)
|
||||
#ifdef NRF52_PLATFORM
|
||||
if (spi) { spi->setPins(P_LORA_MISO, P_LORA_SCLK, P_LORA_MOSI); spi->begin(); }
|
||||
#elif defined(RP2040_PLATFORM)
|
||||
if (spi) {
|
||||
spi->setMISO(P_LORA_MISO);
|
||||
//spi->setCS(P_LORA_NSS); // Setting CS results in freeze
|
||||
spi->setSCK(P_LORA_SCLK);
|
||||
spi->setMOSI(P_LORA_MOSI);
|
||||
spi->begin();
|
||||
}
|
||||
#else
|
||||
if (spi) spi->begin(P_LORA_SCLK, P_LORA_MISO, P_LORA_MOSI);
|
||||
#endif
|
||||
#endif
|
||||
int status = begin(LORA_FREQ, LORA_BW, LORA_SF, cr, RADIOLIB_LR2021_LORA_SYNC_WORD_PRIVATE, LORA_TX_POWER, 16, tcxo);
|
||||
// if radio init fails with -707/-706, try again with tcxo voltage set to 0.0f
|
||||
if (status == RADIOLIB_ERR_SPI_CMD_FAILED || status == RADIOLIB_ERR_SPI_CMD_INVALID) {
|
||||
tcxo = 0.0f;
|
||||
status = begin(LORA_FREQ, LORA_BW, LORA_SF, cr, RADIOLIB_LR2021_LORA_SYNC_WORD_PRIVATE, LORA_TX_POWER, 16, tcxo);
|
||||
}
|
||||
if (status != RADIOLIB_ERR_NONE) {
|
||||
Serial.print("ERROR: radio init failed: ");
|
||||
Serial.println(status);
|
||||
return false; // fail
|
||||
}
|
||||
|
||||
setCRC(2);
|
||||
explicitHeader();
|
||||
|
||||
|
||||
#ifdef LR2021_RX_BOOSTED_GAIN
|
||||
setRxBoostedGainMode(LR2021_RX_BOOSTED_GAIN);
|
||||
#endif
|
||||
|
||||
return true; // success
|
||||
}
|
||||
|
||||
float getFreqMHz() const { return freqMHz; }
|
||||
|
||||
bool getRxBoostedGainMode() const { return _rx_boosted; }
|
||||
|
||||
bool isReceiving() {
|
||||
uint32_t irq = getIrqStatus();
|
||||
bool detected = ((irq & RADIOLIB_LR2021_IRQ_SYNCWORD_VALID) || (irq & RADIOLIB_LR2021_IRQ_PREAMBLE_DETECTED));
|
||||
return detected;
|
||||
}
|
||||
|
||||
uint8_t getSpreadingFactor() const { return spreadingFactor; }
|
||||
};
|
||||
@@ -0,0 +1,107 @@
|
||||
#pragma once
|
||||
|
||||
#include "CustomLR2021.h"
|
||||
#include "RadioLibWrappers.h"
|
||||
|
||||
#ifndef USE_LR2021
|
||||
#define USE_LR2021
|
||||
#endif
|
||||
|
||||
#ifndef LR2021_RX_BOOST_LEVEL
|
||||
#define LR2021_RX_BOOST_LEVEL 7
|
||||
#endif
|
||||
|
||||
class CustomLR2021Wrapper : public RadioLibWrapper {
|
||||
public:
|
||||
CustomLR2021Wrapper(CustomLR2021& radio, mesh::MainBoard& board) : RadioLibWrapper(radio, board) { }
|
||||
|
||||
void setParams(float freq, float bw, uint8_t sf, uint8_t cr) override {
|
||||
((CustomLR2021 *)_radio)->setFrequency(freq);
|
||||
((CustomLR2021 *)_radio)->setSpreadingFactor(sf);
|
||||
((CustomLR2021 *)_radio)->setBandwidth(bw);
|
||||
((CustomLR2021 *)_radio)->setCodingRate(cr);
|
||||
updatePreamble(sf);
|
||||
applySideDetectorConfig();
|
||||
}
|
||||
|
||||
bool configSideDetectors(const uint8_t* sideDetSFs, uint8_t num, float bw) override {
|
||||
LR2021LoRaSideDetector_t tmp[3];
|
||||
uint8_t sf = getSpreadingFactor();
|
||||
|
||||
if (sf >= 10 && num > 1) { return false; } // only 1 side detector allowed when primary SF >= 10
|
||||
for (int i = 0; i < num; i++) {
|
||||
if (sideDetSFs[i] > 12 || sideDetSFs[i] < 5) { return false; } // must be valid SF
|
||||
if (sideDetSFs[i] <= sf) { return false; } // must be < primary SF
|
||||
if (sideDetSFs[i] > sf + 4) { return false; } // span must not be > 4
|
||||
|
||||
tmp[i].sf = sideDetSFs[i];
|
||||
float tSym = calcTsym(tmp[i].sf, bw);
|
||||
if (tSym >= 16.0f) {
|
||||
tmp[i].ldro = true;
|
||||
} else {
|
||||
tmp[i].ldro = false;
|
||||
}
|
||||
tmp[i].invertIQ = false;
|
||||
tmp[i].syncWord = 0x12;
|
||||
}
|
||||
int16_t status = ((CustomLR2021 *)_radio)->setSideDetector(tmp, num);
|
||||
RadioLibWrapper::idle(); // trigger startReceive()
|
||||
MESH_DEBUG_PRINTLN("setSideDetector() returned %d", status);
|
||||
|
||||
if (status == RADIOLIB_ERR_NONE) {
|
||||
for (int i = 0; i < num; i++) { _sideDet[i] = tmp[i]; }
|
||||
_numSideDet = num;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int16_t applySideDetectorConfig() {
|
||||
int16_t status = ((CustomLR2021 *)_radio)->setSideDetector(_sideDet, _numSideDet);
|
||||
RadioLibWrapper::idle(); // trigger startReceive()
|
||||
return status;
|
||||
}
|
||||
|
||||
float calcTsym(uint8_t sf, float bw) {
|
||||
float tSym = (float)(uint32_t(1) << sf) / (float)bw;
|
||||
return tSym;
|
||||
}
|
||||
|
||||
bool isReceivingPacket() override {
|
||||
return ((CustomLR2021 *)_radio)->isReceiving();
|
||||
}
|
||||
|
||||
float getCurrentRSSI() override {
|
||||
float rssi = -110;
|
||||
((CustomLR2021 *)_radio)->getRssiInst(&rssi);
|
||||
return rssi;
|
||||
}
|
||||
|
||||
void onSendFinished() override {
|
||||
RadioLibWrapper::onSendFinished();
|
||||
_radio->setPreambleLength(preambleLengthForSF(getSpreadingFactor())); // overcomes weird issues with small and big pkts
|
||||
}
|
||||
|
||||
float getLastRSSI() const override { return ((CustomLR2021 *)_radio)->getRSSI(); }
|
||||
float getLastSNR() const override { return ((CustomLR2021 *)_radio)->getSNR(); }
|
||||
|
||||
uint8_t getSpreadingFactor() const override { return ((CustomLR2021 *)_radio)->getSpreadingFactor(); }
|
||||
|
||||
bool setRxBoostedGainMode(bool en) override {
|
||||
((CustomLR2021 *)_radio)->standby(); // LR2021 must be in standby to accept setRxBoostedGainMode
|
||||
int16_t status = ((CustomLR2021 *)_radio)->setRxBoostedGainMode(en ? LR2021_RX_BOOST_LEVEL: 0);
|
||||
RadioLibWrapper::idle(); // trigger startReceive()
|
||||
return status == RADIOLIB_ERR_NONE;
|
||||
}
|
||||
|
||||
bool getRxBoostedGainMode() const override {
|
||||
return ((CustomLR2021 *)_radio)->getRxBoostedGainMode();
|
||||
}
|
||||
|
||||
protected:
|
||||
LR2021LoRaSideDetector_t _sideDet[3];
|
||||
size_t _numSideDet = 0;
|
||||
|
||||
};
|
||||
@@ -105,6 +105,9 @@ void RadioLibWrapper::loop() {
|
||||
}
|
||||
|
||||
void RadioLibWrapper::startRecv() {
|
||||
#if defined(USE_LR2021)
|
||||
_radio->standby(); // without this LR2021 can throw -706 when calling startReceive after hardware CAD when side detectors are enabled
|
||||
#endif
|
||||
int err = _radio->startReceive();
|
||||
if (err == RADIOLIB_ERR_NONE) {
|
||||
state = STATE_RX;
|
||||
@@ -135,7 +138,11 @@ int RadioLibWrapper::recvRaw(uint8_t* bytes, int sz) {
|
||||
last_recv_millis = millis();
|
||||
}
|
||||
}
|
||||
#if defined(USE_LR2021)
|
||||
state = STATE_RX; // LR2021 stays in Rx after readData, calling startReceive while still in Rx throws -706 errors
|
||||
#else
|
||||
state = STATE_IDLE; // need another startReceive()
|
||||
#endif
|
||||
}
|
||||
|
||||
if (state != STATE_RX) {
|
||||
|
||||
@@ -88,6 +88,8 @@ public:
|
||||
|
||||
virtual bool setRxBoostedGainMode(bool) { return false; }
|
||||
virtual bool getRxBoostedGainMode() const { return false; }
|
||||
|
||||
virtual bool configSideDetectors(const uint8_t sideDetSFs[], uint8_t num, float bw) { return false; }
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
#ifdef HAS_DRV2605
|
||||
|
||||
#include "DRV2605Vibration.h"
|
||||
#include <Wire.h>
|
||||
|
||||
void DRV2605Vibration::begin() {
|
||||
#ifdef PIN_DRV_EN
|
||||
pinMode(PIN_DRV_EN, OUTPUT);
|
||||
digitalWrite(PIN_DRV_EN, HIGH); // power up the haptic driver
|
||||
delay(10);
|
||||
#endif
|
||||
if (!drv.begin(&Wire)) {
|
||||
return; // no haptic driver found, stay silent
|
||||
}
|
||||
#ifdef DRV2605_USE_LRA
|
||||
// LRA mode: 4x brake factor, medium loop gain, back-EMF gain 2
|
||||
drv.writeRegister8(DRV2605_REG_FEEDBACK, 0xB6);
|
||||
#endif
|
||||
drv.selectLibrary(1);
|
||||
drv.setMode(DRV2605_MODE_INTTRIG);
|
||||
_ready = true;
|
||||
}
|
||||
|
||||
void DRV2605Vibration::trigger(bool force) {
|
||||
if (!_ready || _quiet) return;
|
||||
unsigned long now = millis();
|
||||
if (!force && _last_trigger != 0 && now - _last_trigger < VIBRATION_TIMEOUT) return;
|
||||
_last_trigger = now;
|
||||
drv.setWaveform(0, DRV2605_EFFECT);
|
||||
drv.setWaveform(1, 0); // pause
|
||||
drv.setWaveform(2, DRV2605_EFFECT);
|
||||
drv.setWaveform(3, 0); // end of sequence
|
||||
drv.go();
|
||||
}
|
||||
|
||||
void DRV2605Vibration::loop() {
|
||||
}
|
||||
|
||||
bool DRV2605Vibration::isVibrating() {
|
||||
return false; // effects are short, treat as instantaneous
|
||||
}
|
||||
|
||||
void DRV2605Vibration::stop() {
|
||||
if (_ready) drv.stop();
|
||||
}
|
||||
|
||||
#endif // ifdef HAS_DRV2605
|
||||
@@ -0,0 +1,39 @@
|
||||
#pragma once
|
||||
|
||||
#ifdef HAS_DRV2605
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <Adafruit_DRV2605.h>
|
||||
|
||||
/*
|
||||
* Vibration control class for boards where the motor is behind a
|
||||
* DRV2605 haptic driver on I2C (e.g. Seeed SenseCAP MeshTracker X1).
|
||||
* Same interface as GenericVibration.
|
||||
*/
|
||||
|
||||
#ifndef VIBRATION_TIMEOUT
|
||||
#define VIBRATION_TIMEOUT 5000 // cooldown between vibrations
|
||||
#endif
|
||||
|
||||
#ifndef DRV2605_EFFECT
|
||||
#define DRV2605_EFFECT 16 // "1000 ms alert" from the DRV2605 effect library
|
||||
#endif
|
||||
|
||||
class DRV2605Vibration {
|
||||
public:
|
||||
void begin(); // power up and init the DRV2605
|
||||
void trigger(bool force = false); // trigger vibration; force skips the cooldown
|
||||
void loop(); // no-op, the DRV2605 plays effects autonomously
|
||||
bool isVibrating();
|
||||
void stop(); // stop vibration immediately
|
||||
void quiet(bool q) { _quiet = q; }
|
||||
bool isQuiet() const { return _quiet; }
|
||||
|
||||
private:
|
||||
Adafruit_DRV2605 drv;
|
||||
bool _ready = false;
|
||||
bool _quiet = false;
|
||||
unsigned long _last_trigger = 0;
|
||||
};
|
||||
|
||||
#endif // ifdef HAS_DRV2605
|
||||
@@ -119,3 +119,8 @@ lib_deps =
|
||||
${LilyGo_T-Echo_Card.lib_deps}
|
||||
end2endzone/NonBlockingRTTTL@^1.3.0
|
||||
densaugeo/base64 @ ~1.4.0
|
||||
|
||||
[env:LilyGo_T-Echo_Card_kiss_modem]
|
||||
extends = LilyGo_T-Echo_Card
|
||||
build_src_filter = ${LilyGo_T-Echo_Card.build_src_filter}
|
||||
+<../examples/kiss_modem/>
|
||||
@@ -12,10 +12,9 @@ build_flags = ${nrf52_base.build_flags}
|
||||
-D WRAPPER_CLASS=CustomSX1262Wrapper
|
||||
-D LORA_TX_POWER=22
|
||||
-D SX126X_POWER_EN=30
|
||||
-D SX126X_DIO3_TCXO_VOLTAGE=1.8
|
||||
-D SX126X_DIO3_TCXO_VOLTAGE=3.0
|
||||
-D SX126X_CURRENT_LIMIT=140
|
||||
-D SX126X_RX_BOOSTED_GAIN=1
|
||||
-D SX126X_USE_REGULATOR_LDO=1
|
||||
-D P_LORA_TX_LED=LED_GREEN
|
||||
-D DISABLE_DIAGNOSTIC_OUTPUT
|
||||
-D ENV_INCLUDE_GPS=1
|
||||
@@ -117,7 +116,7 @@ build_flags =
|
||||
-D WRAPPER_CLASS=CustomSX1262Wrapper
|
||||
-D LORA_TX_POWER=22
|
||||
-D SX126X_POWER_EN=30
|
||||
-D SX126X_DIO3_TCXO_VOLTAGE=1.8
|
||||
-D SX126X_DIO3_TCXO_VOLTAGE=3.0
|
||||
-D SX126X_CURRENT_LIMIT=140
|
||||
-D SX126X_RX_BOOSTED_GAIN=1
|
||||
-D P_LORA_TX_LED=LED_GREEN
|
||||
@@ -162,6 +161,7 @@ build_flags =
|
||||
-D WRAPPER_CLASS=CustomSX1262Wrapper
|
||||
-D LORA_TX_POWER=22
|
||||
-D SX126X_POWER_EN=30
|
||||
-D SX126X_DIO3_TCXO_VOLTAGE=3.0
|
||||
-D SX126X_CURRENT_LIMIT=140
|
||||
-D SX126X_RX_BOOSTED_GAIN=1
|
||||
-D P_LORA_TX_LED=LED_GREEN
|
||||
|
||||
@@ -105,12 +105,14 @@
|
||||
#define LORA_CS _PINNUM(0, 11)
|
||||
#define SX126X_POWER_EN _PINNUM(0, 30)
|
||||
#define SX126X_DIO1 _PINNUM(1, 8)
|
||||
#define SX126X_DIO2 _PINNUM(0, 5)
|
||||
#define SX126X_BUSY _PINNUM(0, 14)
|
||||
#define SX126X_RESET _PINNUM(0, 7)
|
||||
#define SX126X_RXEN _PINNUM(1, 1)
|
||||
#define SX126X_TXEN _PINNUM(0, 27)
|
||||
|
||||
#define P_LORA_DIO_1 SX126X_DIO1
|
||||
#define P_LORA_DIO_2 SX126X_DIO2
|
||||
#define P_LORA_NSS LORA_CS
|
||||
#define P_LORA_RESET SX126X_RESET
|
||||
#define P_LORA_BUSY SX126X_BUSY
|
||||
|
||||
@@ -98,3 +98,8 @@ build_src_filter = ${LilyGo_TETH_Elite_sx1262.build_src_filter}
|
||||
lib_deps =
|
||||
${LilyGo_TETH_Elite_sx1262.lib_deps}
|
||||
densaugeo/base64 @ ~1.4.0
|
||||
|
||||
[env:LilyGo_TETH_Elite_sx1262_kiss_modem]
|
||||
extends = LilyGo_TETH_Elite_sx1262
|
||||
build_src_filter = ${LilyGo_TETH_Elite_sx1262.build_src_filter}
|
||||
+<../examples/kiss_modem/>
|
||||
@@ -0,0 +1,83 @@
|
||||
#include "MeshnologyW12Board.h"
|
||||
|
||||
void MeshnologyW12Board::begin() {
|
||||
ESP32Board::begin();
|
||||
|
||||
pinMode(PIN_ADC_CTRL, OUTPUT);
|
||||
digitalWrite(PIN_ADC_CTRL, LOW); // Disable battery sense until required
|
||||
|
||||
pinMode(P_LORA_LF_PA_POWER, OUTPUT);
|
||||
digitalWrite(P_LORA_LF_PA_POWER, HIGH); // PA_EN_M — power the GC1109 FEM
|
||||
|
||||
pinMode(P_LORA_HF_PA_POWER, OUTPUT);
|
||||
digitalWrite(P_LORA_HF_PA_POWER, LOW); // PA_EN_G — disable the 2.4GHz FEM
|
||||
|
||||
delay(100); // give the GC1109 some time to start
|
||||
|
||||
periph_power.begin();
|
||||
esp_reset_reason_t reason = esp_reset_reason();
|
||||
if (reason == ESP_RST_DEEPSLEEP) {
|
||||
long wakeup_source = esp_sleep_get_ext1_wakeup_status();
|
||||
if (wakeup_source & (1 << P_LORA_DIO_1)) { // received a LoRa packet (while in deep sleep)
|
||||
startup_reason = BD_STARTUP_RX_PACKET;
|
||||
}
|
||||
|
||||
rtc_gpio_hold_dis((gpio_num_t)P_LORA_NSS);
|
||||
rtc_gpio_deinit((gpio_num_t)P_LORA_DIO_1);
|
||||
}
|
||||
}
|
||||
|
||||
void MeshnologyW12Board::onBeforeTransmit(void) {
|
||||
neopixelWrite(NEOPIXEL_LED, NEOPIXEL_BRIGHTNESS, NEOPIXEL_BRIGHTNESS, NEOPIXEL_BRIGHTNESS); // turn TX neopixel on (White)
|
||||
}
|
||||
|
||||
void MeshnologyW12Board::onAfterTransmit(void) {
|
||||
neopixelWrite(NEOPIXEL_LED, 0, 0, 0); // turn TX neopixel off
|
||||
}
|
||||
|
||||
void MeshnologyW12Board::enterDeepSleep(uint32_t secs, int pin_wake_btn) {
|
||||
esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_ON);
|
||||
|
||||
// Make sure the DIO1 and NSS GPIOs are hold on required levels during deep sleep
|
||||
rtc_gpio_set_direction((gpio_num_t)P_LORA_DIO_1, RTC_GPIO_MODE_INPUT_ONLY);
|
||||
rtc_gpio_pulldown_en((gpio_num_t)P_LORA_DIO_1);
|
||||
|
||||
rtc_gpio_hold_en((gpio_num_t)P_LORA_NSS);
|
||||
|
||||
if (pin_wake_btn < 0) {
|
||||
esp_sleep_enable_ext1_wakeup( (1L << P_LORA_DIO_1), ESP_EXT1_WAKEUP_ANY_HIGH); // wake up on: recv LoRa packet
|
||||
} else {
|
||||
esp_sleep_enable_ext1_wakeup( (1L << P_LORA_DIO_1) | (1L << pin_wake_btn), ESP_EXT1_WAKEUP_ANY_HIGH); // wake up on: recv LoRa packet OR wake btn
|
||||
}
|
||||
|
||||
if (secs > 0) {
|
||||
esp_sleep_enable_timer_wakeup(secs * 1000000);
|
||||
}
|
||||
|
||||
// Finally set ESP32 into sleep
|
||||
esp_deep_sleep_start(); // CPU halts here and never returns!
|
||||
}
|
||||
|
||||
void MeshnologyW12Board::powerOff() {
|
||||
enterDeepSleep(0);
|
||||
}
|
||||
|
||||
uint16_t MeshnologyW12Board::getBattMilliVolts() {
|
||||
analogReadResolution(12);
|
||||
analogSetAttenuation(ADC_11db);
|
||||
digitalWrite(PIN_ADC_CTRL, HIGH);
|
||||
delay(10);
|
||||
uint32_t raw = 0;
|
||||
for (int i = 0; i < 8; i++) {
|
||||
raw += analogRead(PIN_VBAT_READ);
|
||||
}
|
||||
raw = raw / 8;
|
||||
|
||||
digitalWrite(PIN_ADC_CTRL, LOW);
|
||||
|
||||
return (adc_mult * (3.3 / 4096.0) * raw) * 1000;
|
||||
}
|
||||
|
||||
const char* MeshnologyW12Board::getManufacturerName() const {
|
||||
return "Meshnology W12";
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
#pragma once
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <helpers/RefCountedDigitalPin.h>
|
||||
#include <helpers/ESP32Board.h>
|
||||
#include <driver/rtc_io.h>
|
||||
|
||||
#ifndef ADC_MULTIPLIER
|
||||
#define ADC_MULTIPLIER 5.42
|
||||
#endif
|
||||
|
||||
class MeshnologyW12Board : public ESP32Board {
|
||||
|
||||
protected:
|
||||
float adc_mult = ADC_MULTIPLIER;
|
||||
|
||||
public:
|
||||
RefCountedDigitalPin periph_power;
|
||||
MeshnologyW12Board() : periph_power(PIN_VEXT_EN, PIN_VEXT_EN_ACTIVE) { }
|
||||
|
||||
void begin();
|
||||
void onBeforeTransmit(void) override;
|
||||
void onAfterTransmit(void) override;
|
||||
void enterDeepSleep(uint32_t secs, int pin_wake_btn = -1);
|
||||
void powerOff() override;
|
||||
uint16_t getBattMilliVolts() 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;
|
||||
};
|
||||
@@ -0,0 +1,69 @@
|
||||
#ifndef Pins_Arduino_h
|
||||
#define Pins_Arduino_h
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
static const uint8_t LED_BUILTIN = -1;
|
||||
#define BUILTIN_LED LED_BUILTIN // backward compatibility
|
||||
#define LED_BUILTIN LED_BUILTIN // allow testing #ifdef LED_BUILTIN
|
||||
|
||||
static const uint8_t TX = 43;
|
||||
static const uint8_t RX = 44;
|
||||
|
||||
static const uint8_t SDA = 3;
|
||||
static const uint8_t SCL = 4;
|
||||
|
||||
static const uint8_t SS = 8;
|
||||
static const uint8_t MOSI = 10;
|
||||
static const uint8_t MISO = 11;
|
||||
static const uint8_t SCK = 9;
|
||||
|
||||
static const uint8_t A0 = 1;
|
||||
static const uint8_t A1 = 2;
|
||||
static const uint8_t A2 = 3;
|
||||
static const uint8_t A3 = 4;
|
||||
static const uint8_t A4 = 5;
|
||||
static const uint8_t A5 = 6;
|
||||
static const uint8_t A6 = 7;
|
||||
static const uint8_t A7 = 8;
|
||||
static const uint8_t A8 = 9;
|
||||
static const uint8_t A9 = 10;
|
||||
static const uint8_t A10 = 11;
|
||||
static const uint8_t A11 = 12;
|
||||
static const uint8_t A12 = 13;
|
||||
static const uint8_t A13 = 14;
|
||||
static const uint8_t A14 = 15;
|
||||
static const uint8_t A15 = 16;
|
||||
static const uint8_t A16 = 17;
|
||||
static const uint8_t A17 = 18;
|
||||
static const uint8_t A18 = 19;
|
||||
static const uint8_t A19 = 20;
|
||||
|
||||
static const uint8_t T1 = 1;
|
||||
static const uint8_t T2 = 2;
|
||||
static const uint8_t T3 = 3;
|
||||
static const uint8_t T4 = 4;
|
||||
static const uint8_t T5 = 5;
|
||||
static const uint8_t T6 = 6;
|
||||
static const uint8_t T7 = 7;
|
||||
static const uint8_t T8 = 8;
|
||||
static const uint8_t T9 = 9;
|
||||
static const uint8_t T10 = 10;
|
||||
static const uint8_t T11 = 11;
|
||||
static const uint8_t T12 = 12;
|
||||
static const uint8_t T13 = 13;
|
||||
static const uint8_t T14 = 14;
|
||||
|
||||
static const uint8_t Vext = 45;
|
||||
static const uint8_t LED = -1;
|
||||
static const uint8_t RST_OLED = 21;
|
||||
static const uint8_t SCL_OLED = 18;
|
||||
static const uint8_t SDA_OLED = 17;
|
||||
|
||||
static const uint8_t RST_LoRa = 12;
|
||||
static const uint8_t BUSY_LoRa = 13;
|
||||
static const uint8_t DIO0 = 14;
|
||||
|
||||
|
||||
|
||||
#endif /* Pins_Arduino_h */
|
||||
@@ -0,0 +1,216 @@
|
||||
[meshnology_w12]
|
||||
extends = esp32_base
|
||||
board = meshnology_w12
|
||||
build_flags =
|
||||
${esp32_base.build_flags}
|
||||
${sensor_base.build_flags}
|
||||
-I variants/meshnology_w12
|
||||
-D MESHNOLOGY_W12
|
||||
-D ESP32_CPU_FREQ=80
|
||||
-D RADIO_CLASS=CustomLR2021
|
||||
-D WRAPPER_CLASS=CustomLR2021Wrapper
|
||||
-D USE_LR2021
|
||||
-D NEOPIXEL_LED=46
|
||||
-D NEOPIXEL_BRIGHTNESS=64
|
||||
-D P_LORA_DIO_1=14
|
||||
-D LR2021_IRQ_DIO=8 ; GPIO14 is connected to LR2021 DIO8
|
||||
-D P_LORA_NSS=8
|
||||
-D P_LORA_SCLK=9
|
||||
-D P_LORA_MOSI=10
|
||||
-D P_LORA_MISO=11
|
||||
-D P_LORA_RESET=12
|
||||
-D P_LORA_BUSY=13
|
||||
-D LR2021_TCXO_VOLTAGE=0.0f ; this board has no tcxo
|
||||
-D RF_SWITCH_TABLE ; used below in commented code for the RF switch table.
|
||||
-D P_LORA_LF_PA_POWER=4 ; PA_EN_M - power enable for the GC1109 868/915 PA
|
||||
-D P_LORA_HF_PA_POWER=3 ; PA_EN_G - power enable for RFX2402E 2.4G PA
|
||||
-D PIN_USER_BTN=0
|
||||
-D PIN_VEXT_EN=45
|
||||
-D PIN_VEXT_EN_ACTIVE=HIGH
|
||||
-D LORA_TX_POWER=4
|
||||
-D MAX_LORA_TX_POWER=4 ; GC1109 datasheet says max input at TX port is +5dbm, confirmed full saturation seems to occur at around 3-4dbm
|
||||
-D PIN_GPS_RX=38
|
||||
-D PIN_GPS_TX=39
|
||||
-D PIN_GPS_RESET=42
|
||||
-D PIN_GPS_RESET_ACTIVE=LOW
|
||||
-D PIN_GPS_EN=48
|
||||
-D PIN_GPS_EN_ACTIVE=LOW
|
||||
; -D ENV_INCLUDE_GPS=1
|
||||
-D PIN_VBAT_READ=1
|
||||
-D PIN_ADC_CTRL=2
|
||||
-D PIN_BOARD_SDA=17
|
||||
-D PIN_BOARD_SCL=18
|
||||
-D PIN_RESET=47
|
||||
build_src_filter = ${esp32_base.build_src_filter}
|
||||
+<../variants/meshnology_w12>
|
||||
+<helpers/sensors>
|
||||
lib_deps =
|
||||
${esp32_base.lib_deps}
|
||||
${sensor_base.lib_deps}
|
||||
|
||||
[env:meshnology_w12_repeater]
|
||||
extends = meshnology_w12
|
||||
build_flags =
|
||||
${meshnology_w12.build_flags}
|
||||
-D DISPLAY_CLASS=SSD1306Display
|
||||
-D ADVERT_NAME='"Meshnology W12 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
|
||||
build_src_filter = ${meshnology_w12.build_src_filter}
|
||||
+<helpers/ui/SSD1306Display.cpp>
|
||||
+<../examples/simple_repeater>
|
||||
lib_deps =
|
||||
${meshnology_w12.lib_deps}
|
||||
${esp32_ota.lib_deps}
|
||||
bakercp/CRC32 @ ^2.0.0
|
||||
|
||||
[env:meshnology_w12_repeater_bridge_espnow]
|
||||
extends = meshnology_w12
|
||||
build_flags =
|
||||
${meshnology_w12.build_flags}
|
||||
-D DISPLAY_CLASS=SSD1306Display
|
||||
-D ADVERT_NAME='"ESPNow Bridge"'
|
||||
-D ADVERT_LAT=0.0
|
||||
-D ADVERT_LON=0.0
|
||||
-D ADMIN_PASSWORD='"password"'
|
||||
-D MAX_NEIGHBOURS=50
|
||||
-D WITH_ESPNOW_BRIDGE=1
|
||||
; -D BRIDGE_DEBUG=1
|
||||
; -D MESH_PACKET_LOGGING=1
|
||||
; -D MESH_DEBUG=1
|
||||
build_src_filter = ${meshnology_w12.build_src_filter}
|
||||
+<helpers/bridges/ESPNowBridge.cpp>
|
||||
+<helpers/ui/SSD1306Display.cpp>
|
||||
+<../examples/simple_repeater>
|
||||
lib_deps =
|
||||
${meshnology_w12.lib_deps}
|
||||
${esp32_ota.lib_deps}
|
||||
|
||||
[env:meshnology_w12_room_server]
|
||||
extends = meshnology_w12
|
||||
build_flags =
|
||||
${meshnology_w12.build_flags}
|
||||
-D DISPLAY_CLASS=SSD1306Display
|
||||
-D ADVERT_NAME='"Meshnology W12 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
|
||||
build_src_filter = ${meshnology_w12.build_src_filter}
|
||||
+<helpers/ui/SSD1306Display.cpp>
|
||||
+<../examples/simple_room_server>
|
||||
lib_deps =
|
||||
${meshnology_w12.lib_deps}
|
||||
${esp32_ota.lib_deps}
|
||||
|
||||
[env:meshnology_w12_terminal_chat]
|
||||
extends = meshnology_w12
|
||||
build_flags =
|
||||
${meshnology_w12.build_flags}
|
||||
-D MAX_CONTACTS=350
|
||||
-D MAX_GROUP_CHANNELS=1
|
||||
; -D MESH_PACKET_LOGGING=1
|
||||
; -D MESH_DEBUG=1
|
||||
build_src_filter = ${meshnology_w12.build_src_filter}
|
||||
+<../examples/simple_secure_chat/main.cpp>
|
||||
lib_deps =
|
||||
${meshnology_w12.lib_deps}
|
||||
densaugeo/base64 @ ~1.4.0
|
||||
|
||||
[env:meshnology_w12_companion_radio_usb]
|
||||
extends = meshnology_w12
|
||||
build_flags =
|
||||
${meshnology_w12.build_flags}
|
||||
-I examples/companion_radio/ui-new
|
||||
-D MAX_CONTACTS=350
|
||||
-D MAX_GROUP_CHANNELS=40
|
||||
-D DISPLAY_CLASS=SSD1306Display
|
||||
; NOTE: DO NOT ENABLE --> -D MESH_PACKET_LOGGING=1
|
||||
; NOTE: DO NOT ENABLE --> -D MESH_DEBUG=1
|
||||
build_src_filter = ${meshnology_w12.build_src_filter}
|
||||
+<helpers/ui/SSD1306Display.cpp>
|
||||
+<helpers/ui/MomentaryButton.cpp>
|
||||
+<../examples/companion_radio/*.cpp>
|
||||
+<../examples/companion_radio/ui-new/*.cpp>
|
||||
lib_deps =
|
||||
${meshnology_w12.lib_deps}
|
||||
densaugeo/base64 @ ~1.4.0
|
||||
|
||||
[env:meshnology_w12_companion_radio_ble]
|
||||
extends = meshnology_w12
|
||||
build_flags =
|
||||
${meshnology_w12.build_flags}
|
||||
-I examples/companion_radio/ui-new
|
||||
-D MAX_CONTACTS=350
|
||||
-D MAX_GROUP_CHANNELS=40
|
||||
-D DISPLAY_CLASS=SSD1306Display
|
||||
-D BLE_PIN_CODE=123456 ; dynamic, random PIN
|
||||
; -D AUTO_SHUTDOWN_MILLIVOLTS=3400 ; disabled by default, otherwise reading bounce causes shutdown when there's no battery connected.
|
||||
; -D BLE_DEBUG_LOGGING=1
|
||||
-D OFFLINE_QUEUE_SIZE=256
|
||||
; -D MESH_PACKET_LOGGING=1
|
||||
; -D MESH_DEBUG=1
|
||||
build_src_filter = ${meshnology_w12.build_src_filter}
|
||||
+<helpers/ui/SSD1306Display.cpp>
|
||||
+<helpers/ui/MomentaryButton.cpp>
|
||||
+<helpers/esp32/*.cpp>
|
||||
+<../examples/companion_radio/*.cpp>
|
||||
+<../examples/companion_radio/ui-new/*.cpp>
|
||||
lib_deps =
|
||||
${meshnology_w12.lib_deps}
|
||||
densaugeo/base64 @ ~1.4.0
|
||||
|
||||
[env:meshnology_w12_companion_radio_wifi]
|
||||
extends = meshnology_w12
|
||||
build_flags =
|
||||
${meshnology_w12.build_flags}
|
||||
-I examples/companion_radio/ui-new
|
||||
-D MAX_CONTACTS=350
|
||||
-D MAX_GROUP_CHANNELS=40
|
||||
-D OFFLINE_QUEUE_SIZE=256
|
||||
-D DISPLAY_CLASS=SSD1306Display
|
||||
; -D WIFI_DEBUG_LOGGING=1
|
||||
-D WIFI_SSID='"myssid"'
|
||||
-D WIFI_PWD='"mypwd"'
|
||||
; -D MESH_PACKET_LOGGING=1
|
||||
; -D MESH_DEBUG=1
|
||||
build_src_filter = ${meshnology_w12.build_src_filter}
|
||||
+<helpers/ui/SSD1306Display.cpp>
|
||||
+<helpers/ui/MomentaryButton.cpp>
|
||||
+<helpers/esp32/*.cpp>
|
||||
+<../examples/companion_radio/*.cpp>
|
||||
+<../examples/companion_radio/ui-new/*.cpp>
|
||||
lib_deps =
|
||||
${meshnology_w12.lib_deps}
|
||||
densaugeo/base64 @ ~1.4.0
|
||||
|
||||
[env:meshnology_w12_sensor]
|
||||
extends = meshnology_w12
|
||||
build_flags =
|
||||
${meshnology_w12.build_flags}
|
||||
-D ADVERT_NAME='"Meshnology W12 Sensor"'
|
||||
-D ADVERT_LAT=0.0
|
||||
-D ADVERT_LON=0.0
|
||||
-D ADMIN_PASSWORD='"password"'
|
||||
-D ENV_PIN_SDA=3
|
||||
-D ENV_PIN_SCL=4
|
||||
-D DISPLAY_CLASS=SSD1306Display
|
||||
; -D MESH_PACKET_LOGGING=1
|
||||
; -D MESH_DEBUG=1
|
||||
build_src_filter = ${meshnology_w12.build_src_filter}
|
||||
+<helpers/ui/SSD1306Display.cpp>
|
||||
+<../examples/simple_sensor>
|
||||
lib_deps =
|
||||
${meshnology_w12.lib_deps}
|
||||
${esp32_ota.lib_deps}
|
||||
|
||||
[env:meshnology_w12_kiss_modem]
|
||||
extends = meshnology_w12
|
||||
build_src_filter = ${meshnology_w12.build_src_filter}
|
||||
+<../examples/kiss_modem/>
|
||||
@@ -0,0 +1,73 @@
|
||||
#include <Arduino.h>
|
||||
#include "target.h"
|
||||
|
||||
MeshnologyW12Board board;
|
||||
|
||||
#if defined(P_LORA_SCLK)
|
||||
static SPIClass spi;
|
||||
RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY, spi);
|
||||
#else
|
||||
RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY);
|
||||
#endif
|
||||
|
||||
WRAPPER_CLASS radio_driver(radio, board);
|
||||
|
||||
ESP32RTCClock fallback_clock;
|
||||
AutoDiscoverRTCClock rtc_clock(fallback_clock);
|
||||
|
||||
#if ENV_INCLUDE_GPS
|
||||
#include <helpers/sensors/MicroNMEALocationProvider.h>
|
||||
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1, &rtc_clock);
|
||||
EnvironmentSensorManager sensors = EnvironmentSensorManager(nmea);
|
||||
#else
|
||||
EnvironmentSensorManager sensors;
|
||||
#endif
|
||||
|
||||
#ifdef DISPLAY_CLASS
|
||||
DISPLAY_CLASS display(NULL);
|
||||
MomentaryButton user_btn(PIN_USER_BTN, 1000, true);
|
||||
#endif
|
||||
|
||||
const uint32_t rfswitch_dios[] = {
|
||||
RADIOLIB_LR2021_DIO5, // RFX2402E 2.4G_TX_EN
|
||||
RADIOLIB_LR2021_DIO6, // RFX2402E 2.4G_RX_EN
|
||||
RADIOLIB_LR2021_DIO9, // GC1109 CTX (Transmit mode)
|
||||
RADIOLIB_LR2021_DIO10, // GC1109 CPS (Bypass mode)
|
||||
RADIOLIB_LR2021_DIO11, // GC1109 CSD (Shutdown)
|
||||
};
|
||||
|
||||
static const Module::RfSwitchMode_t rfswitch_table[] = {
|
||||
// DIO5 DIO6 DIO9 DIO10 DIO11
|
||||
{ LR2021::MODE_STBY, { LOW, LOW, LOW, LOW, LOW } }, // everything off
|
||||
{ LR2021::MODE_RX, { LOW, LOW, LOW, LOW, HIGH } }, // rx_lf: GC1109 LNA
|
||||
{ LR2021::MODE_TX, { LOW, LOW, HIGH, HIGH, HIGH } }, // tx_lf: GC1109 full PA
|
||||
{ LR2021::MODE_RX_HF, { LOW, HIGH, LOW, LOW, LOW } }, // rx_hf: 2G4 LNA, GC1109 off
|
||||
{ LR2021::MODE_TX_HF, { HIGH, LOW, LOW, LOW, LOW } }, // tx_hf: 2G4 PA, GC1109 off
|
||||
END_OF_MODE_TABLE,
|
||||
};
|
||||
|
||||
|
||||
bool radio_init() {
|
||||
fallback_clock.begin();
|
||||
rtc_clock.begin(Wire);
|
||||
|
||||
#if defined(P_LORA_SCLK)
|
||||
int err = radio.std_init(&spi);
|
||||
if (err != 1) return err;
|
||||
#else
|
||||
int err = radio.std_init();
|
||||
if (err != 1) return err;
|
||||
#endif
|
||||
|
||||
#ifdef RF_SWITCH_TABLE
|
||||
radio.setRfSwitchTable(rfswitch_dios, rfswitch_table);
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
mesh::LocalIdentity radio_new_identity() {
|
||||
RadioNoiseListener rng(radio);
|
||||
return mesh::LocalIdentity(&rng); // create new random identity
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
#pragma once
|
||||
|
||||
#define RADIOLIB_STATIC_ONLY 1
|
||||
#include <RadioLib.h>
|
||||
#include <helpers/radiolib/RadioLibWrappers.h>
|
||||
#include <MeshnologyW12Board.h>
|
||||
#include <helpers/radiolib/CustomLR2021Wrapper.h>
|
||||
#include <helpers/AutoDiscoverRTCClock.h>
|
||||
#include <helpers/SensorManager.h>
|
||||
#include <helpers/sensors/EnvironmentSensorManager.h>
|
||||
#ifdef DISPLAY_CLASS
|
||||
#include <helpers/ui/SSD1306Display.h>
|
||||
#include <helpers/ui/MomentaryButton.h>
|
||||
#endif
|
||||
|
||||
extern MeshnologyW12Board board;
|
||||
extern WRAPPER_CLASS radio_driver;
|
||||
extern AutoDiscoverRTCClock rtc_clock;
|
||||
extern EnvironmentSensorManager sensors;
|
||||
|
||||
#ifdef DISPLAY_CLASS
|
||||
extern DISPLAY_CLASS display;
|
||||
extern MomentaryButton user_btn;
|
||||
#endif
|
||||
|
||||
bool radio_init();
|
||||
mesh::LocalIdentity radio_new_identity();
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
#include <Arduino.h>
|
||||
#include <Wire.h>
|
||||
|
||||
#include "MeshTrackerX1Board.h"
|
||||
|
||||
void MeshTrackerX1Board::begin() {
|
||||
NRF52BoardDCDC::begin();
|
||||
btn_prev_state = LOW; // button is active HIGH
|
||||
|
||||
#ifdef BUTTON_PIN
|
||||
pinMode(BATTERY_PIN, INPUT);
|
||||
pinMode(BUTTON_PIN, INPUT_PULLDOWN);
|
||||
pinMode(LED_PIN, OUTPUT);
|
||||
#endif
|
||||
|
||||
#if defined(PIN_BOARD_SDA) && defined(PIN_BOARD_SCL)
|
||||
Wire.setPins(PIN_BOARD_SDA, PIN_BOARD_SCL);
|
||||
#endif
|
||||
|
||||
Wire.begin();
|
||||
|
||||
delay(10); // give lr2021 some time to power up
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
#pragma once
|
||||
|
||||
#include <MeshCore.h>
|
||||
#include <Arduino.h>
|
||||
#include <helpers/NRF52Board.h>
|
||||
|
||||
class MeshTrackerX1Board : public NRF52BoardDCDC {
|
||||
protected:
|
||||
uint8_t btn_prev_state;
|
||||
|
||||
public:
|
||||
MeshTrackerX1Board() : NRF52Board("X1_OTA") {}
|
||||
void begin();
|
||||
|
||||
uint16_t getBattMilliVolts() override {
|
||||
#ifdef BATTERY_PIN
|
||||
#ifdef PIN_BAT_ADC_EN
|
||||
digitalWrite(PIN_BAT_ADC_EN, HIGH);
|
||||
#endif
|
||||
analogReference(AR_INTERNAL_3_0);
|
||||
analogReadResolution(12);
|
||||
delay(10);
|
||||
float volts = (analogRead(BATTERY_PIN) * ADC_MULTIPLIER * AREF_VOLTAGE) / 4096;
|
||||
|
||||
analogReference(AR_DEFAULT); // put back to default
|
||||
analogReadResolution(10);
|
||||
|
||||
return volts * 1000;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
const char* getManufacturerName() const override {
|
||||
return "Seeed SenseCAP MeshTracker X1";
|
||||
}
|
||||
|
||||
int buttonStateChanged() {
|
||||
#ifdef BUTTON_PIN
|
||||
uint8_t v = digitalRead(BUTTON_PIN);
|
||||
if (v != btn_prev_state) {
|
||||
btn_prev_state = v;
|
||||
return (v == USER_BTN_PRESSED) ? 1 : -1;
|
||||
}
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
void powerOff() override {
|
||||
#ifdef HAS_GPS
|
||||
digitalWrite(GPS_VRTC_EN, LOW);
|
||||
digitalWrite(GPS_RESET, LOW);
|
||||
digitalWrite(GPS_SLEEP_INT, LOW);
|
||||
digitalWrite(GPS_RTC_INT, LOW);
|
||||
digitalWrite(GPS_EN, LOW);
|
||||
#endif
|
||||
|
||||
#ifdef PIN_DRV_EN
|
||||
digitalWrite(PIN_DRV_EN, LOW);
|
||||
#endif
|
||||
|
||||
#ifdef PIN_BAT_ADC_EN
|
||||
digitalWrite(PIN_BAT_ADC_EN, LOW);
|
||||
#endif
|
||||
|
||||
#ifdef PIN_3V3_EN
|
||||
digitalWrite(PIN_3V3_EN, LOW);
|
||||
#endif
|
||||
|
||||
// set led on and wait for button release before poweroff
|
||||
#ifdef LED_PIN
|
||||
digitalWrite(LED_PIN, HIGH);
|
||||
#endif
|
||||
#ifdef BUTTON_PIN
|
||||
while(digitalRead(BUTTON_PIN));
|
||||
#endif
|
||||
#ifdef LED_PIN
|
||||
digitalWrite(LED_PIN, LOW);
|
||||
#endif
|
||||
|
||||
#ifdef BUTTON_PIN
|
||||
nrf_gpio_cfg_sense_input(BUTTON_PIN, NRF_GPIO_PIN_PULLDOWN, NRF_GPIO_PIN_SENSE_HIGH);
|
||||
#endif
|
||||
|
||||
sd_power_system_off();
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,137 @@
|
||||
[MeshTracker_X1]
|
||||
extends = nrf52_base
|
||||
board = seeed-mesh-tracker-x1
|
||||
board_build.ldscript = boards/nrf52840_s140_v7.ld
|
||||
build_flags = ${nrf52_base.build_flags}
|
||||
-I src/helpers/nrf52
|
||||
-I lib/nrf52/s140_nrf52_7.3.0_API/include
|
||||
-I lib/nrf52/s140_nrf52_7.3.0_API/include/nrf52
|
||||
-I variants/meshtracker_x1
|
||||
-I src/helpers/ui
|
||||
-D MESH_TRACKER_X1
|
||||
-D PIN_USER_BTN=6
|
||||
-D USER_BTN_PRESSED=HIGH
|
||||
-D PIN_STATUS_LED=24
|
||||
-D PIN_STATUS_LED_R=3 ; P0.3 red
|
||||
-D PIN_STATUS_LED_G=24 ; P0.24 green
|
||||
-D PIN_STATUS_LED_B=28 ; P0.28 blue
|
||||
-D RADIO_CLASS=CustomLR2021
|
||||
-D USE_LR2021
|
||||
-D WRAPPER_CLASS=CustomLR2021Wrapper
|
||||
-D LORA_TX_POWER=22
|
||||
-D P_LORA_BUSY=7 ; P0.7
|
||||
-D P_LORA_SCLK=11 ; P0.11
|
||||
-D P_LORA_NSS=12 ; P0.12
|
||||
-D P_LORA_DIO_1=33 ; P1.1
|
||||
-D P_LORA_MISO=40 ; P1.8
|
||||
-D P_LORA_MOSI=41 ; P1.9
|
||||
-D P_LORA_RESET=42 ; P1.10
|
||||
-D LR2021_IRQ_DIO=8 ; P1.1 is connected to LR2021 DIO8
|
||||
-D LR2021_TCXO_VOLTAGE=1.6f
|
||||
-D ENV_INCLUDE_GPS=1
|
||||
build_src_filter = ${nrf52_base.build_src_filter}
|
||||
+<helpers/*.cpp>
|
||||
+<../variants/meshtracker_x1>
|
||||
lib_deps = ${nrf52_base.lib_deps}
|
||||
https://github.com/adafruit/Adafruit_SPA06_003/archive/refs/tags/1.0.2.zip
|
||||
debug_tool = jlink
|
||||
upload_protocol = nrfutil
|
||||
|
||||
[env:MeshTracker_X1_repeater]
|
||||
extends = MeshTracker_X1
|
||||
build_flags = ${MeshTracker_X1.build_flags}
|
||||
-I examples/companion_radio/ui-orig
|
||||
-D ADVERT_NAME='"MeshTracker X1 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
|
||||
build_src_filter = ${MeshTracker_X1.build_src_filter}
|
||||
+<../examples/simple_repeater>
|
||||
lib_deps = ${MeshTracker_X1.lib_deps}
|
||||
stevemarple/MicroNMEA @ ^2.0.6
|
||||
|
||||
[env:MeshTracker_X1_room_server]
|
||||
extends = MeshTracker_X1
|
||||
build_flags = ${MeshTracker_X1.build_flags}
|
||||
-I examples/companion_radio/ui-orig
|
||||
-D ADVERT_NAME='"MeshTracker X1 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
|
||||
build_src_filter = ${MeshTracker_X1.build_src_filter}
|
||||
+<../examples/simple_room_server>
|
||||
lib_deps = ${MeshTracker_X1.lib_deps}
|
||||
stevemarple/MicroNMEA @ ^2.0.6
|
||||
|
||||
[env:MeshTracker_X1_companion_radio_usb]
|
||||
extends = MeshTracker_X1
|
||||
board_build.ldscript = boards/nrf52840_s140_v7_extrafs.ld
|
||||
board_upload.maximum_size = 708608
|
||||
build_flags = ${MeshTracker_X1.build_flags}
|
||||
-I examples/companion_radio/ui-orig
|
||||
-D QSPIFLASH=1
|
||||
-D MAX_CONTACTS=350
|
||||
-D MAX_GROUP_CHANNELS=40
|
||||
; -D MESH_PACKET_LOGGING=1
|
||||
; -D MESH_DEBUG=1
|
||||
-D OFFLINE_QUEUE_SIZE=256
|
||||
-D DISPLAY_CLASS=NullDisplayDriver
|
||||
-D PIN_BUZZER=25
|
||||
-D HAS_DRV2605=1
|
||||
-D DRV2605_USE_LRA=1
|
||||
-D ENABLE_USB_INTERFACE
|
||||
build_src_filter = ${MeshTracker_X1.build_src_filter}
|
||||
+<helpers/ui/buzzer.cpp>
|
||||
+<helpers/ui/NullDisplayDriver.cpp>
|
||||
+<helpers/ui/DRV2605Vibration.cpp>
|
||||
+<../examples/companion_radio/*.cpp>
|
||||
+<../examples/companion_radio/ui-orig/*.cpp>
|
||||
lib_deps = ${MeshTracker_X1.lib_deps}
|
||||
densaugeo/base64 @ ~1.4.0
|
||||
stevemarple/MicroNMEA @ ^2.0.6
|
||||
end2endzone/NonBlockingRTTTL@^1.3.0
|
||||
adafruit/Adafruit DRV2605 Library @ ^1.2.4
|
||||
|
||||
[env:MeshTracker_X1_companion_radio_ble]
|
||||
extends = MeshTracker_X1
|
||||
board_build.ldscript = boards/nrf52840_s140_v7_extrafs.ld
|
||||
board_upload.maximum_size = 708608
|
||||
build_flags = ${MeshTracker_X1.build_flags}
|
||||
-I examples/companion_radio/ui-orig
|
||||
-D QSPIFLASH=1
|
||||
-D MAX_CONTACTS=350
|
||||
-D MAX_GROUP_CHANNELS=40
|
||||
-D BLE_PIN_CODE=123456
|
||||
-D BLE_TX_POWER=0
|
||||
; -D BLE_DEBUG_LOGGING=1
|
||||
; -D MESH_PACKET_LOGGING=1
|
||||
; -D MESH_DEBUG=1
|
||||
-D OFFLINE_QUEUE_SIZE=256
|
||||
-D DISPLAY_CLASS=NullDisplayDriver
|
||||
-D PIN_BUZZER=25
|
||||
-D HAS_DRV2605=1
|
||||
-D DRV2605_USE_LRA=1
|
||||
-D ADVERT_NAME='"@@MAC"'
|
||||
build_src_filter = ${MeshTracker_X1.build_src_filter}
|
||||
+<helpers/nrf52/SerialBLEInterface.cpp>
|
||||
+<helpers/ui/buzzer.cpp>
|
||||
+<helpers/ui/NullDisplayDriver.cpp>
|
||||
+<helpers/ui/DRV2605Vibration.cpp>
|
||||
+<../examples/companion_radio/*.cpp>
|
||||
+<../examples/companion_radio/ui-orig/*.cpp>
|
||||
lib_deps = ${MeshTracker_X1.lib_deps}
|
||||
densaugeo/base64 @ ~1.4.0
|
||||
stevemarple/MicroNMEA @ ^2.0.6
|
||||
end2endzone/NonBlockingRTTTL@^1.3.0
|
||||
adafruit/Adafruit DRV2605 Library @ ^1.2.4
|
||||
|
||||
[env:MeshTracker_X1_kiss_modem]
|
||||
extends = MeshTracker_X1
|
||||
build_src_filter = ${MeshTracker_X1.build_src_filter}
|
||||
+<../examples/kiss_modem/>
|
||||
@@ -0,0 +1,132 @@
|
||||
#include <Arduino.h>
|
||||
#include "target.h"
|
||||
#include <helpers/sensors/MicroNMEALocationProvider.h>
|
||||
|
||||
MeshTrackerX1Board 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 rtc_clock;
|
||||
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1, &rtc_clock);
|
||||
MeshTrackerX1SensorManager sensors = MeshTrackerX1SensorManager(nmea);
|
||||
|
||||
#ifdef DISPLAY_CLASS
|
||||
NullDisplayDriver display;
|
||||
#endif
|
||||
|
||||
bool radio_init() {
|
||||
return radio.std_init(&SPI);
|
||||
}
|
||||
|
||||
mesh::LocalIdentity radio_new_identity() {
|
||||
RadioNoiseListener rng(radio);
|
||||
return mesh::LocalIdentity(&rng); // create new random identity
|
||||
}
|
||||
|
||||
void MeshTrackerX1SensorManager::start_gps() {
|
||||
gps_active = true;
|
||||
// this init sequence comes from seeed examples and deals with all gps pins
|
||||
pinMode(GPS_EN, OUTPUT);
|
||||
digitalWrite(GPS_EN, HIGH);
|
||||
delay(10);
|
||||
pinMode(GPS_VRTC_EN, OUTPUT);
|
||||
digitalWrite(GPS_VRTC_EN, HIGH);
|
||||
delay(10);
|
||||
|
||||
pinMode(GPS_RESET, OUTPUT);
|
||||
digitalWrite(GPS_RESET, HIGH);
|
||||
delay(10);
|
||||
digitalWrite(GPS_RESET, LOW);
|
||||
|
||||
pinMode(GPS_SLEEP_INT, OUTPUT);
|
||||
digitalWrite(GPS_SLEEP_INT, HIGH);
|
||||
pinMode(GPS_RTC_INT, OUTPUT);
|
||||
digitalWrite(GPS_RTC_INT, LOW);
|
||||
}
|
||||
|
||||
void MeshTrackerX1SensorManager::sleep_gps() {
|
||||
gps_active = false;
|
||||
digitalWrite(GPS_VRTC_EN, HIGH); // keep RTC alive for faster fix on wake
|
||||
digitalWrite(GPS_EN, LOW);
|
||||
digitalWrite(GPS_RESET, LOW);
|
||||
digitalWrite(GPS_SLEEP_INT, HIGH);
|
||||
digitalWrite(GPS_RTC_INT, LOW);
|
||||
}
|
||||
|
||||
void MeshTrackerX1SensorManager::stop_gps() {
|
||||
gps_active = false;
|
||||
digitalWrite(GPS_VRTC_EN, LOW);
|
||||
digitalWrite(GPS_EN, LOW);
|
||||
digitalWrite(GPS_RESET, LOW);
|
||||
digitalWrite(GPS_SLEEP_INT, HIGH);
|
||||
digitalWrite(GPS_RTC_INT, LOW);
|
||||
}
|
||||
|
||||
bool MeshTrackerX1SensorManager::begin() {
|
||||
// init GPS
|
||||
Serial1.begin(GPS_BAUD_RATE);
|
||||
|
||||
// init SPA06-003 barometer
|
||||
baro_ok = spa06.begin(SPA06_003_DEFAULT_ADDR, &Wire) || spa06.begin(0x76, &Wire);
|
||||
if (baro_ok) {
|
||||
spa06.setPressureOversampling(SPA06_003_OVERSAMPLE_8);
|
||||
spa06.setTemperatureOversampling(SPA06_003_OVERSAMPLE_8);
|
||||
// 1 Hz continuous keeps reads non-blocking at minimal power cost
|
||||
spa06.setPressureMeasureRate(SPA06_003_RATE_1);
|
||||
spa06.setTemperatureMeasureRate(SPA06_003_RATE_1);
|
||||
spa06.setMeasurementMode(SPA06_003_MEAS_CONTINUOUS_BOTH);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool MeshTrackerX1SensorManager::querySensors(uint8_t requester_permissions, CayenneLPP& telemetry) {
|
||||
if (requester_permissions & TELEM_PERM_LOCATION) { // does requester have permission?
|
||||
telemetry.addGPS(TELEM_CHANNEL_SELF, node_lat, node_lon, node_altitude);
|
||||
}
|
||||
if (requester_permissions & TELEM_PERM_ENVIRONMENT && baro_ok) {
|
||||
telemetry.addTemperature(TELEM_CHANNEL_SELF, spa06.readTemperature());
|
||||
telemetry.addBarometricPressure(TELEM_CHANNEL_SELF, spa06.readPressure());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void MeshTrackerX1SensorManager::loop() {
|
||||
static long next_gps_update = 0;
|
||||
|
||||
|
||||
_nmea->loop();
|
||||
|
||||
if (millis() > next_gps_update) {
|
||||
if (gps_active && _nmea->isValid()) {
|
||||
node_lat = ((double)_nmea->getLatitude())/1000000.;
|
||||
node_lon = ((double)_nmea->getLongitude())/1000000.;
|
||||
node_altitude = ((double)_nmea->getAltitude()) / 1000.0;
|
||||
}
|
||||
next_gps_update = millis() + 1000;
|
||||
}
|
||||
}
|
||||
|
||||
int MeshTrackerX1SensorManager::getNumSettings() const { return 1; } // just one supported: "gps" (power switch)
|
||||
|
||||
const char* MeshTrackerX1SensorManager::getSettingName(int i) const {
|
||||
return i == 0 ? "gps" : NULL;
|
||||
}
|
||||
const char* MeshTrackerX1SensorManager::getSettingValue(int i) const {
|
||||
if (i == 0) {
|
||||
return gps_active ? "1" : "0";
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
bool MeshTrackerX1SensorManager::setSettingValue(const char* name, const char* value) {
|
||||
if (strcmp(name, "gps") == 0) {
|
||||
if (strcmp(value, "0") == 0) {
|
||||
sleep_gps(); // sleep for faster fix !
|
||||
} else {
|
||||
start_gps();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false; // not supported
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
#pragma once
|
||||
|
||||
#define RADIOLIB_STATIC_ONLY 1
|
||||
#include <RadioLib.h>
|
||||
#include <helpers/radiolib/RadioLibWrappers.h>
|
||||
#include "MeshTrackerX1Board.h"
|
||||
#include <helpers/radiolib/CustomLR2021Wrapper.h>
|
||||
#include <helpers/ArduinoHelpers.h>
|
||||
#include <helpers/SensorManager.h>
|
||||
#include <helpers/sensors/LocationProvider.h>
|
||||
#include <Adafruit_SPA06_003.h>
|
||||
#ifdef DISPLAY_CLASS
|
||||
#include "NullDisplayDriver.h"
|
||||
#endif
|
||||
|
||||
class MeshTrackerX1SensorManager: public SensorManager {
|
||||
bool gps_active = false;
|
||||
bool baro_ok = false;
|
||||
Adafruit_SPA06_003 spa06;
|
||||
LocationProvider * _nmea;
|
||||
|
||||
void start_gps();
|
||||
void sleep_gps();
|
||||
void stop_gps();
|
||||
public:
|
||||
MeshTrackerX1SensorManager(LocationProvider &nmea): _nmea(&nmea) { }
|
||||
bool begin() override;
|
||||
bool querySensors(uint8_t requester_permissions, CayenneLPP& telemetry) override;
|
||||
void loop() override;
|
||||
int getNumSettings() const override;
|
||||
const char* getSettingName(int i) const override;
|
||||
const char* getSettingValue(int i) const override;
|
||||
bool setSettingValue(const char* name, const char* value) override;
|
||||
LocationProvider* getLocationProvider() { return _nmea; }
|
||||
};
|
||||
|
||||
#ifdef DISPLAY_CLASS
|
||||
extern NullDisplayDriver display;
|
||||
#endif
|
||||
|
||||
extern MeshTrackerX1Board board;
|
||||
extern WRAPPER_CLASS radio_driver;
|
||||
extern VolatileRTCClock rtc_clock;
|
||||
extern MeshTrackerX1SensorManager sensors;
|
||||
|
||||
bool radio_init();
|
||||
mesh::LocalIdentity radio_new_identity();
|
||||
@@ -0,0 +1,109 @@
|
||||
/*
|
||||
* variant.cpp - Seeed SenseCAP MeshTracker X1 (nRF52840 + Semtech LR2021)
|
||||
*/
|
||||
|
||||
#include "variant.h"
|
||||
#include "wiring_constants.h"
|
||||
#include "wiring_digital.h"
|
||||
|
||||
const uint32_t g_ADigitalPinMap[PINS_COUNT + 1] =
|
||||
{
|
||||
0, // P0.00
|
||||
1, // P0.01
|
||||
2, // P0.02, AIN0 BATTERY_PIN
|
||||
3, // P0.03, LED_RED
|
||||
4, // P0.04, AIN2 VCC_ADC
|
||||
5, // P0.05, AIN3 EXT_PWR_DETECT
|
||||
6, // P0.06, PIN_BUTTON1
|
||||
7, // P0.07, LORA_BUSY
|
||||
8, // P0.08, GPS_RESET
|
||||
9, // P0.09, PIN_RTC_EN
|
||||
10, // P0.10
|
||||
11, // P0.11, PIN_SPI_SCK
|
||||
12, // P0.12, PIN_SPI_NSS
|
||||
13, // P0.13, PIN_SERIAL1_TX
|
||||
14, // P0.14, PIN_SERIAL1_RX
|
||||
15, // P0.15
|
||||
16, // P0.16, PIN_SERIAL2_TX
|
||||
17, // P0.17, PIN_SERIAL2_RX
|
||||
18, // P0.18
|
||||
19, // P0.19
|
||||
20, // P0.20
|
||||
21, // P0.21
|
||||
22, // P0.22
|
||||
23, // P0.23
|
||||
24, // P0.24, LED_GREEN
|
||||
25, // P0.25, BUZZER_PIN
|
||||
26, // P0.26
|
||||
27, // P0.27
|
||||
28, // P0.28, LED_BLUE
|
||||
29, // P0.29, GPS_RTC_INT
|
||||
30, // P0.30, GPS_SLEEP_INT
|
||||
31, // P0.31
|
||||
32, // P1.00
|
||||
33, // P1.01, LORA_DIO_1 (LR2021 DIO8 IRQ)
|
||||
34, // P1.02
|
||||
35, // P1.03, EXT_CHRG_DETECT
|
||||
36, // P1.04, CHARGE_DONE
|
||||
37, // P1.05, PIN_DRV_EN
|
||||
38, // P1.06, PIN_BAT_ADC_EN
|
||||
39, // P1.07, PIN_3V3_EN
|
||||
40, // P1.08, PIN_SPI_MISO
|
||||
41, // P1.09, PIN_SPI_MOSI
|
||||
42, // P1.10, LORA_RESET
|
||||
43, // P1.11, GPS_EN
|
||||
44, // P1.12
|
||||
45, // P1.13, GPS_VRTC_EN
|
||||
46, // P1.14, PIN_WIRE_SCL
|
||||
47, // P1.15, PIN_WIRE_SDA
|
||||
255, // NRFX_SPIM_PIN_NOT_USED
|
||||
};
|
||||
|
||||
void initVariant()
|
||||
{
|
||||
pinMode(BATTERY_PIN, INPUT);
|
||||
pinMode(EXT_CHRG_DETECT, INPUT_PULLUP);
|
||||
pinMode(EXT_PWR_DETECT, INPUT);
|
||||
pinMode(PIN_BUTTON1, INPUT_PULLDOWN);
|
||||
|
||||
pinMode(PIN_3V3_EN, OUTPUT);
|
||||
digitalWrite(PIN_3V3_EN, HIGH);
|
||||
|
||||
pinMode(PIN_FLASH_EN, OUTPUT);
|
||||
digitalWrite(PIN_FLASH_EN, HIGH);
|
||||
|
||||
pinMode(PIN_BAT_ADC_EN, OUTPUT);
|
||||
digitalWrite(PIN_BAT_ADC_EN, HIGH);
|
||||
|
||||
pinMode(PIN_RTC_EN, OUTPUT);
|
||||
digitalWrite(PIN_RTC_EN, LOW);
|
||||
|
||||
pinMode(PIN_DRV_EN, OUTPUT);
|
||||
digitalWrite(PIN_DRV_EN, LOW);
|
||||
|
||||
pinMode(LED_RED, OUTPUT);
|
||||
digitalWrite(LED_RED, LOW);
|
||||
|
||||
pinMode(LED_GREEN, OUTPUT);
|
||||
digitalWrite(LED_GREEN, LOW);
|
||||
|
||||
pinMode(LED_BLUE, OUTPUT);
|
||||
digitalWrite(LED_BLUE, LOW);
|
||||
|
||||
pinMode(GPS_EN, OUTPUT);
|
||||
digitalWrite(GPS_EN, LOW);
|
||||
|
||||
pinMode(GPS_VRTC_EN, OUTPUT);
|
||||
digitalWrite(GPS_VRTC_EN, HIGH);
|
||||
|
||||
pinMode(GPS_RESET, OUTPUT);
|
||||
digitalWrite(GPS_RESET, LOW);
|
||||
|
||||
pinMode(GPS_SLEEP_INT, OUTPUT);
|
||||
digitalWrite(GPS_SLEEP_INT, HIGH);
|
||||
|
||||
pinMode(GPS_RTC_INT, OUTPUT);
|
||||
digitalWrite(GPS_RTC_INT, LOW);
|
||||
|
||||
pinMode(BUZZER_PIN, INPUT_PULLDOWN);
|
||||
}
|
||||
@@ -0,0 +1,139 @@
|
||||
/*
|
||||
* variant.h - Seeed SenseCAP MeshTracker X1 (nRF52840 + Semtech LR2021)
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "WVariant.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Low frequency clock source
|
||||
|
||||
#define USE_LFXO // 32.768 kHz crystal oscillator
|
||||
#define VARIANT_MCK (64000000ul)
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Power
|
||||
|
||||
#define NRF_APM // detect usb power
|
||||
#define PIN_3V3_EN (39) // P1.7 Power to sensors
|
||||
#define PIN_BAT_ADC_EN (38) // P1.6 Power to battery ADC divider
|
||||
#define PIN_RTC_EN (9) // P0.9 Power to RTC
|
||||
|
||||
#define BATTERY_PIN (2) // P0.2/AIN0
|
||||
#define BATTERY_IMMUTABLE
|
||||
#define ADC_MULTIPLIER (2.0F)
|
||||
|
||||
#define EXT_CHRG_DETECT (35) // P1.3, LOW while charging
|
||||
// P1.4 is the charger's second status line, but it reads LOW regardless of
|
||||
// charge state on this board, so it is not used (Meshtastic leaves it out too)
|
||||
#define EXT_PWR_DETECT (5) // P0.5
|
||||
|
||||
#define ADC_RESOLUTION (14)
|
||||
#define BATTERY_SENSE_RES (12)
|
||||
|
||||
#define AREF_VOLTAGE (3.0)
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Number of pins
|
||||
|
||||
#define PINS_COUNT (48)
|
||||
#define NUM_DIGITAL_PINS (48)
|
||||
#define NUM_ANALOG_INPUTS (6)
|
||||
#define NUM_ANALOG_OUTPUTS (0)
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// UART pin definition
|
||||
|
||||
#define PIN_SERIAL1_RX (14) // P0.14 (GPS)
|
||||
#define PIN_SERIAL1_TX (13) // P0.13 (GPS)
|
||||
|
||||
#define PIN_SERIAL2_RX (17) // P0.17
|
||||
#define PIN_SERIAL2_TX (16) // P0.16
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// I2C pin definition
|
||||
|
||||
#define HAS_WIRE (1)
|
||||
#define WIRE_INTERFACES_COUNT (1)
|
||||
|
||||
#define PIN_WIRE_SDA (47) // P1.15
|
||||
#define PIN_WIRE_SCL (46) // P1.14
|
||||
#define I2C_NO_RESCAN
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// SPI pin definition
|
||||
|
||||
#define SPI_INTERFACES_COUNT (1)
|
||||
|
||||
#define PIN_SPI_MISO (40) // P1.8
|
||||
#define PIN_SPI_MOSI (41) // P1.9
|
||||
#define PIN_SPI_SCK (11) // P0.11
|
||||
#define PIN_SPI_NSS (12) // P0.12
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Builtin LEDs (RGB)
|
||||
|
||||
#define LED_BUILTIN (-1)
|
||||
#define LED_RED (3) // P0.3
|
||||
#define LED_GREEN (24) // P0.24
|
||||
#define LED_BLUE (28) // P0.28
|
||||
#define LED_PIN LED_GREEN
|
||||
|
||||
#define LED_STATE_ON HIGH
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Builtin buttons
|
||||
|
||||
#define PIN_BUTTON1 (6) // P0.6, active HIGH (internal pull-down)
|
||||
#define BUTTON_PIN PIN_BUTTON1
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// LR2021
|
||||
|
||||
#define LORA_DIO_1 (33) // P1.1, IRQ line (LR2021 DIO8)
|
||||
#define LORA_NSS (PIN_SPI_NSS) // P0.12
|
||||
#define LORA_RESET (42) // P1.10
|
||||
#define LORA_BUSY (7) // P0.7
|
||||
#define LORA_SCLK (PIN_SPI_SCK) // P0.11
|
||||
#define LORA_MISO (PIN_SPI_MISO) // P1.8
|
||||
#define LORA_MOSI (PIN_SPI_MOSI) // P1.9
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// GPS (Airoha, dual-band L1+L5)
|
||||
|
||||
#define HAS_GPS 1
|
||||
#define GPS_RX_PIN PIN_SERIAL1_RX
|
||||
#define GPS_TX_PIN PIN_SERIAL1_TX
|
||||
#define GPS_BAUD_RATE (115200)
|
||||
|
||||
#define GPS_EN (43) // P1.11, active HIGH
|
||||
#define GPS_RESET (8) // P0.8, active HIGH
|
||||
|
||||
#define GPS_VRTC_EN (45) // P1.13
|
||||
#define GPS_SLEEP_INT (30) // P0.30
|
||||
#define GPS_RTC_INT (29) // P0.29
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Haptic driver (DRV2605 on I2C)
|
||||
|
||||
#define PIN_DRV_EN (37) // P1.5, power to haptic driver
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Buzzer
|
||||
|
||||
#define BUZZER_PIN (25) // P0.25, pwm output
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// QSPI Flash
|
||||
|
||||
#define PIN_FLASH_EN (15) // P0.15 (Flash power enable)
|
||||
|
||||
#define PIN_QSPI_SCK (19) // P0.19
|
||||
#define PIN_QSPI_CS (20) // P0.20
|
||||
#define PIN_QSPI_IO0 (21) // P0.21
|
||||
#define PIN_QSPI_IO1 (22) // P0.22
|
||||
#define PIN_QSPI_IO2 (23) // P0.23
|
||||
#define PIN_QSPI_IO3 (32) // P1.00
|
||||
|
||||
#define EXTERNAL_FLASH_DEVICES GD25Q64C
|
||||
@@ -33,7 +33,7 @@ lib_deps=${esp32_base.lib_deps}
|
||||
lovyan03/LovyanGFX @ ^1.2.7
|
||||
|
||||
[env:SenseCapIndicator-ESPNow_comp_radio_usb]
|
||||
extends =SenseCapIndicator-ESPNow
|
||||
extends = SenseCapIndicator-ESPNow
|
||||
build_flags =
|
||||
${SenseCapIndicator-ESPNow.build_flags}
|
||||
-I examples/companion_radio/ui-new
|
||||
@@ -47,4 +47,4 @@ build_src_filter = ${SenseCapIndicator-ESPNow.build_src_filter}
|
||||
+<../examples/companion_radio/*.cpp>
|
||||
lib_deps =
|
||||
${SenseCapIndicator-ESPNow.lib_deps}
|
||||
densaugeo/base64 @ ~1.4.0
|
||||
densaugeo/base64 @ ~1.4.0
|
||||
@@ -101,3 +101,8 @@ build_src_filter = ${SenseCap_Solar.build_src_filter}
|
||||
lib_deps =
|
||||
${SenseCap_Solar.lib_deps}
|
||||
densaugeo/base64 @ ~1.4.0
|
||||
|
||||
[env:SenseCap_Solar_kiss_modem]
|
||||
extends = SenseCap_Solar
|
||||
build_src_filter = ${SenseCap_Solar.build_src_filter}
|
||||
+<../examples/kiss_modem/>
|
||||
@@ -277,7 +277,7 @@ build_flags =
|
||||
-D WIFI_DEBUG_LOGGING=1
|
||||
-D WIFI_SSID='"myssid"'
|
||||
-D WIFI_PWD='"mypwd"'
|
||||
-D OFFLINE_QUEUE_SIZE=256
|
||||
-D OFFLINE_QUEUE_SIZE=256
|
||||
; -D MESH_PACKET_LOGGING=1
|
||||
; -D MESH_DEBUG=1
|
||||
build_src_filter = ${Station_G2.build_src_filter}
|
||||
@@ -290,11 +290,9 @@ lib_deps =
|
||||
|
||||
[env:Station_G2_kiss_modem]
|
||||
extends = Station_G2
|
||||
build_unflags =
|
||||
-DARDUINO_USB_MODE=0
|
||||
build_flags =
|
||||
${Station_G2.build_flags}
|
||||
-DARDUINO_USB_MODE=1
|
||||
-D ARDUINO_USB_MODE=1
|
||||
build_src_filter = ${Station_G2.build_src_filter}
|
||||
+<../examples/kiss_modem/>
|
||||
|
||||
|
||||
@@ -85,7 +85,6 @@ build_flags =
|
||||
-D BLE_DEBUG_LOGGING=1
|
||||
-D OFFLINE_QUEUE_SIZE=256
|
||||
-D AUTO_SHUTDOWN_MILLIVOLTS=3300
|
||||
-D QSPIFLASH=1
|
||||
; -D MESH_PACKET_LOGGING=1
|
||||
; -D MESH_DEBUG=1
|
||||
build_src_filter = ${ThinkNode_M6.build_src_filter}
|
||||
@@ -107,7 +106,6 @@ build_flags =
|
||||
-I examples/companion_radio/ui-new
|
||||
-D MAX_CONTACTS=350
|
||||
-D MAX_GROUP_CHANNELS=40
|
||||
-D QSPIFLASH=1
|
||||
-D OFFLINE_QUEUE_SIZE=256
|
||||
-D AUTO_SHUTDOWN_MILLIVOLTS=3300
|
||||
-D ENABLE_USB_INTERFACE
|
||||
|
||||
@@ -30,6 +30,8 @@ void initVariant() {
|
||||
digitalWrite(PIN_GPS_STANDBY, HIGH);
|
||||
pinMode(PIN_GPS_EN, OUTPUT);
|
||||
digitalWrite(PIN_GPS_EN, HIGH);
|
||||
pinMode(PIN_GPS_RESET, OUTPUT);
|
||||
digitalWrite(PIN_GPS_RESET, HIGH);
|
||||
// PIN_GPS_RESET (pin 29 / REINIT) is intentionally left floating (input).
|
||||
// Driving it HIGH holds the L76K silent, so it never streams NMEA and the
|
||||
// firmware reports "no GPS". Letting it float lets the module run, matching
|
||||
// the Meshtastic M6 variant. See GPS_RESET (-1) in variant.h.
|
||||
}
|
||||
@@ -102,7 +102,12 @@
|
||||
#define PIN_GPS_RX (2)
|
||||
#define PIN_GPS_TX (3)
|
||||
#define PIN_GPS_EN (6) // EN
|
||||
#define PIN_GPS_RESET (29)
|
||||
#define PIN_GPS_RESET (29) // REINIT - must FLOAT; driving it (esp. HIGH) silences the L76K
|
||||
// The M6's L76K streams NMEA on its own and must not have its REINIT pin driven.
|
||||
// Tell the location provider there is no reset pin so it never touches pin 29
|
||||
// (driving it HIGH holds the module silent). Matches Meshtastic, which leaves
|
||||
// this pin as an input. See variant.cpp (pin 29 is intentionally not configured).
|
||||
#define GPS_RESET (-1)
|
||||
#define PIN_GPS_STANDBY (30) // STANDBY
|
||||
#define PIN_GPS_PPS (31)
|
||||
#define GPS_BAUD_RATE 9600
|
||||
Reference in new issue
Block a user