mirror of
https://github.com/meshtastic/firmware.git
synced 2025-09-18 08:12:57 +00:00
Merge branch 'meshtastic:master' into master
This commit is contained in:
commit
21986183b6
17
.github/actions/setup-base/action.yml
vendored
17
.github/actions/setup-base/action.yml
vendored
@ -22,19 +22,20 @@ runs:
|
|||||||
with:
|
with:
|
||||||
python-version: 3.x
|
python-version: 3.x
|
||||||
|
|
||||||
- name: Cache python libs
|
# - name: Cache python libs
|
||||||
uses: actions/cache@v4
|
# uses: actions/cache@v4
|
||||||
id: cache-pip # needed in if test
|
# id: cache-pip # needed in if test
|
||||||
with:
|
# with:
|
||||||
path: ~/.cache/pip
|
# path: ~/.cache/pip
|
||||||
key: ${{ runner.os }}-pip
|
# key: ${{ runner.os }}-pip
|
||||||
|
|
||||||
- name: Upgrade python tools
|
- name: Upgrade python tools
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
python -m pip install --upgrade pip
|
python -m pip install --upgrade pip
|
||||||
pip install -U platformio adafruit-nrfutil
|
pip install -U --no-build-isolation --no-cache-dir "setuptools<72"
|
||||||
pip install -U meshtastic --pre
|
pip install -U platformio adafruit-nrfutil --no-build-isolation
|
||||||
|
pip install -U meshtastic --pre --no-build-isolation
|
||||||
|
|
||||||
- name: Upgrade platformio
|
- name: Upgrade platformio
|
||||||
shell: bash
|
shell: bash
|
||||||
|
@ -135,6 +135,7 @@ Input:
|
|||||||
|
|
||||||
Logging:
|
Logging:
|
||||||
LogLevel: info # debug, info, warn, error
|
LogLevel: info # debug, info, warn, error
|
||||||
|
# TraceFile: /var/log/meshtasticd.json
|
||||||
|
|
||||||
Webserver:
|
Webserver:
|
||||||
# Port: 443 # Port for Webserver & Webservices
|
# Port: 443 # Port for Webserver & Webservices
|
||||||
|
@ -49,7 +49,11 @@ size_t RedirectablePrint::write(uint8_t c)
|
|||||||
size_t RedirectablePrint::vprintf(const char *logLevel, const char *format, va_list arg)
|
size_t RedirectablePrint::vprintf(const char *logLevel, const char *format, va_list arg)
|
||||||
{
|
{
|
||||||
va_list copy;
|
va_list copy;
|
||||||
|
#if ENABLE_JSON_LOGGING || ARCH_PORTDUINO
|
||||||
|
static char printBuf[512];
|
||||||
|
#else
|
||||||
static char printBuf[160];
|
static char printBuf[160];
|
||||||
|
#endif
|
||||||
|
|
||||||
va_copy(copy, arg);
|
va_copy(copy, arg);
|
||||||
size_t len = vsnprintf(printBuf, sizeof(printBuf), format, copy);
|
size_t len = vsnprintf(printBuf, sizeof(printBuf), format, copy);
|
||||||
@ -98,6 +102,8 @@ void RedirectablePrint::log_to_serial(const char *logLevel, const char *format,
|
|||||||
Print::write("\u001b[33m", 6);
|
Print::write("\u001b[33m", 6);
|
||||||
if (strcmp(logLevel, MESHTASTIC_LOG_LEVEL_ERROR) == 0)
|
if (strcmp(logLevel, MESHTASTIC_LOG_LEVEL_ERROR) == 0)
|
||||||
Print::write("\u001b[31m", 6);
|
Print::write("\u001b[31m", 6);
|
||||||
|
if (strcmp(logLevel, MESHTASTIC_LOG_LEVEL_TRACE) == 0)
|
||||||
|
Print::write("\u001b[35m", 6);
|
||||||
uint32_t rtc_sec = getValidTime(RTCQuality::RTCQualityDevice, true); // display local time on logfile
|
uint32_t rtc_sec = getValidTime(RTCQuality::RTCQualityDevice, true); // display local time on logfile
|
||||||
if (rtc_sec > 0) {
|
if (rtc_sec > 0) {
|
||||||
long hms = rtc_sec % SEC_PER_DAY;
|
long hms = rtc_sec % SEC_PER_DAY;
|
||||||
@ -244,7 +250,21 @@ meshtastic_LogRecord_Level RedirectablePrint::getLogLevel(const char *logLevel)
|
|||||||
|
|
||||||
void RedirectablePrint::log(const char *logLevel, const char *format, ...)
|
void RedirectablePrint::log(const char *logLevel, const char *format, ...)
|
||||||
{
|
{
|
||||||
#ifdef ARCH_PORTDUINO
|
#if ARCH_PORTDUINO
|
||||||
|
// level trace is special, two possible ways to handle it.
|
||||||
|
if (strcmp(logLevel, MESHTASTIC_LOG_LEVEL_TRACE) == 0) {
|
||||||
|
if (settingsStrings[traceFilename] != "") {
|
||||||
|
va_list arg;
|
||||||
|
va_start(arg, format);
|
||||||
|
try {
|
||||||
|
traceFile << va_arg(arg, char *) << std::endl;
|
||||||
|
} catch (const std::ios_base::failure &e) {
|
||||||
|
}
|
||||||
|
va_end(arg);
|
||||||
|
}
|
||||||
|
if (settingsMap[logoutputlevel] < level_trace && strcmp(logLevel, MESHTASTIC_LOG_LEVEL_TRACE) == 0)
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (settingsMap[logoutputlevel] < level_debug && strcmp(logLevel, MESHTASTIC_LOG_LEVEL_DEBUG) == 0)
|
if (settingsMap[logoutputlevel] < level_debug && strcmp(logLevel, MESHTASTIC_LOG_LEVEL_DEBUG) == 0)
|
||||||
return;
|
return;
|
||||||
else if (settingsMap[logoutputlevel] < level_info && strcmp(logLevel, MESHTASTIC_LOG_LEVEL_INFO) == 0)
|
else if (settingsMap[logoutputlevel] < level_info && strcmp(logLevel, MESHTASTIC_LOG_LEVEL_INFO) == 0)
|
||||||
|
@ -20,6 +20,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
#include "Screen.h"
|
#include "Screen.h"
|
||||||
|
#include "../userPrefs.h"
|
||||||
#include "configuration.h"
|
#include "configuration.h"
|
||||||
#if HAS_SCREEN
|
#if HAS_SCREEN
|
||||||
#include <OLEDDisplay.h>
|
#include <OLEDDisplay.h>
|
||||||
@ -156,7 +157,11 @@ static void drawIconScreen(const char *upperMsg, OLEDDisplay *display, OLEDDispl
|
|||||||
|
|
||||||
display->setFont(FONT_MEDIUM);
|
display->setFont(FONT_MEDIUM);
|
||||||
display->setTextAlignment(TEXT_ALIGN_LEFT);
|
display->setTextAlignment(TEXT_ALIGN_LEFT);
|
||||||
|
#ifdef SPLASH_TITLE_USERPREFS
|
||||||
|
const char *title = SPLASH_TITLE_USERPREFS;
|
||||||
|
#else
|
||||||
const char *title = "meshtastic.org";
|
const char *title = "meshtastic.org";
|
||||||
|
#endif
|
||||||
display->drawString(x + getStringCenteredX(title), y + SCREEN_HEIGHT - FONT_HEIGHT_MEDIUM, title);
|
display->drawString(x + getStringCenteredX(title), y + SCREEN_HEIGHT - FONT_HEIGHT_MEDIUM, title);
|
||||||
display->setFont(FONT_SMALL);
|
display->setFont(FONT_SMALL);
|
||||||
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
#ifndef HAS_USERPREFS_SPLASH
|
||||||
#define icon_width 50
|
#define icon_width 50
|
||||||
#define icon_height 28
|
#define icon_height 28
|
||||||
static uint8_t icon_bits[] = {
|
static uint8_t icon_bits[] = {
|
||||||
@ -18,3 +19,4 @@ static uint8_t icon_bits[] = {
|
|||||||
0x7E, 0x00, 0x3E, 0x00, 0x00, 0xF8, 0x01, 0x38, 0x00, 0x3C, 0x00, 0x00,
|
0x7E, 0x00, 0x3E, 0x00, 0x00, 0xF8, 0x01, 0x38, 0x00, 0x3C, 0x00, 0x00,
|
||||||
0x70, 0x00, 0x10, 0x00, 0x10, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00,
|
0x70, 0x00, 0x10, 0x00, 0x10, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00,
|
||||||
0x00, 0x00, 0x00, 0x00, };
|
0x00, 0x00, 0x00, 0x00, };
|
||||||
|
#endif
|
@ -1,4 +1,5 @@
|
|||||||
#include "Channels.h"
|
#include "Channels.h"
|
||||||
|
#include "../userPrefs.h"
|
||||||
#include "CryptoEngine.h"
|
#include "CryptoEngine.h"
|
||||||
#include "DisplayFormatters.h"
|
#include "DisplayFormatters.h"
|
||||||
#include "NodeDB.h"
|
#include "NodeDB.h"
|
||||||
@ -90,6 +91,7 @@ void Channels::initDefaultChannel(ChannelIndex chIndex)
|
|||||||
loraConfig.modem_preset = meshtastic_Config_LoRaConfig_ModemPreset_LONG_FAST; // Default to Long Range & Fast
|
loraConfig.modem_preset = meshtastic_Config_LoRaConfig_ModemPreset_LONG_FAST; // Default to Long Range & Fast
|
||||||
loraConfig.use_preset = true;
|
loraConfig.use_preset = true;
|
||||||
loraConfig.tx_power = 0; // default
|
loraConfig.tx_power = 0; // default
|
||||||
|
loraConfig.channel_num = 0;
|
||||||
uint8_t defaultpskIndex = 1;
|
uint8_t defaultpskIndex = 1;
|
||||||
channelSettings.psk.bytes[0] = defaultpskIndex;
|
channelSettings.psk.bytes[0] = defaultpskIndex;
|
||||||
channelSettings.psk.size = 1;
|
channelSettings.psk.size = 1;
|
||||||
@ -99,6 +101,29 @@ void Channels::initDefaultChannel(ChannelIndex chIndex)
|
|||||||
|
|
||||||
ch.has_settings = true;
|
ch.has_settings = true;
|
||||||
ch.role = meshtastic_Channel_Role_PRIMARY;
|
ch.role = meshtastic_Channel_Role_PRIMARY;
|
||||||
|
|
||||||
|
#ifdef LORACONFIG_MODEM_PRESET_USERPREFS
|
||||||
|
loraConfig.modem_preset = LORACONFIG_MODEM_PRESET_USERPREFS;
|
||||||
|
#endif
|
||||||
|
#ifdef LORACONFIG_CHANNEL_NUM_USERPREFS
|
||||||
|
loraConfig.channel_num = LORACONFIG_CHANNEL_NUM_USERPREFS;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Install custom defaults. Will eventually support setting multiple default channels
|
||||||
|
if (chIndex == 0) {
|
||||||
|
#ifdef CHANNEL_0_PSK_USERPREFS
|
||||||
|
static const uint8_t defaultpsk[] = CHANNEL_0_PSK_USERPREFS;
|
||||||
|
memcpy(channelSettings.psk.bytes, defaultpsk, sizeof(defaultpsk));
|
||||||
|
channelSettings.psk.size = sizeof(defaultpsk);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#ifdef CHANNEL_0_NAME_USERPREFS
|
||||||
|
strcpy(channelSettings.name, CHANNEL_0_NAME_USERPREFS);
|
||||||
|
#endif
|
||||||
|
#ifdef CHANNEL_0_PRECISION_USERPREFS
|
||||||
|
channelSettings.module_settings.position_precision = CHANNEL_0_PRECISION_USERPREFS;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CryptoKey Channels::getKey(ChannelIndex chIndex)
|
CryptoKey Channels::getKey(ChannelIndex chIndex)
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
#include "../userPrefs.h"
|
||||||
#include "configuration.h"
|
#include "configuration.h"
|
||||||
#if !MESHTASTIC_EXCLUDE_GPS
|
#if !MESHTASTIC_EXCLUDE_GPS
|
||||||
#include "GPS.h"
|
#include "GPS.h"
|
||||||
@ -237,10 +238,22 @@ void NodeDB::installDefaultConfig()
|
|||||||
config.lora.tx_enabled =
|
config.lora.tx_enabled =
|
||||||
true; // FIXME: maybe false in the future, and setting region to enable it. (unset region forces it off)
|
true; // FIXME: maybe false in the future, and setting region to enable it. (unset region forces it off)
|
||||||
config.lora.override_duty_cycle = false;
|
config.lora.override_duty_cycle = false;
|
||||||
|
#ifdef CONFIG_LORA_REGION_USERPREFS
|
||||||
|
config.lora.region = CONFIG_LORA_REGION_USERPREFS;
|
||||||
|
#else
|
||||||
config.lora.region = meshtastic_Config_LoRaConfig_RegionCode_UNSET;
|
config.lora.region = meshtastic_Config_LoRaConfig_RegionCode_UNSET;
|
||||||
|
#endif
|
||||||
|
#ifdef LORACONFIG_MODEM_PRESET_USERPREFS
|
||||||
|
config.lora.modem_preset = LORACONFIG_MODEM_PRESET_USERPREFS;
|
||||||
|
#else
|
||||||
config.lora.modem_preset = meshtastic_Config_LoRaConfig_ModemPreset_LONG_FAST;
|
config.lora.modem_preset = meshtastic_Config_LoRaConfig_ModemPreset_LONG_FAST;
|
||||||
|
#endif
|
||||||
config.lora.hop_limit = HOP_RELIABLE;
|
config.lora.hop_limit = HOP_RELIABLE;
|
||||||
|
#ifdef CONFIG_LORA_IGNORE_MQTT_USERPREFS
|
||||||
|
config.lora.ignore_mqtt = CONFIG_LORA_IGNORE_MQTT_USERPREFS;
|
||||||
|
#else
|
||||||
config.lora.ignore_mqtt = false;
|
config.lora.ignore_mqtt = false;
|
||||||
|
#endif
|
||||||
#ifdef PIN_GPS_EN
|
#ifdef PIN_GPS_EN
|
||||||
config.position.gps_en_gpio = PIN_GPS_EN;
|
config.position.gps_en_gpio = PIN_GPS_EN;
|
||||||
#endif
|
#endif
|
||||||
|
@ -11,6 +11,12 @@
|
|||||||
#if !MESHTASTIC_EXCLUDE_MQTT
|
#if !MESHTASTIC_EXCLUDE_MQTT
|
||||||
#include "mqtt/MQTT.h"
|
#include "mqtt/MQTT.h"
|
||||||
#endif
|
#endif
|
||||||
|
#if ARCH_PORTDUINO
|
||||||
|
#include "platform/portduino/PortduinoGlue.h"
|
||||||
|
#endif
|
||||||
|
#if ENABLE_JSON_LOGGING || ARCH_PORTDUINO
|
||||||
|
#include "serialization/MeshPacketSerializer.h"
|
||||||
|
#endif
|
||||||
/**
|
/**
|
||||||
* Router todo
|
* Router todo
|
||||||
*
|
*
|
||||||
@ -356,6 +362,13 @@ bool perhapsDecode(meshtastic_MeshPacket *p)
|
|||||||
} */
|
} */
|
||||||
|
|
||||||
printPacket("decoded message", p);
|
printPacket("decoded message", p);
|
||||||
|
#if ENABLE_JSON_LOGGING
|
||||||
|
LOG_TRACE("%s\n", MeshPacketSerializer::JsonSerialize(p, false).c_str());
|
||||||
|
#elif ARCH_PORTDUINO
|
||||||
|
if (settingsStrings[traceFilename] != "" || settingsMap[logoutputlevel] == level_trace) {
|
||||||
|
LOG_TRACE("%s\n", MeshPacketSerializer::JsonSerialize(p, false).c_str());
|
||||||
|
}
|
||||||
|
#endif
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -491,6 +504,17 @@ void Router::handleReceived(meshtastic_MeshPacket *p, RxSource src)
|
|||||||
|
|
||||||
void Router::perhapsHandleReceived(meshtastic_MeshPacket *p)
|
void Router::perhapsHandleReceived(meshtastic_MeshPacket *p)
|
||||||
{
|
{
|
||||||
|
#if ENABLE_JSON_LOGGING
|
||||||
|
// Even ignored packets get logged in the trace
|
||||||
|
p->rx_time = getValidTime(RTCQualityFromNet); // store the arrival timestamp for the phone
|
||||||
|
LOG_TRACE("%s\n", MeshPacketSerializer::JsonSerializeEncrypted(p).c_str());
|
||||||
|
#elif ARCH_PORTDUINO
|
||||||
|
// Even ignored packets get logged in the trace
|
||||||
|
if (settingsStrings[traceFilename] != "" || settingsMap[logoutputlevel] == level_trace) {
|
||||||
|
p->rx_time = getValidTime(RTCQualityFromNet); // store the arrival timestamp for the phone
|
||||||
|
LOG_TRACE("%s\n", MeshPacketSerializer::JsonSerializeEncrypted(p).c_str());
|
||||||
|
}
|
||||||
|
#endif
|
||||||
// assert(radioConfig.has_preferences);
|
// assert(radioConfig.has_preferences);
|
||||||
bool ignore = is_in_repeated(config.lora.ignore_incoming, p->from) || (config.lora.ignore_mqtt && p->via_mqtt);
|
bool ignore = is_in_repeated(config.lora.ignore_incoming, p->from) || (config.lora.ignore_mqtt && p->via_mqtt);
|
||||||
|
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
std::map<configNames, int> settingsMap;
|
std::map<configNames, int> settingsMap;
|
||||||
std::map<configNames, std::string> settingsStrings;
|
std::map<configNames, std::string> settingsStrings;
|
||||||
|
std::ofstream traceFile;
|
||||||
char *configPath = nullptr;
|
char *configPath = nullptr;
|
||||||
|
|
||||||
// FIXME - move setBluetoothEnable into a HALPlatform class
|
// FIXME - move setBluetoothEnable into a HALPlatform class
|
||||||
@ -134,7 +135,9 @@ void portduinoSetup()
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
if (yamlConfig["Logging"]) {
|
if (yamlConfig["Logging"]) {
|
||||||
if (yamlConfig["Logging"]["LogLevel"].as<std::string>("info") == "debug") {
|
if (yamlConfig["Logging"]["LogLevel"].as<std::string>("info") == "trace") {
|
||||||
|
settingsMap[logoutputlevel] = level_trace;
|
||||||
|
} else if (yamlConfig["Logging"]["LogLevel"].as<std::string>("info") == "debug") {
|
||||||
settingsMap[logoutputlevel] = level_debug;
|
settingsMap[logoutputlevel] = level_debug;
|
||||||
} else if (yamlConfig["Logging"]["LogLevel"].as<std::string>("info") == "info") {
|
} else if (yamlConfig["Logging"]["LogLevel"].as<std::string>("info") == "info") {
|
||||||
settingsMap[logoutputlevel] = level_info;
|
settingsMap[logoutputlevel] = level_info;
|
||||||
@ -143,6 +146,7 @@ void portduinoSetup()
|
|||||||
} else if (yamlConfig["Logging"]["LogLevel"].as<std::string>("info") == "error") {
|
} else if (yamlConfig["Logging"]["LogLevel"].as<std::string>("info") == "error") {
|
||||||
settingsMap[logoutputlevel] = level_error;
|
settingsMap[logoutputlevel] = level_error;
|
||||||
}
|
}
|
||||||
|
settingsStrings[traceFilename] = yamlConfig["Logging"]["TraceFile"].as<std::string>("");
|
||||||
}
|
}
|
||||||
if (yamlConfig["Lora"]) {
|
if (yamlConfig["Lora"]) {
|
||||||
settingsMap[use_sx1262] = false;
|
settingsMap[use_sx1262] = false;
|
||||||
@ -346,6 +350,14 @@ void portduinoSetup()
|
|||||||
if (settingsStrings[spidev] != "") {
|
if (settingsStrings[spidev] != "") {
|
||||||
SPI.begin(settingsStrings[spidev].c_str());
|
SPI.begin(settingsStrings[spidev].c_str());
|
||||||
}
|
}
|
||||||
|
if (settingsStrings[traceFilename] != "") {
|
||||||
|
try {
|
||||||
|
traceFile.open(settingsStrings[traceFilename], std::ios::out | std::ios::app);
|
||||||
|
} catch (std::ofstream::failure &e) {
|
||||||
|
std::cout << "*** traceFile Exception " << e.what() << std::endl;
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
#include <fstream>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
enum configNames {
|
enum configNames {
|
||||||
@ -46,6 +47,7 @@ enum configNames {
|
|||||||
displayInvert,
|
displayInvert,
|
||||||
keyboardDevice,
|
keyboardDevice,
|
||||||
logoutputlevel,
|
logoutputlevel,
|
||||||
|
traceFilename,
|
||||||
webserver,
|
webserver,
|
||||||
webserverport,
|
webserverport,
|
||||||
webserverrootpath,
|
webserverrootpath,
|
||||||
@ -53,8 +55,9 @@ enum configNames {
|
|||||||
};
|
};
|
||||||
enum { no_screen, x11, st7789, st7735, st7735s, st7796, ili9341, ili9488, hx8357d };
|
enum { no_screen, x11, st7789, st7735, st7735s, st7796, ili9341, ili9488, hx8357d };
|
||||||
enum { no_touchscreen, xpt2046, stmpe610, gt911, ft5x06 };
|
enum { no_touchscreen, xpt2046, stmpe610, gt911, ft5x06 };
|
||||||
enum { level_error, level_warn, level_info, level_debug };
|
enum { level_error, level_warn, level_info, level_debug, level_trace };
|
||||||
|
|
||||||
extern std::map<configNames, int> settingsMap;
|
extern std::map<configNames, int> settingsMap;
|
||||||
extern std::map<configNames, std::string> settingsStrings;
|
extern std::map<configNames, std::string> settingsStrings;
|
||||||
|
extern std::ofstream traceFile;
|
||||||
int initGPIOPin(int pinNum, std::string gpioChipname);
|
int initGPIOPin(int pinNum, std::string gpioChipname);
|
@ -11,7 +11,7 @@
|
|||||||
#endif
|
#endif
|
||||||
#include "mesh/generated/meshtastic/remote_hardware.pb.h"
|
#include "mesh/generated/meshtastic/remote_hardware.pb.h"
|
||||||
|
|
||||||
std::string MeshPacketSerializer::JsonSerialize(meshtastic_MeshPacket *mp, bool shouldLog)
|
std::string MeshPacketSerializer::JsonSerialize(const meshtastic_MeshPacket *mp, bool shouldLog)
|
||||||
{
|
{
|
||||||
// the created jsonObj is immutable after creation, so
|
// the created jsonObj is immutable after creation, so
|
||||||
// we need to do the heavy lifting before assembling it.
|
// we need to do the heavy lifting before assembling it.
|
||||||
@ -315,3 +315,35 @@ std::string MeshPacketSerializer::JsonSerialize(meshtastic_MeshPacket *mp, bool
|
|||||||
delete value;
|
delete value;
|
||||||
return jsonStr;
|
return jsonStr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string MeshPacketSerializer::JsonSerializeEncrypted(const meshtastic_MeshPacket *mp)
|
||||||
|
{
|
||||||
|
JSONObject jsonObj;
|
||||||
|
|
||||||
|
jsonObj["id"] = new JSONValue((unsigned int)mp->id);
|
||||||
|
jsonObj["time_ms"] = new JSONValue((double)millis());
|
||||||
|
jsonObj["timestamp"] = new JSONValue((unsigned int)mp->rx_time);
|
||||||
|
jsonObj["to"] = new JSONValue((unsigned int)mp->to);
|
||||||
|
jsonObj["from"] = new JSONValue((unsigned int)mp->from);
|
||||||
|
jsonObj["channel"] = new JSONValue((unsigned int)mp->channel);
|
||||||
|
jsonObj["want_ack"] = new JSONValue(mp->want_ack);
|
||||||
|
|
||||||
|
if (mp->rx_rssi != 0)
|
||||||
|
jsonObj["rssi"] = new JSONValue((int)mp->rx_rssi);
|
||||||
|
if (mp->rx_snr != 0)
|
||||||
|
jsonObj["snr"] = new JSONValue((float)mp->rx_snr);
|
||||||
|
if (mp->hop_start != 0 && mp->hop_limit <= mp->hop_start) {
|
||||||
|
jsonObj["hops_away"] = new JSONValue((unsigned int)(mp->hop_start - mp->hop_limit));
|
||||||
|
jsonObj["hop_start"] = new JSONValue((unsigned int)(mp->hop_start));
|
||||||
|
}
|
||||||
|
jsonObj["size"] = new JSONValue((unsigned int)mp->encrypted.size);
|
||||||
|
auto encryptedStr = bytesToHex(mp->encrypted.bytes, mp->encrypted.size);
|
||||||
|
jsonObj["bytes"] = new JSONValue(encryptedStr.c_str());
|
||||||
|
|
||||||
|
// serialize and write it to the stream
|
||||||
|
JSONValue *value = new JSONValue(jsonObj);
|
||||||
|
std::string jsonStr = value->Stringify();
|
||||||
|
|
||||||
|
delete value;
|
||||||
|
return jsonStr;
|
||||||
|
}
|
@ -1,8 +1,23 @@
|
|||||||
#include <meshtastic/mesh.pb.h>
|
#include <meshtastic/mesh.pb.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
static const char hexChars[16] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
|
||||||
|
|
||||||
class MeshPacketSerializer
|
class MeshPacketSerializer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static std::string JsonSerialize(meshtastic_MeshPacket *mp, bool shouldLog = true);
|
static std::string JsonSerialize(const meshtastic_MeshPacket *mp, bool shouldLog = true);
|
||||||
|
static std::string JsonSerializeEncrypted(const meshtastic_MeshPacket *mp);
|
||||||
|
|
||||||
|
private:
|
||||||
|
static std::string bytesToHex(const uint8_t *bytes, int len)
|
||||||
|
{
|
||||||
|
std::string result = "";
|
||||||
|
for (int i = 0; i < len; ++i) {
|
||||||
|
char const byte = bytes[i];
|
||||||
|
result += hexChars[(byte & 0xF0) >> 4];
|
||||||
|
result += hexChars[(byte & 0x0F) >> 0];
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
};
|
};
|
33
userPrefs.h
Normal file
33
userPrefs.h
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
#ifndef _USERPREFS_
|
||||||
|
#define _USERPREFS_
|
||||||
|
// Uncomment and modify to set device defaults
|
||||||
|
|
||||||
|
// #define CONFIG_LORA_REGION_USERPREFS meshtastic_Config_LoRaConfig_RegionCode_US
|
||||||
|
// #define LORACONFIG_MODEM_PRESET_USERPREFS meshtastic_Config_LoRaConfig_ModemPreset_SHORT_FAST
|
||||||
|
// #define LORACONFIG_CHANNEL_NUM_USERPREFS 31
|
||||||
|
// #define CONFIG_LORA_IGNORE_MQTT_USERPREFS true
|
||||||
|
/*
|
||||||
|
#define CHANNEL_0_PSK_USERPREFS \
|
||||||
|
{ \
|
||||||
|
0x38, 0x4b, 0xbc, 0xc0, 0x1d, 0xc0, 0x22, 0xd1, 0x81, 0xbf, 0x36, 0xb8, 0x61, 0x21, 0xe1, 0xfb, 0x96, 0xb7, 0x2e, 0x55, \
|
||||||
|
0xbf, 0x74, 0x22, 0x7e, 0x9d, 0x6a, 0xfb, 0x48, 0xd6, 0x4c, 0xb1, 0xa1 \
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
// #define CHANNEL_0_NAME_USERPREFS "DEFCONnect"
|
||||||
|
// #define CHANNEL_0_PRECISION_USERPREFS 13
|
||||||
|
|
||||||
|
// #define SPLASH_TITLE_USERPREFS "DEFCONtastic"
|
||||||
|
// #define icon_width 34
|
||||||
|
// #define icon_height 29
|
||||||
|
// #define HAS_USERPREFS_SPLASH
|
||||||
|
/*
|
||||||
|
static unsigned char icon_bits[] = {
|
||||||
|
0x00, 0xC0, 0x0F, 0x00, 0x00, 0x00, 0xF0, 0x3F, 0x00, 0x00, 0x00, 0xF8, 0x7F, 0x00, 0x00, 0x00, 0xFC, 0xFF, 0x00, 0x00, 0x00,
|
||||||
|
0x9E, 0xE7, 0x00, 0x00, 0x00, 0x0E, 0xC7, 0x01, 0x00, 0x1C, 0x0F, 0xC7, 0x01, 0x00, 0x1C, 0xDF, 0xE7, 0x63, 0x00, 0x1C, 0xFF,
|
||||||
|
0xBF, 0xE1, 0x00, 0x3C, 0xF3, 0xBF, 0xE3, 0x00, 0x7F, 0xF7, 0xBF, 0xF1, 0x00, 0xFF, 0xF7, 0xBF, 0xF9, 0x03, 0xFF, 0xE7, 0x9F,
|
||||||
|
0xFF, 0x03, 0xC0, 0xCF, 0xEF, 0xDF, 0x03, 0x00, 0xDF, 0xE3, 0x8F, 0x00, 0x00, 0x7C, 0xFB, 0x03, 0x00, 0x00, 0xF8, 0xFF, 0x00,
|
||||||
|
0x00, 0x00, 0xE0, 0x0F, 0x00, 0x00, 0x00, 0xC0, 0x0F, 0x00, 0x00, 0x00, 0x78, 0x3F, 0x00, 0x00, 0x00, 0xFC, 0xFC, 0x00, 0x00,
|
||||||
|
0x98, 0x3F, 0xF0, 0x23, 0x00, 0xFC, 0x0F, 0xE0, 0x7F, 0x00, 0xFC, 0x03, 0x80, 0xFF, 0x01, 0xFC, 0x00, 0x00, 0x3E, 0x00, 0x70,
|
||||||
|
0x00, 0x00, 0x1C, 0x00, 0x70, 0x00, 0x00, 0x1C, 0x00, 0x70, 0x00, 0x00, 0x1C, 0x00, 0x70, 0x00, 0x00, 0x1C, 0x00};
|
||||||
|
*/
|
||||||
|
#endif
|
@ -1,4 +1,4 @@
|
|||||||
[VERSION]
|
[VERSION]
|
||||||
major = 2
|
major = 2
|
||||||
minor = 4
|
minor = 4
|
||||||
build = 1
|
build = 2
|
||||||
|
Loading…
Reference in New Issue
Block a user