Revert "Merge remote-tracking branch 'origin/dev' into mqtt-bridge-implementation"
This reverts commit2b63765522, reversing changes made to304719e8e0.
This commit is contained in:
1 parent
2b63765522
commit
22eb9b87a3
66 files changed
+119
-860
No files matched your search
@@ -2,7 +2,6 @@
|
|||||||
"name": "MeshCore",
|
"name": "MeshCore",
|
||||||
"image": "mcr.microsoft.com/devcontainers/python:3-bookworm",
|
"image": "mcr.microsoft.com/devcontainers/python:3-bookworm",
|
||||||
"features": {
|
"features": {
|
||||||
"ghcr.io/devcontainers-extra/features/bun:1": {},
|
|
||||||
"ghcr.io/rocker-org/devcontainer-features/apt-packages:1": {
|
"ghcr.io/rocker-org/devcontainer-features/apt-packages:1": {
|
||||||
"packages": [
|
"packages": [
|
||||||
"sudo"
|
"sudo"
|
||||||
@@ -12,15 +11,14 @@
|
|||||||
"runArgs": [
|
"runArgs": [
|
||||||
"--privileged",
|
"--privileged",
|
||||||
"--network=host",
|
"--network=host",
|
||||||
"--device=/dev/bus/usb",
|
"--volume=/dev/bus/usb:/dev/bus/usb:ro",
|
||||||
// arch linux tty* is owned by uucp (986)
|
// arch tty* is owned by uucp (986)
|
||||||
"--group-add=986",
|
|
||||||
// debian tty* is owned by dialout (20)
|
// debian tty* is owned by dialout (20)
|
||||||
"--group-add=20"
|
"--group-add=20",
|
||||||
|
"--group-add=986"
|
||||||
],
|
],
|
||||||
"postCreateCommand": {
|
"postCreateCommand": {
|
||||||
"platformio": "pipx install platformio",
|
"platformio": "pipx install platformio"
|
||||||
"opencode": "curl -fsSL https://opencode.ai/install | bash"
|
|
||||||
},
|
},
|
||||||
"customizations": {
|
"customizations": {
|
||||||
"vscode": {
|
"vscode": {
|
||||||
|
|||||||
@@ -39,7 +39,7 @@
|
|||||||
"frameworks": ["arduino"],
|
"frameworks": ["arduino"],
|
||||||
"name": "Heltec nrf (Adafruit BSP)",
|
"name": "Heltec nrf (Adafruit BSP)",
|
||||||
"upload": {
|
"upload": {
|
||||||
"maximum_ram_size": 235520,
|
"maximum_ram_size": 248832,
|
||||||
"maximum_size": 815104,
|
"maximum_size": 815104,
|
||||||
"speed": 115200,
|
"speed": 115200,
|
||||||
"protocol": "nrfutil",
|
"protocol": "nrfutil",
|
||||||
|
|||||||
@@ -42,7 +42,7 @@
|
|||||||
],
|
],
|
||||||
"name": "Heltec Mesh Solar Board",
|
"name": "Heltec Mesh Solar Board",
|
||||||
"upload": {
|
"upload": {
|
||||||
"maximum_ram_size": 235520,
|
"maximum_ram_size": 248832,
|
||||||
"maximum_size": 815104,
|
"maximum_size": 815104,
|
||||||
"speed": 115200,
|
"speed": 115200,
|
||||||
"protocol": "nrfutil",
|
"protocol": "nrfutil",
|
||||||
|
|||||||
@@ -42,7 +42,7 @@
|
|||||||
],
|
],
|
||||||
"name": "Heltec T114 Board",
|
"name": "Heltec T114 Board",
|
||||||
"upload": {
|
"upload": {
|
||||||
"maximum_ram_size": 235520,
|
"maximum_ram_size": 248832,
|
||||||
"maximum_size": 815104,
|
"maximum_size": 815104,
|
||||||
"speed": 115200,
|
"speed": 115200,
|
||||||
"protocol": "nrfutil",
|
"protocol": "nrfutil",
|
||||||
|
|||||||
@@ -60,7 +60,7 @@
|
|||||||
],
|
],
|
||||||
"name": "Keepteen LT1",
|
"name": "Keepteen LT1",
|
||||||
"upload": {
|
"upload": {
|
||||||
"maximum_ram_size": 235520,
|
"maximum_ram_size": 248832,
|
||||||
"maximum_size": 815104,
|
"maximum_size": 815104,
|
||||||
"speed": 115200,
|
"speed": 115200,
|
||||||
"protocol": "nrfutil",
|
"protocol": "nrfutil",
|
||||||
|
|||||||
@@ -55,7 +55,7 @@
|
|||||||
],
|
],
|
||||||
"name": "Meshtiny",
|
"name": "Meshtiny",
|
||||||
"upload": {
|
"upload": {
|
||||||
"maximum_ram_size": 235520,
|
"maximum_ram_size": 248832,
|
||||||
"maximum_size": 815104,
|
"maximum_size": 815104,
|
||||||
"speed": 115200,
|
"speed": 115200,
|
||||||
"protocol": "nrfutil",
|
"protocol": "nrfutil",
|
||||||
|
|||||||
@@ -38,8 +38,8 @@
|
|||||||
"frameworks": ["arduino"],
|
"frameworks": ["arduino"],
|
||||||
"name": "Minewsemi ME25LS01",
|
"name": "Minewsemi ME25LS01",
|
||||||
"upload": {
|
"upload": {
|
||||||
"maximum_ram_size": 235520,
|
"maximum_ram_size": 248832,
|
||||||
"maximum_size": 811008,
|
"maximum_size": 815104,
|
||||||
"speed": 115200,
|
"speed": 115200,
|
||||||
"protocol": "nrfutil",
|
"protocol": "nrfutil",
|
||||||
"protocols": [
|
"protocols": [
|
||||||
|
|||||||
@@ -54,7 +54,7 @@
|
|||||||
],
|
],
|
||||||
"name": "BQ nRF52840",
|
"name": "BQ nRF52840",
|
||||||
"upload": {
|
"upload": {
|
||||||
"maximum_ram_size": 235520,
|
"maximum_ram_size": 248832,
|
||||||
"maximum_size": 815104,
|
"maximum_size": 815104,
|
||||||
"speed": 115200,
|
"speed": 115200,
|
||||||
"protocol": "nrfutil",
|
"protocol": "nrfutil",
|
||||||
|
|||||||
@@ -60,7 +60,7 @@
|
|||||||
],
|
],
|
||||||
"name": "ProMicro NRF52840",
|
"name": "ProMicro NRF52840",
|
||||||
"upload": {
|
"upload": {
|
||||||
"maximum_ram_size": 235520,
|
"maximum_ram_size": 248832,
|
||||||
"maximum_size": 815104,
|
"maximum_size": 815104,
|
||||||
"speed": 115200,
|
"speed": 115200,
|
||||||
"protocol": "nrfutil",
|
"protocol": "nrfutil",
|
||||||
|
|||||||
+1
-1
@@ -53,7 +53,7 @@
|
|||||||
],
|
],
|
||||||
"name": "WisCore RAK3401 Board",
|
"name": "WisCore RAK3401 Board",
|
||||||
"upload": {
|
"upload": {
|
||||||
"maximum_ram_size": 235520,
|
"maximum_ram_size": 248832,
|
||||||
"maximum_size": 815104,
|
"maximum_size": 815104,
|
||||||
"speed": 115200,
|
"speed": 115200,
|
||||||
"protocol": "nrfutil",
|
"protocol": "nrfutil",
|
||||||
|
|||||||
+1
-1
@@ -53,7 +53,7 @@
|
|||||||
],
|
],
|
||||||
"name": "WisCore RAK4631 Board",
|
"name": "WisCore RAK4631 Board",
|
||||||
"upload": {
|
"upload": {
|
||||||
"maximum_ram_size": 235520,
|
"maximum_ram_size": 248832,
|
||||||
"maximum_size": 815104,
|
"maximum_size": 815104,
|
||||||
"speed": 115200,
|
"speed": 115200,
|
||||||
"protocol": "nrfutil",
|
"protocol": "nrfutil",
|
||||||
|
|||||||
@@ -40,7 +40,7 @@
|
|||||||
],
|
],
|
||||||
"name": "Seeed Wio Tracker L1",
|
"name": "Seeed Wio Tracker L1",
|
||||||
"upload": {
|
"upload": {
|
||||||
"maximum_ram_size": 235520,
|
"maximum_ram_size": 237568,
|
||||||
"maximum_size": 811008,
|
"maximum_size": 811008,
|
||||||
"protocol": "nrfutil",
|
"protocol": "nrfutil",
|
||||||
"speed": 115200,
|
"speed": 115200,
|
||||||
|
|||||||
@@ -40,7 +40,7 @@
|
|||||||
],
|
],
|
||||||
"name": "Seeed Studio XIAO nRF52840",
|
"name": "Seeed Studio XIAO nRF52840",
|
||||||
"upload": {
|
"upload": {
|
||||||
"maximum_ram_size": 235520,
|
"maximum_ram_size": 237568,
|
||||||
"maximum_size": 811008,
|
"maximum_size": 811008,
|
||||||
"protocol": "nrfutil",
|
"protocol": "nrfutil",
|
||||||
"speed": 115200,
|
"speed": 115200,
|
||||||
|
|||||||
@@ -39,8 +39,8 @@
|
|||||||
],
|
],
|
||||||
"name": "Seeed Studio XIAO nRF52840",
|
"name": "Seeed Studio XIAO nRF52840",
|
||||||
"upload": {
|
"upload": {
|
||||||
"maximum_ram_size": 235520,
|
"maximum_ram_size": 248832,
|
||||||
"maximum_size": 811008,
|
"maximum_size": 815104,
|
||||||
"protocol": "nrfutil",
|
"protocol": "nrfutil",
|
||||||
"speed": 115200,
|
"speed": 115200,
|
||||||
"protocols": [
|
"protocols": [
|
||||||
|
|||||||
+1
-1
@@ -45,7 +45,7 @@
|
|||||||
],
|
],
|
||||||
"name": "LilyGo T-ECHO",
|
"name": "LilyGo T-ECHO",
|
||||||
"upload": {
|
"upload": {
|
||||||
"maximum_ram_size": 235520,
|
"maximum_ram_size": 248832,
|
||||||
"maximum_size": 815104,
|
"maximum_size": 815104,
|
||||||
"require_upload_port": true,
|
"require_upload_port": true,
|
||||||
"speed": 115200,
|
"speed": 115200,
|
||||||
|
|||||||
@@ -53,7 +53,7 @@
|
|||||||
],
|
],
|
||||||
"name": "elecrow eink",
|
"name": "elecrow eink",
|
||||||
"upload": {
|
"upload": {
|
||||||
"maximum_ram_size": 235520,
|
"maximum_ram_size": 248832,
|
||||||
"maximum_size": 815104,
|
"maximum_size": 815104,
|
||||||
"speed": 115200,
|
"speed": 115200,
|
||||||
"use_1200bps_touch": true,
|
"use_1200bps_touch": true,
|
||||||
|
|||||||
@@ -53,7 +53,7 @@
|
|||||||
],
|
],
|
||||||
"name": "elecrow nrf",
|
"name": "elecrow nrf",
|
||||||
"upload": {
|
"upload": {
|
||||||
"maximum_ram_size": 235520,
|
"maximum_ram_size": 248832,
|
||||||
"maximum_size": 815104,
|
"maximum_size": 815104,
|
||||||
"speed": 115200,
|
"speed": 115200,
|
||||||
"use_1200bps_touch": true,
|
"use_1200bps_touch": true,
|
||||||
|
|||||||
@@ -53,7 +53,7 @@
|
|||||||
],
|
],
|
||||||
"name": "elecrow solar",
|
"name": "elecrow solar",
|
||||||
"upload": {
|
"upload": {
|
||||||
"maximum_ram_size": 235520,
|
"maximum_ram_size": 248832,
|
||||||
"maximum_size": 815104,
|
"maximum_size": 815104,
|
||||||
"speed": 115200,
|
"speed": 115200,
|
||||||
"use_1200bps_touch": true,
|
"use_1200bps_touch": true,
|
||||||
|
|||||||
@@ -38,8 +38,8 @@
|
|||||||
"frameworks": ["arduino"],
|
"frameworks": ["arduino"],
|
||||||
"name": "Seeed T1000-E",
|
"name": "Seeed T1000-E",
|
||||||
"upload": {
|
"upload": {
|
||||||
"maximum_ram_size": 235520,
|
"maximum_ram_size": 248832,
|
||||||
"maximum_size": 811008,
|
"maximum_size": 815104,
|
||||||
"speed": 115200,
|
"speed": 115200,
|
||||||
"protocol": "nrfutil",
|
"protocol": "nrfutil",
|
||||||
"protocols": [
|
"protocols": [
|
||||||
|
|||||||
@@ -811,7 +811,7 @@ MyMesh::MyMesh(mesh::Radio &radio, mesh::RNG &rng, mesh::RTCClock &rtc, SimpleMe
|
|||||||
|
|
||||||
// defaults
|
// defaults
|
||||||
memset(&_prefs, 0, sizeof(_prefs));
|
memset(&_prefs, 0, sizeof(_prefs));
|
||||||
_prefs.airtime_factor = 1.0;
|
_prefs.airtime_factor = 1.0; // one half
|
||||||
strcpy(_prefs.node_name, "NONAME");
|
strcpy(_prefs.node_name, "NONAME");
|
||||||
_prefs.freq = LORA_FREQ;
|
_prefs.freq = LORA_FREQ;
|
||||||
_prefs.sf = LORA_SF;
|
_prefs.sf = LORA_SF;
|
||||||
@@ -1716,7 +1716,7 @@ void MyMesh::handleCmdFrame(size_t len) {
|
|||||||
out_frame[i++] = STATS_TYPE_CORE;
|
out_frame[i++] = STATS_TYPE_CORE;
|
||||||
uint16_t battery_mv = board.getBattMilliVolts();
|
uint16_t battery_mv = board.getBattMilliVolts();
|
||||||
uint32_t uptime_secs = _ms->getMillis() / 1000;
|
uint32_t uptime_secs = _ms->getMillis() / 1000;
|
||||||
uint8_t queue_len = (uint8_t)_mgr->getOutboundTotal();
|
uint8_t queue_len = (uint8_t)_mgr->getOutboundCount(0xFFFFFFFF);
|
||||||
memcpy(&out_frame[i], &battery_mv, 2); i += 2;
|
memcpy(&out_frame[i], &battery_mv, 2); i += 2;
|
||||||
memcpy(&out_frame[i], &uptime_secs, 4); i += 4;
|
memcpy(&out_frame[i], &uptime_secs, 4); i += 4;
|
||||||
memcpy(&out_frame[i], &_err_flags, 2); i += 2;
|
memcpy(&out_frame[i], &_err_flags, 2); i += 2;
|
||||||
|
|||||||
@@ -253,7 +253,7 @@ int MyMesh::handleRequest(ClientInfo *sender, uint32_t sender_timestamp, uint8_t
|
|||||||
if (payload[0] == REQ_TYPE_GET_STATUS) { // guests can also access this now
|
if (payload[0] == REQ_TYPE_GET_STATUS) { // guests can also access this now
|
||||||
RepeaterStats stats;
|
RepeaterStats stats;
|
||||||
stats.batt_milli_volts = board.getBattMilliVolts();
|
stats.batt_milli_volts = board.getBattMilliVolts();
|
||||||
stats.curr_tx_queue_len = _mgr->getOutboundTotal();
|
stats.curr_tx_queue_len = _mgr->getOutboundCount(0xFFFFFFFF);
|
||||||
stats.noise_floor = (int16_t)_radio->getNoiseFloor();
|
stats.noise_floor = (int16_t)_radio->getNoiseFloor();
|
||||||
stats.last_rssi = (int16_t)radio_driver.getLastRSSI();
|
stats.last_rssi = (int16_t)radio_driver.getLastRSSI();
|
||||||
stats.n_packets_recv = radio_driver.getPacketsRecv();
|
stats.n_packets_recv = radio_driver.getPacketsRecv();
|
||||||
@@ -900,7 +900,7 @@ MyMesh::MyMesh(mesh::MainBoard &board, mesh::Radio &radio, mesh::MillisecondCloc
|
|||||||
|
|
||||||
// defaults
|
// defaults
|
||||||
memset(&_prefs, 0, sizeof(_prefs));
|
memset(&_prefs, 0, sizeof(_prefs));
|
||||||
_prefs.airtime_factor = 1.0;
|
_prefs.airtime_factor = 1.0; // one half
|
||||||
_prefs.rx_delay_base = 0.0f; // turn off by default, was 10.0;
|
_prefs.rx_delay_base = 0.0f; // turn off by default, was 10.0;
|
||||||
_prefs.tx_delay_factor = 0.5f; // was 0.25f
|
_prefs.tx_delay_factor = 0.5f; // was 0.25f
|
||||||
_prefs.direct_tx_delay_factor = 0.3f; // was 0.2
|
_prefs.direct_tx_delay_factor = 0.3f; // was 0.2
|
||||||
@@ -1415,5 +1415,5 @@ bool MyMesh::hasPendingWork() const {
|
|||||||
#if defined(WITH_BRIDGE)
|
#if defined(WITH_BRIDGE)
|
||||||
if (bridge.isRunning()) return true; // bridge needs WiFi radio, can't sleep
|
if (bridge.isRunning()) return true; // bridge needs WiFi radio, can't sleep
|
||||||
#endif
|
#endif
|
||||||
return _mgr->getOutboundTotal() > 0;
|
return _mgr->getOutboundCount(0xFFFFFFFF) > 0;
|
||||||
}
|
}
|
||||||
@@ -140,7 +140,7 @@ int MyMesh::handleRequest(ClientInfo *sender, uint32_t sender_timestamp, uint8_t
|
|||||||
if (payload[0] == REQ_TYPE_GET_STATUS) {
|
if (payload[0] == REQ_TYPE_GET_STATUS) {
|
||||||
ServerStats stats;
|
ServerStats stats;
|
||||||
stats.batt_milli_volts = board.getBattMilliVolts();
|
stats.batt_milli_volts = board.getBattMilliVolts();
|
||||||
stats.curr_tx_queue_len = _mgr->getOutboundTotal();
|
stats.curr_tx_queue_len = _mgr->getOutboundCount(0xFFFFFFFF);
|
||||||
stats.noise_floor = (int16_t)_radio->getNoiseFloor();
|
stats.noise_floor = (int16_t)_radio->getNoiseFloor();
|
||||||
stats.last_rssi = (int16_t)radio_driver.getLastRSSI();
|
stats.last_rssi = (int16_t)radio_driver.getLastRSSI();
|
||||||
stats.n_packets_recv = radio_driver.getPacketsRecv();
|
stats.n_packets_recv = radio_driver.getPacketsRecv();
|
||||||
@@ -624,7 +624,7 @@ MyMesh::MyMesh(mesh::MainBoard &board, mesh::Radio &radio, mesh::MillisecondCloc
|
|||||||
|
|
||||||
// defaults
|
// defaults
|
||||||
memset(&_prefs, 0, sizeof(_prefs));
|
memset(&_prefs, 0, sizeof(_prefs));
|
||||||
_prefs.airtime_factor = 1.0;
|
_prefs.airtime_factor = 1.0; // one half
|
||||||
_prefs.rx_delay_base = 0.0f; // off by default, was 10.0
|
_prefs.rx_delay_base = 0.0f; // off by default, was 10.0
|
||||||
_prefs.tx_delay_factor = 0.5f; // was 0.25f;
|
_prefs.tx_delay_factor = 0.5f; // was 0.25f;
|
||||||
_prefs.direct_tx_delay_factor = 0.2f; // was zero
|
_prefs.direct_tx_delay_factor = 0.2f; // was zero
|
||||||
|
|||||||
@@ -281,7 +281,7 @@ public:
|
|||||||
{
|
{
|
||||||
// defaults
|
// defaults
|
||||||
memset(&_prefs, 0, sizeof(_prefs));
|
memset(&_prefs, 0, sizeof(_prefs));
|
||||||
_prefs.airtime_factor = 1.0;
|
_prefs.airtime_factor = 2.0; // one third
|
||||||
strcpy(_prefs.node_name, "NONAME");
|
strcpy(_prefs.node_name, "NONAME");
|
||||||
_prefs.freq = LORA_FREQ;
|
_prefs.freq = LORA_FREQ;
|
||||||
_prefs.tx_power_dbm = LORA_TX_POWER;
|
_prefs.tx_power_dbm = LORA_TX_POWER;
|
||||||
|
|||||||
@@ -706,7 +706,7 @@ SensorMesh::SensorMesh(mesh::MainBoard& board, mesh::Radio& radio, mesh::Millise
|
|||||||
|
|
||||||
// defaults
|
// defaults
|
||||||
memset(&_prefs, 0, sizeof(_prefs));
|
memset(&_prefs, 0, sizeof(_prefs));
|
||||||
_prefs.airtime_factor = 1.0;
|
_prefs.airtime_factor = 1.0; // one half
|
||||||
_prefs.rx_delay_base = 0.0f; // turn off by default, was 10.0;
|
_prefs.rx_delay_base = 0.0f; // turn off by default, was 10.0;
|
||||||
_prefs.tx_delay_factor = 0.5f; // was 0.25f
|
_prefs.tx_delay_factor = 0.5f; // was 0.25f
|
||||||
_prefs.direct_tx_delay_factor = 0.2f; // was zero
|
_prefs.direct_tx_delay_factor = 0.2f; // was zero
|
||||||
|
|||||||
+8
-56
@@ -8,9 +8,7 @@
|
|||||||
|
|
||||||
namespace mesh {
|
namespace mesh {
|
||||||
|
|
||||||
#define MAX_RX_DELAY_MILLIS 32000 // 32 seconds
|
#define MAX_RX_DELAY_MILLIS 32000 // 32 seconds
|
||||||
#define MIN_TX_BUDGET_RESERVE_MS 100 // min budget (ms) required before allowing next TX
|
|
||||||
#define MIN_TX_BUDGET_AIRTIME_DIV 2 // require at least 1/N of estimated airtime as budget before TX
|
|
||||||
|
|
||||||
#ifndef NOISE_FLOOR_CALIB_INTERVAL
|
#ifndef NOISE_FLOOR_CALIB_INTERVAL
|
||||||
#define NOISE_FLOOR_CALIB_INTERVAL 2000 // 2 seconds
|
#define NOISE_FLOOR_CALIB_INTERVAL 2000 // 2 seconds
|
||||||
@@ -22,34 +20,12 @@ void Dispatcher::begin() {
|
|||||||
_err_flags = 0;
|
_err_flags = 0;
|
||||||
radio_nonrx_start = _ms->getMillis();
|
radio_nonrx_start = _ms->getMillis();
|
||||||
|
|
||||||
duty_cycle_window_ms = getDutyCycleWindowMs();
|
|
||||||
float duty_cycle = 1.0f / (1.0f + getAirtimeBudgetFactor());
|
|
||||||
tx_budget_ms = (unsigned long)(duty_cycle_window_ms * duty_cycle);
|
|
||||||
last_budget_update = _ms->getMillis();
|
|
||||||
|
|
||||||
_radio->begin();
|
_radio->begin();
|
||||||
prev_isrecv_mode = _radio->isInRecvMode();
|
prev_isrecv_mode = _radio->isInRecvMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
float Dispatcher::getAirtimeBudgetFactor() const {
|
float Dispatcher::getAirtimeBudgetFactor() const {
|
||||||
return 1.0;
|
return 2.0; // default, 33.3% (1/3rd)
|
||||||
}
|
|
||||||
|
|
||||||
void Dispatcher::updateTxBudget() {
|
|
||||||
unsigned long now = _ms->getMillis();
|
|
||||||
unsigned long elapsed = now - last_budget_update;
|
|
||||||
|
|
||||||
float duty_cycle = 1.0f / (1.0f + getAirtimeBudgetFactor());
|
|
||||||
unsigned long max_budget = (unsigned long)(getDutyCycleWindowMs() * duty_cycle);
|
|
||||||
unsigned long refill = (unsigned long)(elapsed * duty_cycle);
|
|
||||||
|
|
||||||
if (refill > 0) {
|
|
||||||
tx_budget_ms += refill;
|
|
||||||
if (tx_budget_ms > max_budget) {
|
|
||||||
tx_budget_ms = max_budget;
|
|
||||||
}
|
|
||||||
last_budget_update = now;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int Dispatcher::calcRxDelay(float score, uint32_t air_time) const {
|
int Dispatcher::calcRxDelay(float score, uint32_t air_time) const {
|
||||||
@@ -85,24 +61,11 @@ void Dispatcher::loop() {
|
|||||||
if (outbound) { // waiting for outbound send to be completed
|
if (outbound) { // waiting for outbound send to be completed
|
||||||
if (_radio->isSendComplete()) {
|
if (_radio->isSendComplete()) {
|
||||||
long t = _ms->getMillis() - outbound_start;
|
long t = _ms->getMillis() - outbound_start;
|
||||||
total_air_time += t;
|
total_air_time += t; // keep track of how much air time we are using
|
||||||
//Serial.print(" airtime="); Serial.println(t);
|
//Serial.print(" airtime="); Serial.println(t);
|
||||||
|
|
||||||
updateTxBudget();
|
// will need radio silence up to next_tx_time
|
||||||
|
next_tx_time = futureMillis(t * getAirtimeBudgetFactor());
|
||||||
if (t > tx_budget_ms) {
|
|
||||||
tx_budget_ms = 0;
|
|
||||||
} else {
|
|
||||||
tx_budget_ms -= t;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tx_budget_ms < MIN_TX_BUDGET_RESERVE_MS) {
|
|
||||||
float duty_cycle = 1.0f / (1.0f + getAirtimeBudgetFactor());
|
|
||||||
unsigned long needed = MIN_TX_BUDGET_RESERVE_MS - tx_budget_ms;
|
|
||||||
next_tx_time = futureMillis((unsigned long)(needed / duty_cycle));
|
|
||||||
} else {
|
|
||||||
next_tx_time = _ms->getMillis();
|
|
||||||
}
|
|
||||||
|
|
||||||
_radio->onSendFinished();
|
_radio->onSendFinished();
|
||||||
logTx(outbound, 2 + outbound->getPathByteLen() + outbound->payload_len);
|
logTx(outbound, 2 + outbound->getPathByteLen() + outbound->payload_len);
|
||||||
@@ -272,20 +235,9 @@ void Dispatcher::processRecvPacket(Packet* pkt) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Dispatcher::checkSend() {
|
void Dispatcher::checkSend() {
|
||||||
if (_mgr->getOutboundCount(_ms->getMillis()) == 0) return;
|
if (_mgr->getOutboundCount(_ms->getMillis()) == 0) return; // nothing waiting to send
|
||||||
|
if (!millisHasNowPassed(next_tx_time)) return; // still in 'radio silence' phase (from airtime budget setting)
|
||||||
updateTxBudget();
|
if (_radio->isReceiving()) { // LBT - check if radio is currently mid-receive, or if channel activity
|
||||||
|
|
||||||
uint32_t est_airtime = _radio->getEstAirtimeFor(MAX_TRANS_UNIT);
|
|
||||||
if (tx_budget_ms < est_airtime / MIN_TX_BUDGET_AIRTIME_DIV) {
|
|
||||||
float duty_cycle = 1.0f / (1.0f + getAirtimeBudgetFactor());
|
|
||||||
unsigned long needed = est_airtime / MIN_TX_BUDGET_AIRTIME_DIV - tx_budget_ms;
|
|
||||||
next_tx_time = futureMillis((unsigned long)(needed / duty_cycle));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!millisHasNowPassed(next_tx_time)) return;
|
|
||||||
if (_radio->isReceiving()) {
|
|
||||||
if (cad_busy_start == 0) {
|
if (cad_busy_start == 0) {
|
||||||
cad_busy_start = _ms->getMillis(); // record when CAD busy state started
|
cad_busy_start = _ms->getMillis(); // record when CAD busy state started
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-12
@@ -95,7 +95,6 @@ public:
|
|||||||
virtual void queueOutbound(Packet* packet, uint8_t priority, uint32_t scheduled_for) = 0;
|
virtual void queueOutbound(Packet* packet, uint8_t priority, uint32_t scheduled_for) = 0;
|
||||||
virtual Packet* getNextOutbound(uint32_t now) = 0; // by priority
|
virtual Packet* getNextOutbound(uint32_t now) = 0; // by priority
|
||||||
virtual int getOutboundCount(uint32_t now) const = 0;
|
virtual int getOutboundCount(uint32_t now) const = 0;
|
||||||
virtual int getOutboundTotal() const = 0;
|
|
||||||
virtual int getFreeCount() const = 0;
|
virtual int getFreeCount() const = 0;
|
||||||
virtual Packet* getOutboundByIdx(int i) = 0;
|
virtual Packet* getOutboundByIdx(int i) = 0;
|
||||||
virtual Packet* removeOutboundByIdx(int i) = 0;
|
virtual Packet* removeOutboundByIdx(int i) = 0;
|
||||||
@@ -128,12 +127,8 @@ class Dispatcher {
|
|||||||
bool prev_isrecv_mode;
|
bool prev_isrecv_mode;
|
||||||
uint32_t n_sent_flood, n_sent_direct;
|
uint32_t n_sent_flood, n_sent_direct;
|
||||||
uint32_t n_recv_flood, n_recv_direct;
|
uint32_t n_recv_flood, n_recv_direct;
|
||||||
unsigned long tx_budget_ms;
|
|
||||||
unsigned long last_budget_update;
|
|
||||||
unsigned long duty_cycle_window_ms;
|
|
||||||
|
|
||||||
void processRecvPacket(Packet* pkt);
|
void processRecvPacket(Packet* pkt);
|
||||||
void updateTxBudget();
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
PacketManager* _mgr;
|
PacketManager* _mgr;
|
||||||
@@ -146,15 +141,12 @@ protected:
|
|||||||
{
|
{
|
||||||
outbound = NULL;
|
outbound = NULL;
|
||||||
total_air_time = rx_air_time = 0;
|
total_air_time = rx_air_time = 0;
|
||||||
next_tx_time = ms.getMillis();
|
next_tx_time = 0;
|
||||||
cad_busy_start = 0;
|
cad_busy_start = 0;
|
||||||
next_floor_calib_time = next_agc_reset_time = 0;
|
next_floor_calib_time = next_agc_reset_time = 0;
|
||||||
_err_flags = 0;
|
_err_flags = 0;
|
||||||
radio_nonrx_start = 0;
|
radio_nonrx_start = 0;
|
||||||
prev_isrecv_mode = true;
|
prev_isrecv_mode = true;
|
||||||
tx_budget_ms = 0;
|
|
||||||
last_budget_update = 0;
|
|
||||||
duty_cycle_window_ms = 3600000;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual DispatcherAction onRecvPacket(Packet* pkt) = 0;
|
virtual DispatcherAction onRecvPacket(Packet* pkt) = 0;
|
||||||
@@ -172,7 +164,6 @@ protected:
|
|||||||
virtual uint32_t getCADFailMaxDuration() const;
|
virtual uint32_t getCADFailMaxDuration() const;
|
||||||
virtual int getInterferenceThreshold() const { return 0; } // disabled by default
|
virtual int getInterferenceThreshold() const { return 0; } // disabled by default
|
||||||
virtual int getAGCResetInterval() const { return 0; } // disabled by default
|
virtual int getAGCResetInterval() const { return 0; } // disabled by default
|
||||||
virtual unsigned long getDutyCycleWindowMs() const { return 3600000; }
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void begin();
|
void begin();
|
||||||
@@ -182,9 +173,8 @@ public:
|
|||||||
void releasePacket(Packet* packet);
|
void releasePacket(Packet* packet);
|
||||||
void sendPacket(Packet* packet, uint8_t priority, uint32_t delay_millis=0);
|
void sendPacket(Packet* packet, uint8_t priority, uint32_t delay_millis=0);
|
||||||
|
|
||||||
unsigned long getTotalAirTime() const { return total_air_time; }
|
unsigned long getTotalAirTime() const { return total_air_time; } // in milliseconds
|
||||||
unsigned long getReceiveAirTime() const {return rx_air_time; }
|
unsigned long getReceiveAirTime() const {return rx_air_time; }
|
||||||
unsigned long getRemainingTxBudget() const { return tx_budget_ms; }
|
|
||||||
uint32_t getNumSentFlood() const { return n_sent_flood; }
|
uint32_t getNumSentFlood() const { return n_sent_flood; }
|
||||||
uint32_t getNumSentDirect() const { return n_sent_direct; }
|
uint32_t getNumSentDirect() const { return n_sent_direct; }
|
||||||
uint32_t getNumRecvFlood() const { return n_recv_flood; }
|
uint32_t getNumRecvFlood() const { return n_recv_flood; }
|
||||||
|
|||||||
@@ -26,10 +26,6 @@ static size_t getMQTTFieldsSize(const NodePrefs* prefs) {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef BRIDGE_MAX_BAUD
|
|
||||||
#define BRIDGE_MAX_BAUD 115200
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Believe it or not, this std C function is busted on some platforms!
|
// Believe it or not, this std C function is busted on some platforms!
|
||||||
static uint32_t _atoi(const char* sp) {
|
static uint32_t _atoi(const char* sp) {
|
||||||
uint32_t n = 0;
|
uint32_t n = 0;
|
||||||
@@ -180,7 +176,7 @@ void CommonCLI::loadPrefsInt(FILESYSTEM* fs, const char* filename) {
|
|||||||
_prefs->bridge_enabled = constrain(_prefs->bridge_enabled, 0, 1);
|
_prefs->bridge_enabled = constrain(_prefs->bridge_enabled, 0, 1);
|
||||||
_prefs->bridge_delay = constrain(_prefs->bridge_delay, 0, 10000);
|
_prefs->bridge_delay = constrain(_prefs->bridge_delay, 0, 10000);
|
||||||
_prefs->bridge_pkt_src = constrain(_prefs->bridge_pkt_src, 0, 1);
|
_prefs->bridge_pkt_src = constrain(_prefs->bridge_pkt_src, 0, 1);
|
||||||
_prefs->bridge_baud = constrain(_prefs->bridge_baud, 9600, BRIDGE_MAX_BAUD);
|
_prefs->bridge_baud = constrain(_prefs->bridge_baud, 9600, 115200);
|
||||||
_prefs->bridge_channel = constrain(_prefs->bridge_channel, 0, 14);
|
_prefs->bridge_channel = constrain(_prefs->bridge_channel, 0, 14);
|
||||||
|
|
||||||
_prefs->powersaving_enabled = constrain(_prefs->powersaving_enabled, 0, 1);
|
_prefs->powersaving_enabled = constrain(_prefs->powersaving_enabled, 0, 1);
|
||||||
@@ -1013,13 +1009,13 @@ void CommonCLI::handleCommand(uint32_t sender_timestamp, const char* command, ch
|
|||||||
#ifdef WITH_RS232_BRIDGE
|
#ifdef WITH_RS232_BRIDGE
|
||||||
} else if (memcmp(config, "bridge.baud ", 12) == 0) {
|
} else if (memcmp(config, "bridge.baud ", 12) == 0) {
|
||||||
uint32_t baud = atoi(&config[12]);
|
uint32_t baud = atoi(&config[12]);
|
||||||
if (baud >= 9600 && baud <= BRIDGE_MAX_BAUD) {
|
if (baud >= 9600 && baud <= 115200) {
|
||||||
_prefs->bridge_baud = (uint32_t)baud;
|
_prefs->bridge_baud = (uint32_t)baud;
|
||||||
_callbacks->restartBridge();
|
_callbacks->restartBridge();
|
||||||
savePrefs();
|
savePrefs();
|
||||||
strcpy(reply, "OK");
|
strcpy(reply, "OK");
|
||||||
} else {
|
} else {
|
||||||
sprintf(reply, "Error: baud rate must be between 9600-%d",BRIDGE_MAX_BAUD);
|
strcpy(reply, "Error: baud rate must be between 9600-115200");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef WITH_ESPNOW_BRIDGE
|
#ifdef WITH_ESPNOW_BRIDGE
|
||||||
|
|||||||
@@ -9,8 +9,6 @@ PacketQueue::PacketQueue(int max_entries) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int PacketQueue::countBefore(uint32_t now) const {
|
int PacketQueue::countBefore(uint32_t now) const {
|
||||||
if (now == 0xFFFFFFFF) return _num; // sentinel: count all entries regardless of schedule
|
|
||||||
|
|
||||||
int n = 0;
|
int n = 0;
|
||||||
for (int j = 0; j < _num; j++) {
|
for (int j = 0; j < _num; j++) {
|
||||||
if ((int32_t)(_schedule_table[j] - now) > 0) continue; // scheduled for future... ignore for now
|
if ((int32_t)(_schedule_table[j] - now) > 0) continue; // scheduled for future... ignore for now
|
||||||
@@ -99,10 +97,6 @@ int StaticPoolPacketManager::getOutboundCount(uint32_t now) const {
|
|||||||
return send_queue.countBefore(now);
|
return send_queue.countBefore(now);
|
||||||
}
|
}
|
||||||
|
|
||||||
int StaticPoolPacketManager::getOutboundTotal() const {
|
|
||||||
return send_queue.count();
|
|
||||||
}
|
|
||||||
|
|
||||||
int StaticPoolPacketManager::getFreeCount() const {
|
int StaticPoolPacketManager::getFreeCount() const {
|
||||||
return unused.count();
|
return unused.count();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ public:
|
|||||||
void queueOutbound(mesh::Packet* packet, uint8_t priority, uint32_t scheduled_for) override;
|
void queueOutbound(mesh::Packet* packet, uint8_t priority, uint32_t scheduled_for) override;
|
||||||
mesh::Packet* getNextOutbound(uint32_t now) override;
|
mesh::Packet* getNextOutbound(uint32_t now) override;
|
||||||
int getOutboundCount(uint32_t now) const override;
|
int getOutboundCount(uint32_t now) const override;
|
||||||
int getOutboundTotal() const override;
|
|
||||||
int getFreeCount() const override;
|
int getFreeCount() const override;
|
||||||
mesh::Packet* getOutboundByIdx(int i) override;
|
mesh::Packet* getOutboundByIdx(int i) override;
|
||||||
mesh::Packet* removeOutboundByIdx(int i) override;
|
mesh::Packet* removeOutboundByIdx(int i) override;
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ public:
|
|||||||
board.getBattMilliVolts(),
|
board.getBattMilliVolts(),
|
||||||
ms.getMillis() / 1000,
|
ms.getMillis() / 1000,
|
||||||
err_flags,
|
err_flags,
|
||||||
mgr->getOutboundTotal()
|
mgr->getOutboundCount(0xFFFFFFFF)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -39,13 +39,10 @@ class MicroNMEALocationProvider : public LocationProvider {
|
|||||||
mesh::RTCClock* _clock;
|
mesh::RTCClock* _clock;
|
||||||
Stream* _gps_serial;
|
Stream* _gps_serial;
|
||||||
RefCountedDigitalPin* _peripher_power;
|
RefCountedDigitalPin* _peripher_power;
|
||||||
int8_t _claims = 0;
|
|
||||||
int _pin_reset;
|
int _pin_reset;
|
||||||
int _pin_en;
|
int _pin_en;
|
||||||
long next_check = 0;
|
long next_check = 0;
|
||||||
long time_valid = 0;
|
long time_valid = 0;
|
||||||
unsigned long _last_time_sync = 0;
|
|
||||||
static const unsigned long TIME_SYNC_INTERVAL = 1800000; // Re-sync every 30 minutes
|
|
||||||
|
|
||||||
public :
|
public :
|
||||||
MicroNMEALocationProvider(Stream& ser, mesh::RTCClock* clock = NULL, int pin_reset = GPS_RESET, int pin_en = GPS_EN,RefCountedDigitalPin* peripher_power=NULL) :
|
MicroNMEALocationProvider(Stream& ser, mesh::RTCClock* clock = NULL, int pin_reset = GPS_RESET, int pin_en = GPS_EN,RefCountedDigitalPin* peripher_power=NULL) :
|
||||||
@@ -60,21 +57,8 @@ public :
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void claim() {
|
|
||||||
_claims++;
|
|
||||||
if (_claims > 0) {
|
|
||||||
if (_peripher_power) _peripher_power->claim();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void release() {
|
|
||||||
if (_claims == 0) return; // avoid negative _claims
|
|
||||||
_claims--;
|
|
||||||
if (_peripher_power) _peripher_power->release();
|
|
||||||
}
|
|
||||||
|
|
||||||
void begin() override {
|
void begin() override {
|
||||||
claim();
|
if (_peripher_power) _peripher_power->claim();
|
||||||
if (_pin_en != -1) {
|
if (_pin_en != -1) {
|
||||||
digitalWrite(_pin_en, PIN_GPS_EN_ACTIVE);
|
digitalWrite(_pin_en, PIN_GPS_EN_ACTIVE);
|
||||||
}
|
}
|
||||||
@@ -98,7 +82,7 @@ public :
|
|||||||
if (_pin_reset != -1) {
|
if (_pin_reset != -1) {
|
||||||
digitalWrite(_pin_reset, GPS_RESET_FORCE);
|
digitalWrite(_pin_reset, GPS_RESET_FORCE);
|
||||||
}
|
}
|
||||||
release();
|
if (_peripher_power) _peripher_power->release();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isEnabled() override {
|
bool isEnabled() override {
|
||||||
@@ -145,15 +129,10 @@ public :
|
|||||||
|
|
||||||
if (millis() > next_check) {
|
if (millis() > next_check) {
|
||||||
next_check = millis() + 1000;
|
next_check = millis() + 1000;
|
||||||
// Re-enable time sync periodically when GPS has valid fix
|
|
||||||
if (!_time_sync_needed && _clock != NULL && (millis() - _last_time_sync) > TIME_SYNC_INTERVAL) {
|
|
||||||
_time_sync_needed = true;
|
|
||||||
}
|
|
||||||
if (_time_sync_needed && time_valid > 2) {
|
if (_time_sync_needed && time_valid > 2) {
|
||||||
if (_clock != NULL) {
|
if (_clock != NULL) {
|
||||||
_clock->setCurrentTime(getTimestamp());
|
_clock->setCurrentTime(getTimestamp());
|
||||||
_time_sync_needed = false;
|
_time_sync_needed = false;
|
||||||
_last_time_sync = millis();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (isValid()) {
|
if (isValid()) {
|
||||||
|
|||||||
@@ -1,57 +0,0 @@
|
|||||||
#include <Arduino.h>
|
|
||||||
#include <Wire.h>
|
|
||||||
|
|
||||||
#include "GAT562MeshTrackerProBoard.h"
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef NRF52_POWER_MANAGEMENT
|
|
||||||
// Static configuration for power management
|
|
||||||
// Values set in variant.h defines
|
|
||||||
const PowerMgtConfig power_config = {
|
|
||||||
.lpcomp_ain_channel = PWRMGT_LPCOMP_AIN,
|
|
||||||
.lpcomp_refsel = PWRMGT_LPCOMP_REFSEL,
|
|
||||||
.voltage_bootlock = PWRMGT_VOLTAGE_BOOTLOCK
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
void GAT562MeshTrackerProBoard::initiateShutdown(uint8_t reason) {
|
|
||||||
// Disable LoRa module power before shutdown
|
|
||||||
digitalWrite(SX126X_POWER_EN, LOW);
|
|
||||||
|
|
||||||
if (reason == SHUTDOWN_REASON_LOW_VOLTAGE ||
|
|
||||||
reason == SHUTDOWN_REASON_BOOT_PROTECT) {
|
|
||||||
configureVoltageWake(power_config.lpcomp_ain_channel, power_config.lpcomp_refsel);
|
|
||||||
}
|
|
||||||
|
|
||||||
enterSystemOff(reason);
|
|
||||||
}
|
|
||||||
#endif // NRF52_POWER_MANAGEMENT
|
|
||||||
|
|
||||||
|
|
||||||
void GAT562MeshTrackerProBoard::begin() {
|
|
||||||
NRF52BoardDCDC::begin();
|
|
||||||
pinMode(PIN_VBAT_READ, INPUT);
|
|
||||||
|
|
||||||
// Set all button pins to INPUT_PULLUP
|
|
||||||
pinMode(PIN_BUTTON1, INPUT_PULLUP);
|
|
||||||
pinMode(PIN_BUTTON2, INPUT_PULLUP);
|
|
||||||
pinMode(PIN_BUTTON3, INPUT_PULLUP);
|
|
||||||
pinMode(PIN_BUTTON4, INPUT_PULLUP);
|
|
||||||
pinMode(PIN_BUTTON5, INPUT_PULLUP);
|
|
||||||
pinMode(PIN_BUTTON6, INPUT_PULLUP);
|
|
||||||
|
|
||||||
#if defined(PIN_BOARD_SDA) && defined(PIN_BOARD_SCL)
|
|
||||||
Wire.setPins(PIN_BOARD_SDA, PIN_BOARD_SCL);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
Wire.begin();
|
|
||||||
|
|
||||||
pinMode(SX126X_POWER_EN, OUTPUT);
|
|
||||||
#ifdef NRF52_POWER_MANAGEMENT
|
|
||||||
// Boot voltage protection check (may not return if voltage too low)
|
|
||||||
// We need to call this after we configure SX126X_POWER_EN as output but before we pull high
|
|
||||||
checkBootVoltage(&power_config);
|
|
||||||
#endif
|
|
||||||
digitalWrite(SX126X_POWER_EN, HIGH);
|
|
||||||
delay(10); // give sx1268 some time to power up
|
|
||||||
}
|
|
||||||
@@ -1,53 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include <MeshCore.h>
|
|
||||||
#include <Arduino.h>
|
|
||||||
#include <helpers/NRF52Board.h>
|
|
||||||
|
|
||||||
|
|
||||||
class GAT562MeshTrackerProBoard : public NRF52BoardDCDC {
|
|
||||||
protected:
|
|
||||||
#ifdef NRF52_POWER_MANAGEMENT
|
|
||||||
void initiateShutdown(uint8_t reason) override;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
public:
|
|
||||||
GAT562MeshTrackerProBoard() : NRF52Board("GAT562_OTA") {}
|
|
||||||
void begin();
|
|
||||||
|
|
||||||
#define BATTERY_SAMPLES 8
|
|
||||||
|
|
||||||
uint16_t getBattMilliVolts() override {
|
|
||||||
analogReadResolution(12);
|
|
||||||
|
|
||||||
uint32_t raw = 0;
|
|
||||||
for (int i = 0; i < BATTERY_SAMPLES; i++) {
|
|
||||||
raw += analogRead(PIN_VBAT_READ);
|
|
||||||
}
|
|
||||||
raw = raw / BATTERY_SAMPLES;
|
|
||||||
|
|
||||||
return (ADC_MULTIPLIER * raw) / 4096;
|
|
||||||
}
|
|
||||||
|
|
||||||
const char* getManufacturerName() const override {
|
|
||||||
return "GAT562 Mesh Tracker Pro";
|
|
||||||
}
|
|
||||||
|
|
||||||
#if defined(P_LORA_TX_LED)
|
|
||||||
void onBeforeTransmit() override {
|
|
||||||
digitalWrite(P_LORA_TX_LED, HIGH); // turn TX LED on
|
|
||||||
}
|
|
||||||
|
|
||||||
void onAfterTransmit() override {
|
|
||||||
digitalWrite(P_LORA_TX_LED, LOW); // turn TX LED off
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void powerOff() override {
|
|
||||||
uint32_t button_pin = PIN_BUTTON1;
|
|
||||||
nrf_gpio_cfg_input(button_pin, NRF_GPIO_PIN_PULLUP);
|
|
||||||
nrf_gpio_cfg_sense_set(button_pin, NRF_GPIO_PIN_SENSE_LOW);
|
|
||||||
sd_power_system_off();
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
@@ -1,114 +0,0 @@
|
|||||||
[GAT562_Mesh_Tracker_Pro]
|
|
||||||
extends = nrf52_base
|
|
||||||
board = rak4631
|
|
||||||
board_check = true
|
|
||||||
build_flags = ${nrf52_base.build_flags}
|
|
||||||
${sensor_base.build_flags}
|
|
||||||
-I variants/gat562_mesh_tracker_pro
|
|
||||||
-D RAK_4631
|
|
||||||
-D RAK_BOARD
|
|
||||||
-D NRF52_POWER_MANAGEMENT
|
|
||||||
-D LORA_FREQ=475
|
|
||||||
-D LORA_BW=125
|
|
||||||
-D LORA_SF=10
|
|
||||||
-D LORA_CR=6
|
|
||||||
-D PIN_BOARD_SCL=14
|
|
||||||
-D PIN_BOARD_SDA=13
|
|
||||||
-D PIN_OLED_RESET=-1
|
|
||||||
-D UI_HAS_JOYSTICK=1
|
|
||||||
-D RADIO_CLASS=CustomSX1262
|
|
||||||
-D WRAPPER_CLASS=CustomSX1262Wrapper
|
|
||||||
-D LORA_TX_POWER=22
|
|
||||||
-D SX126X_CURRENT_LIMIT=140
|
|
||||||
-D SX126X_RX_BOOSTED_GAIN=1
|
|
||||||
build_src_filter = ${nrf52_base.build_src_filter}
|
|
||||||
+<../variants/gat562_mesh_tracker_pro>
|
|
||||||
+<helpers/ui/SSD1306Display.cpp>
|
|
||||||
+<helpers/ui/MomentaryButton.cpp>
|
|
||||||
+<helpers/sensors>
|
|
||||||
lib_deps =
|
|
||||||
${nrf52_base.lib_deps}
|
|
||||||
${sensor_base.lib_deps}
|
|
||||||
adafruit/Adafruit SSD1306 @ ^2.5.13
|
|
||||||
sparkfun/SparkFun u-blox GNSS Arduino Library@^2.2.27
|
|
||||||
|
|
||||||
|
|
||||||
[env:GAT562_Mesh_Tracker_Pro_repeater]
|
|
||||||
extends = GAT562_Mesh_Tracker_Pro
|
|
||||||
build_flags =
|
|
||||||
${GAT562_Mesh_Tracker_Pro.build_flags}
|
|
||||||
-D DISPLAY_CLASS=SSD1306Display
|
|
||||||
-D ADVERT_NAME='"GAT562 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 = ${GAT562_Mesh_Tracker_Pro.build_src_filter}
|
|
||||||
+<helpers/ui/SSD1306Display.cpp>
|
|
||||||
+<../examples/simple_repeater>
|
|
||||||
|
|
||||||
|
|
||||||
[env:GAT562_Mesh_Tracker_Pro_room_server]
|
|
||||||
extends = GAT562_Mesh_Tracker_Pro
|
|
||||||
build_flags =
|
|
||||||
${GAT562_Mesh_Tracker_Pro.build_flags}
|
|
||||||
-D DISPLAY_CLASS=SSD1306Display
|
|
||||||
-D ADVERT_NAME='"GAT562 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 = ${GAT562_Mesh_Tracker_Pro.build_src_filter}
|
|
||||||
+<helpers/ui/SSD1306Display.cpp>
|
|
||||||
+<../examples/simple_room_server>
|
|
||||||
|
|
||||||
|
|
||||||
[env:GAT562_Mesh_Tracker_Pro_companion_radio_usb]
|
|
||||||
extends = GAT562_Mesh_Tracker_Pro
|
|
||||||
board_build.ldscript = boards/nrf52840_s140_v6_extrafs.ld
|
|
||||||
board_upload.maximum_size = 712704
|
|
||||||
build_flags =
|
|
||||||
${GAT562_Mesh_Tracker_Pro.build_flags}
|
|
||||||
-I examples/companion_radio/ui-new
|
|
||||||
-D DISPLAY_CLASS=SSD1306Display
|
|
||||||
-D MAX_CONTACTS=350
|
|
||||||
-D MAX_GROUP_CHANNELS=40
|
|
||||||
; NOTE: DO NOT ENABLE --> -D MESH_PACKET_LOGGING=1
|
|
||||||
; NOTE: DO NOT ENABLE --> -D MESH_DEBUG=1
|
|
||||||
build_src_filter = ${GAT562_Mesh_Tracker_Pro.build_src_filter}
|
|
||||||
+<../examples/companion_radio/*.cpp>
|
|
||||||
+<../examples/companion_radio/ui-new/*.cpp>
|
|
||||||
lib_deps =
|
|
||||||
${GAT562_Mesh_Tracker_Pro.lib_deps}
|
|
||||||
densaugeo/base64 @ ~1.4.0
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[env:GAT562_Mesh_Tracker_Pro_companion_radio_ble]
|
|
||||||
extends = GAT562_Mesh_Tracker_Pro
|
|
||||||
board_build.ldscript = boards/nrf52840_s140_v6_extrafs.ld
|
|
||||||
board_upload.maximum_size = 712704
|
|
||||||
build_flags =
|
|
||||||
${GAT562_Mesh_Tracker_Pro.build_flags}
|
|
||||||
-I examples/companion_radio/ui-new
|
|
||||||
-D DISPLAY_CLASS=SSD1306Display
|
|
||||||
-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 = ${GAT562_Mesh_Tracker_Pro.build_src_filter}
|
|
||||||
+<helpers/nrf52/SerialBLEInterface.cpp>
|
|
||||||
+<helpers/ui/MomentaryButton.cpp>
|
|
||||||
+<../examples/companion_radio/*.cpp>
|
|
||||||
+<../examples/companion_radio/ui-new/*.cpp>
|
|
||||||
lib_deps =
|
|
||||||
${GAT562_Mesh_Tracker_Pro.lib_deps}
|
|
||||||
densaugeo/base64 @ ~1.4.0
|
|
||||||
|
|
||||||
@@ -1,59 +0,0 @@
|
|||||||
#include <Arduino.h>
|
|
||||||
#include "target.h"
|
|
||||||
#include <helpers/ArduinoHelpers.h>
|
|
||||||
|
|
||||||
GAT562MeshTrackerProBoard board;
|
|
||||||
|
|
||||||
#ifndef PIN_USER_BTN
|
|
||||||
#define PIN_USER_BTN (-1)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef DISPLAY_CLASS
|
|
||||||
DISPLAY_CLASS display;
|
|
||||||
MomentaryButton user_btn(PIN_USER_BTN, 1000, true, false, false);
|
|
||||||
MomentaryButton joystick_left(JOYSTICK_LEFT, 1000, true, false, false);
|
|
||||||
MomentaryButton joystick_right(JOYSTICK_RIGHT, 1000, true, false, false);
|
|
||||||
MomentaryButton back_btn(PIN_BACK_BTN, 1000, true, false, true);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
#if ENV_INCLUDE_GPS
|
|
||||||
#include <helpers/sensors/MicroNMEALocationProvider.h>
|
|
||||||
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1, &rtc_clock);
|
|
||||||
EnvironmentSensorManager sensors = EnvironmentSensorManager(nmea);
|
|
||||||
#else
|
|
||||||
EnvironmentSensorManager sensors;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
bool radio_init() {
|
|
||||||
rtc_clock.begin(Wire);
|
|
||||||
return radio.std_init(&SPI);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t radio_get_rng_seed() {
|
|
||||||
return radio.random(0x7FFFFFFF);
|
|
||||||
}
|
|
||||||
|
|
||||||
void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr) {
|
|
||||||
radio.setFrequency(freq);
|
|
||||||
radio.setSpreadingFactor(sf);
|
|
||||||
radio.setBandwidth(bw);
|
|
||||||
radio.setCodingRate(cr);
|
|
||||||
}
|
|
||||||
|
|
||||||
void radio_set_tx_power(int8_t dbm) {
|
|
||||||
radio.setOutputPower(dbm);
|
|
||||||
}
|
|
||||||
|
|
||||||
mesh::LocalIdentity radio_new_identity() {
|
|
||||||
RadioNoiseListener rng(radio);
|
|
||||||
return mesh::LocalIdentity(&rng); // create new random identity
|
|
||||||
}
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#define RADIOLIB_STATIC_ONLY 1
|
|
||||||
#include <RadioLib.h>
|
|
||||||
#include <helpers/radiolib/RadioLibWrappers.h>
|
|
||||||
#include <GAT562MeshTrackerProBoard.h>
|
|
||||||
#include <helpers/radiolib/CustomSX1262Wrapper.h>
|
|
||||||
#include <helpers/AutoDiscoverRTCClock.h>
|
|
||||||
#include <helpers/sensors/EnvironmentSensorManager.h>
|
|
||||||
|
|
||||||
#ifdef DISPLAY_CLASS
|
|
||||||
#include <helpers/ui/SSD1306Display.h>
|
|
||||||
extern DISPLAY_CLASS display;
|
|
||||||
#include <helpers/ui/MomentaryButton.h>
|
|
||||||
extern MomentaryButton user_btn;
|
|
||||||
extern MomentaryButton joystick_left;
|
|
||||||
extern MomentaryButton joystick_right;
|
|
||||||
extern MomentaryButton back_btn;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
extern GAT562MeshTrackerProBoard board;
|
|
||||||
extern WRAPPER_CLASS radio_driver;
|
|
||||||
extern AutoDiscoverRTCClock rtc_clock;
|
|
||||||
extern EnvironmentSensorManager sensors;
|
|
||||||
|
|
||||||
bool radio_init();
|
|
||||||
uint32_t radio_get_rng_seed();
|
|
||||||
void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr);
|
|
||||||
void radio_set_tx_power(int8_t dbm);
|
|
||||||
mesh::LocalIdentity radio_new_identity();
|
|
||||||
@@ -1,49 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright (c) 2014-2015 Arduino LLC. All right reserved.
|
|
||||||
Copyright (c) 2016 Sandeep Mistry All right reserved.
|
|
||||||
Copyright (c) 2018, Adafruit Industries (adafruit.com)
|
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU Lesser General Public
|
|
||||||
License as published by the Free Software Foundation; either
|
|
||||||
version 2.1 of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
This library is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
||||||
See the GNU Lesser General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public
|
|
||||||
License along with this library; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "variant.h"
|
|
||||||
#include "wiring_constants.h"
|
|
||||||
#include "wiring_digital.h"
|
|
||||||
#include "nrf.h"
|
|
||||||
|
|
||||||
const uint32_t g_ADigitalPinMap[] =
|
|
||||||
{
|
|
||||||
// P0
|
|
||||||
0 , 1 , 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,
|
|
||||||
|
|
||||||
// P1
|
|
||||||
32, 33, 34, 35, 36, 37, 38, 39,
|
|
||||||
40, 41, 42, 43, 44, 45, 46, 47
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
void initVariant()
|
|
||||||
{
|
|
||||||
// LED1 & LED2
|
|
||||||
pinMode(PIN_LED1, OUTPUT);
|
|
||||||
ledOff(PIN_LED1);
|
|
||||||
|
|
||||||
// pinMode(PIN_LED2, OUTPUT);
|
|
||||||
// ledOff(PIN_LED2);;
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,226 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright (c) 2014-2015 Arduino LLC. All right reserved.
|
|
||||||
Copyright (c) 2016 Sandeep Mistry All right reserved.
|
|
||||||
Copyright (c) 2018, Adafruit Industries (adafruit.com)
|
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU Lesser General Public
|
|
||||||
License as published by the Free Software Foundation; either
|
|
||||||
version 2.1 of the License, or (at your option) any later version.
|
|
||||||
This library is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
||||||
See the GNU Lesser General Public License for more details.
|
|
||||||
You should have received a copy of the GNU Lesser General Public
|
|
||||||
License along with this library; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _VARIANT_RAK4630_
|
|
||||||
#define _VARIANT_RAK4630_
|
|
||||||
|
|
||||||
#define RAK4630
|
|
||||||
|
|
||||||
/** Master clock frequency */
|
|
||||||
#define VARIANT_MCK (64000000ul)
|
|
||||||
|
|
||||||
#define USE_LFXO // Board uses 32khz crystal for LF
|
|
||||||
// define USE_LFRC // Board uses RC for LF
|
|
||||||
|
|
||||||
/*----------------------------------------------------------------------------
|
|
||||||
* Headers
|
|
||||||
*----------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
#include "WVariant.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C"
|
|
||||||
{
|
|
||||||
#endif // __cplusplus
|
|
||||||
|
|
||||||
/*
|
|
||||||
* WisBlock Base GPIO definitions
|
|
||||||
*/
|
|
||||||
static const uint8_t WB_IO1 = 17; // SLOT_A SLOT_B
|
|
||||||
static const uint8_t WB_IO2 = 34; // SLOT_A SLOT_B
|
|
||||||
static const uint8_t WB_IO3 = 21; // SLOT_C
|
|
||||||
static const uint8_t WB_IO4 = 4; // SLOT_C
|
|
||||||
static const uint8_t WB_IO5 = 9; // SLOT_D
|
|
||||||
static const uint8_t WB_IO6 = 10; // SLOT_D
|
|
||||||
static const uint8_t WB_SW1 = 33; // IO_SLOT
|
|
||||||
static const uint8_t WB_A0 = 5; // IO_SLOT
|
|
||||||
static const uint8_t WB_A1 = 31; // IO_SLOT
|
|
||||||
static const uint8_t WB_I2C1_SDA = 13; // SENSOR_SLOT IO_SLOT
|
|
||||||
static const uint8_t WB_I2C1_SCL = 14; // SENSOR_SLOT IO_SLOT
|
|
||||||
static const uint8_t WB_I2C2_SDA = 24; // IO_SLOT
|
|
||||||
static const uint8_t WB_I2C2_SCL = 25; // IO_SLOT
|
|
||||||
static const uint8_t WB_SPI_CS = 26; // IO_SLOT
|
|
||||||
static const uint8_t WB_SPI_CLK = 3; // IO_SLOT
|
|
||||||
static const uint8_t WB_SPI_MISO = 29; // IO_SLOT
|
|
||||||
static const uint8_t WB_SPI_MOSI = 30; // IO_SLOT
|
|
||||||
|
|
||||||
// Number of pins defined in PinDescription array
|
|
||||||
#define PINS_COUNT (48)
|
|
||||||
#define NUM_DIGITAL_PINS (48)
|
|
||||||
#define NUM_ANALOG_INPUTS (6)
|
|
||||||
#define NUM_ANALOG_OUTPUTS (0)
|
|
||||||
|
|
||||||
// LEDs
|
|
||||||
#define PIN_LED1 (35)
|
|
||||||
#define PIN_LED2 (36)
|
|
||||||
|
|
||||||
#define LED_BUILTIN PIN_LED1
|
|
||||||
#define LED_CONN PIN_LED2
|
|
||||||
|
|
||||||
#define LED_GREEN PIN_LED1
|
|
||||||
#define LED_BLUE PIN_LED2
|
|
||||||
|
|
||||||
#define LED_STATE_ON 1 // State when LED is litted
|
|
||||||
|
|
||||||
// #define P_LORA_TX_LED LED_GREEN
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Buttons
|
|
||||||
*/
|
|
||||||
#define PIN_BUTTON1 (9) // Menu / User Button
|
|
||||||
#define PIN_BUTTON2 (28) // Joystick Up
|
|
||||||
#define PIN_BUTTON3 (4) // Joystick Down
|
|
||||||
#define PIN_BUTTON4 (30) // Joystick Left
|
|
||||||
#define PIN_BUTTON5 (31) // Joystick Right
|
|
||||||
#define PIN_BUTTON6 (26) // Joystick Press
|
|
||||||
#define PIN_BACK_BTN PIN_BUTTON1
|
|
||||||
#define JOYSTICK_UP PIN_BUTTON2
|
|
||||||
#define JOYSTICK_DOWN PIN_BUTTON3
|
|
||||||
#define JOYSTICK_LEFT PIN_BUTTON4
|
|
||||||
#define JOYSTICK_RIGHT PIN_BUTTON5
|
|
||||||
#define JOYSTICK_PRESS PIN_BUTTON6
|
|
||||||
#define PIN_USER_BTN PIN_BUTTON6
|
|
||||||
|
|
||||||
|
|
||||||
// Analog pins
|
|
||||||
#define PIN_VBAT_READ (5)
|
|
||||||
#define ADC_MULTIPLIER (3 * 1.75 * 1.187 * 1000)
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Analog pins
|
|
||||||
*/
|
|
||||||
#define PIN_A0 (5) //(3)
|
|
||||||
#define PIN_A1 (31) //(4)
|
|
||||||
#define PIN_A2 (28)
|
|
||||||
#define PIN_A3 (29)
|
|
||||||
#define PIN_A4 (30)
|
|
||||||
#define PIN_A5 (31)
|
|
||||||
#define PIN_A6 (0xff)
|
|
||||||
#define PIN_A7 (0xff)
|
|
||||||
|
|
||||||
static const uint8_t A0 = PIN_A0;
|
|
||||||
static const uint8_t A1 = PIN_A1;
|
|
||||||
static const uint8_t A2 = PIN_A2;
|
|
||||||
static const uint8_t A3 = PIN_A3;
|
|
||||||
static const uint8_t A4 = PIN_A4;
|
|
||||||
static const uint8_t A5 = PIN_A5;
|
|
||||||
static const uint8_t A6 = PIN_A6;
|
|
||||||
static const uint8_t A7 = PIN_A7;
|
|
||||||
#define ADC_RESOLUTION 14
|
|
||||||
|
|
||||||
// Power management boot protection threshold (millivolts)
|
|
||||||
// Set to 0 to disable boot protection
|
|
||||||
#define PWRMGT_VOLTAGE_BOOTLOCK 3300 // Won't boot below this voltage (mV)
|
|
||||||
// LPCOMP wake configuration (voltage recovery from SYSTEMOFF)
|
|
||||||
// AIN3 = P0.05 = PIN_A0 / PIN_VBAT_READ
|
|
||||||
#define PWRMGT_LPCOMP_AIN 3
|
|
||||||
#define PWRMGT_LPCOMP_REFSEL 4 // 5/8 VDD (~3.13-3.44V)
|
|
||||||
|
|
||||||
// Other pins
|
|
||||||
#define PIN_AREF (2)
|
|
||||||
#define PIN_NFC1 (9)
|
|
||||||
#define PIN_NFC2 (10)
|
|
||||||
|
|
||||||
static const uint8_t AREF = PIN_AREF;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Serial interfaces
|
|
||||||
*/
|
|
||||||
// TXD1 RXD1 on Base Board
|
|
||||||
#define PIN_SERIAL1_RX (15)
|
|
||||||
#define PIN_SERIAL1_TX (16)
|
|
||||||
|
|
||||||
// TXD0 RXD0 on Base Board
|
|
||||||
#define PIN_SERIAL2_RX (19)
|
|
||||||
#define PIN_SERIAL2_TX (20)
|
|
||||||
|
|
||||||
/*
|
|
||||||
* SPI Interfaces
|
|
||||||
*/
|
|
||||||
#define SPI_INTERFACES_COUNT 1
|
|
||||||
|
|
||||||
#define PIN_SPI_MISO (29)
|
|
||||||
#define PIN_SPI_MOSI (30)
|
|
||||||
#define PIN_SPI_SCK (3)
|
|
||||||
|
|
||||||
static const uint8_t SS = 26;
|
|
||||||
static const uint8_t MOSI = PIN_SPI_MOSI;
|
|
||||||
static const uint8_t MISO = PIN_SPI_MISO;
|
|
||||||
static const uint8_t SCK = PIN_SPI_SCK;
|
|
||||||
|
|
||||||
// LoRa radio module pins for RAK4631
|
|
||||||
|
|
||||||
#define SX126X_POWER_EN (37)
|
|
||||||
#define P_LORA_RESET (38)
|
|
||||||
#define P_LORA_NSS (42)
|
|
||||||
#define P_LORA_SCLK (43)
|
|
||||||
#define P_LORA_MOSI (44)
|
|
||||||
#define P_LORA_MISO (45)
|
|
||||||
#define P_LORA_BUSY (46)
|
|
||||||
#define P_LORA_DIO_1 (47)
|
|
||||||
|
|
||||||
#define SX126X_DIO2_AS_RF_SWITCH true
|
|
||||||
#define SX126X_DIO3_TCXO_VOLTAGE 1.8
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Wire Interfaces
|
|
||||||
*/
|
|
||||||
#define WIRE_INTERFACES_COUNT 2
|
|
||||||
|
|
||||||
#define PIN_WIRE_SDA (13)
|
|
||||||
#define PIN_WIRE_SCL (14)
|
|
||||||
|
|
||||||
#define PIN_WIRE1_SDA (24)
|
|
||||||
#define PIN_WIRE1_SCL (25)
|
|
||||||
|
|
||||||
// QSPI Pins
|
|
||||||
// QSPI occupied by GPIO's
|
|
||||||
#define PIN_QSPI_SCK 3 // 19
|
|
||||||
#define PIN_QSPI_CS 26 // 17
|
|
||||||
#define PIN_QSPI_IO0 30 // 20
|
|
||||||
#define PIN_QSPI_IO1 29 // 21
|
|
||||||
#define PIN_QSPI_IO2 28 // 22
|
|
||||||
#define PIN_QSPI_IO3 2 // 23
|
|
||||||
|
|
||||||
// On-board QSPI Flash
|
|
||||||
// No onboard flash
|
|
||||||
#define EXTERNAL_FLASH_DEVICES IS25LP080D
|
|
||||||
#define EXTERNAL_FLASH_USE_QSPI
|
|
||||||
|
|
||||||
#define GPS_ADDRESS 0x42 //i2c address for GPS
|
|
||||||
|
|
||||||
|
|
||||||
// GPS L76KB
|
|
||||||
#define GPS_BAUD_RATE 9600
|
|
||||||
#define GPS_THREAD_INTERVAL 50
|
|
||||||
#define PIN_GPS_TX PIN_SERIAL1_RX
|
|
||||||
#define PIN_GPS_RX PIN_SERIAL1_TX
|
|
||||||
#define PIN_GPS_EN (33)
|
|
||||||
#define PIN_GPS_PPS (17)
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*----------------------------------------------------------------------------
|
|
||||||
* Arduino objects - C++ only
|
|
||||||
*----------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -11,7 +11,7 @@ WRAPPER_CLASS radio_driver(radio, board);
|
|||||||
|
|
||||||
VolatileRTCClock fallback_clock;
|
VolatileRTCClock fallback_clock;
|
||||||
AutoDiscoverRTCClock rtc_clock(fallback_clock);
|
AutoDiscoverRTCClock rtc_clock(fallback_clock);
|
||||||
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1, &rtc_clock);
|
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1);
|
||||||
SolarSensorManager sensors = SolarSensorManager(nmea);
|
SolarSensorManager sensors = SolarSensorManager(nmea);
|
||||||
|
|
||||||
#ifdef DISPLAY_CLASS
|
#ifdef DISPLAY_CLASS
|
||||||
|
|||||||
@@ -6,7 +6,19 @@ void HeltecTrackerV2Board::begin() {
|
|||||||
pinMode(PIN_ADC_CTRL, OUTPUT);
|
pinMode(PIN_ADC_CTRL, OUTPUT);
|
||||||
digitalWrite(PIN_ADC_CTRL, LOW); // Initially inactive
|
digitalWrite(PIN_ADC_CTRL, LOW); // Initially inactive
|
||||||
|
|
||||||
loRaFEMControl.init();
|
// Set up digital GPIO registers before releasing RTC hold. The hold latches
|
||||||
|
// the pad state including function select, so register writes accumulate
|
||||||
|
// without affecting the pad. On hold release, all changes apply atomically
|
||||||
|
// (IO MUX switches to digital GPIO with output already HIGH — no glitch).
|
||||||
|
pinMode(P_LORA_PA_POWER, OUTPUT);
|
||||||
|
digitalWrite(P_LORA_PA_POWER,HIGH);
|
||||||
|
rtc_gpio_hold_dis((gpio_num_t)P_LORA_PA_POWER);
|
||||||
|
|
||||||
|
pinMode(P_LORA_PA_EN, OUTPUT);
|
||||||
|
digitalWrite(P_LORA_PA_EN,HIGH);
|
||||||
|
rtc_gpio_hold_dis((gpio_num_t)P_LORA_PA_EN);
|
||||||
|
pinMode(P_LORA_PA_TX_EN, OUTPUT);
|
||||||
|
digitalWrite(P_LORA_PA_TX_EN,LOW);
|
||||||
|
|
||||||
esp_reset_reason_t reason = esp_reset_reason();
|
esp_reset_reason_t reason = esp_reset_reason();
|
||||||
if (reason != ESP_RST_DEEPSLEEP) {
|
if (reason != ESP_RST_DEEPSLEEP) {
|
||||||
@@ -48,13 +60,16 @@ void HeltecTrackerV2Board::begin() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void HeltecTrackerV2Board::onBeforeTransmit(void) {
|
void HeltecTrackerV2Board::onBeforeTransmit(void) {
|
||||||
digitalWrite(P_LORA_TX_LED, HIGH); // turn TX LED on
|
// GPIO46 is a strapping pin - only drive it when actively transmitting
|
||||||
loRaFEMControl.setTxModeEnable();
|
pinMode(P_LORA_PA_TX_EN, OUTPUT);
|
||||||
|
digitalWrite(P_LORA_PA_TX_EN, HIGH); // CPS=1: Enable full PA mode
|
||||||
|
digitalWrite(P_LORA_TX_LED, HIGH);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HeltecTrackerV2Board::onAfterTransmit(void) {
|
void HeltecTrackerV2Board::onAfterTransmit(void) {
|
||||||
digitalWrite(P_LORA_TX_LED, LOW); // turn TX LED off
|
digitalWrite(P_LORA_PA_TX_EN, LOW);
|
||||||
loRaFEMControl.setRxModeEnable();
|
pinMode(P_LORA_PA_TX_EN, INPUT); // Release strapping pin
|
||||||
|
digitalWrite(P_LORA_TX_LED, LOW);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HeltecTrackerV2Board::enterDeepSleep(uint32_t secs, int pin_wake_btn) {
|
void HeltecTrackerV2Board::enterDeepSleep(uint32_t secs, int pin_wake_btn) {
|
||||||
@@ -66,8 +81,11 @@ void HeltecTrackerV2Board::begin() {
|
|||||||
|
|
||||||
rtc_gpio_hold_en((gpio_num_t)P_LORA_NSS);
|
rtc_gpio_hold_en((gpio_num_t)P_LORA_NSS);
|
||||||
|
|
||||||
loRaFEMControl.setRxModeEnableWhenMCUSleep();//It also needs to be enabled in receive mode
|
// Hold GC1109 FEM pins during sleep for RX wake capability
|
||||||
rtc_gpio_hold_en((gpio_num_t)P_LORA_PA_POWER); // keep FEM power enabled during deep sleep
|
// State: CSD=1, CTX=0 (DIO2), CPS=X -> Receive LNA mode
|
||||||
|
rtc_gpio_hold_en((gpio_num_t)P_LORA_PA_POWER); // VFEM_Ctrl - keep LDO powered
|
||||||
|
rtc_gpio_hold_en((gpio_num_t)P_LORA_PA_EN); // CSD=1 - chip enabled
|
||||||
|
// Note: GPIO46 (CPS) is NOT an RTC GPIO, cannot hold - but CPS is don't care for RX
|
||||||
|
|
||||||
if (pin_wake_btn < 0) {
|
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
|
esp_sleep_enable_ext1_wakeup( (1L << P_LORA_DIO_1), ESP_EXT1_WAKEUP_ANY_HIGH); // wake up on: recv LoRa packet
|
||||||
|
|||||||
@@ -4,13 +4,11 @@
|
|||||||
#include <helpers/RefCountedDigitalPin.h>
|
#include <helpers/RefCountedDigitalPin.h>
|
||||||
#include <helpers/ESP32Board.h>
|
#include <helpers/ESP32Board.h>
|
||||||
#include <driver/rtc_io.h>
|
#include <driver/rtc_io.h>
|
||||||
#include "LoRaFEMControl.h"
|
|
||||||
|
|
||||||
class HeltecTrackerV2Board : public ESP32Board {
|
class HeltecTrackerV2Board : public ESP32Board {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
RefCountedDigitalPin periph_power;
|
RefCountedDigitalPin periph_power;
|
||||||
LoRaFEMControl loRaFEMControl;
|
|
||||||
|
|
||||||
HeltecTrackerV2Board() : periph_power(PIN_VEXT_EN,PIN_VEXT_EN_ACTIVE) { }
|
HeltecTrackerV2Board() : periph_power(PIN_VEXT_EN,PIN_VEXT_EN_ACTIVE) { }
|
||||||
|
|
||||||
|
|||||||
@@ -1,58 +0,0 @@
|
|||||||
#include "LoRaFEMControl.h"
|
|
||||||
#include <driver/rtc_io.h>
|
|
||||||
#include <esp_sleep.h>
|
|
||||||
#include <Arduino.h>
|
|
||||||
|
|
||||||
void LoRaFEMControl::init(void)
|
|
||||||
{
|
|
||||||
pinMode(P_LORA_PA_POWER, OUTPUT);
|
|
||||||
digitalWrite(P_LORA_PA_POWER, HIGH);
|
|
||||||
rtc_gpio_hold_dis((gpio_num_t)P_LORA_PA_POWER);
|
|
||||||
rtc_gpio_hold_dis((gpio_num_t)P_LORA_KCT8103L_PA_CSD);
|
|
||||||
rtc_gpio_hold_dis((gpio_num_t)P_LORA_KCT8103L_PA_CTX);
|
|
||||||
delay(1);
|
|
||||||
pinMode(P_LORA_KCT8103L_PA_CSD, OUTPUT);
|
|
||||||
digitalWrite(P_LORA_KCT8103L_PA_CSD, HIGH);
|
|
||||||
pinMode(P_LORA_KCT8103L_PA_CTX, OUTPUT);
|
|
||||||
digitalWrite(P_LORA_KCT8103L_PA_CTX, HIGH);
|
|
||||||
setLnaCanControl(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
void LoRaFEMControl::setSleepModeEnable(void)
|
|
||||||
{
|
|
||||||
// shutdown the PA
|
|
||||||
digitalWrite(P_LORA_KCT8103L_PA_CSD, LOW);
|
|
||||||
}
|
|
||||||
|
|
||||||
void LoRaFEMControl::setTxModeEnable(void)
|
|
||||||
{
|
|
||||||
digitalWrite(P_LORA_KCT8103L_PA_CSD, HIGH);
|
|
||||||
digitalWrite(P_LORA_KCT8103L_PA_CTX, HIGH);
|
|
||||||
}
|
|
||||||
|
|
||||||
void LoRaFEMControl::setRxModeEnable(void)
|
|
||||||
{
|
|
||||||
digitalWrite(P_LORA_KCT8103L_PA_CSD, HIGH);
|
|
||||||
if (lna_enabled) {
|
|
||||||
digitalWrite(P_LORA_KCT8103L_PA_CTX, LOW);
|
|
||||||
} else {
|
|
||||||
digitalWrite(P_LORA_KCT8103L_PA_CTX, HIGH);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void LoRaFEMControl::setRxModeEnableWhenMCUSleep(void)
|
|
||||||
{
|
|
||||||
digitalWrite(P_LORA_KCT8103L_PA_CSD, HIGH);
|
|
||||||
rtc_gpio_hold_en((gpio_num_t)P_LORA_KCT8103L_PA_CSD);
|
|
||||||
if (lna_enabled) {
|
|
||||||
digitalWrite(P_LORA_KCT8103L_PA_CTX, LOW);
|
|
||||||
} else {
|
|
||||||
digitalWrite(P_LORA_KCT8103L_PA_CTX, HIGH);
|
|
||||||
}
|
|
||||||
rtc_gpio_hold_en((gpio_num_t)P_LORA_KCT8103L_PA_CTX);
|
|
||||||
}
|
|
||||||
|
|
||||||
void LoRaFEMControl::setLNAEnable(bool enabled)
|
|
||||||
{
|
|
||||||
lna_enabled = enabled;
|
|
||||||
}
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
class LoRaFEMControl
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
LoRaFEMControl() {}
|
|
||||||
virtual ~LoRaFEMControl() {}
|
|
||||||
void init(void);
|
|
||||||
void setSleepModeEnable(void);
|
|
||||||
void setTxModeEnable(void);
|
|
||||||
void setRxModeEnable(void);
|
|
||||||
void setRxModeEnableWhenMCUSleep(void);
|
|
||||||
void setLNAEnable(bool enabled);
|
|
||||||
bool isLnaCanControl(void) { return lna_can_control; }
|
|
||||||
void setLnaCanControl(bool can_control) { lna_can_control = can_control; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
bool lna_enabled = false;
|
|
||||||
bool lna_can_control = false;
|
|
||||||
};
|
|
||||||
@@ -17,18 +17,20 @@ build_flags =
|
|||||||
-D P_LORA_SCLK=9
|
-D P_LORA_SCLK=9
|
||||||
-D P_LORA_MISO=11
|
-D P_LORA_MISO=11
|
||||||
-D P_LORA_MOSI=10
|
-D P_LORA_MOSI=10
|
||||||
-D P_LORA_PA_POWER=7 ;VFEM_Ctrl -LDO power enable
|
-D P_LORA_PA_POWER=7 ; VFEM_Ctrl - GC1109 LDO power enable
|
||||||
-D P_LORA_KCT8103L_PA_CSD=4
|
-D P_LORA_PA_EN=4 ; CSD - GC1109 chip enable (HIGH=on)
|
||||||
-D P_LORA_KCT8103L_PA_CTX=5
|
-D P_LORA_PA_TX_EN=46 ; CPS - GC1109 PA mode (HIGH=full PA, LOW=bypass)
|
||||||
-D LORA_TX_POWER=9 ; 9dBm + ~13dB KCT8103L gain = ~22dBm output
|
-D LORA_TX_POWER=10 ; 10dBm + ~11dB GC1109 gain = ~21dBm output
|
||||||
-D MAX_LORA_TX_POWER=22 ; Max SX1262 output -> ~28dBm at antenna
|
-D MAX_LORA_TX_POWER=22 ; Max SX1262 output -> ~28dBm at antenna
|
||||||
-D SX126X_DIO2_AS_RF_SWITCH=true
|
-D SX126X_DIO2_AS_RF_SWITCH=true
|
||||||
-D SX126X_DIO3_TCXO_VOLTAGE=1.8
|
-D SX126X_DIO3_TCXO_VOLTAGE=1.8
|
||||||
-D SX126X_CURRENT_LIMIT=140
|
-D SX126X_CURRENT_LIMIT=140
|
||||||
-D SX126X_RX_BOOSTED_GAIN=1
|
-D SX126X_RX_BOOSTED_GAIN=1
|
||||||
-D SX126X_REGISTER_PATCH=1
|
-D SX126X_REGISTER_PATCH=1
|
||||||
-D PIN_BOARD_SDA=6
|
; GC1109 FEM: TX/RX switching is handled by DIO2 -> CTX pin (via SX126X_DIO2_AS_RF_SWITCH)
|
||||||
-D PIN_BOARD_SCL=17
|
; GPIO46 is CPS (PA mode), not TX control - do not use for RF switching
|
||||||
|
-D PIN_BOARD_SDA=5
|
||||||
|
-D PIN_BOARD_SCL=6
|
||||||
-D PIN_USER_BTN=0
|
-D PIN_USER_BTN=0
|
||||||
-D PIN_TFT_SDA=42 ; SDIN
|
-D PIN_TFT_SDA=42 ; SDIN
|
||||||
-D PIN_TFT_SCL=41 ; SCLK
|
-D PIN_TFT_SCL=41 ; SCLK
|
||||||
@@ -207,6 +209,8 @@ build_flags =
|
|||||||
-D ADVERT_LAT=0.0
|
-D ADVERT_LAT=0.0
|
||||||
-D ADVERT_LON=0.0
|
-D ADVERT_LON=0.0
|
||||||
-D ADMIN_PASSWORD='"password"'
|
-D ADMIN_PASSWORD='"password"'
|
||||||
|
-D ENV_PIN_SDA=3
|
||||||
|
-D ENV_PIN_SCL=4
|
||||||
-D DISPLAY_CLASS=ST7735Display
|
-D DISPLAY_CLASS=ST7735Display
|
||||||
; -D MESH_PACKET_LOGGING=1
|
; -D MESH_PACKET_LOGGING=1
|
||||||
; -D MESH_DEBUG=1
|
; -D MESH_DEBUG=1
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ AutoDiscoverRTCClock rtc_clock(fallback_clock);
|
|||||||
|
|
||||||
#if ENV_INCLUDE_GPS
|
#if ENV_INCLUDE_GPS
|
||||||
#include <helpers/sensors/MicroNMEALocationProvider.h>
|
#include <helpers/sensors/MicroNMEALocationProvider.h>
|
||||||
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1, &rtc_clock, GPS_RESET, GPS_EN, &board.periph_power);
|
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1, NULL, GPS_RESET, GPS_EN, &board.periph_power);
|
||||||
EnvironmentSensorManager sensors = EnvironmentSensorManager(nmea);
|
EnvironmentSensorManager sensors = EnvironmentSensorManager(nmea);
|
||||||
#else
|
#else
|
||||||
EnvironmentSensorManager sensors;
|
EnvironmentSensorManager sensors;
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ AutoDiscoverRTCClock rtc_clock(fallback_clock);
|
|||||||
|
|
||||||
#if ENV_INCLUDE_GPS
|
#if ENV_INCLUDE_GPS
|
||||||
#include <helpers/sensors/MicroNMEALocationProvider.h>
|
#include <helpers/sensors/MicroNMEALocationProvider.h>
|
||||||
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1, &rtc_clock);
|
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1);
|
||||||
EnvironmentSensorManager sensors = EnvironmentSensorManager(nmea);
|
EnvironmentSensorManager sensors = EnvironmentSensorManager(nmea);
|
||||||
#else
|
#else
|
||||||
EnvironmentSensorManager sensors;
|
EnvironmentSensorManager sensors;
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ AutoDiscoverRTCClock rtc_clock(fallback_clock);
|
|||||||
|
|
||||||
#if ENV_INCLUDE_GPS
|
#if ENV_INCLUDE_GPS
|
||||||
#include <helpers/sensors/MicroNMEALocationProvider.h>
|
#include <helpers/sensors/MicroNMEALocationProvider.h>
|
||||||
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1, &rtc_clock);
|
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1);
|
||||||
EnvironmentSensorManager sensors = EnvironmentSensorManager(nmea);
|
EnvironmentSensorManager sensors = EnvironmentSensorManager(nmea);
|
||||||
#else
|
#else
|
||||||
EnvironmentSensorManager sensors;
|
EnvironmentSensorManager sensors;
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ VolatileRTCClock fallback_clock;
|
|||||||
AutoDiscoverRTCClock rtc_clock(fallback_clock);
|
AutoDiscoverRTCClock rtc_clock(fallback_clock);
|
||||||
#if ENV_INCLUDE_GPS
|
#if ENV_INCLUDE_GPS
|
||||||
#include <helpers/sensors/MicroNMEALocationProvider.h>
|
#include <helpers/sensors/MicroNMEALocationProvider.h>
|
||||||
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1, &rtc_clock);
|
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1);
|
||||||
EnvironmentSensorManager sensors = EnvironmentSensorManager(nmea);
|
EnvironmentSensorManager sensors = EnvironmentSensorManager(nmea);
|
||||||
#else
|
#else
|
||||||
EnvironmentSensorManager sensors;
|
EnvironmentSensorManager sensors;
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ AutoDiscoverRTCClock rtc_clock(fallback_clock);
|
|||||||
|
|
||||||
#if ENV_INCLUDE_GPS
|
#if ENV_INCLUDE_GPS
|
||||||
#include <helpers/sensors/MicroNMEALocationProvider.h>
|
#include <helpers/sensors/MicroNMEALocationProvider.h>
|
||||||
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1, &rtc_clock);
|
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1);
|
||||||
EnvironmentSensorManager sensors = EnvironmentSensorManager(nmea);
|
EnvironmentSensorManager sensors = EnvironmentSensorManager(nmea);
|
||||||
#else
|
#else
|
||||||
EnvironmentSensorManager sensors;
|
EnvironmentSensorManager sensors;
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ AutoDiscoverRTCClock rtc_clock(fallback_clock);
|
|||||||
|
|
||||||
#if ENV_INCLUDE_GPS
|
#if ENV_INCLUDE_GPS
|
||||||
#include <helpers/sensors/MicroNMEALocationProvider.h>
|
#include <helpers/sensors/MicroNMEALocationProvider.h>
|
||||||
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1, &rtc_clock);
|
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1);
|
||||||
EnvironmentSensorManager sensors = EnvironmentSensorManager(nmea);
|
EnvironmentSensorManager sensors = EnvironmentSensorManager(nmea);
|
||||||
#else
|
#else
|
||||||
EnvironmentSensorManager sensors;
|
EnvironmentSensorManager sensors;
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ AutoDiscoverRTCClock rtc_clock(fallback_clock);
|
|||||||
|
|
||||||
#if ENV_INCLUDE_GPS
|
#if ENV_INCLUDE_GPS
|
||||||
#include <helpers/sensors/MicroNMEALocationProvider.h>
|
#include <helpers/sensors/MicroNMEALocationProvider.h>
|
||||||
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1, &rtc_clock);
|
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1);
|
||||||
EnvironmentSensorManager sensors = EnvironmentSensorManager(nmea);
|
EnvironmentSensorManager sensors = EnvironmentSensorManager(nmea);
|
||||||
#else
|
#else
|
||||||
EnvironmentSensorManager sensors;
|
EnvironmentSensorManager sensors;
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ AutoDiscoverRTCClock rtc_clock(fallback_clock);
|
|||||||
|
|
||||||
#if ENV_INCLUDE_GPS
|
#if ENV_INCLUDE_GPS
|
||||||
#include <helpers/sensors/MicroNMEALocationProvider.h>
|
#include <helpers/sensors/MicroNMEALocationProvider.h>
|
||||||
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1, &rtc_clock);
|
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1);
|
||||||
EnvironmentSensorManager sensors = EnvironmentSensorManager(nmea);
|
EnvironmentSensorManager sensors = EnvironmentSensorManager(nmea);
|
||||||
#else
|
#else
|
||||||
EnvironmentSensorManager sensors;
|
EnvironmentSensorManager sensors;
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ WRAPPER_CLASS radio_driver(radio, board);
|
|||||||
|
|
||||||
ESP32RTCClock fallback_clock;
|
ESP32RTCClock fallback_clock;
|
||||||
AutoDiscoverRTCClock rtc_clock(fallback_clock);
|
AutoDiscoverRTCClock rtc_clock(fallback_clock);
|
||||||
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1, &rtc_clock);
|
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1);
|
||||||
MASensorManager sensors = MASensorManager(nmea);
|
MASensorManager sensors = MASensorManager(nmea);
|
||||||
|
|
||||||
#ifdef DISPLAY_CLASS
|
#ifdef DISPLAY_CLASS
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ WRAPPER_CLASS radio_driver(radio, board);
|
|||||||
|
|
||||||
VolatileRTCClock fallback_clock;
|
VolatileRTCClock fallback_clock;
|
||||||
AutoDiscoverRTCClock rtc_clock(fallback_clock);
|
AutoDiscoverRTCClock rtc_clock(fallback_clock);
|
||||||
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1, &rtc_clock);
|
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1);
|
||||||
NanoG2UltraSensorManager sensors = NanoG2UltraSensorManager(nmea);
|
NanoG2UltraSensorManager sensors = NanoG2UltraSensorManager(nmea);
|
||||||
|
|
||||||
#ifdef DISPLAY_CLASS
|
#ifdef DISPLAY_CLASS
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ VolatileRTCClock fallback_clock;
|
|||||||
AutoDiscoverRTCClock rtc_clock(fallback_clock);
|
AutoDiscoverRTCClock rtc_clock(fallback_clock);
|
||||||
#if ENV_INCLUDE_GPS
|
#if ENV_INCLUDE_GPS
|
||||||
#include <helpers/sensors/MicroNMEALocationProvider.h>
|
#include <helpers/sensors/MicroNMEALocationProvider.h>
|
||||||
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1, &rtc_clock);
|
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1);
|
||||||
EnvironmentSensorManager sensors = EnvironmentSensorManager(nmea);
|
EnvironmentSensorManager sensors = EnvironmentSensorManager(nmea);
|
||||||
#else
|
#else
|
||||||
EnvironmentSensorManager sensors;
|
EnvironmentSensorManager sensors;
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ AutoDiscoverRTCClock rtc_clock(fallback_clock);
|
|||||||
|
|
||||||
#if ENV_INCLUDE_GPS
|
#if ENV_INCLUDE_GPS
|
||||||
#include <helpers/sensors/MicroNMEALocationProvider.h>
|
#include <helpers/sensors/MicroNMEALocationProvider.h>
|
||||||
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1, &rtc_clock);
|
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1);
|
||||||
EnvironmentSensorManager sensors = EnvironmentSensorManager(nmea);
|
EnvironmentSensorManager sensors = EnvironmentSensorManager(nmea);
|
||||||
#else
|
#else
|
||||||
EnvironmentSensorManager sensors;
|
EnvironmentSensorManager sensors;
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ AutoDiscoverRTCClock rtc_clock(fallback_clock);
|
|||||||
|
|
||||||
#if ENV_INCLUDE_GPS
|
#if ENV_INCLUDE_GPS
|
||||||
#include <helpers/sensors/MicroNMEALocationProvider.h>
|
#include <helpers/sensors/MicroNMEALocationProvider.h>
|
||||||
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1, &rtc_clock);
|
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1);
|
||||||
EnvironmentSensorManager sensors = EnvironmentSensorManager(nmea);
|
EnvironmentSensorManager sensors = EnvironmentSensorManager(nmea);
|
||||||
#else
|
#else
|
||||||
EnvironmentSensorManager sensors;
|
EnvironmentSensorManager sensors;
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ AutoDiscoverRTCClock rtc_clock(fallback_clock);
|
|||||||
|
|
||||||
#if ENV_INCLUDE_GPS
|
#if ENV_INCLUDE_GPS
|
||||||
#include <helpers/sensors/MicroNMEALocationProvider.h>
|
#include <helpers/sensors/MicroNMEALocationProvider.h>
|
||||||
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1, &rtc_clock);
|
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1);
|
||||||
EnvironmentSensorManager sensors = EnvironmentSensorManager(nmea);
|
EnvironmentSensorManager sensors = EnvironmentSensorManager(nmea);
|
||||||
#else
|
#else
|
||||||
EnvironmentSensorManager sensors;
|
EnvironmentSensorManager sensors;
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ AutoDiscoverRTCClock rtc_clock(fallback_clock);
|
|||||||
|
|
||||||
#if ENV_INCLUDE_GPS
|
#if ENV_INCLUDE_GPS
|
||||||
#include <helpers/sensors/MicroNMEALocationProvider.h>
|
#include <helpers/sensors/MicroNMEALocationProvider.h>
|
||||||
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1, &rtc_clock);
|
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1);
|
||||||
EnvironmentSensorManager sensors = EnvironmentSensorManager(nmea);
|
EnvironmentSensorManager sensors = EnvironmentSensorManager(nmea);
|
||||||
#else
|
#else
|
||||||
EnvironmentSensorManager sensors;
|
EnvironmentSensorManager sensors;
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ build_flags = ${nrf52_base.build_flags}
|
|||||||
-I lib/nrf52/s140_nrf52_7.3.0_API/include/nrf52
|
-I lib/nrf52/s140_nrf52_7.3.0_API/include/nrf52
|
||||||
-I variants/sensecap_solar
|
-I variants/sensecap_solar
|
||||||
-I src/helpers/nrf52
|
-I src/helpers/nrf52
|
||||||
|
-UENV_INCLUDE_GPS
|
||||||
-D NRF52_PLATFORM=1
|
-D NRF52_PLATFORM=1
|
||||||
-D RADIO_CLASS=CustomSX1262
|
-D RADIO_CLASS=CustomSX1262
|
||||||
-D WRAPPER_CLASS=CustomSX1262Wrapper
|
-D WRAPPER_CLASS=CustomSX1262Wrapper
|
||||||
@@ -23,7 +24,6 @@ build_flags = ${nrf52_base.build_flags}
|
|||||||
-D SX126X_DIO3_TCXO_VOLTAGE=1.8
|
-D SX126X_DIO3_TCXO_VOLTAGE=1.8
|
||||||
-D SX126X_CURRENT_LIMIT=140
|
-D SX126X_CURRENT_LIMIT=140
|
||||||
-D SX126X_RX_BOOSTED_GAIN=1
|
-D SX126X_RX_BOOSTED_GAIN=1
|
||||||
-D ENV_INCLUDE_GPS=1
|
|
||||||
build_src_filter = ${nrf52_base.build_src_filter}
|
build_src_filter = ${nrf52_base.build_src_filter}
|
||||||
+<helpers/*.cpp>
|
+<helpers/*.cpp>
|
||||||
+<helpers/sensors>
|
+<helpers/sensors>
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include "target.h"
|
#include "target.h"
|
||||||
#include <helpers/ArduinoHelpers.h>
|
#include <helpers/ArduinoHelpers.h>
|
||||||
#ifdef ENV_INCLUDE_GPS
|
|
||||||
#include <helpers/sensors/MicroNMEALocationProvider.h>
|
|
||||||
#endif
|
|
||||||
SenseCapSolarBoard board;
|
SenseCapSolarBoard board;
|
||||||
|
|
||||||
RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY, SPI);
|
RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY, SPI);
|
||||||
@@ -12,12 +10,7 @@ WRAPPER_CLASS radio_driver(radio, board);
|
|||||||
|
|
||||||
VolatileRTCClock fallback_clock;
|
VolatileRTCClock fallback_clock;
|
||||||
AutoDiscoverRTCClock rtc_clock(fallback_clock);
|
AutoDiscoverRTCClock rtc_clock(fallback_clock);
|
||||||
#ifdef ENV_INCLUDE_GPS
|
EnvironmentSensorManager sensors;
|
||||||
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1, &rtc_clock);
|
|
||||||
EnvironmentSensorManager sensors = EnvironmentSensorManager(nmea);
|
|
||||||
#else
|
|
||||||
EnvironmentSensorManager sensors = EnvironmentSensorManager();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
bool radio_init() {
|
bool radio_init() {
|
||||||
rtc_clock.begin(Wire);
|
rtc_clock.begin(Wire);
|
||||||
|
|||||||
@@ -18,8 +18,8 @@ const uint32_t g_ADigitalPinMap[] = {
|
|||||||
47, // D10 P1.15 (SPI_MOSI) LORA_MOSI
|
47, // D10 P1.15 (SPI_MOSI) LORA_MOSI
|
||||||
|
|
||||||
// D11-D12 - LED outputs
|
// D11-D12 - LED outputs
|
||||||
15, // D11 P0.15 User LED (White LED)
|
15, // D11 P0.15 User LED
|
||||||
19, // D12 P0.19 Breathing LED (Blue LED - LoRa TX)
|
19, // D12 P0.19 Breathing LED
|
||||||
|
|
||||||
// D13 - User input
|
// D13 - User input
|
||||||
33, // D13 P1.01 User Button
|
33, // D13 P1.01 User Button
|
||||||
@@ -58,9 +58,14 @@ void initVariant() {
|
|||||||
pinMode(PIN_QSPI_CS, OUTPUT);
|
pinMode(PIN_QSPI_CS, OUTPUT);
|
||||||
digitalWrite(PIN_QSPI_CS, HIGH);
|
digitalWrite(PIN_QSPI_CS, HIGH);
|
||||||
|
|
||||||
pinMode(LED_WHITE, OUTPUT);
|
pinMode(LED_GREEN, OUTPUT);
|
||||||
digitalWrite(LED_WHITE, LOW);
|
digitalWrite(LED_GREEN, LOW);
|
||||||
|
|
||||||
pinMode(LED_BLUE, OUTPUT);
|
pinMode(LED_BLUE, OUTPUT);
|
||||||
digitalWrite(LED_BLUE, LOW);
|
digitalWrite(LED_BLUE, LOW);
|
||||||
|
|
||||||
|
/* disable gps until we actually support it.
|
||||||
|
pinMode(GPS_EN, OUTPUT);
|
||||||
|
digitalWrite(GPS_EN, HIGH);
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
@@ -24,8 +24,8 @@
|
|||||||
#define LED_BUILTIN (PIN_LED)
|
#define LED_BUILTIN (PIN_LED)
|
||||||
|
|
||||||
#define LED_RED (PINS_COUNT)
|
#define LED_RED (PINS_COUNT)
|
||||||
#define LED_WHITE (11)
|
#define LED_GREEN (12)
|
||||||
#define LED_BLUE (12) // LoRa TX indicator
|
#define LED_BLUE (11)
|
||||||
|
|
||||||
#define LED_STATE_ON (1) // State when LED is litted
|
#define LED_STATE_ON (1) // State when LED is litted
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ static unsigned int ntc_res2[136] = {
|
|||||||
1081, 1053, 1026, 999, 974, 949, 925, 902, 880, 858,
|
1081, 1053, 1026, 999, 974, 949, 925, 902, 880, 858,
|
||||||
};
|
};
|
||||||
|
|
||||||
static int8_t ntc_temp2[136] = {
|
static char ntc_temp2[136] = {
|
||||||
-30, -29, -28, -27, -26, -25, -24, -23, -22, -21, -20, -19, -18, -17, -16, -15, -14, -13, -12, -11,
|
-30, -29, -28, -27, -26, -25, -24, -23, -22, -21, -20, -19, -18, -17, -16, -15, -14, -13, -12, -11,
|
||||||
-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
|
-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 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,
|
10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ WRAPPER_CLASS radio_driver(radio, board);
|
|||||||
VolatileRTCClock fallback_clock;
|
VolatileRTCClock fallback_clock;
|
||||||
AutoDiscoverRTCClock rtc_clock(fallback_clock);
|
AutoDiscoverRTCClock rtc_clock(fallback_clock);
|
||||||
#ifdef ENV_INCLUDE_GPS
|
#ifdef ENV_INCLUDE_GPS
|
||||||
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1, &rtc_clock);
|
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1);
|
||||||
EnvironmentSensorManager sensors = EnvironmentSensorManager(nmea);
|
EnvironmentSensorManager sensors = EnvironmentSensorManager(nmea);
|
||||||
#else
|
#else
|
||||||
EnvironmentSensorManager sensors = EnvironmentSensorManager();
|
EnvironmentSensorManager sensors = EnvironmentSensorManager();
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ AutoDiscoverRTCClock rtc_clock(fallback_clock);
|
|||||||
|
|
||||||
#if ENV_INCLUDE_GPS
|
#if ENV_INCLUDE_GPS
|
||||||
#include <helpers/sensors/MicroNMEALocationProvider.h>
|
#include <helpers/sensors/MicroNMEALocationProvider.h>
|
||||||
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1, &rtc_clock);
|
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1);
|
||||||
EnvironmentSensorManager sensors = EnvironmentSensorManager(nmea);
|
EnvironmentSensorManager sensors = EnvironmentSensorManager(nmea);
|
||||||
#else
|
#else
|
||||||
EnvironmentSensorManager sensors;
|
EnvironmentSensorManager sensors;
|
||||||
|
|||||||
Reference in new issue
Block a user