kopia lustrzana https://github.com/meshtastic/firmware
Add multiple configuration options for a minimized build (GPS,WiFi,BT,MQTT,Screen). (#3469)
Co-authored-by: Ben Meadors <benmmeadors@gmail.com>pull/3494/head
rodzic
728b58fb94
commit
acc32916c3
|
@ -6,4 +6,4 @@
|
||||||
"platformio.platformio-ide",
|
"platformio.platformio-ide",
|
||||||
"trunk.io"
|
"trunk.io"
|
||||||
],
|
],
|
||||||
}
|
}
|
|
@ -1,10 +1,12 @@
|
||||||
#include "ButtonThread.h"
|
#include "ButtonThread.h"
|
||||||
|
#include "configuration.h"
|
||||||
|
#if !MESHTASTIC_EXCLUDE_GPS
|
||||||
#include "GPS.h"
|
#include "GPS.h"
|
||||||
|
#endif
|
||||||
#include "MeshService.h"
|
#include "MeshService.h"
|
||||||
#include "PowerFSM.h"
|
#include "PowerFSM.h"
|
||||||
#include "RadioLibInterface.h"
|
#include "RadioLibInterface.h"
|
||||||
#include "buzz.h"
|
#include "buzz.h"
|
||||||
#include "graphics/Screen.h"
|
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "modules/ExternalNotificationModule.h"
|
#include "modules/ExternalNotificationModule.h"
|
||||||
#include "power.h"
|
#include "power.h"
|
||||||
|
@ -145,7 +147,7 @@ int32_t ButtonThread::runOnce()
|
||||||
screen->print("Sent ad-hoc ping\n");
|
screen->print("Sent ad-hoc ping\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
#if HAS_GPS
|
||||||
case BUTTON_EVENT_MULTI_PRESSED: {
|
case BUTTON_EVENT_MULTI_PRESSED: {
|
||||||
LOG_BUTTON("Multi press!\n");
|
LOG_BUTTON("Multi press!\n");
|
||||||
if (!config.device.disable_triple_click && (gps != nullptr)) {
|
if (!config.device.disable_triple_click && (gps != nullptr)) {
|
||||||
|
@ -155,7 +157,7 @@ int32_t ButtonThread::runOnce()
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
case BUTTON_EVENT_LONG_PRESSED: {
|
case BUTTON_EVENT_LONG_PRESSED: {
|
||||||
LOG_BUTTON("Long press!\n");
|
LOG_BUTTON("Long press!\n");
|
||||||
powerFSM.trigger(EVENT_PRESS);
|
powerFSM.trigger(EVENT_PRESS);
|
||||||
|
|
|
@ -24,11 +24,13 @@
|
||||||
#include "nrfx_power.h"
|
#include "nrfx_power.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef DEBUG_HEAP_MQTT
|
#if defined(DEBUG_HEAP_MQTT) && !MESHTASTIC_EXCLUDE_MQTT
|
||||||
#include "mqtt/MQTT.h"
|
#include "mqtt/MQTT.h"
|
||||||
#include "target_specific.h"
|
#include "target_specific.h"
|
||||||
|
#if !MESTASTIC_EXCLUDE_WIFI
|
||||||
#include <WiFi.h>
|
#include <WiFi.h>
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef DELAY_FOREVER
|
#ifndef DELAY_FOREVER
|
||||||
#define DELAY_FOREVER portMAX_DELAY
|
#define DELAY_FOREVER portMAX_DELAY
|
||||||
|
|
|
@ -171,17 +171,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
/* Step #3: mop up with disabled values for HAS_ options not handled by the above two */
|
/* Step #3: mop up with disabled values for HAS_ options not handled by the above two */
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
// GPS
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#ifndef GPS_BAUDRATE
|
|
||||||
#define GPS_BAUDRATE 9600
|
|
||||||
#endif
|
|
||||||
#ifndef GPS_THREAD_INTERVAL
|
|
||||||
#define GPS_THREAD_INTERVAL 100
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef HAS_WIFI
|
#ifndef HAS_WIFI
|
||||||
#define HAS_WIFI 0
|
#define HAS_WIFI 0
|
||||||
#endif
|
#endif
|
||||||
|
@ -232,7 +221,21 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#error HW_VENDOR must be defined
|
#error HW_VENDOR must be defined
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// global switch to turn off all optional modules for a minimzed build
|
// -----------------------------------------------------------------------------
|
||||||
|
// Global switches to turn off features for a minimized build
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// #define MESHTASTIC_MINIMIZE_BUILD 1
|
||||||
|
#ifdef MESHTASTIC_MINIMIZE_BUILD
|
||||||
|
#define MESHTASTIC_EXCLUDE_MODULES 1
|
||||||
|
#define MESHTASTIC_EXCLUDE_WIFI 1
|
||||||
|
#define MESHTASTIC_EXCLUDE_BLUETOOTH 1
|
||||||
|
#define MESHTASTIC_EXCLUDE_GPS 1
|
||||||
|
#define MESHTASTIC_EXCLUDE_SCREEN 1
|
||||||
|
#define MESHTASTIC_EXCLUDE_MQTT 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Turn off all optional modules
|
||||||
#ifdef MESHTASTIC_EXCLUDE_MODULES
|
#ifdef MESHTASTIC_EXCLUDE_MODULES
|
||||||
#define MESHTASTIC_EXCLUDE_AUDIO 1
|
#define MESHTASTIC_EXCLUDE_AUDIO 1
|
||||||
#define MESHTASTIC_EXCLUDE_DETECTIONSENSOR 1
|
#define MESHTASTIC_EXCLUDE_DETECTIONSENSOR 1
|
||||||
|
@ -251,3 +254,30 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#define MESHTASTIC_EXCLUDE_INPUTBROKER 1
|
#define MESHTASTIC_EXCLUDE_INPUTBROKER 1
|
||||||
#define MESHTASTIC_EXCLUDE_SERIAL 1
|
#define MESHTASTIC_EXCLUDE_SERIAL 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// // Turn off wifi even if HW supports wifi (webserver relies on wifi and is also disabled)
|
||||||
|
#ifdef MESHTASTIC_EXCLUDE_WIFI
|
||||||
|
#define MESHTASTIC_EXCLUDE_WEBSERVER 1
|
||||||
|
#undef HAS_WIFI
|
||||||
|
#define HAS_WIFI 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// // Turn off Bluetooth
|
||||||
|
#ifdef MESHTASTIC_EXCLUDE_BLUETOOTH
|
||||||
|
#undef HAS_BLUETOOTH
|
||||||
|
#define HAS_BLUETOOTH 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// // Turn off GPS
|
||||||
|
#ifdef MESHTASTIC_EXCLUDE_GPS
|
||||||
|
#undef HAS_GPS
|
||||||
|
#define HAS_GPS 0
|
||||||
|
#undef MESHTASTIC_EXCLUDE_RANGETEST
|
||||||
|
#define MESHTASTIC_EXCLUDE_RANGETEST 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Turn off Screen
|
||||||
|
#ifdef MESHTASTIC_EXCLUDE_SCREEN
|
||||||
|
#undef HAS_SCREEN
|
||||||
|
#define HAS_SCREEN 0
|
||||||
|
#endif
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
#include "GPS.h"
|
#include "configuration.h"
|
||||||
|
#if !MESHTASTIC_EXCLUDE_GPS
|
||||||
#include "Default.h"
|
#include "Default.h"
|
||||||
|
#include "GPS.h"
|
||||||
#include "NodeDB.h"
|
#include "NodeDB.h"
|
||||||
#include "RTC.h"
|
#include "RTC.h"
|
||||||
#include "configuration.h"
|
|
||||||
#include "main.h" // pmu_found
|
#include "main.h" // pmu_found
|
||||||
#include "sleep.h"
|
#include "sleep.h"
|
||||||
#include "ubx.h"
|
#include "ubx.h"
|
||||||
|
@ -1481,4 +1483,5 @@ void GPS::toggleGpsMode()
|
||||||
LOG_DEBUG("Flag set to true to restore power. GpsMode: ENABLED\n");
|
LOG_DEBUG("Flag set to true to restore power. GpsMode: ENABLED\n");
|
||||||
enable();
|
enable();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif // Exclude GPS
|
|
@ -1,4 +1,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
#include "configuration.h"
|
||||||
|
#if !MESHTASTIC_EXCLUDE_GPS
|
||||||
|
|
||||||
#include "GPSStatus.h"
|
#include "GPSStatus.h"
|
||||||
#include "Observer.h"
|
#include "Observer.h"
|
||||||
|
@ -268,4 +270,5 @@ class GPS : private concurrency::OSThread
|
||||||
GnssModel_t gnssModel = GNSS_MODEL_UNKNOWN;
|
GnssModel_t gnssModel = GNSS_MODEL_UNKNOWN;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern GPS *gps;
|
extern GPS *gps;
|
||||||
|
#endif // Exclude GPS
|
|
@ -1,3 +1,4 @@
|
||||||
|
#if !MESHTASTIC_EXCLUDE_GPS
|
||||||
#include "NMEAWPL.h"
|
#include "NMEAWPL.h"
|
||||||
#include "GeoCoord.h"
|
#include "GeoCoord.h"
|
||||||
#include "RTC.h"
|
#include "RTC.h"
|
||||||
|
@ -93,4 +94,6 @@ uint32_t printGGA(char *buf, size_t bufsz, const meshtastic_Position &pos)
|
||||||
}
|
}
|
||||||
len += snprintf(buf + len, bufsz - len, "*%02X\r\n", chk);
|
len += snprintf(buf + len, bufsz - len, "*%02X\r\n", chk);
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -25,7 +25,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#include <OLEDDisplay.h>
|
#include <OLEDDisplay.h>
|
||||||
|
|
||||||
#include "DisplayFormatters.h"
|
#include "DisplayFormatters.h"
|
||||||
|
#if !MESHTASTIC_EXCLUDE_GPS
|
||||||
#include "GPS.h"
|
#include "GPS.h"
|
||||||
|
#endif
|
||||||
#include "MeshService.h"
|
#include "MeshService.h"
|
||||||
#include "NodeDB.h"
|
#include "NodeDB.h"
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
|
@ -92,8 +94,10 @@ std::vector<MeshModule *> moduleFrames;
|
||||||
// Stores the last 4 of our hardware ID, to make finding the device for pairing easier
|
// Stores the last 4 of our hardware ID, to make finding the device for pairing easier
|
||||||
static char ourId[5];
|
static char ourId[5];
|
||||||
|
|
||||||
|
#if HAS_GPS
|
||||||
// GeoCoord object for the screen
|
// GeoCoord object for the screen
|
||||||
GeoCoord geoCoord;
|
GeoCoord geoCoord;
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef SHOW_REDRAWS
|
#ifdef SHOW_REDRAWS
|
||||||
static bool heartbeat = false;
|
static bool heartbeat = false;
|
||||||
|
@ -483,7 +487,7 @@ static void drawNodes(OLEDDisplay *display, int16_t x, int16_t y, const NodeStat
|
||||||
if (config.display.heading_bold)
|
if (config.display.heading_bold)
|
||||||
display->drawString(x + 11, y - 2, usersString);
|
display->drawString(x + 11, y - 2, usersString);
|
||||||
}
|
}
|
||||||
|
#if HAS_GPS
|
||||||
// Draw GPS status summary
|
// Draw GPS status summary
|
||||||
static void drawGPS(OLEDDisplay *display, int16_t x, int16_t y, const GPSStatus *gps)
|
static void drawGPS(OLEDDisplay *display, int16_t x, int16_t y, const GPSStatus *gps)
|
||||||
{
|
{
|
||||||
|
@ -625,7 +629,7 @@ static void drawGPScoordinates(OLEDDisplay *display, int16_t x, int16_t y, const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -1542,6 +1546,7 @@ void DebugInfo::drawFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16
|
||||||
} else {
|
} else {
|
||||||
drawNodes(display, x + (SCREEN_WIDTH * 0.25), y + 3, nodeStatus);
|
drawNodes(display, x + (SCREEN_WIDTH * 0.25), y + 3, nodeStatus);
|
||||||
}
|
}
|
||||||
|
#if HAS_GPS
|
||||||
// Display GPS status
|
// Display GPS status
|
||||||
if (config.position.gps_mode != meshtastic_Config_PositionConfig_GpsMode_ENABLED) {
|
if (config.position.gps_mode != meshtastic_Config_PositionConfig_GpsMode_ENABLED) {
|
||||||
drawGPSpowerstat(display, x, y + 2, gpsStatus);
|
drawGPSpowerstat(display, x, y + 2, gpsStatus);
|
||||||
|
@ -1552,7 +1557,7 @@ void DebugInfo::drawFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16
|
||||||
drawGPS(display, x + (SCREEN_WIDTH * 0.63), y + 3, gpsStatus);
|
drawGPS(display, x + (SCREEN_WIDTH * 0.63), y + 3, gpsStatus);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
display->setColor(WHITE);
|
display->setColor(WHITE);
|
||||||
// Draw the channel name
|
// Draw the channel name
|
||||||
display->drawString(x, y + FONT_HEIGHT_SMALL, channelStr);
|
display->drawString(x, y + FONT_HEIGHT_SMALL, channelStr);
|
||||||
|
@ -1771,6 +1776,7 @@ void DebugInfo::drawFrameSettings(OLEDDisplay *display, OLEDDisplayUiState *stat
|
||||||
char chUtil[13];
|
char chUtil[13];
|
||||||
snprintf(chUtil, sizeof(chUtil), "ChUtil %2.0f%%", airTime->channelUtilizationPercent());
|
snprintf(chUtil, sizeof(chUtil), "ChUtil %2.0f%%", airTime->channelUtilizationPercent());
|
||||||
display->drawString(x + SCREEN_WIDTH - display->getStringWidth(chUtil), y + FONT_HEIGHT_SMALL * 1, chUtil);
|
display->drawString(x + SCREEN_WIDTH - display->getStringWidth(chUtil), y + FONT_HEIGHT_SMALL * 1, chUtil);
|
||||||
|
#if HAS_GPS
|
||||||
if (config.position.gps_mode == meshtastic_Config_PositionConfig_GpsMode_ENABLED) {
|
if (config.position.gps_mode == meshtastic_Config_PositionConfig_GpsMode_ENABLED) {
|
||||||
// Line 3
|
// Line 3
|
||||||
if (config.display.gps_format !=
|
if (config.display.gps_format !=
|
||||||
|
@ -1782,6 +1788,7 @@ void DebugInfo::drawFrameSettings(OLEDDisplay *display, OLEDDisplayUiState *stat
|
||||||
} else {
|
} else {
|
||||||
drawGPSpowerstat(display, x, y + FONT_HEIGHT_SMALL * 2, gpsStatus);
|
drawGPSpowerstat(display, x, y + FONT_HEIGHT_SMALL * 2, gpsStatus);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
/* Display a heartbeat pixel that blinks every time the frame is redrawn */
|
/* Display a heartbeat pixel that blinks every time the frame is redrawn */
|
||||||
#ifdef SHOW_REDRAWS
|
#ifdef SHOW_REDRAWS
|
||||||
if (heartbeat)
|
if (heartbeat)
|
||||||
|
|
37
src/main.cpp
37
src/main.cpp
|
@ -1,4 +1,7 @@
|
||||||
|
#include "configuration.h"
|
||||||
|
#if !MESHTASTIC_EXCLUDE_GPS
|
||||||
#include "GPS.h"
|
#include "GPS.h"
|
||||||
|
#endif
|
||||||
#include "MeshRadio.h"
|
#include "MeshRadio.h"
|
||||||
#include "MeshService.h"
|
#include "MeshService.h"
|
||||||
#include "NodeDB.h"
|
#include "NodeDB.h"
|
||||||
|
@ -6,7 +9,7 @@
|
||||||
#include "ReliableRouter.h"
|
#include "ReliableRouter.h"
|
||||||
#include "airtime.h"
|
#include "airtime.h"
|
||||||
#include "buzz.h"
|
#include "buzz.h"
|
||||||
#include "configuration.h"
|
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
#include "power.h"
|
#include "power.h"
|
||||||
// #include "debug.h"
|
// #include "debug.h"
|
||||||
|
@ -36,9 +39,11 @@
|
||||||
#if !MESHTASTIC_EXCLUDE_WEBSERVER
|
#if !MESHTASTIC_EXCLUDE_WEBSERVER
|
||||||
#include "mesh/http/WebServer.h"
|
#include "mesh/http/WebServer.h"
|
||||||
#endif
|
#endif
|
||||||
|
#if !MESHTASTIC_EXCLUDE_BLUETOOTH
|
||||||
#include "nimble/NimbleBluetooth.h"
|
#include "nimble/NimbleBluetooth.h"
|
||||||
NimbleBluetooth *nimbleBluetooth;
|
NimbleBluetooth *nimbleBluetooth;
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef ARCH_NRF52
|
#ifdef ARCH_NRF52
|
||||||
#include "NRF52Bluetooth.h"
|
#include "NRF52Bluetooth.h"
|
||||||
|
@ -54,16 +59,21 @@ NRF52Bluetooth *nrf52Bluetooth;
|
||||||
#include "mesh/api/ethServerAPI.h"
|
#include "mesh/api/ethServerAPI.h"
|
||||||
#include "mesh/eth/ethClient.h"
|
#include "mesh/eth/ethClient.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if !MESHTASTIC_EXCLUDE_MQTT
|
||||||
#include "mqtt/MQTT.h"
|
#include "mqtt/MQTT.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "LLCC68Interface.h"
|
#include "LLCC68Interface.h"
|
||||||
#include "RF95Interface.h"
|
#include "RF95Interface.h"
|
||||||
#include "SX1262Interface.h"
|
#include "SX1262Interface.h"
|
||||||
#include "SX1268Interface.h"
|
#include "SX1268Interface.h"
|
||||||
#include "SX1280Interface.h"
|
#include "SX1280Interface.h"
|
||||||
|
|
||||||
#ifdef ARCH_STM32WL
|
#ifdef ARCH_STM32WL
|
||||||
#include "STM32WLE5JCInterface.h"
|
#include "STM32WLE5JCInterface.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !HAS_RADIO && defined(ARCH_PORTDUINO)
|
#if !HAS_RADIO && defined(ARCH_PORTDUINO)
|
||||||
#include "platform/portduino/SimRadio.h"
|
#include "platform/portduino/SimRadio.h"
|
||||||
#endif
|
#endif
|
||||||
|
@ -80,6 +90,7 @@ NRF52Bluetooth *nrf52Bluetooth;
|
||||||
#if HAS_BUTTON || defined(ARCH_PORTDUINO)
|
#if HAS_BUTTON || defined(ARCH_PORTDUINO)
|
||||||
#include "ButtonThread.h"
|
#include "ButtonThread.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "PowerFSMThread.h"
|
#include "PowerFSMThread.h"
|
||||||
|
|
||||||
#if !defined(ARCH_PORTDUINO) && !defined(ARCH_STM32WL)
|
#if !defined(ARCH_PORTDUINO) && !defined(ARCH_STM32WL)
|
||||||
|
@ -640,16 +651,21 @@ void setup()
|
||||||
|
|
||||||
readFromRTC(); // read the main CPU RTC at first (in case we can't get GPS time)
|
readFromRTC(); // read the main CPU RTC at first (in case we can't get GPS time)
|
||||||
|
|
||||||
|
#if !MESHTASTIC_EXCLUDE_GPS
|
||||||
// If we're taking on the repeater role, ignore GPS
|
// If we're taking on the repeater role, ignore GPS
|
||||||
if (config.device.role != meshtastic_Config_DeviceConfig_Role_REPEATER &&
|
if (HAS_GPS) {
|
||||||
config.position.gps_mode != meshtastic_Config_PositionConfig_GpsMode_NOT_PRESENT) {
|
if (config.device.role != meshtastic_Config_DeviceConfig_Role_REPEATER &&
|
||||||
gps = GPS::createGps();
|
config.position.gps_mode != meshtastic_Config_PositionConfig_GpsMode_NOT_PRESENT) {
|
||||||
}
|
gps = GPS::createGps();
|
||||||
if (gps) {
|
if (gps) {
|
||||||
gpsStatus->observe(&gps->newStatus);
|
gpsStatus->observe(&gps->newStatus);
|
||||||
} else {
|
} else {
|
||||||
LOG_DEBUG("Running without GPS.\n");
|
LOG_DEBUG("Running without GPS.\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
nodeStatus->observe(&nodeDB->newStatus);
|
nodeStatus->observe(&nodeDB->newStatus);
|
||||||
|
|
||||||
#ifdef HAS_I2S
|
#ifdef HAS_I2S
|
||||||
|
@ -852,9 +868,12 @@ void setup()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if !MESHTASTIC_EXCLUDE_MQTT
|
||||||
mqttInit();
|
mqttInit();
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef ARCH_PORTDUINO
|
#ifndef ARCH_PORTDUINO
|
||||||
|
|
||||||
// Initialize Wifi
|
// Initialize Wifi
|
||||||
#if HAS_WIFI
|
#if HAS_WIFI
|
||||||
initWifi();
|
initWifi();
|
||||||
|
|
|
@ -54,6 +54,7 @@ extern int TCPPort; // set by Portduino
|
||||||
|
|
||||||
// Global Screen singleton.
|
// Global Screen singleton.
|
||||||
extern graphics::Screen *screen;
|
extern graphics::Screen *screen;
|
||||||
|
|
||||||
// extern Observable<meshtastic::PowerStatus> newPowerStatus; //TODO: move this to main-esp32.cpp somehow or a helper class
|
// extern Observable<meshtastic::PowerStatus> newPowerStatus; //TODO: move this to main-esp32.cpp somehow or a helper class
|
||||||
|
|
||||||
// extern meshtastic::PowerStatus *powerStatus;
|
// extern meshtastic::PowerStatus *powerStatus;
|
||||||
|
|
|
@ -7,7 +7,9 @@
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
|
#if !MESHTASTIC_EXCLUDE_MQTT
|
||||||
#include "mqtt/MQTT.h"
|
#include "mqtt/MQTT.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
/// 16 bytes of random PSK for our _public_ default channel that all devices power up on (AES128)
|
/// 16 bytes of random PSK for our _public_ default channel that all devices power up on (AES128)
|
||||||
static const uint8_t defaultpsk[] = {0xd4, 0xf1, 0xbb, 0x3a, 0x20, 0x29, 0x07, 0x59,
|
static const uint8_t defaultpsk[] = {0xd4, 0xf1, 0xbb, 0x3a, 0x20, 0x29, 0x07, 0x59,
|
||||||
|
@ -18,7 +20,9 @@ Channels channels;
|
||||||
const char *Channels::adminChannel = "admin";
|
const char *Channels::adminChannel = "admin";
|
||||||
const char *Channels::gpioChannel = "gpio";
|
const char *Channels::gpioChannel = "gpio";
|
||||||
const char *Channels::serialChannel = "serial";
|
const char *Channels::serialChannel = "serial";
|
||||||
|
#if !MESHTASTIC_EXCLUDE_MQTT
|
||||||
const char *Channels::mqttChannel = "mqtt";
|
const char *Channels::mqttChannel = "mqtt";
|
||||||
|
#endif
|
||||||
|
|
||||||
uint8_t xorHash(const uint8_t *p, size_t len)
|
uint8_t xorHash(const uint8_t *p, size_t len)
|
||||||
{
|
{
|
||||||
|
@ -195,10 +199,12 @@ void Channels::onConfigChanged()
|
||||||
if (ch.role == meshtastic_Channel_Role_PRIMARY)
|
if (ch.role == meshtastic_Channel_Role_PRIMARY)
|
||||||
primaryIndex = i;
|
primaryIndex = i;
|
||||||
}
|
}
|
||||||
|
#if !MESHTASTIC_EXCLUDE_MQTT
|
||||||
if (channels.anyMqttEnabled() && mqtt && !mqtt->isEnabled()) {
|
if (channels.anyMqttEnabled() && mqtt && !mqtt->isEnabled()) {
|
||||||
LOG_DEBUG("MQTT is enabled on at least one channel, so set MQTT thread to run immediately\n");
|
LOG_DEBUG("MQTT is enabled on at least one channel, so set MQTT thread to run immediately\n");
|
||||||
mqtt->start();
|
mqtt->start();
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
meshtastic_Channel &Channels::getByIndex(ChannelIndex chIndex)
|
meshtastic_Channel &Channels::getByIndex(ChannelIndex chIndex)
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
#include "configuration.h"
|
#include "configuration.h"
|
||||||
#include <assert.h>
|
|
||||||
#include <string>
|
#if !MESHTASTIC_EXCLUDE_GPS
|
||||||
|
#include "GPS.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "../concurrency/Periodic.h"
|
#include "../concurrency/Periodic.h"
|
||||||
#include "BluetoothCommon.h" // needed for updateBatteryLevel, FIXME, eventually when we pull mesh out into a lib we shouldn't be whacking bluetooth from here
|
#include "BluetoothCommon.h" // needed for updateBatteryLevel, FIXME, eventually when we pull mesh out into a lib we shouldn't be whacking bluetooth from here
|
||||||
#include "GPS.h"
|
|
||||||
#include "MeshService.h"
|
#include "MeshService.h"
|
||||||
#include "NodeDB.h"
|
#include "NodeDB.h"
|
||||||
#include "PowerFSM.h"
|
#include "PowerFSM.h"
|
||||||
|
@ -15,8 +16,10 @@
|
||||||
#include "modules/NodeInfoModule.h"
|
#include "modules/NodeInfoModule.h"
|
||||||
#include "modules/PositionModule.h"
|
#include "modules/PositionModule.h"
|
||||||
#include "power.h"
|
#include "power.h"
|
||||||
|
#include <assert.h>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
#ifdef ARCH_ESP32
|
#if defined(ARCH_ESP32) && !MESHTASTIC_EXCLUDE_BLUETOOTH
|
||||||
#include "nimble/NimbleBluetooth.h"
|
#include "nimble/NimbleBluetooth.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -71,10 +74,11 @@ MeshService::MeshService()
|
||||||
void MeshService::init()
|
void MeshService::init()
|
||||||
{
|
{
|
||||||
// moved much earlier in boot (called from setup())
|
// moved much earlier in boot (called from setup())
|
||||||
// nodeDB->init();
|
// nodeDB.init();
|
||||||
|
#if HAS_GPS
|
||||||
if (gps)
|
if (gps)
|
||||||
gpsObserver.observe(&gps->newStatus);
|
gpsObserver.observe(&gps->newStatus);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int MeshService::handleFromRadio(const meshtastic_MeshPacket *mp)
|
int MeshService::handleFromRadio(const meshtastic_MeshPacket *mp)
|
||||||
|
@ -270,11 +274,13 @@ void MeshService::sendNetworkPing(NodeNum dest, bool wantReplies)
|
||||||
assert(node);
|
assert(node);
|
||||||
|
|
||||||
if (hasValidPosition(node)) {
|
if (hasValidPosition(node)) {
|
||||||
|
#if HAS_GPS
|
||||||
if (positionModule) {
|
if (positionModule) {
|
||||||
LOG_INFO("Sending position ping to 0x%x, wantReplies=%d, channel=%d\n", dest, wantReplies, node->channel);
|
LOG_INFO("Sending position ping to 0x%x, wantReplies=%d, channel=%d\n", dest, wantReplies, node->channel);
|
||||||
positionModule->sendOurPosition(dest, wantReplies, node->channel);
|
positionModule->sendOurPosition(dest, wantReplies, node->channel);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
#endif
|
||||||
if (nodeInfoModule) {
|
if (nodeInfoModule) {
|
||||||
LOG_INFO("Sending nodeinfo ping to 0x%x, wantReplies=%d, channel=%d\n", dest, wantReplies, node->channel);
|
LOG_INFO("Sending nodeinfo ping to 0x%x, wantReplies=%d, channel=%d\n", dest, wantReplies, node->channel);
|
||||||
nodeInfoModule->sendOurNodeInfo(dest, wantReplies, node->channel);
|
nodeInfoModule->sendOurNodeInfo(dest, wantReplies, node->channel);
|
||||||
|
@ -344,6 +350,7 @@ meshtastic_NodeInfoLite *MeshService::refreshLocalMeshNode()
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if HAS_GPS
|
||||||
int MeshService::onGPSChanged(const meshtastic::GPSStatus *newStatus)
|
int MeshService::onGPSChanged(const meshtastic::GPSStatus *newStatus)
|
||||||
{
|
{
|
||||||
// Update our local node info with our position (even if we don't decide to update anyone else)
|
// Update our local node info with our position (even if we don't decide to update anyone else)
|
||||||
|
@ -377,7 +384,7 @@ int MeshService::onGPSChanged(const meshtastic::GPSStatus *newStatus)
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
bool MeshService::isToPhoneQueueEmpty()
|
bool MeshService::isToPhoneQueueEmpty()
|
||||||
{
|
{
|
||||||
return toPhoneQueue.isEmpty();
|
return toPhoneQueue.isEmpty();
|
||||||
|
|
|
@ -23,9 +23,10 @@ extern Allocator<meshtastic_MqttClientProxyMessage> &mqttClientProxyMessagePool;
|
||||||
*/
|
*/
|
||||||
class MeshService
|
class MeshService
|
||||||
{
|
{
|
||||||
|
#if HAS_GPS
|
||||||
CallbackObserver<MeshService, const meshtastic::GPSStatus *> gpsObserver =
|
CallbackObserver<MeshService, const meshtastic::GPSStatus *> gpsObserver =
|
||||||
CallbackObserver<MeshService, const meshtastic::GPSStatus *>(this, &MeshService::onGPSChanged);
|
CallbackObserver<MeshService, const meshtastic::GPSStatus *>(this, &MeshService::onGPSChanged);
|
||||||
|
#endif
|
||||||
/// received packets waiting for the phone to process them
|
/// received packets waiting for the phone to process them
|
||||||
/// FIXME, change to a DropOldestQueue and keep a count of the number of dropped packets to ensure
|
/// FIXME, change to a DropOldestQueue and keep a count of the number of dropped packets to ensure
|
||||||
/// we never hang because android hasn't been there in a while
|
/// we never hang because android hasn't been there in a while
|
||||||
|
@ -132,10 +133,11 @@ class MeshService
|
||||||
ErrorCode sendQueueStatusToPhone(const meshtastic_QueueStatus &qs, ErrorCode res, uint32_t mesh_packet_id);
|
ErrorCode sendQueueStatusToPhone(const meshtastic_QueueStatus &qs, ErrorCode res, uint32_t mesh_packet_id);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
#if HAS_GPS
|
||||||
/// Called when our gps position has changed - updates nodedb and sends Location message out into the mesh
|
/// Called when our gps position has changed - updates nodedb and sends Location message out into the mesh
|
||||||
/// returns 0 to allow further processing
|
/// returns 0 to allow further processing
|
||||||
int onGPSChanged(const meshtastic::GPSStatus *arg);
|
int onGPSChanged(const meshtastic::GPSStatus *arg);
|
||||||
|
#endif
|
||||||
/// Handle a packet that just arrived from the radio. This method does _ReliableRouternot_ free the provided packet. If it
|
/// Handle a packet that just arrived from the radio. This method does _ReliableRouternot_ free the provided packet. If it
|
||||||
/// needs to keep the packet around it makes a copy
|
/// needs to keep the packet around it makes a copy
|
||||||
int handleFromRadio(const meshtastic_MeshPacket *p);
|
int handleFromRadio(const meshtastic_MeshPacket *p);
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
#include "configuration.h"
|
#include "configuration.h"
|
||||||
|
#if !MESHTASTIC_EXCLUDE_GPS
|
||||||
|
#include "GPS.h"
|
||||||
|
#endif
|
||||||
#include "../detect/ScanI2C.h"
|
#include "../detect/ScanI2C.h"
|
||||||
#include "Channels.h"
|
#include "Channels.h"
|
||||||
#include "CryptoEngine.h"
|
#include "CryptoEngine.h"
|
||||||
#include "Default.h"
|
#include "Default.h"
|
||||||
#include "FSCommon.h"
|
#include "FSCommon.h"
|
||||||
#include "GPS.h"
|
|
||||||
#include "MeshRadio.h"
|
#include "MeshRadio.h"
|
||||||
#include "NodeDB.h"
|
#include "NodeDB.h"
|
||||||
#include "PacketHistory.h"
|
#include "PacketHistory.h"
|
||||||
|
@ -25,7 +26,9 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#ifdef ARCH_ESP32
|
#ifdef ARCH_ESP32
|
||||||
|
#if !MESHTASTIC_EXCLUDE_WIFI
|
||||||
#include "mesh/wifi/WiFiAPClient.h"
|
#include "mesh/wifi/WiFiAPClient.h"
|
||||||
|
#endif
|
||||||
#include "modules/esp32/StoreForwardModule.h"
|
#include "modules/esp32/StoreForwardModule.h"
|
||||||
#include <Preferences.h>
|
#include <Preferences.h>
|
||||||
#include <nvs_flash.h>
|
#include <nvs_flash.h>
|
||||||
|
@ -230,7 +233,7 @@ void NodeDB::installDefaultConfig()
|
||||||
config.has_position = true;
|
config.has_position = true;
|
||||||
config.has_power = true;
|
config.has_power = true;
|
||||||
config.has_network = true;
|
config.has_network = true;
|
||||||
config.has_bluetooth = true;
|
config.has_bluetooth = (HAS_BLUETOOTH ? true : false);
|
||||||
config.device.rebroadcast_mode = meshtastic_Config_DeviceConfig_RebroadcastMode_ALL;
|
config.device.rebroadcast_mode = meshtastic_Config_DeviceConfig_RebroadcastMode_ALL;
|
||||||
|
|
||||||
config.lora.sx126x_rx_boosted_gain = true;
|
config.lora.sx126x_rx_boosted_gain = true;
|
||||||
|
|
|
@ -1,13 +1,16 @@
|
||||||
#include "PhoneAPI.h"
|
#include "configuration.h"
|
||||||
|
#if !MESHTASTIC_EXCLUDE_GPS
|
||||||
|
#include "GPS.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "Channels.h"
|
#include "Channels.h"
|
||||||
#include "Default.h"
|
#include "Default.h"
|
||||||
#include "GPS.h"
|
|
||||||
#include "MeshService.h"
|
#include "MeshService.h"
|
||||||
#include "NodeDB.h"
|
#include "NodeDB.h"
|
||||||
|
#include "PhoneAPI.h"
|
||||||
#include "PowerFSM.h"
|
#include "PowerFSM.h"
|
||||||
#include "RadioInterface.h"
|
#include "RadioInterface.h"
|
||||||
#include "TypeConversions.h"
|
#include "TypeConversions.h"
|
||||||
#include "configuration.h"
|
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "xmodem.h"
|
#include "xmodem.h"
|
||||||
|
|
||||||
|
@ -18,8 +21,9 @@
|
||||||
#if ToRadio_size > MAX_TO_FROM_RADIO_SIZE
|
#if ToRadio_size > MAX_TO_FROM_RADIO_SIZE
|
||||||
#error ToRadio is too big
|
#error ToRadio is too big
|
||||||
#endif
|
#endif
|
||||||
|
#if !MESHTASTIC_EXCLUDE_MQTT
|
||||||
#include "mqtt/MQTT.h"
|
#include "mqtt/MQTT.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
PhoneAPI::PhoneAPI()
|
PhoneAPI::PhoneAPI()
|
||||||
{
|
{
|
||||||
|
@ -104,6 +108,7 @@ bool PhoneAPI::handleToRadio(const uint8_t *buf, size_t bufLength)
|
||||||
LOG_INFO("Got xmodem packet\n");
|
LOG_INFO("Got xmodem packet\n");
|
||||||
xModem.handlePacket(toRadioScratch.xmodemPacket);
|
xModem.handlePacket(toRadioScratch.xmodemPacket);
|
||||||
break;
|
break;
|
||||||
|
#if !MESHTASTIC_EXCLUDE_MQTT
|
||||||
case meshtastic_ToRadio_mqttClientProxyMessage_tag:
|
case meshtastic_ToRadio_mqttClientProxyMessage_tag:
|
||||||
LOG_INFO("Got MqttClientProxy message\n");
|
LOG_INFO("Got MqttClientProxy message\n");
|
||||||
if (mqtt && moduleConfig.mqtt.proxy_to_client_enabled && moduleConfig.mqtt.enabled &&
|
if (mqtt && moduleConfig.mqtt.proxy_to_client_enabled && moduleConfig.mqtt.enabled &&
|
||||||
|
@ -114,6 +119,7 @@ bool PhoneAPI::handleToRadio(const uint8_t *buf, size_t bufLength)
|
||||||
"not enabled\n");
|
"not enabled\n");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
#endif
|
||||||
case meshtastic_ToRadio_heartbeat_tag:
|
case meshtastic_ToRadio_heartbeat_tag:
|
||||||
LOG_DEBUG("Got client heartbeat\n");
|
LOG_DEBUG("Got client heartbeat\n");
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -11,9 +11,9 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#include "mesh/compression/unishox2.h"
|
#include "mesh/compression/unishox2.h"
|
||||||
}
|
}
|
||||||
|
#if !MESHTASTIC_EXCLUDE_MQTT
|
||||||
#include "mqtt/MQTT.h"
|
#include "mqtt/MQTT.h"
|
||||||
|
#endif
|
||||||
/**
|
/**
|
||||||
* Router todo
|
* Router todo
|
||||||
*
|
*
|
||||||
|
@ -261,11 +261,12 @@ ErrorCode Router::send(meshtastic_MeshPacket *p)
|
||||||
abortSendAndNak(encodeResult, p);
|
abortSendAndNak(encodeResult, p);
|
||||||
return encodeResult; // FIXME - this isn't a valid ErrorCode
|
return encodeResult; // FIXME - this isn't a valid ErrorCode
|
||||||
}
|
}
|
||||||
|
#if !MESHTASTIC_EXCLUDE_MQTT
|
||||||
// Only publish to MQTT if we're the original transmitter of the packet
|
// Only publish to MQTT if we're the original transmitter of the packet
|
||||||
if (moduleConfig.mqtt.enabled && p->from == nodeDB->getNodeNum() && mqtt) {
|
if (moduleConfig.mqtt.enabled && p->from == nodeDB->getNodeNum() && mqtt) {
|
||||||
mqtt->onSend(*p, *p_decoded, chIndex);
|
mqtt->onSend(*p, *p_decoded, chIndex);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
packetPool.release(p_decoded);
|
packetPool.release(p_decoded);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -465,10 +466,12 @@ void Router::handleReceived(meshtastic_MeshPacket *p, RxSource src)
|
||||||
cancelSending(p->from, p->id);
|
cancelSending(p->from, p->id);
|
||||||
skipHandle = true;
|
skipHandle = true;
|
||||||
}
|
}
|
||||||
|
#if !MESHTASTIC_EXCLUDE_MQTT
|
||||||
// Publish received message to MQTT if we're not the original transmitter of the packet
|
// Publish received message to MQTT if we're not the original transmitter of the packet
|
||||||
if (!skipHandle && moduleConfig.mqtt.enabled && getFrom(p) != nodeDB->getNodeNum() && mqtt)
|
if (!skipHandle && moduleConfig.mqtt.enabled && getFrom(p) != nodeDB->getNodeNum() && mqtt)
|
||||||
mqtt->onSend(*p_encrypted, *p, p->channel);
|
mqtt->onSend(*p_encrypted, *p, p->channel);
|
||||||
|
#endif
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
printPacket("packet decoding failed or skipped (no PSK?)", p);
|
printPacket("packet decoding failed or skipped (no PSK?)", p);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,9 +2,12 @@
|
||||||
#include "NodeDB.h"
|
#include "NodeDB.h"
|
||||||
#include "RTC.h"
|
#include "RTC.h"
|
||||||
#include "concurrency/Periodic.h"
|
#include "concurrency/Periodic.h"
|
||||||
|
#include "configuration.h"
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "mesh/api/ethServerAPI.h"
|
#include "mesh/api/ethServerAPI.h"
|
||||||
|
#if !MESHTASTIC_EXCLUDE_MQTT
|
||||||
#include "mqtt/MQTT.h"
|
#include "mqtt/MQTT.h"
|
||||||
|
#endif
|
||||||
#include "target_specific.h"
|
#include "target_specific.h"
|
||||||
#include <RAK13800_W5100S.h>
|
#include <RAK13800_W5100S.h>
|
||||||
#include <SPI.h>
|
#include <SPI.h>
|
||||||
|
@ -66,11 +69,12 @@ static int32_t reconnectETH()
|
||||||
|
|
||||||
ethStartupComplete = true;
|
ethStartupComplete = true;
|
||||||
}
|
}
|
||||||
|
#if !MESHTASTIC_EXCLUDE_MQTT
|
||||||
// FIXME this is kinda yucky, instead we should just have an observable for 'wifireconnected'
|
// FIXME this is kinda yucky, instead we should just have an observable for 'wifireconnected'
|
||||||
if (mqtt && !moduleConfig.mqtt.proxy_to_client_enabled && !mqtt->isConnectedDirectly()) {
|
if (mqtt && !moduleConfig.mqtt.proxy_to_client_enabled && !mqtt->isConnectedDirectly()) {
|
||||||
mqtt->reconnect();
|
mqtt->reconnect();
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef DISABLE_NTP
|
#ifndef DISABLE_NTP
|
||||||
|
|
|
@ -6,7 +6,9 @@
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "mesh/http/ContentHelper.h"
|
#include "mesh/http/ContentHelper.h"
|
||||||
#include "mesh/http/WebServer.h"
|
#include "mesh/http/WebServer.h"
|
||||||
|
#if !MESHTASTIC_EXCLUDE_WIFI
|
||||||
#include "mesh/wifi/WiFiAPClient.h"
|
#include "mesh/wifi/WiFiAPClient.h"
|
||||||
|
#endif
|
||||||
#include "mqtt/JSON.h"
|
#include "mqtt/JSON.h"
|
||||||
#include "power.h"
|
#include "power.h"
|
||||||
#include "sleep.h"
|
#include "sleep.h"
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
|
#include "configuration.h"
|
||||||
#if !MESHTASTIC_EXCLUDE_WEBSERVER
|
#if !MESHTASTIC_EXCLUDE_WEBSERVER
|
||||||
#include "mesh/http/WebServer.h"
|
|
||||||
#include "NodeDB.h"
|
#include "NodeDB.h"
|
||||||
#include "graphics/Screen.h"
|
#include "graphics/Screen.h"
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
|
#include "mesh/http/WebServer.h"
|
||||||
#include "mesh/wifi/WiFiAPClient.h"
|
#include "mesh/wifi/WiFiAPClient.h"
|
||||||
#include "sleep.h"
|
#include "sleep.h"
|
||||||
#include <HTTPBodyParser.hpp>
|
#include <HTTPBodyParser.hpp>
|
||||||
#include <HTTPMultipartBodyParser.hpp>
|
#include <HTTPMultipartBodyParser.hpp>
|
||||||
#include <HTTPURLEncodedBodyParser.hpp>
|
#include <HTTPURLEncodedBodyParser.hpp>
|
||||||
|
|
||||||
#include <WebServer.h>
|
#include <WebServer.h>
|
||||||
#include <WiFi.h>
|
#include <WiFi.h>
|
||||||
|
|
||||||
|
|
|
@ -1,18 +1,24 @@
|
||||||
#include "mesh/wifi/WiFiAPClient.h"
|
#include "configuration.h"
|
||||||
|
#if !MESHTASTIC_EXCLUDE_WIFI
|
||||||
#include "NodeDB.h"
|
#include "NodeDB.h"
|
||||||
#include "RTC.h"
|
#include "RTC.h"
|
||||||
#include "concurrency/Periodic.h"
|
#include "concurrency/Periodic.h"
|
||||||
#include "configuration.h"
|
#include "mesh/wifi/WiFiAPClient.h"
|
||||||
|
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "mesh/api/WiFiServerAPI.h"
|
#include "mesh/api/WiFiServerAPI.h"
|
||||||
|
#if !MESHTASTIC_EXCLUDE_MQTT
|
||||||
#include "mqtt/MQTT.h"
|
#include "mqtt/MQTT.h"
|
||||||
|
#endif
|
||||||
#include "target_specific.h"
|
#include "target_specific.h"
|
||||||
#include <WiFi.h>
|
#include <WiFi.h>
|
||||||
#include <WiFiUdp.h>
|
#include <WiFiUdp.h>
|
||||||
#ifdef ARCH_ESP32
|
#ifdef ARCH_ESP32
|
||||||
#if !MESHTASTIC_EXCLUDE_WEBSERVER
|
#if !MESHTASTIC_EXCLUDE_WEBSERVER
|
||||||
|
#if !MESHTASTIC_EXCLUDE_WEBSERVER
|
||||||
#include "mesh/http/WebServer.h"
|
#include "mesh/http/WebServer.h"
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
#include <ESPmDNS.h>
|
#include <ESPmDNS.h>
|
||||||
#include <esp_wifi.h>
|
#include <esp_wifi.h>
|
||||||
static void WiFiEvent(WiFiEvent_t event);
|
static void WiFiEvent(WiFiEvent_t event);
|
||||||
|
@ -408,3 +414,4 @@ uint8_t getWifiDisconnectReason()
|
||||||
{
|
{
|
||||||
return wifiDisconnectReason;
|
return wifiDisconnectReason;
|
||||||
}
|
}
|
||||||
|
#endif
|
|
@ -5,7 +5,7 @@
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
|
||||||
#if defined(HAS_WIFI) && !defined(ARCH_PORTDUINO)
|
#if HAS_WIFI && !defined(ARCH_PORTDUINO)
|
||||||
#include <WiFi.h>
|
#include <WiFi.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
#include "NodeDB.h"
|
#include "NodeDB.h"
|
||||||
#include "PowerFSM.h"
|
#include "PowerFSM.h"
|
||||||
#include <FSCommon.h>
|
#include <FSCommon.h>
|
||||||
#ifdef ARCH_ESP32
|
#if defined(ARCH_ESP32) && !MESHTASTIC_EXCLUDE_BLUETOOTH
|
||||||
#include "BleOta.h"
|
#include "BleOta.h"
|
||||||
#endif
|
#endif
|
||||||
#include "Router.h"
|
#include "Router.h"
|
||||||
|
@ -18,7 +18,9 @@
|
||||||
#endif
|
#endif
|
||||||
#include "Default.h"
|
#include "Default.h"
|
||||||
|
|
||||||
|
#if !MESHTASTIC_EXCLUDE_MQTT
|
||||||
#include "mqtt/MQTT.h"
|
#include "mqtt/MQTT.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
AdminModule *adminModule;
|
AdminModule *adminModule;
|
||||||
bool hasOpenEditTransaction;
|
bool hasOpenEditTransaction;
|
||||||
|
@ -119,7 +121,7 @@ bool AdminModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, meshta
|
||||||
}
|
}
|
||||||
case meshtastic_AdminMessage_reboot_ota_seconds_tag: {
|
case meshtastic_AdminMessage_reboot_ota_seconds_tag: {
|
||||||
int32_t s = r->reboot_ota_seconds;
|
int32_t s = r->reboot_ota_seconds;
|
||||||
#ifdef ARCH_ESP32
|
#if defined(ARCH_ESP32) && !MESHTASTIC_EXCLUDE_BLUETOOTH
|
||||||
if (BleOta::getOtaAppVersion().isEmpty()) {
|
if (BleOta::getOtaAppVersion().isEmpty()) {
|
||||||
LOG_INFO("No OTA firmware available, scheduling regular reboot in %d seconds\n", s);
|
LOG_INFO("No OTA firmware available, scheduling regular reboot in %d seconds\n", s);
|
||||||
screen->startRebootScreen();
|
screen->startRebootScreen();
|
||||||
|
@ -666,7 +668,9 @@ void AdminModule::handleGetDeviceConnectionStatus(const meshtastic_MeshPacket &r
|
||||||
if (Ethernet.linkStatus() == LinkON) {
|
if (Ethernet.linkStatus() == LinkON) {
|
||||||
conn.ethernet.status.is_connected = true;
|
conn.ethernet.status.is_connected = true;
|
||||||
conn.ethernet.status.ip_address = Ethernet.localIP();
|
conn.ethernet.status.ip_address = Ethernet.localIP();
|
||||||
|
#if !MESHTASTIC_EXCLUDE_MQTT
|
||||||
conn.ethernet.status.is_mqtt_connected = mqtt && mqtt->isConnectedDirectly();
|
conn.ethernet.status.is_mqtt_connected = mqtt && mqtt->isConnectedDirectly();
|
||||||
|
#endif
|
||||||
conn.ethernet.status.is_syslog_connected = false; // FIXME wire this up
|
conn.ethernet.status.is_syslog_connected = false; // FIXME wire this up
|
||||||
} else {
|
} else {
|
||||||
conn.ethernet.status.is_connected = false;
|
conn.ethernet.status.is_connected = false;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "ProtobufModule.h"
|
#include "ProtobufModule.h"
|
||||||
#if HAS_WIFI
|
#if HAS_WIFI && !MESHTASTIC_EXCLUDE_WIFI
|
||||||
#include "mesh/wifi/WiFiAPClient.h"
|
#include "mesh/wifi/WiFiAPClient.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,9 @@
|
||||||
#include "modules/NeighborInfoModule.h"
|
#include "modules/NeighborInfoModule.h"
|
||||||
#endif
|
#endif
|
||||||
#include "modules/NodeInfoModule.h"
|
#include "modules/NodeInfoModule.h"
|
||||||
|
#if !MESHTASTIC_EXCLUDE_GPS
|
||||||
#include "modules/PositionModule.h"
|
#include "modules/PositionModule.h"
|
||||||
|
#endif
|
||||||
#if !MESHTASTIC_EXCLUDE_REMOTEHARDWARE
|
#if !MESHTASTIC_EXCLUDE_REMOTEHARDWARE
|
||||||
#include "modules/RemoteHardwareModule.h"
|
#include "modules/RemoteHardwareModule.h"
|
||||||
#endif
|
#endif
|
||||||
|
@ -61,15 +63,13 @@
|
||||||
#if !MESHTASTIC_EXCLUDE_EXTERNALNOTIFICATION
|
#if !MESHTASTIC_EXCLUDE_EXTERNALNOTIFICATION
|
||||||
#include "modules/ExternalNotificationModule.h"
|
#include "modules/ExternalNotificationModule.h"
|
||||||
#endif
|
#endif
|
||||||
#if !MESHTASTIC_EXCLUDE_RANGETEST
|
#if !MESHTASTIC_EXCLUDE_RANGETEST && !MESHTASTIC_EXCLUDE_GPS
|
||||||
#include "modules/RangeTestModule.h"
|
#include "modules/RangeTestModule.h"
|
||||||
#endif
|
#endif
|
||||||
#if (defined(ARCH_ESP32) || defined(ARCH_NRF52) || defined(ARCH_RP2040)) && !defined(CONFIG_IDF_TARGET_ESP32S2)
|
#if !defined(CONFIG_IDF_TARGET_ESP32S2) && !MESHTASTIC_EXCLUDE_SERIAL
|
||||||
#if !MESHTASTIC_EXCLUDE_SERIAL
|
|
||||||
#include "modules/SerialModule.h"
|
#include "modules/SerialModule.h"
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
/**
|
/**
|
||||||
* Create module instances here. If you are adding a new module, you must 'new' it here (or somewhere else)
|
* Create module instances here. If you are adding a new module, you must 'new' it here (or somewhere else)
|
||||||
*/
|
*/
|
||||||
|
@ -81,7 +81,9 @@ void setupModules()
|
||||||
#endif
|
#endif
|
||||||
adminModule = new AdminModule();
|
adminModule = new AdminModule();
|
||||||
nodeInfoModule = new NodeInfoModule();
|
nodeInfoModule = new NodeInfoModule();
|
||||||
|
#if !MESHTASTIC_EXCLUDE_GPS
|
||||||
positionModule = new PositionModule();
|
positionModule = new PositionModule();
|
||||||
|
#endif
|
||||||
#if !MESHTASTIC_EXCLUDE_WAYPOINT
|
#if !MESHTASTIC_EXCLUDE_WAYPOINT
|
||||||
waypointModule = new WaypointModule();
|
waypointModule = new WaypointModule();
|
||||||
#endif
|
#endif
|
||||||
|
@ -169,7 +171,7 @@ void setupModules()
|
||||||
#if !MESHTASTIC_EXCLUDE_EXTERNALNOTIFICATION
|
#if !MESHTASTIC_EXCLUDE_EXTERNALNOTIFICATION
|
||||||
externalNotificationModule = new ExternalNotificationModule();
|
externalNotificationModule = new ExternalNotificationModule();
|
||||||
#endif
|
#endif
|
||||||
#if !MESHTASTIC_EXCLUDE_RANGETEST
|
#if !MESHTASTIC_EXCLUDE_RANGETEST && !MESHTASTIC_EXCLUDE_GPS
|
||||||
new RangeTestModule();
|
new RangeTestModule();
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
#if !MESHTASTIC_EXCLUDE_GPS
|
||||||
#include "PositionModule.h"
|
#include "PositionModule.h"
|
||||||
#include "Default.h"
|
#include "Default.h"
|
||||||
#include "GPS.h"
|
#include "GPS.h"
|
||||||
|
@ -418,4 +419,6 @@ void PositionModule::handleNewPosition()
|
||||||
lastGpsSend = now;
|
lastGpsSend = now;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -179,14 +179,14 @@ int32_t SerialModule::runOnce()
|
||||||
} else {
|
} else {
|
||||||
if (moduleConfig.serial.mode == meshtastic_ModuleConfig_SerialConfig_Serial_Mode_PROTO) {
|
if (moduleConfig.serial.mode == meshtastic_ModuleConfig_SerialConfig_Serial_Mode_PROTO) {
|
||||||
return runOncePart();
|
return runOncePart();
|
||||||
} else if (moduleConfig.serial.mode == meshtastic_ModuleConfig_SerialConfig_Serial_Mode_NMEA) {
|
} else if ((moduleConfig.serial.mode == meshtastic_ModuleConfig_SerialConfig_Serial_Mode_NMEA) && HAS_GPS) {
|
||||||
// in NMEA mode send out GGA every 2 seconds, Don't read from Port
|
// in NMEA mode send out GGA every 2 seconds, Don't read from Port
|
||||||
if (millis() - lastNmeaTime > 2000) {
|
if (millis() - lastNmeaTime > 2000) {
|
||||||
lastNmeaTime = millis();
|
lastNmeaTime = millis();
|
||||||
printGGA(outbuf, sizeof(outbuf), localPosition);
|
printGGA(outbuf, sizeof(outbuf), localPosition);
|
||||||
serialPrint->printf("%s", outbuf);
|
serialPrint->printf("%s", outbuf);
|
||||||
}
|
}
|
||||||
} else if (moduleConfig.serial.mode == meshtastic_ModuleConfig_SerialConfig_Serial_Mode_CALTOPO) {
|
} else if ((moduleConfig.serial.mode == meshtastic_ModuleConfig_SerialConfig_Serial_Mode_CALTOPO) && HAS_GPS) {
|
||||||
if (millis() - lastNmeaTime > 10000) {
|
if (millis() - lastNmeaTime > 10000) {
|
||||||
lastNmeaTime = millis();
|
lastNmeaTime = millis();
|
||||||
uint32_t readIndex = 0;
|
uint32_t readIndex = 0;
|
||||||
|
@ -295,8 +295,9 @@ ProcessMessage SerialModuleRadio::handleReceived(const meshtastic_MeshPacket &mp
|
||||||
serialPrint->println();
|
serialPrint->println();
|
||||||
serialPrint->printf("%s: %s", sender, p.payload.bytes);
|
serialPrint->printf("%s: %s", sender, p.payload.bytes);
|
||||||
serialPrint->println();
|
serialPrint->println();
|
||||||
} else if (moduleConfig.serial.mode == meshtastic_ModuleConfig_SerialConfig_Serial_Mode_NMEA ||
|
} else if ((moduleConfig.serial.mode == meshtastic_ModuleConfig_SerialConfig_Serial_Mode_NMEA ||
|
||||||
moduleConfig.serial.mode == meshtastic_ModuleConfig_SerialConfig_Serial_Mode_CALTOPO) {
|
moduleConfig.serial.mode == meshtastic_ModuleConfig_SerialConfig_Serial_Mode_CALTOPO) &&
|
||||||
|
HAS_GPS) {
|
||||||
// Decode the Payload some more
|
// Decode the Payload some more
|
||||||
meshtastic_Position scratch;
|
meshtastic_Position scratch;
|
||||||
meshtastic_Position *decoded = NULL;
|
meshtastic_Position *decoded = NULL;
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#include "MeshService.h"
|
#include "MeshService.h"
|
||||||
#include "NodeDB.h"
|
#include "NodeDB.h"
|
||||||
#include "PowerFSM.h"
|
#include "PowerFSM.h"
|
||||||
|
#include "configuration.h"
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "mesh/Channels.h"
|
#include "mesh/Channels.h"
|
||||||
#include "mesh/Router.h"
|
#include "mesh/Router.h"
|
||||||
|
@ -13,7 +14,7 @@
|
||||||
#endif
|
#endif
|
||||||
#include "mesh/generated/meshtastic/remote_hardware.pb.h"
|
#include "mesh/generated/meshtastic/remote_hardware.pb.h"
|
||||||
#include "sleep.h"
|
#include "sleep.h"
|
||||||
#if HAS_WIFI
|
#if HAS_WIFI && !MESHTASTIC_EXCLUDE_WIFI
|
||||||
#include "mesh/wifi/WiFiAPClient.h"
|
#include "mesh/wifi/WiFiAPClient.h"
|
||||||
#include <WiFi.h>
|
#include <WiFi.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
#include "NimbleBluetooth.h"
|
|
||||||
#include "BluetoothCommon.h"
|
|
||||||
#include "PowerFSM.h"
|
|
||||||
#include "configuration.h"
|
#include "configuration.h"
|
||||||
|
#if !MESHTASTIC_EXCLUDE_BLUETOOTH
|
||||||
|
#include "BluetoothCommon.h"
|
||||||
|
#include "NimbleBluetooth.h"
|
||||||
|
#include "PowerFSM.h"
|
||||||
|
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "mesh/PhoneAPI.h"
|
#include "mesh/PhoneAPI.h"
|
||||||
#include "mesh/mesh-pb-constants.h"
|
#include "mesh/mesh-pb-constants.h"
|
||||||
|
@ -227,3 +229,4 @@ void clearNVS()
|
||||||
ESP.restart();
|
ESP.restart();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
#endif
|
|
@ -3,11 +3,14 @@
|
||||||
#include "esp_task_wdt.h"
|
#include "esp_task_wdt.h"
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
|
|
||||||
#if !defined(CONFIG_IDF_TARGET_ESP32S2)
|
#if !defined(CONFIG_IDF_TARGET_ESP32S2) && !MESHTASTIC_EXCLUDE_BLUETOOTH
|
||||||
|
#include "BleOta.h"
|
||||||
#include "nimble/NimbleBluetooth.h"
|
#include "nimble/NimbleBluetooth.h"
|
||||||
#endif
|
#endif
|
||||||
#include "BleOta.h"
|
|
||||||
|
#if !MESHTASTIC_EXCLUDE_WIFI
|
||||||
#include "mesh/wifi/WiFiAPClient.h"
|
#include "mesh/wifi/WiFiAPClient.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "meshUtils.h"
|
#include "meshUtils.h"
|
||||||
#include "sleep.h"
|
#include "sleep.h"
|
||||||
|
@ -18,8 +21,7 @@
|
||||||
#include <nvs.h>
|
#include <nvs.h>
|
||||||
#include <nvs_flash.h>
|
#include <nvs_flash.h>
|
||||||
|
|
||||||
#if !defined(CONFIG_IDF_TARGET_ESP32S2)
|
#if !defined(CONFIG_IDF_TARGET_ESP32S2) && !MESHTASTIC_EXCLUDE_BLUETOOTH
|
||||||
|
|
||||||
void setBluetoothEnable(bool enable)
|
void setBluetoothEnable(bool enable)
|
||||||
{
|
{
|
||||||
if (!isWifiAvailable() && config.bluetooth.enabled == true) {
|
if (!isWifiAvailable() && config.bluetooth.enabled == true) {
|
||||||
|
@ -108,12 +110,16 @@ void esp32Setup()
|
||||||
preferences.putUInt("rebootCounter", rebootCounter);
|
preferences.putUInt("rebootCounter", rebootCounter);
|
||||||
preferences.end();
|
preferences.end();
|
||||||
LOG_DEBUG("Number of Device Reboots: %d\n", rebootCounter);
|
LOG_DEBUG("Number of Device Reboots: %d\n", rebootCounter);
|
||||||
|
#if !MESHTASTIC_EXCLUDE_BLUETOOTH
|
||||||
String BLEOTA = BleOta::getOtaAppVersion();
|
String BLEOTA = BleOta::getOtaAppVersion();
|
||||||
if (BLEOTA.isEmpty()) {
|
if (BLEOTA.isEmpty()) {
|
||||||
LOG_DEBUG("No OTA firmware available\n");
|
LOG_DEBUG("No OTA firmware available\n");
|
||||||
} else {
|
} else {
|
||||||
LOG_DEBUG("OTA firmware version %s\n", BLEOTA.c_str());
|
LOG_DEBUG("OTA firmware version %s\n", BLEOTA.c_str());
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
LOG_DEBUG("No OTA firmware available\n");
|
||||||
|
#endif
|
||||||
|
|
||||||
// enableModemSleep();
|
// enableModemSleep();
|
||||||
|
|
||||||
|
|
|
@ -65,6 +65,7 @@ static void initBrownout()
|
||||||
|
|
||||||
static const bool useSoftDevice = true; // Set to false for easier debugging
|
static const bool useSoftDevice = true; // Set to false for easier debugging
|
||||||
|
|
||||||
|
#if !MESHTASTIC_EXCLUDE_BLUETOOTH
|
||||||
void setBluetoothEnable(bool enable)
|
void setBluetoothEnable(bool enable)
|
||||||
{
|
{
|
||||||
if (enable && config.bluetooth.enabled) {
|
if (enable && config.bluetooth.enabled) {
|
||||||
|
@ -88,7 +89,9 @@ void setBluetoothEnable(bool enable)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
void setBluetoothEnable(bool enable) {}
|
||||||
|
#endif
|
||||||
/**
|
/**
|
||||||
* Override printf to use the SEGGER output library (note - this does not effect the printf method on the debug console)
|
* Override printf to use the SEGGER output library (note - this does not effect the printf method on the debug console)
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,17 +1,23 @@
|
||||||
#include "sleep.h"
|
#include "configuration.h"
|
||||||
|
|
||||||
|
#if !MESHTASTIC_EXCLUDE_GPS
|
||||||
#include "GPS.h"
|
#include "GPS.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "MeshRadio.h"
|
#include "MeshRadio.h"
|
||||||
#include "MeshService.h"
|
#include "MeshService.h"
|
||||||
#include "NodeDB.h"
|
#include "NodeDB.h"
|
||||||
#include "configuration.h"
|
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
|
#include "sleep.h"
|
||||||
#include "target_specific.h"
|
#include "target_specific.h"
|
||||||
|
|
||||||
#ifdef ARCH_ESP32
|
#ifdef ARCH_ESP32
|
||||||
#include "esp32/pm.h"
|
#include "esp32/pm.h"
|
||||||
#include "esp_pm.h"
|
#include "esp_pm.h"
|
||||||
|
#if !MESHTASTIC_EXCLUDE_WIFI
|
||||||
#include "mesh/wifi/WiFiAPClient.h"
|
#include "mesh/wifi/WiFiAPClient.h"
|
||||||
|
#endif
|
||||||
#include "rom/rtc.h"
|
#include "rom/rtc.h"
|
||||||
#include <driver/rtc_io.h>
|
#include <driver/rtc_io.h>
|
||||||
#include <driver/uart.h>
|
#include <driver/uart.h>
|
||||||
|
@ -48,7 +54,7 @@ RTC_DATA_ATTR int bootCount = 0;
|
||||||
*/
|
*/
|
||||||
void setCPUFast(bool on)
|
void setCPUFast(bool on)
|
||||||
{
|
{
|
||||||
#ifdef ARCH_ESP32
|
#if defined(ARCH_ESP32) && !MESHTASTIC_EXCLUDE_WIFI
|
||||||
|
|
||||||
if (isWifiAvailable()) {
|
if (isWifiAvailable()) {
|
||||||
/*
|
/*
|
||||||
|
@ -206,11 +212,11 @@ void doDeepSleep(uint32_t msecToWake, bool skipPreflight = false)
|
||||||
// pinMode(PIN_POWER_EN1, INPUT_PULLDOWN);
|
// pinMode(PIN_POWER_EN1, INPUT_PULLDOWN);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
#if HAS_GPS
|
||||||
// Kill GPS power completely (even if previously we just had it in sleep mode)
|
// Kill GPS power completely (even if previously we just had it in sleep mode)
|
||||||
if (gps)
|
if (gps)
|
||||||
gps->setGPSPower(false, false, 0);
|
gps->setGPSPower(false, false, 0);
|
||||||
|
#endif
|
||||||
setLed(false);
|
setLed(false);
|
||||||
|
|
||||||
#ifdef RESET_OLED
|
#ifdef RESET_OLED
|
||||||
|
|
Ładowanie…
Reference in New Issue