mirror of https://github.com/meshcore-dev/MeshCore
committed by
GitHub
145 changed files with 3508 additions and 664 deletions
@ -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", "0x1001"]], |
||||
|
"mcu": "esp32s3", |
||||
|
"variant": "heltec_v4_r8" |
||||
|
}, |
||||
|
"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 v4 r8 (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,42 @@ |
|||||
|
{ |
||||
|
"build": { |
||||
|
"arduino": { |
||||
|
"ldscript": "esp32s3_out.ld", |
||||
|
"memory_type": "qio_opi" |
||||
|
}, |
||||
|
"core": "esp32", |
||||
|
"extra_flags": [ |
||||
|
"-D BOARD_HAS_PSRAM", |
||||
|
"-D ARDUINO_USB_CDC_ON_BOOT=0", |
||||
|
"-D ARDUINO_USB_MODE=0", |
||||
|
"-D ARDUINO_RUNNING_CORE=1", |
||||
|
"-D ARDUINO_EVENT_RUNNING_CORE=0" |
||||
|
], |
||||
|
"f_cpu": "240000000L", |
||||
|
"f_flash": "80000000L", |
||||
|
"flash_mode": "qio", |
||||
|
"psram_type": "qio_opi", |
||||
|
"hwids": [["0x303A", "0x1001"]], |
||||
|
"mcu": "esp32s3", |
||||
|
"variant": "ELECROW-ThinkNode-M7" |
||||
|
}, |
||||
|
"connectivity": ["wifi", "bluetooth", "lora"], |
||||
|
"debug": { |
||||
|
"default_tool": "esp-builtin", |
||||
|
"onboard_tools": ["esp-builtin"], |
||||
|
"openocd_target": "esp32s3.cfg" |
||||
|
}, |
||||
|
"frameworks": ["arduino", "espidf"], |
||||
|
"name": "ELECROW ThinkNode M7", |
||||
|
"upload": { |
||||
|
"flash_size": "8MB", |
||||
|
"maximum_ram_size": 524288, |
||||
|
"maximum_size": 8388608, |
||||
|
"use_1200bps_touch": true, |
||||
|
"wait_for_upload_port": true, |
||||
|
"require_upload_port": true, |
||||
|
"speed": 921600 |
||||
|
}, |
||||
|
"url": "https://www.elecrow.com", |
||||
|
"vendor": "ELECROW" |
||||
|
} |
||||
@ -0,0 +1,57 @@ |
|||||
|
{ |
||||
|
"build": { |
||||
|
"arduino": { |
||||
|
"ldscript": "esp32s3_out.ld", |
||||
|
"memory_type": "qio_opi", |
||||
|
"partitions": "default_16MB.csv" |
||||
|
}, |
||||
|
"core": "esp32", |
||||
|
"extra_flags": [ |
||||
|
"-DBOARD_HAS_PSRAM", |
||||
|
"-DARDUINO_USB_CDC_ON_BOOT=0", |
||||
|
"-DARDUINO_USB_MODE=0", |
||||
|
"-DARDUINO_RUNNING_CORE=1", |
||||
|
"-DARDUINO_EVENT_RUNNING_CORE=0" |
||||
|
], |
||||
|
"f_cpu": "240000000L", |
||||
|
"f_flash": "80000000L", |
||||
|
"flash_mode": "qio", |
||||
|
"psram_type": "qio_opi", |
||||
|
"hwids": [ |
||||
|
[ |
||||
|
"0x303A", |
||||
|
"0x1001" |
||||
|
] |
||||
|
], |
||||
|
"mcu": "esp32s3", |
||||
|
"variant": "ELECROW-ThinkNode-M9" |
||||
|
}, |
||||
|
"connectivity": [ |
||||
|
"wifi", |
||||
|
"bluetooth", |
||||
|
"lora" |
||||
|
], |
||||
|
"debug": { |
||||
|
"default_tool": "esp-builtin", |
||||
|
"onboard_tools": [ |
||||
|
"esp-builtin" |
||||
|
], |
||||
|
"openocd_target": "esp32s3.cfg" |
||||
|
}, |
||||
|
"frameworks": [ |
||||
|
"arduino", |
||||
|
"espidf" |
||||
|
], |
||||
|
"name": "elecrow-thinknode-m9", |
||||
|
"upload": { |
||||
|
"flash_size": "16MB", |
||||
|
"maximum_ram_size": 524288, |
||||
|
"maximum_size": 16777216, |
||||
|
"use_1200bps_touch": true, |
||||
|
"wait_for_upload_port": true, |
||||
|
"require_upload_port": true, |
||||
|
"speed": 921600 |
||||
|
}, |
||||
|
"url": "https://www.elecrow.com/thinknode-m1-meshtastic-lora-signal-transceiver-powered-by-nrf52840-with-154-screen-support-gps.html", |
||||
|
"vendor": "ELECROW" |
||||
|
} |
||||
@ -1,11 +1,12 @@ |
|||||
{ pkgs ? import <nixpkgs> {} }: |
{pkgs ? import <nixpkgs> {}}: let |
||||
let |
|
||||
in |
in |
||||
pkgs.mkShell { |
pkgs.mkShell { |
||||
buildInputs = [ |
buildInputs = [ |
||||
pkgs.platformio |
pkgs.platformio |
||||
pkgs.python3 |
pkgs.python3 |
||||
|
pkgs.gcc |
||||
|
pkgs.gtest |
||||
# optional: needed as a programmer i.e. for esp32 |
# optional: needed as a programmer i.e. for esp32 |
||||
pkgs.avrdude |
pkgs.avrdude |
||||
]; |
]; |
||||
} |
} |
||||
|
|||||
@ -18,6 +18,7 @@ Once you have a working app/project, you need to be able to demonstrate it exist |
|||||
| 0100 | MeshCore Open | [email protected] — https://github.com/zjs81/meshcore-open | |
| 0100 | MeshCore Open | [email protected] — https://github.com/zjs81/meshcore-open | |
||||
| 0110 - 011F | Ripple | [email protected] — https://buymeacoffee.com/ripplebiz | |
| 0110 - 011F | Ripple | [email protected] — https://buymeacoffee.com/ripplebiz | |
||||
| 0120 | MCO Advanced | [email protected] — https://hdden.ru/MCOa/ | |
| 0120 | MCO Advanced | [email protected] — https://hdden.ru/MCOa/ | |
||||
|
| 0130 - 013F | StreamSensor | [email protected] - https://housedillon.com/blog/lora-e5-with-seeed-fusion | |
||||
| FF00 - FFFF | -reserved for testing/dev- | | |
| FF00 - FFFF | -reserved for testing/dev- | | |
||||
|
|
||||
(add rows, inside the range 0100 - FEFF for custom apps) |
(add rows, inside the range 0100 - FEFF for custom apps) |
||||
|
|||||
@ -0,0 +1,12 @@ |
|||||
|
#pragma once |
||||
|
|
||||
|
class ExternalWatchdogManager { |
||||
|
protected: |
||||
|
unsigned long last_feed_watchdog; |
||||
|
public: |
||||
|
ExternalWatchdogManager() { last_feed_watchdog = 0; } |
||||
|
virtual bool begin() { return false; } |
||||
|
virtual void loop() { } |
||||
|
virtual unsigned long getIntervalMs() const { return 0; } |
||||
|
virtual void feed() { } |
||||
|
}; |
||||
@ -0,0 +1,157 @@ |
|||||
|
#pragma once |
||||
|
|
||||
|
#ifdef ETHERNET_ENABLED |
||||
|
|
||||
|
#include <Arduino.h> |
||||
|
#include <SPI.h> |
||||
|
#include <RAK13800_W5100S.h> |
||||
|
#include <helpers/nrf52/EthernetMac.h> |
||||
|
|
||||
|
#define PIN_SPI1_MISO (29) |
||||
|
#define PIN_SPI1_MOSI (30) |
||||
|
#define PIN_SPI1_SCK (3) |
||||
|
|
||||
|
static SPIClass ETHERNET_SPI_PORT(NRF_SPIM1, PIN_SPI1_MISO, PIN_SPI1_SCK, PIN_SPI1_MOSI); |
||||
|
|
||||
|
#define PIN_ETHERNET_POWER_EN WB_IO2 |
||||
|
#define PIN_ETHERNET_RESET 21 |
||||
|
#define PIN_ETHERNET_SS 26 |
||||
|
|
||||
|
#ifndef ETHERNET_TCP_PORT |
||||
|
#define ETHERNET_TCP_PORT 23 // telnet port for CLI access
|
||||
|
#endif |
||||
|
|
||||
|
#ifndef ETHERNET_CLI_BANNER |
||||
|
#define ETHERNET_CLI_BANNER "MeshCore CLI" |
||||
|
#endif |
||||
|
|
||||
|
#define ETHERNET_RETRY_INTERVAL_MS 30000 |
||||
|
|
||||
|
static EthernetServer ethernet_server(ETHERNET_TCP_PORT); |
||||
|
static EthernetClient ethernet_client; |
||||
|
static volatile bool ethernet_running = false; |
||||
|
|
||||
|
// FreeRTOS task: handles hw init, DHCP, and retries in the background
|
||||
|
static void ethernet_task(void* param) { |
||||
|
(void)param; |
||||
|
|
||||
|
Serial.println("ETH: Initializing hardware"); |
||||
|
// WB_IO2 (power enable) is already driven HIGH by early constructor
|
||||
|
// in RAK4631Board.cpp to support POE boot.
|
||||
|
// Skip hardware reset — the W5100S comes out of power-on reset cleanly,
|
||||
|
// and toggling reset kills the PHY link which breaks POE power.
|
||||
|
pinMode(PIN_ETHERNET_RESET, OUTPUT); |
||||
|
digitalWrite(PIN_ETHERNET_RESET, HIGH); |
||||
|
|
||||
|
ETHERNET_SPI_PORT.begin(); |
||||
|
Ethernet.init(ETHERNET_SPI_PORT, PIN_ETHERNET_SS); |
||||
|
|
||||
|
uint8_t mac[6]; |
||||
|
generateEthernetMac(mac); |
||||
|
Serial.printf("ETH: MAC: %02X:%02X:%02X:%02X:%02X:%02X\n", |
||||
|
mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); |
||||
|
|
||||
|
// Retry loop: keep trying until we get an IP
|
||||
|
while (!ethernet_running) { |
||||
|
Serial.println("ETH: Attempting DHCP..."); |
||||
|
if (Ethernet.begin(mac, 10000, 2000) == 0) { |
||||
|
if (Ethernet.hardwareStatus() == EthernetNoHardware) { |
||||
|
Serial.println("ETH: Hardware not found, giving up"); |
||||
|
vTaskDelete(NULL); |
||||
|
return; |
||||
|
} |
||||
|
if (Ethernet.linkStatus() == LinkOFF) { |
||||
|
Serial.println("ETH: Cable not connected, will retry"); |
||||
|
} else { |
||||
|
Serial.println("ETH: DHCP failed, will retry"); |
||||
|
} |
||||
|
vTaskDelay(pdMS_TO_TICKS(ETHERNET_RETRY_INTERVAL_MS)); |
||||
|
continue; |
||||
|
} |
||||
|
|
||||
|
IPAddress ip = Ethernet.localIP(); |
||||
|
Serial.printf("ETH: IP: %u.%u.%u.%u\n", ip[0], ip[1], ip[2], ip[3]); |
||||
|
Serial.printf("ETH: Listening on TCP port %d\n", ETHERNET_TCP_PORT); |
||||
|
ethernet_server.begin(); |
||||
|
ethernet_running = true; |
||||
|
} |
||||
|
|
||||
|
// DHCP succeeded, task is done
|
||||
|
vTaskDelete(NULL); |
||||
|
} |
||||
|
|
||||
|
static void ethernet_start_task() { |
||||
|
xTaskCreate(ethernet_task, "eth_init", 1024, NULL, 1, NULL); |
||||
|
} |
||||
|
|
||||
|
// Format ethernet status into reply buffer. Returns true if command was handled.
|
||||
|
static bool ethernet_handle_command(const char* command, char* reply) { |
||||
|
if (strcmp(command, "eth.status") == 0) { |
||||
|
if (!ethernet_running) { |
||||
|
strcpy(reply, "ETH: not connected"); |
||||
|
} else { |
||||
|
IPAddress ip = Ethernet.localIP(); |
||||
|
sprintf(reply, "ETH: %u.%u.%u.%u:%d", ip[0], ip[1], ip[2], ip[3], ETHERNET_TCP_PORT); |
||||
|
} |
||||
|
return true; |
||||
|
} |
||||
|
return false; |
||||
|
} |
||||
|
|
||||
|
// Check for new TCP client connections, replacing any existing connection.
|
||||
|
// Use accept() (not available()) so we only see newly-accepted sockets;
|
||||
|
// available() also returns existing connected sockets that have data, which
|
||||
|
// would force us to disambiguate every inbound packet from a real new client.
|
||||
|
static void ethernet_check_client() { |
||||
|
auto newClient = ethernet_server.accept(); |
||||
|
if (newClient) { |
||||
|
if (ethernet_client) ethernet_client.stop(); |
||||
|
ethernet_client = newClient; |
||||
|
IPAddress ip = ethernet_client.remoteIP(); |
||||
|
Serial.printf("ETH: Client connected from %u.%u.%u.%u\n", ip[0], ip[1], ip[2], ip[3]); |
||||
|
ethernet_client.println(ETHERNET_CLI_BANNER); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
// Call from loop() to maintain DHCP and check for new clients
|
||||
|
static void ethernet_loop_maintain() { |
||||
|
if (ethernet_running) { |
||||
|
ethernet_check_client(); |
||||
|
Ethernet.maintain(); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
// Read a line from the Ethernet client into the command buffer.
|
||||
|
// Returns true when a complete line is ready to process (command is null-terminated).
|
||||
|
// The caller should process the command and then reset ethernet_command[0] = 0.
|
||||
|
static bool ethernet_read_line(char* ethernet_command, size_t buf_size) { |
||||
|
if (!ethernet_running || !ethernet_client || !ethernet_client.connected()) return false; |
||||
|
|
||||
|
int elen = strlen(ethernet_command); |
||||
|
while (ethernet_client.available() && elen < (int)buf_size - 1) { |
||||
|
char c = ethernet_client.read(); |
||||
|
if (c == '\n' && elen == 0) continue; // ignore leading LF (from CR+LF)
|
||||
|
if (c == '\r' || c == '\n') { ethernet_command[elen++] = '\r'; break; } |
||||
|
ethernet_command[elen++] = c; |
||||
|
ethernet_command[elen] = 0; |
||||
|
} |
||||
|
if (elen == (int)buf_size - 1) { |
||||
|
ethernet_command[buf_size - 1] = '\r'; |
||||
|
} |
||||
|
|
||||
|
if (elen > 0 && ethernet_command[elen - 1] == '\r') { |
||||
|
ethernet_command[elen - 1] = 0; |
||||
|
ethernet_client.println(); |
||||
|
return true; |
||||
|
} |
||||
|
return false; |
||||
|
} |
||||
|
|
||||
|
// Send a reply to the Ethernet client
|
||||
|
static void ethernet_send_reply(const char* reply) { |
||||
|
if (reply[0]) { |
||||
|
ethernet_client.print(" -> "); ethernet_client.println(reply); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
#endif // ETHERNET_ENABLED
|
||||
@ -0,0 +1,13 @@ |
|||||
|
#pragma once |
||||
|
|
||||
|
#include <Arduino.h> |
||||
|
|
||||
|
static inline void generateEthernetMac(uint8_t mac[6]) { |
||||
|
uint32_t device_id = NRF_FICR->DEVICEID[0]; |
||||
|
mac[0] = 0x02; |
||||
|
mac[1] = 0x92; |
||||
|
mac[2] = 0x1F; |
||||
|
mac[3] = (device_id >> 16) & 0xFF; |
||||
|
mac[4] = (device_id >> 8) & 0xFF; |
||||
|
mac[5] = device_id & 0xFF; |
||||
|
} |
||||
@ -0,0 +1,264 @@ |
|||||
|
#include "SerialEthernetInterface.h" |
||||
|
#include "EthernetMac.h" |
||||
|
#include <SPI.h> |
||||
|
#include <EthernetUdp.h> |
||||
|
|
||||
|
#define PIN_SPI1_MISO (29) // (0 + 29)
|
||||
|
#define PIN_SPI1_MOSI (30) // (0 + 30)
|
||||
|
#define PIN_SPI1_SCK (3) // (0 + 3)
|
||||
|
|
||||
|
SPIClass ETHERNET_SPI_PORT(NRF_SPIM1, PIN_SPI1_MISO, PIN_SPI1_SCK, PIN_SPI1_MOSI); |
||||
|
|
||||
|
#define PIN_ETHERNET_POWER_EN WB_IO2 // output, high to enable
|
||||
|
#define PIN_ETHERNET_RESET 21 |
||||
|
#define PIN_ETHERNET_SS 26 |
||||
|
|
||||
|
#define RECV_STATE_IDLE 0 |
||||
|
#define RECV_STATE_HDR_FOUND 1 |
||||
|
#define RECV_STATE_LEN1_FOUND 2 |
||||
|
#define RECV_STATE_LEN2_FOUND 3 |
||||
|
|
||||
|
bool SerialEthernetInterface::begin() { |
||||
|
|
||||
|
ETHERNET_DEBUG_PRINTLN("Ethernet initializing"); |
||||
|
|
||||
|
// WB_IO2 (power enable) is already driven HIGH by early constructor
|
||||
|
// in RAK4631Board.cpp to support POE boot.
|
||||
|
// Skip hardware reset — the W5100S comes out of power-on reset cleanly,
|
||||
|
// and toggling reset kills the PHY link which breaks POE power.
|
||||
|
#ifdef PIN_ETHERNET_RESET |
||||
|
pinMode(PIN_ETHERNET_RESET, OUTPUT); |
||||
|
digitalWrite(PIN_ETHERNET_RESET, HIGH); |
||||
|
#endif |
||||
|
|
||||
|
uint8_t mac[6]; |
||||
|
generateEthernetMac(mac); |
||||
|
ETHERNET_DEBUG_PRINTLN( |
||||
|
"Ethernet MAC: %02X:%02X:%02X:%02X:%02X:%02X", |
||||
|
mac[0], |
||||
|
mac[1], |
||||
|
mac[2], |
||||
|
mac[3], |
||||
|
mac[4], |
||||
|
mac[5]); |
||||
|
ETHERNET_DEBUG_PRINTLN("Init"); |
||||
|
ETHERNET_SPI_PORT.begin(); |
||||
|
Ethernet.init(ETHERNET_SPI_PORT, PIN_ETHERNET_SS); |
||||
|
|
||||
|
// Use static IP if build flags are defined, otherwise DHCP
|
||||
|
#if defined(ETHERNET_STATIC_IP) && defined(ETHERNET_STATIC_GATEWAY) && defined(ETHERNET_STATIC_SUBNET) && defined(ETHERNET_STATIC_DNS) |
||||
|
IPAddress ip(ETHERNET_STATIC_IP); |
||||
|
IPAddress gateway(ETHERNET_STATIC_GATEWAY); |
||||
|
IPAddress subnet(ETHERNET_STATIC_SUBNET); |
||||
|
IPAddress dns(ETHERNET_STATIC_DNS); |
||||
|
Ethernet.begin(mac, ip, dns, gateway, subnet); |
||||
|
#else |
||||
|
ETHERNET_DEBUG_PRINTLN("Begin"); |
||||
|
if (Ethernet.begin(mac) == 0) { |
||||
|
ETHERNET_DEBUG_PRINTLN("Begin failed."); |
||||
|
|
||||
|
// DHCP failed -- let's figure out why
|
||||
|
if (Ethernet.hardwareStatus() == EthernetNoHardware) // Check for Ethernet hardware present.
|
||||
|
{ |
||||
|
ETHERNET_DEBUG_PRINTLN("Ethernet hardware not found."); |
||||
|
return false; |
||||
|
} |
||||
|
if (Ethernet.linkStatus() == LinkOFF) // No physical connection
|
||||
|
{ |
||||
|
ETHERNET_DEBUG_PRINTLN("Ethernet cable not connected."); |
||||
|
return false; |
||||
|
} |
||||
|
ETHERNET_DEBUG_PRINTLN("Ethernet: DHCP failed for unknown reason."); |
||||
|
return false; |
||||
|
} |
||||
|
#endif |
||||
|
ETHERNET_DEBUG_PRINTLN("Ethernet begin complete"); |
||||
|
ETHERNET_DEBUG_PRINT_IP("IP", Ethernet.localIP()); |
||||
|
ETHERNET_DEBUG_PRINT_IP("Subnet", Ethernet.subnetMask()); |
||||
|
ETHERNET_DEBUG_PRINT_IP("Gateway", Ethernet.gatewayIP()); |
||||
|
|
||||
|
server.begin(); // start listening for clients
|
||||
|
ETHERNET_DEBUG_PRINTLN("Ethernet: listening on TCP port: %d", ETHERNET_TCP_PORT); |
||||
|
|
||||
|
return true; |
||||
|
} |
||||
|
|
||||
|
void SerialEthernetInterface::enable() { |
||||
|
if (_isEnabled) return; |
||||
|
|
||||
|
_isEnabled = true; |
||||
|
clearBuffers(); |
||||
|
} |
||||
|
|
||||
|
void SerialEthernetInterface::disable() { |
||||
|
_isEnabled = false; |
||||
|
} |
||||
|
|
||||
|
size_t SerialEthernetInterface::writeFrame(const uint8_t src[], size_t len) { |
||||
|
if (len > MAX_FRAME_SIZE) { |
||||
|
ETHERNET_DEBUG_PRINTLN("writeFrame(), frame too big, len=%d\n", len); |
||||
|
return 0; |
||||
|
} |
||||
|
|
||||
|
if (deviceConnected && len > 0) { |
||||
|
if (send_queue_len >= FRAME_QUEUE_SIZE) { |
||||
|
ETHERNET_DEBUG_PRINTLN("writeFrame(), send_queue is full!"); |
||||
|
return 0; |
||||
|
} |
||||
|
|
||||
|
send_queue[send_queue_len].len = len; // add to send queue
|
||||
|
memcpy(send_queue[send_queue_len].buf, src, len); |
||||
|
send_queue_len++; |
||||
|
|
||||
|
return len; |
||||
|
} |
||||
|
return 0; |
||||
|
} |
||||
|
|
||||
|
bool SerialEthernetInterface::isWriteBusy() const { |
||||
|
return false; |
||||
|
} |
||||
|
|
||||
|
size_t SerialEthernetInterface::checkRecvFrame(uint8_t dest[]) { |
||||
|
// Use accept() (not available()) so we only see newly-accepted sockets.
|
||||
|
// available() also returns existing connected sockets that have data,
|
||||
|
// which would cause us to treat each inbound packet as a "new client"
|
||||
|
// and stop() the underlying socket — disconnecting the companion.
|
||||
|
auto newClient = server.accept(); |
||||
|
if (newClient) { |
||||
|
IPAddress new_ip = newClient.remoteIP(); |
||||
|
uint16_t new_port = newClient.remotePort(); |
||||
|
ETHERNET_DEBUG_PRINTLN( |
||||
|
"New client accepted %u.%u.%u.%u:%u", |
||||
|
new_ip[0], |
||||
|
new_ip[1], |
||||
|
new_ip[2], |
||||
|
new_ip[3], |
||||
|
new_port); |
||||
|
|
||||
|
deviceConnected = false; |
||||
|
if (client) { |
||||
|
ETHERNET_DEBUG_PRINTLN("Closing previous client"); |
||||
|
client.stop(); |
||||
|
} |
||||
|
_state = RECV_STATE_IDLE; |
||||
|
_frame_len = 0; |
||||
|
_rx_len = 0; |
||||
|
client = newClient; |
||||
|
ETHERNET_DEBUG_PRINTLN("Switched to new client"); |
||||
|
} |
||||
|
|
||||
|
if (client.connected()) { |
||||
|
if (!deviceConnected) { |
||||
|
ETHERNET_DEBUG_PRINTLN( |
||||
|
"Got connection %u.%u.%u.%u:%u", |
||||
|
client.remoteIP()[0], |
||||
|
client.remoteIP()[1], |
||||
|
client.remoteIP()[2], |
||||
|
client.remoteIP()[3], |
||||
|
client.remotePort()); |
||||
|
deviceConnected = true; |
||||
|
} |
||||
|
} else { |
||||
|
if (deviceConnected) { |
||||
|
deviceConnected = false; |
||||
|
ETHERNET_DEBUG_PRINTLN("Disconnected"); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
if (deviceConnected) { |
||||
|
if (send_queue_len > 0) { // first, check send queue
|
||||
|
|
||||
|
_last_write = millis(); |
||||
|
int len = send_queue[0].len; |
||||
|
|
||||
|
#if ETHERNET_RAW_LINE |
||||
|
ETHERNET_DEBUG_PRINTLN("TX line len=%d", len); |
||||
|
client.write(send_queue[0].buf, len); |
||||
|
client.write("\r\n", 2); |
||||
|
#else |
||||
|
uint8_t pkt[3+len]; // use same header as serial interface so client can delimit frames
|
||||
|
pkt[0] = '>'; |
||||
|
pkt[1] = (len & 0xFF); // LSB
|
||||
|
pkt[2] = (len >> 8); // MSB
|
||||
|
memcpy(&pkt[3], send_queue[0].buf, send_queue[0].len); |
||||
|
ETHERNET_DEBUG_PRINTLN("Sending frame len=%d", len); |
||||
|
#if ETHERNET_DEBUG_LOGGING && ARDUINO |
||||
|
ETHERNET_DEBUG_PRINTLN("TX frame len=%d", len); |
||||
|
#endif |
||||
|
client.write(pkt, 3 + len); |
||||
|
#endif |
||||
|
send_queue_len--; |
||||
|
for (int i = 0; i < send_queue_len; i++) { // delete top item from queue
|
||||
|
send_queue[i] = send_queue[i + 1]; |
||||
|
} |
||||
|
} else { |
||||
|
while (client.available()) { |
||||
|
int c = client.read(); |
||||
|
if (c < 0) break; |
||||
|
|
||||
|
#if ETHERNET_RAW_LINE |
||||
|
if (c == '\r' || c == '\n') { |
||||
|
if (_rx_len == 0) { |
||||
|
continue; |
||||
|
} |
||||
|
uint16_t out_len = _rx_len; |
||||
|
if (out_len > MAX_FRAME_SIZE) { |
||||
|
out_len = MAX_FRAME_SIZE; |
||||
|
} |
||||
|
memcpy(dest, _rx_buf, out_len); |
||||
|
_rx_len = 0; |
||||
|
return out_len; |
||||
|
} |
||||
|
if (_rx_len < MAX_FRAME_SIZE) { |
||||
|
_rx_buf[_rx_len] = (uint8_t)c; |
||||
|
_rx_len++; |
||||
|
} |
||||
|
#else |
||||
|
switch (_state) { |
||||
|
case RECV_STATE_IDLE: |
||||
|
if (c == '<') { |
||||
|
_state = RECV_STATE_HDR_FOUND; |
||||
|
} |
||||
|
break; |
||||
|
case RECV_STATE_HDR_FOUND: |
||||
|
_frame_len = (uint8_t)c; |
||||
|
_state = RECV_STATE_LEN1_FOUND; |
||||
|
break; |
||||
|
case RECV_STATE_LEN1_FOUND: |
||||
|
_frame_len |= ((uint16_t)c) << 8; |
||||
|
_rx_len = 0; |
||||
|
_state = _frame_len > 0 ? RECV_STATE_LEN2_FOUND : RECV_STATE_IDLE; |
||||
|
break; |
||||
|
default: |
||||
|
if (_rx_len < MAX_FRAME_SIZE) { |
||||
|
_rx_buf[_rx_len] = (uint8_t)c; |
||||
|
} |
||||
|
_rx_len++; |
||||
|
if (_rx_len >= _frame_len) { |
||||
|
if (_frame_len > MAX_FRAME_SIZE) { |
||||
|
_frame_len = MAX_FRAME_SIZE; |
||||
|
} |
||||
|
#if ETHERNET_DEBUG_LOGGING && ARDUINO |
||||
|
ETHERNET_DEBUG_PRINTLN("RX frame len=%d", _frame_len); |
||||
|
#endif |
||||
|
memcpy(dest, _rx_buf, _frame_len); |
||||
|
_state = RECV_STATE_IDLE; |
||||
|
return _frame_len; |
||||
|
} |
||||
|
} |
||||
|
#endif |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
return 0; |
||||
|
} |
||||
|
|
||||
|
bool SerialEthernetInterface::isConnected() const { |
||||
|
return deviceConnected; |
||||
|
} |
||||
|
|
||||
|
void SerialEthernetInterface::loop() { |
||||
|
Ethernet.maintain(); |
||||
|
} |
||||
@ -0,0 +1,78 @@ |
|||||
|
#pragma once |
||||
|
|
||||
|
#include "helpers/BaseSerialInterface.h" |
||||
|
#include <SPI.h> |
||||
|
#include <RAK13800_W5100S.h> |
||||
|
|
||||
|
#ifndef ETHERNET_TCP_PORT |
||||
|
#define ETHERNET_TCP_PORT 5000 |
||||
|
#endif |
||||
|
// define ETHERNET_RAW_LINE=1 to use raw line-based CLI instead of framed packets
|
||||
|
|
||||
|
class SerialEthernetInterface : public BaseSerialInterface { |
||||
|
bool deviceConnected; |
||||
|
bool _isEnabled; |
||||
|
unsigned long _last_write; |
||||
|
uint8_t _state; |
||||
|
uint16_t _frame_len; |
||||
|
uint16_t _rx_len; |
||||
|
uint8_t _rx_buf[MAX_FRAME_SIZE]; |
||||
|
|
||||
|
EthernetServer server; |
||||
|
EthernetClient client; |
||||
|
|
||||
|
struct Frame { |
||||
|
uint8_t len; |
||||
|
uint8_t buf[MAX_FRAME_SIZE]; |
||||
|
}; |
||||
|
|
||||
|
#define FRAME_QUEUE_SIZE 4 |
||||
|
int send_queue_len; |
||||
|
Frame send_queue[FRAME_QUEUE_SIZE]; |
||||
|
|
||||
|
void clearBuffers() { |
||||
|
send_queue_len = 0; |
||||
|
_state = 0; |
||||
|
_frame_len = 0; |
||||
|
_rx_len = 0; |
||||
|
} |
||||
|
|
||||
|
protected: |
||||
|
|
||||
|
public: |
||||
|
SerialEthernetInterface() : server(EthernetServer(ETHERNET_TCP_PORT)) { |
||||
|
deviceConnected = false; |
||||
|
_isEnabled = false; |
||||
|
_last_write = 0; |
||||
|
send_queue_len = 0; |
||||
|
_state = 0; |
||||
|
_frame_len = 0; |
||||
|
_rx_len = 0; |
||||
|
} |
||||
|
bool begin(); |
||||
|
|
||||
|
// BaseSerialInterface methods
|
||||
|
void enable() override; |
||||
|
void disable() override; |
||||
|
bool isEnabled() const override { return _isEnabled; } |
||||
|
|
||||
|
bool isConnected() const override; |
||||
|
bool isWriteBusy() const override; |
||||
|
|
||||
|
size_t writeFrame(const uint8_t src[], size_t len) override; |
||||
|
size_t checkRecvFrame(uint8_t dest[]) override; |
||||
|
|
||||
|
void loop(); |
||||
|
}; |
||||
|
|
||||
|
|
||||
|
#if ETHERNET_DEBUG_LOGGING && ARDUINO |
||||
|
#include <Arduino.h> |
||||
|
#define ETHERNET_DEBUG_PRINT(F, ...) Serial.printf("ETH: " F, ##__VA_ARGS__) |
||||
|
#define ETHERNET_DEBUG_PRINTLN(F, ...) Serial.printf("ETH: " F "\n", ##__VA_ARGS__) |
||||
|
#define ETHERNET_DEBUG_PRINT_IP(name, ip) Serial.printf(name ": %u.%u.%u.%u" "\n", ip[0], ip[1], ip[2], ip[3]) |
||||
|
#else |
||||
|
#define ETHERNET_DEBUG_PRINT(...) {} |
||||
|
#define ETHERNET_DEBUG_PRINTLN(...) {} |
||||
|
#define ETHERNET_DEBUG_PRINT_IP(...) {} |
||||
|
#endif |
||||
@ -0,0 +1,103 @@ |
|||||
|
#include <gtest/gtest.h> |
||||
|
#include "helpers/SimpleMeshTables.h" |
||||
|
|
||||
|
using namespace mesh; |
||||
|
|
||||
|
// Build a packet that calculatePacketHash() distinguishes by payload content.
|
||||
|
// header selects ROUTE_TYPE_FLOOD so isRouteDirect() returns false.
|
||||
|
static Packet makeFloodPacket(uint8_t seed) { |
||||
|
Packet p; |
||||
|
p.header = ROUTE_TYPE_FLOOD | (PAYLOAD_TYPE_ACK << PH_TYPE_SHIFT); |
||||
|
p.payload[0] = seed; |
||||
|
p.payload_len = 1; |
||||
|
p.path_len = 0; |
||||
|
return p; |
||||
|
} |
||||
|
|
||||
|
static Packet makeDirectPacket(uint8_t seed) { |
||||
|
Packet p; |
||||
|
p.header = ROUTE_TYPE_DIRECT | (PAYLOAD_TYPE_ACK << PH_TYPE_SHIFT); |
||||
|
p.payload[0] = seed; |
||||
|
p.payload_len = 1; |
||||
|
p.path_len = 0; |
||||
|
return p; |
||||
|
} |
||||
|
|
||||
|
// ── wasSeen: pure query ───────────────────────────────────────────────────────
|
||||
|
|
||||
|
TEST(SimpleMeshTables, WasSeen_ReturnsFalseForUnseen) { |
||||
|
SimpleMeshTables t; |
||||
|
Packet p = makeFloodPacket(0x01); |
||||
|
EXPECT_FALSE(t.wasSeen(&p)); |
||||
|
} |
||||
|
|
||||
|
// wasSeen shouldn't change state
|
||||
|
TEST(SimpleMeshTables, WasSeen_IsPureQuery_DoesNotInsert) { |
||||
|
SimpleMeshTables t; |
||||
|
Packet p = makeFloodPacket(0x01); |
||||
|
EXPECT_FALSE(t.wasSeen(&p)); |
||||
|
EXPECT_FALSE(t.wasSeen(&p)); |
||||
|
} |
||||
|
|
||||
|
// ── markSeen + wasSeen ───────────────────────────────────────────────────────
|
||||
|
|
||||
|
TEST(SimpleMeshTables, MarkSeen_MakesWasSeenReturnTrue) { |
||||
|
SimpleMeshTables t; |
||||
|
Packet p = makeFloodPacket(0x01); |
||||
|
t.markSeen(&p); |
||||
|
EXPECT_TRUE(t.wasSeen(&p)); |
||||
|
} |
||||
|
|
||||
|
TEST(SimpleMeshTables, MarkSeen_DoesNotAffectOtherPackets) { |
||||
|
SimpleMeshTables t; |
||||
|
Packet p1 = makeFloodPacket(0x01); |
||||
|
Packet p2 = makeFloodPacket(0x02); |
||||
|
t.markSeen(&p1); |
||||
|
EXPECT_FALSE(t.wasSeen(&p2)); |
||||
|
} |
||||
|
|
||||
|
// Canonical pattern used at every onRecvPacket call site:
|
||||
|
// if (!wasSeen(pkt)) { markSeen(pkt); process(pkt); }
|
||||
|
TEST(SimpleMeshTables, QueryThenMark_WorksCorrectly) { |
||||
|
SimpleMeshTables t; |
||||
|
Packet p = makeFloodPacket(0x01); |
||||
|
EXPECT_FALSE(t.wasSeen(&p)); |
||||
|
t.markSeen(&p); |
||||
|
EXPECT_TRUE(t.wasSeen(&p)); |
||||
|
} |
||||
|
|
||||
|
// ── dup stats ────────────────────────────────────────────────────────────────
|
||||
|
|
||||
|
TEST(SimpleMeshTables, WasSeen_IncrementsFloodDupStat) { |
||||
|
SimpleMeshTables t; |
||||
|
Packet p = makeFloodPacket(0x01); |
||||
|
t.markSeen(&p); |
||||
|
t.wasSeen(&p); |
||||
|
EXPECT_EQ(1u, t.getNumFloodDups()); |
||||
|
EXPECT_EQ(0u, t.getNumDirectDups()); |
||||
|
} |
||||
|
|
||||
|
TEST(SimpleMeshTables, WasSeen_IncrementsDirectDupStat) { |
||||
|
SimpleMeshTables t; |
||||
|
Packet p = makeDirectPacket(0x01); |
||||
|
t.markSeen(&p); |
||||
|
t.wasSeen(&p); |
||||
|
EXPECT_EQ(0u, t.getNumFloodDups()); |
||||
|
EXPECT_EQ(1u, t.getNumDirectDups()); |
||||
|
} |
||||
|
|
||||
|
// ── clear ────────────────────────────────────────────────────────────────────
|
||||
|
|
||||
|
TEST(SimpleMeshTables, Clear_RemovesSeenPacket) { |
||||
|
SimpleMeshTables t; |
||||
|
Packet p = makeFloodPacket(0x01); |
||||
|
t.markSeen(&p); |
||||
|
ASSERT_TRUE(t.wasSeen(&p)); |
||||
|
t.clear(&p); |
||||
|
EXPECT_FALSE(t.wasSeen(&p)); |
||||
|
} |
||||
|
|
||||
|
int main(int argc, char** argv) { |
||||
|
::testing::InitGoogleTest(&argc, argv); |
||||
|
return RUN_ALL_TESTS(); |
||||
|
} |
||||
@ -0,0 +1,86 @@ |
|||||
|
#include "HeltecV4R8Board.h" |
||||
|
|
||||
|
void HeltecV4R8Board::begin() { |
||||
|
ESP32Board::begin(); |
||||
|
|
||||
|
periph_power.begin(); |
||||
|
periph_power.claim(); // R8 VEXT also feeds the LoRa antenna boost rail.
|
||||
|
|
||||
|
loRaFEMControl.init(); |
||||
|
|
||||
|
#ifdef PIN_TOUCH_RST |
||||
|
pinMode(PIN_TOUCH_RST, OUTPUT); |
||||
|
digitalWrite(PIN_TOUCH_RST, HIGH); |
||||
|
delay(10); |
||||
|
digitalWrite(PIN_TOUCH_RST, LOW); |
||||
|
delay(100); |
||||
|
digitalWrite(PIN_TOUCH_RST, HIGH); |
||||
|
#endif |
||||
|
|
||||
|
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)) { |
||||
|
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 HeltecV4R8Board::onBeforeTransmit(void) { |
||||
|
digitalWrite(P_LORA_TX_LED, HIGH); |
||||
|
loRaFEMControl.setTxModeEnable(); |
||||
|
} |
||||
|
|
||||
|
void HeltecV4R8Board::onAfterTransmit(void) { |
||||
|
digitalWrite(P_LORA_TX_LED, LOW); |
||||
|
loRaFEMControl.setRxModeEnable(); |
||||
|
} |
||||
|
|
||||
|
void HeltecV4R8Board::enterDeepSleep(uint32_t secs, int pin_wake_btn) { |
||||
|
esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_ON); |
||||
|
|
||||
|
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); |
||||
|
loRaFEMControl.setRxModeEnableWhenMCUSleep(); |
||||
|
|
||||
|
if (pin_wake_btn < 0) { |
||||
|
esp_sleep_enable_ext1_wakeup((1L << P_LORA_DIO_1), ESP_EXT1_WAKEUP_ANY_HIGH); |
||||
|
} else { |
||||
|
esp_sleep_enable_ext1_wakeup((1L << P_LORA_DIO_1) | (1L << pin_wake_btn), ESP_EXT1_WAKEUP_ANY_HIGH); |
||||
|
} |
||||
|
|
||||
|
if (secs > 0) { |
||||
|
esp_sleep_enable_timer_wakeup(secs * 1000000); |
||||
|
} |
||||
|
|
||||
|
esp_deep_sleep_start(); |
||||
|
} |
||||
|
|
||||
|
void HeltecV4R8Board::powerOff() { |
||||
|
enterDeepSleep(0); |
||||
|
} |
||||
|
|
||||
|
uint16_t HeltecV4R8Board::getBattMilliVolts() { |
||||
|
analogReadResolution(12); |
||||
|
|
||||
|
uint32_t raw = 0; |
||||
|
for (int i = 0; i < 8; i++) { |
||||
|
raw += analogReadMilliVolts(PIN_VBAT_READ); |
||||
|
} |
||||
|
raw = raw / 8; |
||||
|
|
||||
|
return (adc_mult * raw); |
||||
|
} |
||||
|
|
||||
|
const char* HeltecV4R8Board::getManufacturerName() const { |
||||
|
#ifdef HELTEC_V4_R8_TFT |
||||
|
return "Heltec V4 R8 TFT"; |
||||
|
#else |
||||
|
return "Heltec V4 R8 OLED"; |
||||
|
#endif |
||||
|
} |
||||
@ -0,0 +1,39 @@ |
|||||
|
#pragma once |
||||
|
|
||||
|
#include <Arduino.h> |
||||
|
#include <driver/rtc_io.h> |
||||
|
#include <helpers/ESP32Board.h> |
||||
|
#include <helpers/RefCountedDigitalPin.h> |
||||
|
#include "LoRaFEMControl.h" |
||||
|
|
||||
|
#ifndef ADC_MULTIPLIER |
||||
|
#define ADC_MULTIPLIER (4.9f * 1.035f) |
||||
|
#endif |
||||
|
|
||||
|
class HeltecV4R8Board : public ESP32Board { |
||||
|
protected: |
||||
|
float adc_mult = ADC_MULTIPLIER; |
||||
|
|
||||
|
public: |
||||
|
RefCountedDigitalPin periph_power; |
||||
|
LoRaFEMControl loRaFEMControl; |
||||
|
|
||||
|
HeltecV4R8Board() : 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,52 @@ |
|||||
|
#include "LoRaFEMControl.h" |
||||
|
|
||||
|
#include <Arduino.h> |
||||
|
#include <driver/rtc_io.h> |
||||
|
#include <esp_sleep.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); |
||||
|
|
||||
|
esp_reset_reason_t reason = esp_reset_reason(); |
||||
|
if (reason != ESP_RST_DEEPSLEEP) { |
||||
|
delay(1); |
||||
|
} |
||||
|
|
||||
|
rtc_gpio_hold_dis((gpio_num_t)P_LORA_KCT8103L_PA_CSD); |
||||
|
rtc_gpio_hold_dis((gpio_num_t)P_LORA_KCT8103L_PA_CTX); |
||||
|
|
||||
|
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, lna_enabled ? LOW : HIGH); |
||||
|
} |
||||
|
|
||||
|
void LoRaFEMControl::setSleepModeEnable(void) { |
||||
|
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); |
||||
|
digitalWrite(P_LORA_KCT8103L_PA_CTX, lna_enabled ? LOW : HIGH); |
||||
|
} |
||||
|
|
||||
|
void LoRaFEMControl::setRxModeEnableWhenMCUSleep(void) { |
||||
|
digitalWrite(P_LORA_PA_POWER, HIGH); |
||||
|
rtc_gpio_hold_en((gpio_num_t)P_LORA_PA_POWER); |
||||
|
|
||||
|
digitalWrite(P_LORA_KCT8103L_PA_CSD, HIGH); |
||||
|
rtc_gpio_hold_en((gpio_num_t)P_LORA_KCT8103L_PA_CSD); |
||||
|
digitalWrite(P_LORA_KCT8103L_PA_CTX, lna_enabled ? LOW : HIGH); |
||||
|
rtc_gpio_hold_en((gpio_num_t)P_LORA_KCT8103L_PA_CTX); |
||||
|
} |
||||
|
|
||||
|
void LoRaFEMControl::setLNAEnable(bool enabled) { |
||||
|
lna_enabled = enabled; |
||||
|
} |
||||
@ -0,0 +1,24 @@ |
|||||
|
#pragma once |
||||
|
|
||||
|
typedef enum { |
||||
|
KCT8103L_PA, |
||||
|
OTHER_FEM_TYPES |
||||
|
} LoRaFEMType; |
||||
|
|
||||
|
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 true; } |
||||
|
void setLnaCanControl(bool can_control) { } |
||||
|
LoRaFEMType getFEMType(void) const { return KCT8103L_PA; } |
||||
|
|
||||
|
private: |
||||
|
bool lna_enabled = false; |
||||
|
}; |
||||
@ -0,0 +1,56 @@ |
|||||
|
#ifndef Pins_Arduino_h |
||||
|
#define Pins_Arduino_h |
||||
|
|
||||
|
#include <stdint.h> |
||||
|
|
||||
|
#define USB_VID 0x303a |
||||
|
#define USB_PID 0x1001 |
||||
|
|
||||
|
static const uint8_t TX = 43; |
||||
|
static const uint8_t RX = 44; |
||||
|
|
||||
|
static const uint8_t SDA = 17; |
||||
|
static const uint8_t SCL = 18; |
||||
|
|
||||
|
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; |
||||
|
|
||||
|
#endif |
||||
@ -0,0 +1,342 @@ |
|||||
|
[Heltec_v4_r8] |
||||
|
extends = esp32_base |
||||
|
board = heltec_v4_r8 |
||||
|
build_flags = |
||||
|
${esp32_base.build_flags} |
||||
|
${sensor_base.build_flags} |
||||
|
-I variants/heltec_v4_r8 |
||||
|
-D HELTEC_V4_R8 |
||||
|
-D USE_SX1262 |
||||
|
-D ESP32_CPU_FREQ=80 |
||||
|
-D RADIO_CLASS=CustomSX1262 |
||||
|
-D WRAPPER_CLASS=CustomSX1262Wrapper |
||||
|
-D P_LORA_DIO_1=14 |
||||
|
-D P_LORA_NSS=8 |
||||
|
-D P_LORA_RESET=12 |
||||
|
-D P_LORA_BUSY=13 |
||||
|
-D P_LORA_SCLK=9 |
||||
|
-D P_LORA_MISO=11 |
||||
|
-D P_LORA_MOSI=10 |
||||
|
-D P_LORA_PA_POWER=7 |
||||
|
-D P_LORA_KCT8103L_PA_CSD=2 |
||||
|
-D P_LORA_KCT8103L_PA_CTX=5 |
||||
|
-D P_LORA_TX_LED=46 |
||||
|
-D PIN_USER_BTN=0 |
||||
|
-D PIN_VEXT_EN=40 |
||||
|
-D PIN_VEXT_EN_ACTIVE=LOW |
||||
|
-D ADC_MULTIPLIER=5.0715f |
||||
|
-D PIN_VBAT_READ=1 |
||||
|
-D LORA_TX_POWER=10 |
||||
|
-D MAX_LORA_TX_POWER=22 |
||||
|
-D SX126X_REGISTER_PATCH=1 |
||||
|
-D SX126X_DIO2_AS_RF_SWITCH=true |
||||
|
-D SX126X_DIO3_TCXO_VOLTAGE=1.8 |
||||
|
-D SX126X_CURRENT_LIMIT=140 |
||||
|
-D SX126X_RX_BOOSTED_GAIN=1 |
||||
|
-D PIN_GPS_RX=38 |
||||
|
-D PIN_GPS_TX=39 |
||||
|
-D PIN_GPS_EN=42 |
||||
|
-D PIN_GPS_EN_ACTIVE=LOW |
||||
|
-D ENV_INCLUDE_GPS=1 |
||||
|
build_src_filter = ${esp32_base.build_src_filter} |
||||
|
+<../variants/heltec_v4_r8> |
||||
|
+<helpers/sensors> |
||||
|
lib_deps = |
||||
|
${esp32_base.lib_deps} |
||||
|
${sensor_base.lib_deps} |
||||
|
|
||||
|
[heltec_v4_r8_oled] |
||||
|
extends = Heltec_v4_r8 |
||||
|
build_flags = |
||||
|
${Heltec_v4_r8.build_flags} |
||||
|
-D HELTEC_V4_R8_OLED |
||||
|
-D PIN_BOARD_SDA=17 |
||||
|
-D PIN_BOARD_SCL=18 |
||||
|
-D PIN_OLED_RESET=21 |
||||
|
build_src_filter = ${Heltec_v4_r8.build_src_filter} |
||||
|
lib_deps = ${Heltec_v4_r8.lib_deps} |
||||
|
|
||||
|
[heltec_v4_r8_tft] |
||||
|
extends = Heltec_v4_r8 |
||||
|
build_flags = |
||||
|
${Heltec_v4_r8.build_flags} |
||||
|
-D HELTEC_V4_R8_TFT |
||||
|
-D PIN_BOARD_SDA=17 |
||||
|
-D PIN_BOARD_SCL=18 |
||||
|
-D DISPLAY_SCALE_X=2.5 |
||||
|
-D DISPLAY_SCALE_Y=3.75 |
||||
|
-D PIN_TFT_RST=-1 |
||||
|
-D PIN_TFT_VDD_CTL=-1 |
||||
|
-D PIN_TFT_LEDA_CTL=44 |
||||
|
-D PIN_TFT_LEDA_CTL_ACTIVE=HIGH |
||||
|
-D PIN_TFT_CS=47 |
||||
|
-D PIN_TFT_DC=48 |
||||
|
-D PIN_TFT_SCL=16 |
||||
|
-D PIN_TFT_SDA=15 |
||||
|
-D PIN_TFT_MISO=45 |
||||
|
-D PIN_BUZZER=4 |
||||
|
-D PIN_TOUCH_RST=21 |
||||
|
build_src_filter = ${Heltec_v4_r8.build_src_filter} |
||||
|
+<helpers/ui/buzzer.cpp> |
||||
|
lib_deps = |
||||
|
${Heltec_v4_r8.lib_deps} |
||||
|
adafruit/Adafruit ST7735 and ST7789 Library @ ^1.11.0 |
||||
|
end2endzone/NonBlockingRTTTL@^1.3.0 |
||||
|
|
||||
|
[env:heltec_v4_r8_repeater] |
||||
|
extends = heltec_v4_r8_oled |
||||
|
build_flags = |
||||
|
${heltec_v4_r8_oled.build_flags} |
||||
|
-D DISPLAY_CLASS=SSD1306Display |
||||
|
-D ADVERT_NAME='"Heltec R8 Repeater"' |
||||
|
-D ADVERT_LAT=0.0 |
||||
|
-D ADVERT_LON=0.0 |
||||
|
-D ADMIN_PASSWORD='"password"' |
||||
|
-D MAX_NEIGHBOURS=50 |
||||
|
build_src_filter = ${heltec_v4_r8_oled.build_src_filter} |
||||
|
+<helpers/ui/SSD1306Display.cpp> |
||||
|
+<../examples/simple_repeater> |
||||
|
lib_deps = |
||||
|
${heltec_v4_r8_oled.lib_deps} |
||||
|
${esp32_ota.lib_deps} |
||||
|
bakercp/CRC32 @ ^2.0.0 |
||||
|
|
||||
|
[env:heltec_v4_r8_room_server] |
||||
|
extends = heltec_v4_r8_oled |
||||
|
build_flags = |
||||
|
${heltec_v4_r8_oled.build_flags} |
||||
|
-D DISPLAY_CLASS=SSD1306Display |
||||
|
-D ADVERT_NAME='"Heltec R8 Room"' |
||||
|
-D ADVERT_LAT=0.0 |
||||
|
-D ADVERT_LON=0.0 |
||||
|
-D ADMIN_PASSWORD='"password"' |
||||
|
-D ROOM_PASSWORD='"hello"' |
||||
|
build_src_filter = ${heltec_v4_r8_oled.build_src_filter} |
||||
|
+<helpers/ui/SSD1306Display.cpp> |
||||
|
+<../examples/simple_room_server> |
||||
|
lib_deps = |
||||
|
${heltec_v4_r8_oled.lib_deps} |
||||
|
${esp32_ota.lib_deps} |
||||
|
|
||||
|
[env:heltec_v4_r8_terminal_chat] |
||||
|
extends = heltec_v4_r8_oled |
||||
|
build_flags = |
||||
|
${heltec_v4_r8_oled.build_flags} |
||||
|
-D MAX_CONTACTS=350 |
||||
|
-D MAX_GROUP_CHANNELS=1 |
||||
|
build_src_filter = ${heltec_v4_r8_oled.build_src_filter} |
||||
|
+<../examples/simple_secure_chat/main.cpp> |
||||
|
lib_deps = |
||||
|
${heltec_v4_r8_oled.lib_deps} |
||||
|
densaugeo/base64 @ ~1.4.0 |
||||
|
|
||||
|
[env:heltec_v4_r8_companion_radio_usb] |
||||
|
extends = heltec_v4_r8_oled |
||||
|
build_flags = |
||||
|
${heltec_v4_r8_oled.build_flags} |
||||
|
-I examples/companion_radio/ui-new |
||||
|
-D MAX_CONTACTS=350 |
||||
|
-D MAX_GROUP_CHANNELS=40 |
||||
|
-D DISPLAY_CLASS=SSD1306Display |
||||
|
build_src_filter = ${heltec_v4_r8_oled.build_src_filter} |
||||
|
+<helpers/ui/SSD1306Display.cpp> |
||||
|
+<helpers/ui/MomentaryButton.cpp> |
||||
|
+<../examples/companion_radio/*.cpp> |
||||
|
+<../examples/companion_radio/ui-new/*.cpp> |
||||
|
lib_deps = |
||||
|
${heltec_v4_r8_oled.lib_deps} |
||||
|
densaugeo/base64 @ ~1.4.0 |
||||
|
|
||||
|
[env:heltec_v4_r8_companion_radio_ble] |
||||
|
extends = heltec_v4_r8_oled |
||||
|
build_flags = |
||||
|
${heltec_v4_r8_oled.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 |
||||
|
-D AUTO_SHUTDOWN_MILLIVOLTS=3400 |
||||
|
-D BLE_DEBUG_LOGGING=1 |
||||
|
-D OFFLINE_QUEUE_SIZE=256 |
||||
|
build_src_filter = ${heltec_v4_r8_oled.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 = |
||||
|
${heltec_v4_r8_oled.lib_deps} |
||||
|
densaugeo/base64 @ ~1.4.0 |
||||
|
|
||||
|
[env:heltec_v4_r8_companion_radio_wifi] |
||||
|
extends = heltec_v4_r8_oled |
||||
|
build_flags = |
||||
|
${heltec_v4_r8_oled.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"' |
||||
|
build_src_filter = ${heltec_v4_r8_oled.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 = |
||||
|
${heltec_v4_r8_oled.lib_deps} |
||||
|
densaugeo/base64 @ ~1.4.0 |
||||
|
|
||||
|
[env:heltec_v4_r8_sensor] |
||||
|
extends = heltec_v4_r8_oled |
||||
|
build_flags = |
||||
|
${heltec_v4_r8_oled.build_flags} |
||||
|
-D ADVERT_NAME='"Heltec R8 Sensor"' |
||||
|
-D ADVERT_LAT=0.0 |
||||
|
-D ADVERT_LON=0.0 |
||||
|
-D ADMIN_PASSWORD='"password"' |
||||
|
-D DISPLAY_CLASS=SSD1306Display |
||||
|
build_src_filter = ${heltec_v4_r8_oled.build_src_filter} |
||||
|
+<helpers/ui/SSD1306Display.cpp> |
||||
|
+<../examples/simple_sensor> |
||||
|
lib_deps = |
||||
|
${heltec_v4_r8_oled.lib_deps} |
||||
|
${esp32_ota.lib_deps} |
||||
|
|
||||
|
[env:heltec_v4_r8_tft_repeater] |
||||
|
extends = heltec_v4_r8_tft |
||||
|
build_flags = |
||||
|
${heltec_v4_r8_tft.build_flags} |
||||
|
-D DISPLAY_CLASS=ST7789LCDDisplay |
||||
|
-D ADVERT_NAME='"Heltec R8 Repeater"' |
||||
|
-D ADVERT_LAT=0.0 |
||||
|
-D ADVERT_LON=0.0 |
||||
|
-D ADMIN_PASSWORD='"password"' |
||||
|
-D MAX_NEIGHBOURS=50 |
||||
|
build_src_filter = ${heltec_v4_r8_tft.build_src_filter} |
||||
|
+<helpers/ui/ST7789LCDDisplay.cpp> |
||||
|
+<../examples/simple_repeater> |
||||
|
lib_deps = |
||||
|
${heltec_v4_r8_tft.lib_deps} |
||||
|
${esp32_ota.lib_deps} |
||||
|
bakercp/CRC32 @ ^2.0.0 |
||||
|
|
||||
|
[env:heltec_v4_r8_tft_room_server] |
||||
|
extends = heltec_v4_r8_tft |
||||
|
build_flags = |
||||
|
${heltec_v4_r8_tft.build_flags} |
||||
|
-D DISPLAY_CLASS=ST7789LCDDisplay |
||||
|
-D ADVERT_NAME='"Heltec R8 Room"' |
||||
|
-D ADVERT_LAT=0.0 |
||||
|
-D ADVERT_LON=0.0 |
||||
|
-D ADMIN_PASSWORD='"password"' |
||||
|
-D ROOM_PASSWORD='"hello"' |
||||
|
build_src_filter = ${heltec_v4_r8_tft.build_src_filter} |
||||
|
+<helpers/ui/ST7789LCDDisplay.cpp> |
||||
|
+<../examples/simple_room_server> |
||||
|
lib_deps = |
||||
|
${heltec_v4_r8_tft.lib_deps} |
||||
|
${esp32_ota.lib_deps} |
||||
|
|
||||
|
[env:heltec_v4_r8_tft_terminal_chat] |
||||
|
extends = heltec_v4_r8_tft |
||||
|
build_flags = |
||||
|
${heltec_v4_r8_tft.build_flags} |
||||
|
-D MAX_CONTACTS=350 |
||||
|
-D MAX_GROUP_CHANNELS=1 |
||||
|
build_src_filter = ${heltec_v4_r8_tft.build_src_filter} |
||||
|
+<../examples/simple_secure_chat/main.cpp> |
||||
|
lib_deps = |
||||
|
${heltec_v4_r8_tft.lib_deps} |
||||
|
densaugeo/base64 @ ~1.4.0 |
||||
|
|
||||
|
[env:heltec_v4_r8_tft_companion_radio_usb] |
||||
|
extends = heltec_v4_r8_tft |
||||
|
build_flags = |
||||
|
${heltec_v4_r8_tft.build_flags} |
||||
|
-I examples/companion_radio/ui-new |
||||
|
-D MAX_CONTACTS=350 |
||||
|
-D MAX_GROUP_CHANNELS=40 |
||||
|
-D DISPLAY_CLASS=ST7789LCDDisplay |
||||
|
build_src_filter = ${heltec_v4_r8_tft.build_src_filter} |
||||
|
+<helpers/ui/ST7789LCDDisplay.cpp> |
||||
|
+<helpers/ui/MomentaryButton.cpp> |
||||
|
+<../examples/companion_radio/*.cpp> |
||||
|
+<../examples/companion_radio/ui-new/*.cpp> |
||||
|
lib_deps = |
||||
|
${heltec_v4_r8_tft.lib_deps} |
||||
|
densaugeo/base64 @ ~1.4.0 |
||||
|
|
||||
|
[env:heltec_v4_r8_tft_companion_radio_ble] |
||||
|
extends = heltec_v4_r8_tft |
||||
|
build_flags = |
||||
|
${heltec_v4_r8_tft.build_flags} |
||||
|
-I examples/companion_radio/ui-new |
||||
|
-D DISPLAY_CLASS=ST7789LCDDisplay |
||||
|
-D MAX_CONTACTS=350 |
||||
|
-D MAX_GROUP_CHANNELS=40 |
||||
|
-D BLE_PIN_CODE=123456 |
||||
|
-D AUTO_SHUTDOWN_MILLIVOLTS=3400 |
||||
|
-D BLE_DEBUG_LOGGING=1 |
||||
|
-D OFFLINE_QUEUE_SIZE=256 |
||||
|
build_src_filter = ${heltec_v4_r8_tft.build_src_filter} |
||||
|
+<helpers/ui/ST7789LCDDisplay.cpp> |
||||
|
+<helpers/ui/MomentaryButton.cpp> |
||||
|
+<helpers/esp32/*.cpp> |
||||
|
+<../examples/companion_radio/*.cpp> |
||||
|
+<../examples/companion_radio/ui-new/*.cpp> |
||||
|
lib_deps = |
||||
|
${heltec_v4_r8_tft.lib_deps} |
||||
|
densaugeo/base64 @ ~1.4.0 |
||||
|
|
||||
|
[env:heltec_v4_r8_tft_companion_radio_wifi] |
||||
|
extends = heltec_v4_r8_tft |
||||
|
build_flags = |
||||
|
${heltec_v4_r8_tft.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=ST7789LCDDisplay |
||||
|
-D WIFI_DEBUG_LOGGING=1 |
||||
|
-D WIFI_SSID='"myssid"' |
||||
|
-D WIFI_PWD='"mypwd"' |
||||
|
build_src_filter = ${heltec_v4_r8_tft.build_src_filter} |
||||
|
+<helpers/ui/ST7789LCDDisplay.cpp> |
||||
|
+<helpers/ui/MomentaryButton.cpp> |
||||
|
+<helpers/esp32/*.cpp> |
||||
|
+<../examples/companion_radio/*.cpp> |
||||
|
+<../examples/companion_radio/ui-new/*.cpp> |
||||
|
lib_deps = |
||||
|
${heltec_v4_r8_tft.lib_deps} |
||||
|
densaugeo/base64 @ ~1.4.0 |
||||
|
|
||||
|
[env:heltec_v4_r8_tft_sensor] |
||||
|
extends = heltec_v4_r8_tft |
||||
|
build_flags = |
||||
|
${heltec_v4_r8_tft.build_flags} |
||||
|
-D ADVERT_NAME='"Heltec R8 Sensor"' |
||||
|
-D ADVERT_LAT=0.0 |
||||
|
-D ADVERT_LON=0.0 |
||||
|
-D ADMIN_PASSWORD='"password"' |
||||
|
-D DISPLAY_CLASS=ST7789LCDDisplay |
||||
|
build_src_filter = ${heltec_v4_r8_tft.build_src_filter} |
||||
|
+<helpers/ui/ST7789LCDDisplay.cpp> |
||||
|
+<../examples/simple_sensor> |
||||
|
lib_deps = |
||||
|
${heltec_v4_r8_tft.lib_deps} |
||||
|
${esp32_ota.lib_deps} |
||||
|
|
||||
|
[env:heltec_v4_r8_kiss_modem] |
||||
|
extends = Heltec_v4_r8 |
||||
|
build_src_filter = ${Heltec_v4_r8.build_src_filter} |
||||
|
+<../examples/kiss_modem/> |
||||
|
|
||||
|
[env:heltec_v4_r8_tft_kiss_modem] |
||||
|
extends = heltec_v4_r8_tft |
||||
|
build_src_filter = ${heltec_v4_r8_tft.build_src_filter} |
||||
|
+<../examples/kiss_modem/> |
||||
@ -0,0 +1,45 @@ |
|||||
|
#include <Arduino.h> |
||||
|
#include "target.h" |
||||
|
|
||||
|
HeltecV4R8Board 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, GPS_RESET, GPS_EN, &board.periph_power); |
||||
|
EnvironmentSensorManager sensors = EnvironmentSensorManager(nmea); |
||||
|
#else |
||||
|
EnvironmentSensorManager sensors; |
||||
|
#endif |
||||
|
|
||||
|
#ifdef DISPLAY_CLASS |
||||
|
DISPLAY_CLASS display(&board.periph_power); |
||||
|
MomentaryButton user_btn(PIN_USER_BTN, 1000, true); |
||||
|
#endif |
||||
|
|
||||
|
bool radio_init() { |
||||
|
fallback_clock.begin(); |
||||
|
rtc_clock.begin(Wire); |
||||
|
|
||||
|
#if defined(P_LORA_SCLK) |
||||
|
return radio.std_init(&spi); |
||||
|
#else |
||||
|
return radio.std_init(); |
||||
|
#endif |
||||
|
} |
||||
|
|
||||
|
mesh::LocalIdentity radio_new_identity() { |
||||
|
RadioNoiseListener rng(radio); |
||||
|
return mesh::LocalIdentity(&rng); |
||||
|
} |
||||
@ -0,0 +1,31 @@ |
|||||
|
#pragma once |
||||
|
|
||||
|
#define RADIOLIB_STATIC_ONLY 1 |
||||
|
#include <RadioLib.h> |
||||
|
#include <HeltecV4R8Board.h> |
||||
|
#include <helpers/AutoDiscoverRTCClock.h> |
||||
|
#include <helpers/SensorManager.h> |
||||
|
#include <helpers/radiolib/CustomSX1262Wrapper.h> |
||||
|
#include <helpers/radiolib/RadioLibWrappers.h> |
||||
|
#include <helpers/sensors/EnvironmentSensorManager.h> |
||||
|
#ifdef DISPLAY_CLASS |
||||
|
#ifdef HELTEC_V4_R8_OLED |
||||
|
#include <helpers/ui/SSD1306Display.h> |
||||
|
#elif defined(HELTEC_V4_R8_TFT) |
||||
|
#include <helpers/ui/ST7789LCDDisplay.h> |
||||
|
#endif |
||||
|
#include <helpers/ui/MomentaryButton.h> |
||||
|
#endif |
||||
|
|
||||
|
extern HeltecV4R8Board 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(); |
||||
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue