mirror of
https://github.com/pelgraine/Meck.git
synced 2026-03-28 17:42:44 +01:00
Compare commits
10 Commits
firstbuild
...
ble
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5bdcbb25b6 | ||
|
|
53fe89b216 | ||
|
|
e194c2c48c | ||
|
|
9d401f76d3 | ||
|
|
15f392c80e | ||
|
|
621f9f9568 | ||
|
|
8c9106ca86 | ||
|
|
f4b9c89d9f | ||
|
|
a4f5328113 | ||
|
|
2ad02f49e6 |
58
README.md
58
README.md
@@ -1,13 +1,18 @@
|
||||
## Meshcore + Fork = Meck
|
||||
This fork was created specifically to focus on enabling BLE companion firmware for the LilyGo T-Deck Pro. Created with the assistance of Claude AI using Meshcore v1.11 code.
|
||||
|
||||
⭐ ***Please note as of 28 Jan 2026, the T-Deck Pro repeater & usb firmware has not been finalised nor confirmed as functioning.*** ⭐
|
||||
|
||||
## About MeshCore
|
||||
|
||||
MeshCore is a lightweight, portable C++ library that enables multi-hop packet routing for embedded projects using LoRa and other packet radios. It is designed for developers who want to create resilient, decentralized communication networks that work without the internet.
|
||||
|
||||
## 🔍 What is MeshCore?
|
||||
## What is MeshCore?
|
||||
|
||||
MeshCore now supports a range of LoRa devices, allowing for easy flashing without the need to compile firmware manually. Users can flash a pre-built binary using tools like Adafruit ESPTool and interact with the network through a serial console.
|
||||
MeshCore provides the ability to create wireless mesh networks, similar to Meshtastic and Reticulum but with a focus on lightweight multi-hop packet routing for embedded projects. Unlike Meshtastic, which is tailored for casual LoRa communication, or Reticulum, which offers advanced networking, MeshCore balances simplicity with scalability, making it ideal for custom embedded solutions., where devices (nodes) can communicate over long distances by relaying messages through intermediate nodes. This is especially useful in off-grid, emergency, or tactical situations where traditional communication infrastructure is unavailable.
|
||||
|
||||
## ⚡ Key Features
|
||||
## Key Features
|
||||
|
||||
* Multi-Hop Packet Routing
|
||||
* Devices can forward messages across multiple nodes, extending range beyond a single radio's reach.
|
||||
@@ -18,7 +23,7 @@ MeshCore provides the ability to create wireless mesh networks, similar to Mesht
|
||||
* Low Power Consumption – Ideal for battery-powered or solar-powered devices.
|
||||
* Simple to Deploy – Pre-built example applications make it easy to get started.
|
||||
|
||||
## 🎯 What Can You Use MeshCore For?
|
||||
## What Can You Use MeshCore For?
|
||||
|
||||
* Off-Grid Communication: Stay connected even in remote areas.
|
||||
* Emergency Response & Disaster Recovery: Set up instant networks where infrastructure is down.
|
||||
@@ -26,7 +31,7 @@ MeshCore provides the ability to create wireless mesh networks, similar to Mesht
|
||||
* Tactical & Security Applications: Military, law enforcement, and private security use cases.
|
||||
* IoT & Sensor Networks: Collect data from remote sensors and relay it back to a central location.
|
||||
|
||||
## 🚀 How to Get Started
|
||||
## How to Get Started
|
||||
|
||||
- Watch the [MeshCore Intro Video](https://www.youtube.com/watch?v=t1qne8uJBAc) by Andy Kirby.
|
||||
- Read through our [Frequently Asked Questions](./docs/faq.md) section.
|
||||
@@ -39,13 +44,8 @@ For developers;
|
||||
- Clone and open the MeshCore repository in Visual Studio Code.
|
||||
- See the example applications you can modify and run:
|
||||
- [Companion Radio](./examples/companion_radio) - For use with an external chat app, over BLE, USB or WiFi.
|
||||
- [Simple Repeater](./examples/simple_repeater) - Extends network coverage by relaying messages.
|
||||
- [Simple Room Server](./examples/simple_room_server) - A simple BBS server for shared Posts.
|
||||
- [Simple Secure Chat](./examples/simple_secure_chat) - Secure terminal based text communication between devices.
|
||||
|
||||
The Simple Secure Chat example can be interacted with through the Serial Monitor in Visual Studio Code, or with a Serial USB Terminal on Android.
|
||||
|
||||
## ⚡️ MeshCore Flasher
|
||||
## MeshCore Flasher
|
||||
|
||||
We have prebuilt firmware ready to flash on supported devices.
|
||||
|
||||
@@ -55,7 +55,7 @@ We have prebuilt firmware ready to flash on supported devices.
|
||||
- Companion, Repeater or Room Server
|
||||
- Once flashing is complete, you can connect with one of the MeshCore clients below.
|
||||
|
||||
## 📱 MeshCore Clients
|
||||
## MeshCore Clients
|
||||
|
||||
**Companion Firmware**
|
||||
|
||||
@@ -67,14 +67,6 @@ The companion firmware can be connected to via BLE, USB or WiFi depending on the
|
||||
- NodeJS: https://github.com/liamcottle/meshcore.js
|
||||
- Python: https://github.com/fdlamotte/meshcore-cli
|
||||
|
||||
**Repeater and Room Server Firmware**
|
||||
|
||||
The repeater and room server firmwares can be setup via USB in the web config tool.
|
||||
|
||||
- https://config.meshcore.dev
|
||||
|
||||
They can also be managed via LoRa in the mobile app by using the Remote Management feature.
|
||||
|
||||
## 🛠 Hardware Compatibility
|
||||
|
||||
MeshCore is designed for devices listed in the [MeshCore Flasher](https://flasher.meshcore.co.uk)
|
||||
@@ -95,30 +87,16 @@ Here are some general principals you should try to adhere to:
|
||||
|
||||
## Road-Map / To-Do
|
||||
|
||||
There are a number of fairly major features in the pipeline, with no particular time-frames attached yet. In very rough chronological order:
|
||||
- [X] Companion radio: UI redesign
|
||||
- [ ] Repeater + Room Server: add ACL's (like Sensor Node has)
|
||||
- [ ] Standardise Bridge mode for repeaters
|
||||
- [ ] Repeater/Bridge: Standardise the Transport Codes for zoning/filtering
|
||||
- [ ] Core + Repeater: enhanced zero-hop neighbour discovery
|
||||
- [ ] Core: round-trip manual path support
|
||||
- [ ] Companion + Apps: support for multiple sub-meshes (and 'off-grid' client repeat mode)
|
||||
- [ ] Core + Apps: support for LZW message compression
|
||||
- [ ] Core: dynamic CR (Coding Rate) for weak vs strong hops
|
||||
- [ ] Core: new framework for hosting multiple virtual nodes on one physical device
|
||||
- [ ] V2 protocol spec: discussion and consensus around V2 packet protocol, including path hashes, new encryption specs, etc
|
||||
There are a number of fairly major features in the pipeline, with no particular time-frames attached yet. In partly chronological order:
|
||||
- [X] Companion radio: BLE
|
||||
- [ ] Companion radio: USB
|
||||
- [ ] Simple Repeater firmware for the T-Deck Pro
|
||||
- [ ] Get pin 45 with the screen backlight functioning for the T-Deck Pro v1.1
|
||||
- [ ] Canned messages function for Companion BLE firmware
|
||||
- [ ] Text entry for Companion BLE firmware
|
||||
|
||||
## 📞 Get Support
|
||||
|
||||
- Report bugs and request features on the [GitHub Issues](https://github.com/ripplebiz/MeshCore/issues) page.
|
||||
- Find additional guides and components on [my site](https://buymeacoffee.com/ripplebiz).
|
||||
- Join [MeshCore Discord](https://discord.gg/BMwCtwHj5V) to chat with the developers and get help from the community.
|
||||
|
||||
## RAK Wireless Board Support in PlatformIO
|
||||
|
||||
Before building/flashing the RAK4631 targets in this project, there is, unfortunately, some patching you have to do to your platformIO packages to make it work. There is a guide here on the process:
|
||||
[RAK Wireless: How to Perform Installation of Board Support Package in PlatformIO](https://learn.rakwireless.com/hc/en-us/articles/26687276346775-How-To-Perform-Installation-of-Board-Support-Package-in-PlatformIO)
|
||||
|
||||
After building, you will need to convert the output firmware.hex file into a .uf2 file you can copy over to your RAK4631 device (after doing a full erase) by using the command `uf2conv.py -f 0xADA52840 -c firmware.hex` with the python script available from:
|
||||
[GitHub: Microsoft - uf2](https://github.com/Microsoft/uf2/blob/master/utils/uf2conv.py)
|
||||
|
||||
|
||||
@@ -8,11 +8,11 @@
|
||||
#define FIRMWARE_VER_CODE 8
|
||||
|
||||
#ifndef FIRMWARE_BUILD_DATE
|
||||
#define FIRMWARE_BUILD_DATE "28 Jan 2026"
|
||||
#define FIRMWARE_BUILD_DATE "29 Jan 2026"
|
||||
#endif
|
||||
|
||||
#ifndef FIRMWARE_VERSION
|
||||
#define FIRMWARE_VERSION "Meck v0.3"
|
||||
#define FIRMWARE_VERSION "Meck v0.4"
|
||||
#endif
|
||||
|
||||
#if defined(NRF52_PLATFORM) || defined(STM32_PLATFORM)
|
||||
|
||||
@@ -110,14 +110,14 @@ void halt() {
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
delay(100); // Give serial time to initialize
|
||||
Serial.println("=== setup() - STARTING ===");
|
||||
MESH_DEBUG_PRINTLN("=== setup() - STARTING ===");
|
||||
|
||||
board.begin();
|
||||
Serial.println("setup() - board.begin() done");
|
||||
MESH_DEBUG_PRINTLN("setup() - board.begin() done");
|
||||
|
||||
#ifdef DISPLAY_CLASS
|
||||
DisplayDriver* disp = NULL;
|
||||
Serial.println("setup() - about to call display.begin()");
|
||||
MESH_DEBUG_PRINTLN("setup() - about to call display.begin()");
|
||||
|
||||
// =========================================================================
|
||||
// T-Deck Pro V1.1: Initialize E-Ink reset pin BEFORE display.begin()
|
||||
@@ -127,7 +127,7 @@ void setup() {
|
||||
// Initialize E-Ink reset pin (GPIO 16)
|
||||
pinMode(PIN_DISPLAY_RST, OUTPUT);
|
||||
digitalWrite(PIN_DISPLAY_RST, HIGH);
|
||||
Serial.println("setup() - E-Ink reset pin initialized");
|
||||
MESH_DEBUG_PRINTLN("setup() - E-Ink reset pin initialized");
|
||||
|
||||
// Initialize Touch reset pin (GPIO 38)
|
||||
#ifdef CST328_PIN_RST
|
||||
@@ -138,13 +138,13 @@ void setup() {
|
||||
delay(80);
|
||||
digitalWrite(CST328_PIN_RST, HIGH);
|
||||
delay(20);
|
||||
Serial.println("setup() - Touch reset pin initialized");
|
||||
MESH_DEBUG_PRINTLN("setup() - Touch reset pin initialized");
|
||||
#endif
|
||||
#endif
|
||||
// =========================================================================
|
||||
|
||||
if (display.begin()) {
|
||||
Serial.println("setup() - display.begin() returned true");
|
||||
MESH_DEBUG_PRINTLN("setup() - display.begin() returned true");
|
||||
disp = &display;
|
||||
disp->startFrame();
|
||||
#ifdef ST7789
|
||||
@@ -152,25 +152,25 @@ void setup() {
|
||||
#endif
|
||||
disp->drawTextCentered(disp->width() / 2, 28, "Loading...");
|
||||
disp->endFrame();
|
||||
Serial.println("setup() - Loading screen drawn");
|
||||
MESH_DEBUG_PRINTLN("setup() - Loading screen drawn");
|
||||
} else {
|
||||
Serial.println("setup() - display.begin() returned false!");
|
||||
MESH_DEBUG_PRINTLN("setup() - display.begin() returned false!");
|
||||
}
|
||||
#endif
|
||||
|
||||
Serial.println("setup() - about to call radio_init()");
|
||||
MESH_DEBUG_PRINTLN("setup() - about to call radio_init()");
|
||||
if (!radio_init()) {
|
||||
Serial.println("setup() - radio_init() FAILED! Halting.");
|
||||
MESH_DEBUG_PRINTLN("setup() - radio_init() FAILED! Halting.");
|
||||
halt();
|
||||
}
|
||||
Serial.println("setup() - radio_init() done");
|
||||
MESH_DEBUG_PRINTLN("setup() - radio_init() done");
|
||||
|
||||
Serial.println("setup() - about to call fast_rng.begin()");
|
||||
MESH_DEBUG_PRINTLN("setup() - about to call fast_rng.begin()");
|
||||
fast_rng.begin(radio_get_rng_seed());
|
||||
Serial.println("setup() - fast_rng.begin() done");
|
||||
MESH_DEBUG_PRINTLN("setup() - fast_rng.begin() done");
|
||||
|
||||
#if defined(NRF52_PLATFORM) || defined(STM32_PLATFORM)
|
||||
Serial.println("setup() - NRF52/STM32 filesystem init");
|
||||
MESH_DEBUG_PRINTLN("setup() - NRF52/STM32 filesystem init");
|
||||
InternalFS.begin();
|
||||
#if defined(QSPIFLASH)
|
||||
if (!QSPIFlash.begin()) {
|
||||
@@ -183,11 +183,11 @@ void setup() {
|
||||
ExtraFS.begin();
|
||||
#endif
|
||||
#endif
|
||||
Serial.println("setup() - about to call store.begin()");
|
||||
MESH_DEBUG_PRINTLN("setup() - about to call store.begin()");
|
||||
store.begin();
|
||||
Serial.println("setup() - store.begin() done");
|
||||
MESH_DEBUG_PRINTLN("setup() - store.begin() done");
|
||||
|
||||
Serial.println("setup() - about to call the_mesh.begin()");
|
||||
MESH_DEBUG_PRINTLN("setup() - about to call the_mesh.begin()");
|
||||
the_mesh.begin(
|
||||
#ifdef DISPLAY_CLASS
|
||||
disp != NULL
|
||||
@@ -195,27 +195,27 @@ void setup() {
|
||||
false
|
||||
#endif
|
||||
);
|
||||
Serial.println("setup() - the_mesh.begin() done");
|
||||
MESH_DEBUG_PRINTLN("setup() - the_mesh.begin() done");
|
||||
|
||||
#ifdef BLE_PIN_CODE
|
||||
Serial.println("setup() - about to call serial_interface.begin() with BLE");
|
||||
MESH_DEBUG_PRINTLN("setup() - about to call serial_interface.begin() with BLE");
|
||||
serial_interface.begin(BLE_NAME_PREFIX, the_mesh.getNodePrefs()->node_name, the_mesh.getBLEPin());
|
||||
Serial.println("setup() - serial_interface.begin() done");
|
||||
MESH_DEBUG_PRINTLN("setup() - serial_interface.begin() done");
|
||||
#else
|
||||
serial_interface.begin(Serial);
|
||||
#endif
|
||||
Serial.println("setup() - about to call the_mesh.startInterface()");
|
||||
MESH_DEBUG_PRINTLN("setup() - about to call the_mesh.startInterface()");
|
||||
the_mesh.startInterface(serial_interface);
|
||||
Serial.println("setup() - the_mesh.startInterface() done");
|
||||
MESH_DEBUG_PRINTLN("setup() - the_mesh.startInterface() done");
|
||||
|
||||
#elif defined(RP2040_PLATFORM)
|
||||
Serial.println("setup() - RP2040 filesystem init");
|
||||
MESH_DEBUG_PRINTLN("setup() - RP2040 filesystem init");
|
||||
LittleFS.begin();
|
||||
Serial.println("setup() - about to call store.begin()");
|
||||
MESH_DEBUG_PRINTLN("setup() - about to call store.begin()");
|
||||
store.begin();
|
||||
Serial.println("setup() - store.begin() done");
|
||||
MESH_DEBUG_PRINTLN("setup() - store.begin() done");
|
||||
|
||||
Serial.println("setup() - about to call the_mesh.begin()");
|
||||
MESH_DEBUG_PRINTLN("setup() - about to call the_mesh.begin()");
|
||||
the_mesh.begin(
|
||||
#ifdef DISPLAY_CLASS
|
||||
disp != NULL
|
||||
@@ -223,7 +223,7 @@ void setup() {
|
||||
false
|
||||
#endif
|
||||
);
|
||||
Serial.println("setup() - the_mesh.begin() done");
|
||||
MESH_DEBUG_PRINTLN("setup() - the_mesh.begin() done");
|
||||
|
||||
//#ifdef WIFI_SSID
|
||||
// WiFi.begin(WIFI_SSID, WIFI_PWD);
|
||||
@@ -239,20 +239,20 @@ void setup() {
|
||||
#else
|
||||
serial_interface.begin(Serial);
|
||||
#endif
|
||||
Serial.println("setup() - about to call the_mesh.startInterface()");
|
||||
MESH_DEBUG_PRINTLN("setup() - about to call the_mesh.startInterface()");
|
||||
the_mesh.startInterface(serial_interface);
|
||||
Serial.println("setup() - the_mesh.startInterface() done");
|
||||
MESH_DEBUG_PRINTLN("setup() - the_mesh.startInterface() done");
|
||||
|
||||
#elif defined(ESP32)
|
||||
Serial.println("setup() - ESP32 filesystem init - calling SPIFFS.begin()");
|
||||
MESH_DEBUG_PRINTLN("setup() - ESP32 filesystem init - calling SPIFFS.begin()");
|
||||
SPIFFS.begin(true);
|
||||
Serial.println("setup() - SPIFFS.begin() done");
|
||||
MESH_DEBUG_PRINTLN("setup() - SPIFFS.begin() done");
|
||||
|
||||
Serial.println("setup() - about to call store.begin()");
|
||||
MESH_DEBUG_PRINTLN("setup() - about to call store.begin()");
|
||||
store.begin();
|
||||
Serial.println("setup() - store.begin() done");
|
||||
MESH_DEBUG_PRINTLN("setup() - store.begin() done");
|
||||
|
||||
Serial.println("setup() - about to call the_mesh.begin()");
|
||||
MESH_DEBUG_PRINTLN("setup() - about to call the_mesh.begin()");
|
||||
the_mesh.begin(
|
||||
#ifdef DISPLAY_CLASS
|
||||
disp != NULL
|
||||
@@ -260,16 +260,16 @@ void setup() {
|
||||
false
|
||||
#endif
|
||||
);
|
||||
Serial.println("setup() - the_mesh.begin() done");
|
||||
MESH_DEBUG_PRINTLN("setup() - the_mesh.begin() done");
|
||||
|
||||
#ifdef WIFI_SSID
|
||||
Serial.println("setup() - WiFi mode");
|
||||
MESH_DEBUG_PRINTLN("setup() - WiFi mode");
|
||||
WiFi.begin(WIFI_SSID, WIFI_PWD);
|
||||
serial_interface.begin(TCP_PORT);
|
||||
#elif defined(BLE_PIN_CODE)
|
||||
Serial.println("setup() - about to call serial_interface.begin() with BLE");
|
||||
MESH_DEBUG_PRINTLN("setup() - about to call serial_interface.begin() with BLE");
|
||||
serial_interface.begin(BLE_NAME_PREFIX, the_mesh.getNodePrefs()->node_name, the_mesh.getBLEPin());
|
||||
Serial.println("setup() - serial_interface.begin() done");
|
||||
MESH_DEBUG_PRINTLN("setup() - serial_interface.begin() done");
|
||||
#elif defined(SERIAL_RX)
|
||||
companion_serial.setPins(SERIAL_RX, SERIAL_TX);
|
||||
companion_serial.begin(115200);
|
||||
@@ -277,30 +277,30 @@ void setup() {
|
||||
#else
|
||||
serial_interface.begin(Serial);
|
||||
#endif
|
||||
Serial.println("setup() - about to call the_mesh.startInterface()");
|
||||
MESH_DEBUG_PRINTLN("setup() - about to call the_mesh.startInterface()");
|
||||
the_mesh.startInterface(serial_interface);
|
||||
Serial.println("setup() - the_mesh.startInterface() done");
|
||||
MESH_DEBUG_PRINTLN("setup() - the_mesh.startInterface() done");
|
||||
|
||||
#else
|
||||
#error "need to define filesystem"
|
||||
#endif
|
||||
|
||||
Serial.println("setup() - about to call sensors.begin()");
|
||||
MESH_DEBUG_PRINTLN("setup() - about to call sensors.begin()");
|
||||
sensors.begin();
|
||||
Serial.println("setup() - sensors.begin() done");
|
||||
MESH_DEBUG_PRINTLN("setup() - sensors.begin() done");
|
||||
|
||||
// IMPORTANT: sensors.begin() calls initBasicGPS() which steals the GPS pins for Serial1
|
||||
// We need to reinitialize Serial2 to reclaim them
|
||||
#if HAS_GPS
|
||||
Serial2.end(); // Close any existing Serial2
|
||||
Serial2.begin(GPS_BAUDRATE, SERIAL_8N1, GPS_RX_PIN, GPS_TX_PIN);
|
||||
Serial.println("setup() - Reinitialized Serial2 for GPS after sensors.begin()");
|
||||
MESH_DEBUG_PRINTLN("setup() - Reinitialized Serial2 for GPS after sensors.begin()");
|
||||
#endif
|
||||
|
||||
#ifdef DISPLAY_CLASS
|
||||
Serial.println("setup() - about to call ui_task.begin()");
|
||||
MESH_DEBUG_PRINTLN("setup() - about to call ui_task.begin()");
|
||||
ui_task.begin(disp, &sensors, the_mesh.getNodePrefs());
|
||||
Serial.println("setup() - ui_task.begin() done");
|
||||
MESH_DEBUG_PRINTLN("setup() - ui_task.begin() done");
|
||||
#endif
|
||||
|
||||
// Enable GPS by default on T-Deck Pro
|
||||
@@ -309,10 +309,10 @@ void setup() {
|
||||
sensors.setSettingValue("gps", "1");
|
||||
the_mesh.getNodePrefs()->gps_enabled = 1;
|
||||
the_mesh.savePrefs();
|
||||
Serial.println("setup() - GPS enabled by default");
|
||||
MESH_DEBUG_PRINTLN("setup() - GPS enabled by default");
|
||||
#endif
|
||||
|
||||
Serial.println("=== setup() - COMPLETE ===");
|
||||
MESH_DEBUG_PRINTLN("=== setup() - COMPLETE ===");
|
||||
}
|
||||
|
||||
void loop() {
|
||||
@@ -322,24 +322,4 @@ void loop() {
|
||||
ui_task.loop();
|
||||
#endif
|
||||
rtc_clock.tick();
|
||||
|
||||
// Debug: Check for GPS data on Serial2
|
||||
#if HAS_GPS
|
||||
static unsigned long lastGpsDebug = 0;
|
||||
if (millis() - lastGpsDebug > 5000) { // Every 5 seconds
|
||||
lastGpsDebug = millis();
|
||||
Serial.print("GPS Debug - Serial2 available: ");
|
||||
Serial.print(Serial2.available());
|
||||
Serial.print(" bytes");
|
||||
LocationProvider* loc = sensors.getLocationProvider();
|
||||
if (loc) {
|
||||
Serial.print(", valid: ");
|
||||
Serial.print(loc->isValid() ? "YES" : "NO");
|
||||
Serial.print(", sats: ");
|
||||
Serial.println(loc->satellitesCount());
|
||||
} else {
|
||||
Serial.println(", LocationProvider: NULL");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -1,24 +1,25 @@
|
||||
#include <Arduino.h>
|
||||
#include "variant.h"
|
||||
#include "TDeckBoard.h"
|
||||
#include <Mesh.h> // For MESH_DEBUG_PRINTLN
|
||||
|
||||
uint32_t deviceOnline = 0x00;
|
||||
|
||||
void TDeckBoard::begin() {
|
||||
|
||||
Serial.println("TDeckBoard::begin() - starting");
|
||||
MESH_DEBUG_PRINTLN("TDeckBoard::begin() - starting");
|
||||
|
||||
// Enable peripheral power (keyboard, sensors, etc.) FIRST
|
||||
// This powers the BQ27220 fuel gauge and other I2C devices
|
||||
pinMode(PIN_PERF_POWERON, OUTPUT);
|
||||
digitalWrite(PIN_PERF_POWERON, HIGH);
|
||||
delay(50); // Allow peripherals to power up before I2C init
|
||||
Serial.println("TDeckBoard::begin() - peripheral power enabled");
|
||||
MESH_DEBUG_PRINTLN("TDeckBoard::begin() - peripheral power enabled");
|
||||
|
||||
// Initialize I2C with correct pins for T-Deck Pro
|
||||
Wire.begin(I2C_SDA, I2C_SCL);
|
||||
Wire.setClock(100000); // 100kHz for reliable fuel gauge communication
|
||||
Serial.println("TDeckBoard::begin() - I2C initialized");
|
||||
MESH_DEBUG_PRINTLN("TDeckBoard::begin() - I2C initialized");
|
||||
|
||||
// Now call parent class begin (after power and I2C are ready)
|
||||
ESP32Board::begin();
|
||||
@@ -28,7 +29,7 @@ void TDeckBoard::begin() {
|
||||
pinMode(P_LORA_EN, OUTPUT);
|
||||
digitalWrite(P_LORA_EN, HIGH);
|
||||
delay(10); // Allow module to power up
|
||||
Serial.println("TDeckBoard::begin() - LoRa power enabled");
|
||||
MESH_DEBUG_PRINTLN("TDeckBoard::begin() - LoRa power enabled");
|
||||
#endif
|
||||
|
||||
// Enable GPS module power and initialize Serial2
|
||||
@@ -37,14 +38,12 @@ void TDeckBoard::begin() {
|
||||
pinMode(PIN_GPS_EN, OUTPUT);
|
||||
digitalWrite(PIN_GPS_EN, GPS_EN_ACTIVE); // GPS_EN_ACTIVE is 1 (HIGH)
|
||||
delay(100); // Allow GPS to power up
|
||||
Serial.println("TDeckBoard::begin() - GPS power enabled");
|
||||
MESH_DEBUG_PRINTLN("TDeckBoard::begin() - GPS power enabled");
|
||||
#endif
|
||||
|
||||
// Initialize Serial2 for GPS with correct pins
|
||||
Serial2.begin(GPS_BAUDRATE, SERIAL_8N1, GPS_RX_PIN, GPS_TX_PIN);
|
||||
Serial.print("TDeckBoard::begin() - GPS Serial2 initialized at ");
|
||||
Serial.print(GPS_BAUDRATE);
|
||||
Serial.println(" baud");
|
||||
MESH_DEBUG_PRINTLN("TDeckBoard::begin() - GPS Serial2 initialized at %d baud", GPS_BAUDRATE);
|
||||
#endif
|
||||
|
||||
// Configure user button
|
||||
@@ -68,12 +67,10 @@ void TDeckBoard::begin() {
|
||||
// Test BQ27220 communication
|
||||
#if HAS_BQ27220
|
||||
uint16_t voltage = getBattMilliVolts();
|
||||
Serial.print("TDeckBoard::begin() - Battery voltage: ");
|
||||
Serial.print(voltage);
|
||||
Serial.println(" mV");
|
||||
MESH_DEBUG_PRINTLN("TDeckBoard::begin() - Battery voltage: %d mV", voltage);
|
||||
#endif
|
||||
|
||||
Serial.println("TDeckBoard::begin() - complete");
|
||||
MESH_DEBUG_PRINTLN("TDeckBoard::begin() - complete");
|
||||
}
|
||||
|
||||
uint16_t TDeckBoard::getBattMilliVolts() {
|
||||
@@ -81,13 +78,13 @@ uint16_t TDeckBoard::getBattMilliVolts() {
|
||||
Wire.beginTransmission(BQ27220_I2C_ADDR);
|
||||
Wire.write(BQ27220_REG_VOLTAGE);
|
||||
if (Wire.endTransmission(false) != 0) {
|
||||
Serial.println("BQ27220: I2C error reading voltage");
|
||||
MESH_DEBUG_PRINTLN("BQ27220: I2C error reading voltage");
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint8_t count = Wire.requestFrom((uint8_t)BQ27220_I2C_ADDR, (uint8_t)2);
|
||||
if (count != 2) {
|
||||
Serial.println("BQ27220: Read error - wrong byte count");
|
||||
MESH_DEBUG_PRINTLN("BQ27220: Read error - wrong byte count");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,13 @@ class TDeckBoard : public ESP32Board {
|
||||
public:
|
||||
void begin();
|
||||
|
||||
void powerOff() override {
|
||||
// Stop Bluetooth before power off
|
||||
btStop();
|
||||
// Don't call parent or enterDeepSleep - let normal shutdown continue
|
||||
// Display will show "hibernating..." text
|
||||
}
|
||||
|
||||
void enterDeepSleep(uint32_t secs, int pin_wake_btn) {
|
||||
esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_ON);
|
||||
|
||||
|
||||
@@ -113,9 +113,9 @@ extends = LilyGo_TDeck_Pro
|
||||
build_flags =
|
||||
${LilyGo_TDeck_Pro.build_flags}
|
||||
-I examples/companion_radio/ui-new
|
||||
-D MAX_CONTACTS=350
|
||||
-D MAX_GROUP_CHANNELS=40
|
||||
-D BLE_PIN_CODE=234567
|
||||
-D MAX_CONTACTS=400
|
||||
-D MAX_GROUP_CHANNELS=20
|
||||
-D BLE_PIN_CODE=123456
|
||||
-D OFFLINE_QUEUE_SIZE=256
|
||||
build_src_filter = ${LilyGo_TDeck_Pro.build_src_filter}
|
||||
+<helpers/esp32/*.cpp>
|
||||
|
||||
@@ -19,10 +19,8 @@ AutoDiscoverRTCClock rtc_clock(fallback_clock);
|
||||
#if HAS_GPS
|
||||
MicroNMEALocationProvider gps(Serial2, &rtc_clock);
|
||||
EnvironmentSensorManager sensors(gps);
|
||||
#pragma message "GPS enabled - using EnvironmentSensorManager with MicroNMEALocationProvider"
|
||||
#else
|
||||
SensorManager sensors;
|
||||
#pragma message "GPS disabled - using basic SensorManager"
|
||||
#endif
|
||||
|
||||
#ifdef DISPLAY_CLASS
|
||||
@@ -31,37 +29,27 @@ AutoDiscoverRTCClock rtc_clock(fallback_clock);
|
||||
#endif
|
||||
|
||||
bool radio_init() {
|
||||
Serial.println("radio_init() - starting");
|
||||
MESH_DEBUG_PRINTLN("radio_init() - starting");
|
||||
|
||||
// NOTE: board.begin() is called by main.cpp setup() before radio_init()
|
||||
// I2C is already initialized there with correct pins
|
||||
|
||||
fallback_clock.begin();
|
||||
Serial.println("radio_init() - fallback_clock started");
|
||||
MESH_DEBUG_PRINTLN("radio_init() - fallback_clock started");
|
||||
|
||||
// Wire already initialized in board.begin() - just use it for RTC
|
||||
rtc_clock.begin(Wire);
|
||||
Serial.println("radio_init() - rtc_clock started");
|
||||
|
||||
// Debug GPS status
|
||||
#if HAS_GPS
|
||||
Serial.println("radio_init() - HAS_GPS is defined");
|
||||
Serial.print("radio_init() - gps object address: ");
|
||||
Serial.println((uint32_t)&gps, HEX);
|
||||
#else
|
||||
Serial.println("radio_init() - HAS_GPS is NOT defined");
|
||||
#endif
|
||||
MESH_DEBUG_PRINTLN("radio_init() - rtc_clock started");
|
||||
|
||||
#if defined(P_LORA_SCLK)
|
||||
Serial.println("radio_init() - initializing LoRa SPI...");
|
||||
MESH_DEBUG_PRINTLN("radio_init() - initializing LoRa SPI...");
|
||||
loraSpi.begin(P_LORA_SCLK, P_LORA_MISO, P_LORA_MOSI, P_LORA_NSS);
|
||||
Serial.println("radio_init() - SPI initialized, calling radio.std_init()...");
|
||||
MESH_DEBUG_PRINTLN("radio_init() - SPI initialized, calling radio.std_init()...");
|
||||
bool result = radio.std_init(&loraSpi);
|
||||
Serial.print("radio_init() - radio.std_init() returned: ");
|
||||
Serial.println(result ? "SUCCESS" : "FAILED");
|
||||
MESH_DEBUG_PRINTLN("radio_init() - radio.std_init() returned: %s", result ? "SUCCESS" : "FAILED");
|
||||
return result;
|
||||
#else
|
||||
Serial.println("radio_init() - calling radio.std_init() without custom SPI...");
|
||||
MESH_DEBUG_PRINTLN("radio_init() - calling radio.std_init() without custom SPI...");
|
||||
return radio.std_init();
|
||||
#endif
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user