mirror of
https://github.com/meshtastic/firmware.git
synced 2025-12-27 05:00:38 +00:00
Compare commits
20 Commits
ch341-read
...
sfpp-dev
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1aaf0ffc65 | ||
|
|
c968db94c5 | ||
|
|
fedc7c35b7 | ||
|
|
f8869ab7c3 | ||
|
|
3235fe8638 | ||
|
|
739ad0dc31 | ||
|
|
e8fd5174ec | ||
|
|
96726d22cd | ||
|
|
3330d297b1 | ||
|
|
e9ed2c0335 | ||
|
|
3cbc5b7a8d | ||
|
|
20bf822a48 | ||
|
|
14ee1ed075 | ||
|
|
4d48d517e0 | ||
|
|
ffdb3bc393 | ||
|
|
6e83a9a0b3 | ||
|
|
73cfa3c884 | ||
|
|
f2b6383cbb | ||
|
|
28d507f043 | ||
|
|
d508de9568 |
@@ -94,7 +94,7 @@ lib_deps =
|
||||
# renovate: datasource=custom.pio depName=NonBlockingRTTTL packageName=end2endzone/library/NonBlockingRTTTL
|
||||
end2endzone/NonBlockingRTTTL@1.4.0
|
||||
build_flags = ${env.build_flags} -Os
|
||||
build_src_filter = ${env.build_src_filter} -<platform/portduino/> -<graphics/niche/>
|
||||
build_src_filter = ${env.build_src_filter} -<platform/portduino/> -<graphics/niche/> -<modules/Native/>
|
||||
|
||||
; Common libs for communicating over TCP/IP networks such as MQTT
|
||||
[networking_base]
|
||||
|
||||
@@ -323,9 +323,9 @@ uint32_t RadioInterface::getTxDelayMsecWeighted(meshtastic_MeshPacket *p)
|
||||
void printPacket(const char *prefix, const meshtastic_MeshPacket *p)
|
||||
{
|
||||
#if defined(DEBUG_PORT) && !defined(DEBUG_MUTE)
|
||||
std::string out =
|
||||
DEBUG_PORT.mt_sprintf("%s (id=0x%08x fr=0x%08x to=0x%08x, transport = %u, WantAck=%d, HopLim=%d Ch=0x%x", prefix, p->id,
|
||||
p->from, p->to, p->transport_mechanism, p->want_ack, p->hop_limit, p->channel);
|
||||
std::string out = DEBUG_PORT.mt_sprintf(
|
||||
"%s (id=0x%08x fr=0x%08x to=0x%08x, transport = %u, WantAck=%d, HopLim=%d HopStart=%d Ch=0x%x", prefix, p->id, p->from,
|
||||
p->to, p->transport_mechanism, p->want_ack, p->hop_limit, p->hop_start, p->channel);
|
||||
if (p->which_payload_variant == meshtastic_MeshPacket_decoded_tag) {
|
||||
auto &s = p->decoded;
|
||||
|
||||
|
||||
@@ -33,5 +33,3 @@ PB_BIND(meshtastic_KeyVerificationAdmin, meshtastic_KeyVerificationAdmin, AUTO)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -16,16 +16,6 @@
|
||||
#endif
|
||||
|
||||
/* Enum definitions */
|
||||
/* Firmware update mode for OTA updates */
|
||||
typedef enum _meshtastic_OTAMode {
|
||||
/* Do not reboot into OTA mode */
|
||||
meshtastic_OTAMode_NO_REBOOT_OTA = 0,
|
||||
/* Reboot into OTA mode for BLE firmware update */
|
||||
meshtastic_OTAMode_OTA_BLE = 1,
|
||||
/* Reboot into OTA mode for WiFi firmware update */
|
||||
meshtastic_OTAMode_OTA_WIFI = 2
|
||||
} meshtastic_OTAMode;
|
||||
|
||||
/* TODO: REPLACE */
|
||||
typedef enum _meshtastic_AdminMessage_ConfigType {
|
||||
/* TODO: REPLACE */
|
||||
@@ -268,13 +258,10 @@ typedef struct _meshtastic_AdminMessage {
|
||||
meshtastic_SharedContact add_contact;
|
||||
/* Initiate or respond to a key verification request */
|
||||
meshtastic_KeyVerificationAdmin key_verification;
|
||||
/* Tell the node to reboot into OTA mode for firmware update via BLE or WiFi (ESP32 only for now) */
|
||||
meshtastic_OTAMode reboot_ota_mode;
|
||||
/* Tell the node to factory reset config everything; all device state and configuration will be returned to factory defaults and BLE bonds will be cleared. */
|
||||
int32_t factory_reset_device;
|
||||
/* Tell the node to reboot into the OTA Firmware in this many seconds (or <0 to cancel reboot)
|
||||
Only Implemented for ESP32 Devices. This needs to be issued to send a new main firmware via bluetooth.
|
||||
Deprecated in favor of reboot_ota_mode in 2.7.17 */
|
||||
Only Implemented for ESP32 Devices. This needs to be issued to send a new main firmware via bluetooth. */
|
||||
int32_t reboot_ota_seconds;
|
||||
/* This message is only supported for the simulator Portduino build.
|
||||
If received the simulator will exit successfully. */
|
||||
@@ -301,10 +288,6 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
/* Helper constants for enums */
|
||||
#define _meshtastic_OTAMode_MIN meshtastic_OTAMode_NO_REBOOT_OTA
|
||||
#define _meshtastic_OTAMode_MAX meshtastic_OTAMode_OTA_WIFI
|
||||
#define _meshtastic_OTAMode_ARRAYSIZE ((meshtastic_OTAMode)(meshtastic_OTAMode_OTA_WIFI+1))
|
||||
|
||||
#define _meshtastic_AdminMessage_ConfigType_MIN meshtastic_AdminMessage_ConfigType_DEVICE_CONFIG
|
||||
#define _meshtastic_AdminMessage_ConfigType_MAX meshtastic_AdminMessage_ConfigType_DEVICEUI_CONFIG
|
||||
#define _meshtastic_AdminMessage_ConfigType_ARRAYSIZE ((meshtastic_AdminMessage_ConfigType)(meshtastic_AdminMessage_ConfigType_DEVICEUI_CONFIG+1))
|
||||
@@ -326,7 +309,6 @@ extern "C" {
|
||||
#define meshtastic_AdminMessage_payload_variant_backup_preferences_ENUMTYPE meshtastic_AdminMessage_BackupLocation
|
||||
#define meshtastic_AdminMessage_payload_variant_restore_preferences_ENUMTYPE meshtastic_AdminMessage_BackupLocation
|
||||
#define meshtastic_AdminMessage_payload_variant_remove_backup_preferences_ENUMTYPE meshtastic_AdminMessage_BackupLocation
|
||||
#define meshtastic_AdminMessage_payload_variant_reboot_ota_mode_ENUMTYPE meshtastic_OTAMode
|
||||
|
||||
|
||||
|
||||
@@ -414,7 +396,6 @@ extern "C" {
|
||||
#define meshtastic_AdminMessage_commit_edit_settings_tag 65
|
||||
#define meshtastic_AdminMessage_add_contact_tag 66
|
||||
#define meshtastic_AdminMessage_key_verification_tag 67
|
||||
#define meshtastic_AdminMessage_reboot_ota_mode_tag 68
|
||||
#define meshtastic_AdminMessage_factory_reset_device_tag 94
|
||||
#define meshtastic_AdminMessage_reboot_ota_seconds_tag 95
|
||||
#define meshtastic_AdminMessage_exit_simulator_tag 96
|
||||
@@ -473,7 +454,6 @@ X(a, STATIC, ONEOF, BOOL, (payload_variant,begin_edit_settings,begin_ed
|
||||
X(a, STATIC, ONEOF, BOOL, (payload_variant,commit_edit_settings,commit_edit_settings), 65) \
|
||||
X(a, STATIC, ONEOF, MESSAGE, (payload_variant,add_contact,add_contact), 66) \
|
||||
X(a, STATIC, ONEOF, MESSAGE, (payload_variant,key_verification,key_verification), 67) \
|
||||
X(a, STATIC, ONEOF, UENUM, (payload_variant,reboot_ota_mode,reboot_ota_mode), 68) \
|
||||
X(a, STATIC, ONEOF, INT32, (payload_variant,factory_reset_device,factory_reset_device), 94) \
|
||||
X(a, STATIC, ONEOF, INT32, (payload_variant,reboot_ota_seconds,reboot_ota_seconds), 95) \
|
||||
X(a, STATIC, ONEOF, BOOL, (payload_variant,exit_simulator,exit_simulator), 96) \
|
||||
|
||||
@@ -822,6 +822,8 @@ typedef struct _meshtastic_StoreForwardPlusPlus {
|
||||
uint32_t encapsulated_from;
|
||||
/* The receive time of the message in question */
|
||||
uint32_t encapsulated_rxtime;
|
||||
/* Used in a LINK_REQUEST to specify the message X spots back from head */
|
||||
uint32_t chain_count;
|
||||
} meshtastic_StoreForwardPlusPlus;
|
||||
|
||||
/* Waypoint message, used to share arbitrary locations across the mesh */
|
||||
@@ -1428,7 +1430,7 @@ extern "C" {
|
||||
#define meshtastic_Routing_init_default {0, {meshtastic_RouteDiscovery_init_default}}
|
||||
#define meshtastic_Data_init_default {_meshtastic_PortNum_MIN, {0, {0}}, 0, 0, 0, 0, 0, 0, false, 0}
|
||||
#define meshtastic_KeyVerification_init_default {0, {0, {0}}, {0, {0}}}
|
||||
#define meshtastic_StoreForwardPlusPlus_init_default {_meshtastic_StoreForwardPlusPlus_SFPP_message_type_MIN, {0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}, 0, 0, 0, 0}
|
||||
#define meshtastic_StoreForwardPlusPlus_init_default {_meshtastic_StoreForwardPlusPlus_SFPP_message_type_MIN, {0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}, 0, 0, 0, 0, 0}
|
||||
#define meshtastic_Waypoint_init_default {0, false, 0, false, 0, 0, 0, "", "", 0}
|
||||
#define meshtastic_MqttClientProxyMessage_init_default {"", 0, {{0, {0}}}, 0}
|
||||
#define meshtastic_MeshPacket_init_default {0, 0, 0, 0, {meshtastic_Data_init_default}, 0, 0, 0, 0, 0, _meshtastic_MeshPacket_Priority_MIN, 0, _meshtastic_MeshPacket_Delayed_MIN, 0, 0, {0, {0}}, 0, 0, 0, 0, _meshtastic_MeshPacket_TransportMechanism_MIN}
|
||||
@@ -1460,7 +1462,7 @@ extern "C" {
|
||||
#define meshtastic_Routing_init_zero {0, {meshtastic_RouteDiscovery_init_zero}}
|
||||
#define meshtastic_Data_init_zero {_meshtastic_PortNum_MIN, {0, {0}}, 0, 0, 0, 0, 0, 0, false, 0}
|
||||
#define meshtastic_KeyVerification_init_zero {0, {0, {0}}, {0, {0}}}
|
||||
#define meshtastic_StoreForwardPlusPlus_init_zero {_meshtastic_StoreForwardPlusPlus_SFPP_message_type_MIN, {0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}, 0, 0, 0, 0}
|
||||
#define meshtastic_StoreForwardPlusPlus_init_zero {_meshtastic_StoreForwardPlusPlus_SFPP_message_type_MIN, {0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}, 0, 0, 0, 0, 0}
|
||||
#define meshtastic_Waypoint_init_zero {0, false, 0, false, 0, 0, 0, "", "", 0}
|
||||
#define meshtastic_MqttClientProxyMessage_init_zero {"", 0, {{0, {0}}}, 0}
|
||||
#define meshtastic_MeshPacket_init_zero {0, 0, 0, 0, {meshtastic_Data_init_zero}, 0, 0, 0, 0, 0, _meshtastic_MeshPacket_Priority_MIN, 0, _meshtastic_MeshPacket_Delayed_MIN, 0, 0, {0, {0}}, 0, 0, 0, 0, _meshtastic_MeshPacket_TransportMechanism_MIN}
|
||||
@@ -1548,6 +1550,7 @@ extern "C" {
|
||||
#define meshtastic_StoreForwardPlusPlus_encapsulated_to_tag 7
|
||||
#define meshtastic_StoreForwardPlusPlus_encapsulated_from_tag 8
|
||||
#define meshtastic_StoreForwardPlusPlus_encapsulated_rxtime_tag 9
|
||||
#define meshtastic_StoreForwardPlusPlus_chain_count_tag 10
|
||||
#define meshtastic_Waypoint_id_tag 1
|
||||
#define meshtastic_Waypoint_latitude_i_tag 2
|
||||
#define meshtastic_Waypoint_longitude_i_tag 3
|
||||
@@ -1773,7 +1776,8 @@ X(a, STATIC, SINGULAR, BYTES, message, 5) \
|
||||
X(a, STATIC, SINGULAR, UINT32, encapsulated_id, 6) \
|
||||
X(a, STATIC, SINGULAR, UINT32, encapsulated_to, 7) \
|
||||
X(a, STATIC, SINGULAR, UINT32, encapsulated_from, 8) \
|
||||
X(a, STATIC, SINGULAR, UINT32, encapsulated_rxtime, 9)
|
||||
X(a, STATIC, SINGULAR, UINT32, encapsulated_rxtime, 9) \
|
||||
X(a, STATIC, SINGULAR, UINT32, chain_count, 10)
|
||||
#define meshtastic_StoreForwardPlusPlus_CALLBACK NULL
|
||||
#define meshtastic_StoreForwardPlusPlus_DEFAULT NULL
|
||||
|
||||
@@ -2143,7 +2147,7 @@ extern const pb_msgdesc_t meshtastic_ChunkedPayloadResponse_msg;
|
||||
#define meshtastic_QueueStatus_size 23
|
||||
#define meshtastic_RouteDiscovery_size 256
|
||||
#define meshtastic_Routing_size 259
|
||||
#define meshtastic_StoreForwardPlusPlus_size 371
|
||||
#define meshtastic_StoreForwardPlusPlus_size 377
|
||||
#define meshtastic_ToRadio_size 504
|
||||
#define meshtastic_User_size 115
|
||||
#define meshtastic_Waypoint_size 165
|
||||
|
||||
@@ -61,6 +61,7 @@
|
||||
#if ARCH_PORTDUINO
|
||||
#include "input/LinuxInputImpl.h"
|
||||
#include "input/SeesawRotary.h"
|
||||
#include "modules/Native/StoreForwardPlusPlus.h"
|
||||
#include "modules/Telemetry/HostMetrics.h"
|
||||
#if !MESHTASTIC_EXCLUDE_STOREFORWARD
|
||||
#include "modules/StoreForwardModule.h"
|
||||
@@ -243,6 +244,9 @@ void setupModules()
|
||||
#endif
|
||||
#if ARCH_PORTDUINO
|
||||
new HostMetricsModule();
|
||||
#if SFPP_ENABLED
|
||||
new StoreForwardPlusPlusModule();
|
||||
#endif
|
||||
#endif
|
||||
#if HAS_TELEMETRY
|
||||
new DeviceTelemetryModule();
|
||||
|
||||
1191
src/modules/Native/StoreForwardPlusPlus.cpp
Normal file
1191
src/modules/Native/StoreForwardPlusPlus.cpp
Normal file
File diff suppressed because it is too large
Load Diff
221
src/modules/Native/StoreForwardPlusPlus.h
Normal file
221
src/modules/Native/StoreForwardPlusPlus.h
Normal file
@@ -0,0 +1,221 @@
|
||||
#pragma once
|
||||
#if __has_include("sqlite3.h")
|
||||
#define SFPP_ENABLED 1
|
||||
#include "Channels.h"
|
||||
#include "ProtobufModule.h"
|
||||
#include "Router.h"
|
||||
#include "SinglePortModule.h"
|
||||
#include "sqlite3.h"
|
||||
|
||||
/**
|
||||
* Store and forward ++ module
|
||||
* There's an obvious need for a store-and-forward mechanism in Meshtastic.
|
||||
* This module takes heavy inspiration from Git, building a chain of messages that can be synced between nodes.
|
||||
* Each message is hashed, and the chain is built by hashing the previous commit hash and the current message hash.
|
||||
* Nodes can request missing messages by requesting the next message after a given commit hash.
|
||||
*
|
||||
* The current focus is text messages, limited to the primary channel.
|
||||
*
|
||||
* Each chain is identified by a root hash, which is derived from the channelHash, the local nodenum, and the timestamp when
|
||||
* created.
|
||||
*
|
||||
* Each message is also given a message hash, derived from the encrypted payload, the to, from, id.
|
||||
* Notably not the timestamp, as we want these to match across nodes, even if the timestamps differ.
|
||||
*
|
||||
* The authoritative node for the chain will generate a commit hash for each message when adding it to the chain.
|
||||
* The first message's commit hash is derived from the root hash and the message hash.
|
||||
* Subsequent messages' commit hashes are derived from the previous commit hash and the current message hash.
|
||||
* This allows a node to see only the last commit hash, and confirm it hasn't missed any messages.
|
||||
*
|
||||
* Nodes can request the next message in the chain by sending a LINK_REQUEST message with the root hash and the last known commit
|
||||
* hash. Any node that has the next message can respond with a LINK_PROVIDE message containing the next message.
|
||||
*
|
||||
* When a satellite node sees a new text message, it stores it in a scratch database.
|
||||
* These messages are periodically offered to the authoritative node for inclusion in the chain.
|
||||
*
|
||||
* The LINK_PROVIDE message does double-duty, sending both on-chain and off-chain messages.
|
||||
* The differentiator is whether the commit hash is set or left empty.
|
||||
*
|
||||
* When a satellite node receives a canonical link message, it checks if it has the message in scratch.
|
||||
* And evicts it when adding it to the canonical chain.
|
||||
*
|
||||
* This approach allows a node to know whether it has seen a given message before, or if it is new coming via SFPP.
|
||||
* If new, and the timestamp is within the rebroadcast timeout, it will process that message as if it were just received from the
|
||||
* mesh, allowing it to be decrypted, shown to the user, and rebroadcast.
|
||||
*/
|
||||
class StoreForwardPlusPlusModule : public ProtobufModule<meshtastic_StoreForwardPlusPlus>, private concurrency::OSThread
|
||||
{
|
||||
struct link_object {
|
||||
uint32_t to;
|
||||
uint32_t from;
|
||||
uint32_t id;
|
||||
uint32_t rx_time = 0;
|
||||
ChannelHash channel_hash;
|
||||
uint8_t encrypted_bytes[256] = {0};
|
||||
size_t encrypted_len;
|
||||
uint8_t message_hash[32] = {0};
|
||||
size_t message_hash_len = 0;
|
||||
uint8_t root_hash[32] = {0};
|
||||
size_t root_hash_len = 0;
|
||||
uint8_t commit_hash[32] = {0};
|
||||
size_t commit_hash_len = 0;
|
||||
uint32_t counter = 0;
|
||||
std::string payload;
|
||||
bool validObject = true; // set this false when a chain calulation fails, etc.
|
||||
};
|
||||
|
||||
public:
|
||||
/** Constructor
|
||||
*
|
||||
*/
|
||||
StoreForwardPlusPlusModule();
|
||||
|
||||
/*
|
||||
-Override the wantPacket method.
|
||||
*/
|
||||
virtual bool wantPacket(const meshtastic_MeshPacket *p) override
|
||||
{
|
||||
switch (p->decoded.portnum) {
|
||||
case meshtastic_PortNum_TEXT_MESSAGE_APP:
|
||||
case meshtastic_PortNum_TEXT_MESSAGE_COMPRESSED_APP:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
/** Called to handle a particular incoming message
|
||||
@return ProcessMessage::STOP if you've guaranteed you've handled this message and no other handlers should be considered for
|
||||
it
|
||||
*/
|
||||
virtual ProcessMessage handleReceived(const meshtastic_MeshPacket &mp) override;
|
||||
virtual bool handleReceivedProtobuf(const meshtastic_MeshPacket &mp, meshtastic_StoreForwardPlusPlus *t) override;
|
||||
|
||||
virtual int32_t runOnce() override;
|
||||
|
||||
private:
|
||||
sqlite3 *ppDb;
|
||||
sqlite3_stmt *chain_insert_stmt;
|
||||
sqlite3_stmt *scratch_insert_stmt;
|
||||
sqlite3_stmt *checkDup;
|
||||
sqlite3_stmt *checkScratch;
|
||||
sqlite3_stmt *removeScratch;
|
||||
sqlite3_stmt *updatePayloadStmt;
|
||||
sqlite3_stmt *getPayloadFromScratchStmt;
|
||||
sqlite3_stmt *fromScratchStmt;
|
||||
sqlite3_stmt *fromScratchByHashStmt;
|
||||
sqlite3_stmt *getNextHashStmt;
|
||||
sqlite3_stmt *getChainEndStmt;
|
||||
sqlite3_stmt *getLinkStmt;
|
||||
sqlite3_stmt *getHashFromRootStmt;
|
||||
sqlite3_stmt *addRootToMappingsStmt;
|
||||
sqlite3_stmt *getRootFromChannelHashStmt;
|
||||
sqlite3_stmt *getFullRootHashStmt;
|
||||
sqlite3_stmt *setChainCountStmt;
|
||||
sqlite3_stmt *getChainCountStmt;
|
||||
|
||||
// For a given Meshtastic ChannelHash, fills the root_hash buffer with a 32-byte root hash
|
||||
// returns true if the root hash was found
|
||||
bool getRootFromChannelHash(ChannelHash, uint8_t *);
|
||||
|
||||
// For a given root hash, returns the ChannelHash
|
||||
// can handle partial root hashes
|
||||
ChannelHash getChannelHashFromRoot(uint8_t *_root_hash, size_t);
|
||||
|
||||
// given a root hash and commit hash, returns the next commit hash in the chain
|
||||
// can handle partial root and commit hashes, always fills the buffer with 32 bytes
|
||||
// returns true if a next hash was found
|
||||
bool getNextHash(uint8_t *, size_t, uint8_t *, size_t, uint8_t *);
|
||||
|
||||
// For a given Meshtastic ChannelHash, fills the root_hash buffer with a 32-byte root hash
|
||||
// but this function will add the root hash if it is not already present
|
||||
// returns true if the hash is new
|
||||
bool getOrAddRootFromChannelHash(ChannelHash, uint8_t *);
|
||||
|
||||
// adds the ChannelHash and root_hash to the mappings table
|
||||
void addRootToMappings(ChannelHash, uint8_t *);
|
||||
|
||||
// requests the next message in the chain from the mesh network
|
||||
// Sends a LINK_REQUEST message
|
||||
void requestNextMessage(uint8_t *, size_t, uint8_t *, size_t);
|
||||
|
||||
// request the message X entries from the end.
|
||||
// used to bootstrap a chain, without downloading all of the history
|
||||
void requestMessageCount(uint8_t *, size_t, uint32_t);
|
||||
|
||||
// sends a LINK_PROVIDE message broadcasting the given link object
|
||||
void broadcastLink(uint8_t *, size_t);
|
||||
|
||||
// sends a LINK_PROVIDE message broadcasting the given link object
|
||||
void broadcastLink(link_object &, bool);
|
||||
|
||||
// sends a LINK_PROVIDE message broadcasting the given link object from scratch message store
|
||||
bool sendFromScratch(uint8_t *);
|
||||
|
||||
// Adds the given link object to the canonical chain database
|
||||
bool addToChain(link_object &);
|
||||
|
||||
// Adds an incoming text message to the scratch database
|
||||
bool addToScratch(link_object &);
|
||||
|
||||
// sends a CANON_ANNOUNCE message, specifying the given root and commit hashes
|
||||
void canonAnnounce(uint8_t *, uint8_t *, uint8_t *, uint32_t);
|
||||
|
||||
// checks if the message hash is present in the canonical chain database
|
||||
bool isInDB(uint8_t *, size_t);
|
||||
|
||||
// checks if the message hash is present in the scratch database
|
||||
bool isInScratch(uint8_t *, size_t);
|
||||
|
||||
// retrieves a link object from the scratch database
|
||||
link_object getFromScratch(uint8_t *, size_t);
|
||||
|
||||
// removes a link object from the scratch database
|
||||
void removeFromScratch(uint8_t *, size_t);
|
||||
|
||||
// fills the payload section with the decrypted data for the given message hash
|
||||
// probably not needed for production, but useful for testing
|
||||
void updatePayload(uint8_t *, size_t, std::string);
|
||||
|
||||
// Takes the decrypted MeshPacket and the encrypted packet copy, and builds a link_object
|
||||
// Generates a message hash, but does not set the commit hash
|
||||
link_object ingestTextPacket(const meshtastic_MeshPacket &, const meshtastic_MeshPacket *);
|
||||
|
||||
// ingests a LINK_PROVIDE message and builds a link_object
|
||||
// confirms the root hash and commit hash
|
||||
link_object ingestLinkMessage(meshtastic_StoreForwardPlusPlus *);
|
||||
|
||||
// retrieves a link object from the canonical chain database given a message hash
|
||||
link_object getLink(uint8_t *, size_t);
|
||||
|
||||
// puts the encrypted payload back into the queue as if it were just received
|
||||
void rebroadcastLinkObject(link_object &);
|
||||
|
||||
// Check if an incoming link object's commit hash matches the calculated commit hash
|
||||
bool checkCommitHash(link_object &lo, uint8_t *commit_hash_bytes, size_t hash_len);
|
||||
|
||||
// given a partial root hash, looks up the full 32-byte root hash
|
||||
// returns true if found
|
||||
bool lookUpFullRootHash(uint8_t *partial_root_hash, size_t partial_root_hash_len, uint8_t *full_root_hash);
|
||||
|
||||
// update the mappings table to set the chain count for the given root hash
|
||||
void setChainCount(uint8_t *, size_t, uint32_t);
|
||||
|
||||
// query the mappings table for the chain count for the given root hash
|
||||
uint32_t getChainCount(uint8_t *, size_t);
|
||||
|
||||
link_object getLinkFromCount(uint32_t, uint8_t *, size_t);
|
||||
|
||||
// Track if we have a scheduled runOnce pending
|
||||
// useful to not accudentally delay a scheduled runOnce
|
||||
bool pendingRun = false;
|
||||
|
||||
// Once we have multiple chain types, we can extend this
|
||||
enum chain_types {
|
||||
channel_chain = 0,
|
||||
};
|
||||
|
||||
uint32_t rebroadcastTimeout = 3600; // Messages older than this (in seconds) will not be rebroadcast
|
||||
};
|
||||
#endif
|
||||
@@ -786,6 +786,11 @@ bool loadConfig(const char *configPath)
|
||||
}
|
||||
}
|
||||
|
||||
if (yamlConfig["StoreAndForward"]) {
|
||||
portduino_config.sfpp_stratum0 = (yamlConfig["StoreAndForward"]["Stratum0"]).as<bool>(false);
|
||||
portduino_config.initial_sync = (yamlConfig["StoreAndForward"]["InitialSync"]).as<int>(10);
|
||||
}
|
||||
|
||||
if (yamlConfig["General"]) {
|
||||
portduino_config.MaxNodes = (yamlConfig["General"]["MaxNodes"]).as<int>(200);
|
||||
portduino_config.maxtophone = (yamlConfig["General"]["MaxMessageQueue"]).as<int>(100);
|
||||
|
||||
@@ -169,6 +169,10 @@ extern struct portduino_config_struct {
|
||||
int configDisplayMode = 0;
|
||||
bool has_configDisplayMode = false;
|
||||
|
||||
// Store and Forward++
|
||||
bool sfpp_stratum0 = false;
|
||||
int initial_sync = 10;
|
||||
|
||||
// General
|
||||
std::string mac_address = "";
|
||||
bool mac_address_explicit = false;
|
||||
@@ -488,6 +492,15 @@ extern struct portduino_config_struct {
|
||||
out << YAML::EndMap; // Config
|
||||
}
|
||||
|
||||
// StoreAndForward
|
||||
if (sfpp_stratum0 || initial_sync != 10) {
|
||||
out << YAML::Key << "StoreAndForward" << YAML::Value << YAML::BeginMap;
|
||||
|
||||
out << YAML::Key << "Stratum0" << YAML::Value << sfpp_stratum0;
|
||||
out << YAML::Key << "InitialSync" << YAML::Value << initial_sync;
|
||||
out << YAML::EndMap; // StoreAndForward
|
||||
}
|
||||
|
||||
// General
|
||||
out << YAML::Key << "General" << YAML::Value << YAML::BeginMap;
|
||||
if (config_directory != "")
|
||||
|
||||
@@ -9,7 +9,7 @@ lib_deps =
|
||||
# renovate: datasource=custom.pio depName=Melopero RV3028 packageName=melopero/library/Melopero RV3028
|
||||
melopero/Melopero RV3028@1.2.0
|
||||
|
||||
build_src_filter = ${portduino_base.build_src_filter}
|
||||
build_src_filter = ${portduino_base.build_src_filter} +<modules/Native/>
|
||||
|
||||
[env:native]
|
||||
extends = native_base
|
||||
@@ -20,6 +20,7 @@ build_flags = ${native_base.build_flags}
|
||||
!pkg-config --libs openssl --silence-errors || :
|
||||
!pkg-config --cflags --libs sdl2 --silence-errors || :
|
||||
!pkg-config --cflags --libs libbsd-overlay --silence-errors || :
|
||||
!pkg-config --cflags --libs sqlite3 --silence-errors || :
|
||||
|
||||
[env:native-tft]
|
||||
extends = native_base
|
||||
@@ -46,6 +47,7 @@ build_flags = ${native_base.build_flags} -Os -lX11 -linput -lxkbcommon -ffunctio
|
||||
!pkg-config --libs openssl --silence-errors || :
|
||||
!pkg-config --cflags --libs sdl2 --silence-errors || :
|
||||
!pkg-config --cflags --libs libbsd-overlay --silence-errors || :
|
||||
!pkg-config --cflags --libs sqlite3 --silence-errors || :
|
||||
build_src_filter =
|
||||
${native_base.build_src_filter}
|
||||
|
||||
@@ -75,6 +77,7 @@ build_flags = ${native_base.build_flags} -Os -ffunction-sections -fdata-sections
|
||||
!pkg-config --libs libulfius --silence-errors || :
|
||||
!pkg-config --libs openssl --silence-errors || :
|
||||
!pkg-config --cflags --libs libbsd-overlay --silence-errors || :
|
||||
!pkg-config --cflags --libs sqlite3 --silence-errors || :
|
||||
build_src_filter =
|
||||
${native_base.build_src_filter}
|
||||
|
||||
@@ -108,6 +111,7 @@ build_flags = ${native_base.build_flags} -O0 -fsanitize=address -lX11 -linput -l
|
||||
!pkg-config --libs libulfius --silence-errors || :
|
||||
!pkg-config --libs openssl --silence-errors || :
|
||||
!pkg-config --cflags --libs libbsd-overlay --silence-errors || :
|
||||
!pkg-config --cflags --libs sqlite3 --silence-errors || :
|
||||
build_src_filter = ${env:native-tft.build_src_filter}
|
||||
|
||||
[env:coverage]
|
||||
|
||||
Reference in New Issue
Block a user