Merge pull request #2282 from meshtastic/master

Catch up
This commit is contained in:
Thomas Göttgens 2023-02-17 12:32:33 +01:00 committed by GitHub
commit 181832aedd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
32 changed files with 235 additions and 221 deletions

View File

@ -12,7 +12,9 @@ build_src_filter =
-<mesh/http/> -<mesh/http/>
-<mesh/eth/> -<mesh/eth/>
-<modules/esp32> -<modules/esp32>
-<modules/Telemetry> -<modules/Telemetry/EnvironmentTelemetry.cpp>
-<modules/Telemetry/AirQualityTelemetry.cpp>
-<modules/Telemetry/Sensor>
+<../variants/portduino> +<../variants/portduino>
lib_deps = lib_deps =
${env.lib_deps} ${env.lib_deps}

@ -1 +1 @@
Subproject commit 400dc2358942f1954b188cb5698a545850ca3d73 Subproject commit cb01d7472fc22321652a5471155dfc6c04a612ab

View File

@ -103,7 +103,7 @@ size_t RedirectablePrint::log(const char *logLevel, const char *format, ...)
} }
r += vprintf(format, arg); r += vprintf(format, arg);
#if HAS_WIFI || HAS_ETHERNET #if (HAS_WIFI || HAS_ETHERNET) && !defined(ARCH_PORTDUINO)
// if syslog is in use, collect the log messages and send them to syslog // if syslog is in use, collect the log messages and send them to syslog
if (syslog.isEnabled()) { if (syslog.isEnabled()) {
int ll = 0; int ll = 0;

View File

@ -392,6 +392,19 @@ void setup()
// radio init MUST BE AFTER service.init, so we have our radio config settings (from nodedb init) // radio init MUST BE AFTER service.init, so we have our radio config settings (from nodedb init)
#if !HAS_RADIO && defined(ARCH_PORTDUINO)
if (!rIf) {
rIf = new SimRadio;
if (!rIf->init()) {
LOG_WARN("Failed to find simulated radio\n");
delete rIf;
rIf = NULL;
} else {
LOG_INFO("Using SIMULATED radio!\n");
}
}
#endif
#if defined(RF95_IRQ) #if defined(RF95_IRQ)
if (!rIf) { if (!rIf) {
rIf = new RF95Interface(RF95_NSS, RF95_IRQ, RF95_RESET, SPI); rIf = new RF95Interface(RF95_NSS, RF95_IRQ, RF95_RESET, SPI);
@ -457,19 +470,6 @@ void setup()
} }
#endif #endif
#ifdef ARCH_PORTDUINO
if (!rIf) {
rIf = new SimRadio;
if (!rIf->init()) {
LOG_WARN("Failed to find simulated radio\n");
delete rIf;
rIf = NULL;
} else {
LOG_INFO("Using SIMULATED radio!\n");
}
}
#endif
// check if the radio chip matches the selected region // check if the radio chip matches the selected region
if ((config.lora.region == meshtastic_Config_LoRaConfig_RegionCode_LORA_24) && (!rIf->wideLora())) { if ((config.lora.region == meshtastic_Config_LoRaConfig_RegionCode_LORA_24) && (!rIf->wideLora())) {
@ -535,6 +535,21 @@ uint32_t shutdownAtMsec; // If not zero we will shutdown at this time (used to s
// This will supress the current delay and instead try to run ASAP. // This will supress the current delay and instead try to run ASAP.
bool runASAP; bool runASAP;
extern meshtastic_DeviceMetadata getDeviceMetadata()
{
meshtastic_DeviceMetadata deviceMetadata;
strncpy(deviceMetadata.firmware_version, myNodeInfo.firmware_version, 18);
deviceMetadata.device_state_version = DEVICESTATE_CUR_VER;
deviceMetadata.canShutdown = pmu_found || HAS_CPU_SHUTDOWN;
deviceMetadata.hasBluetooth = HAS_BLUETOOTH;
deviceMetadata.hasWifi = HAS_WIFI;
deviceMetadata.hasEthernet = HAS_ETHERNET;
deviceMetadata.role = config.device.role;
deviceMetadata.position_flags = config.position.position_flags;
deviceMetadata.hw_model = HW_VENDOR;
return deviceMetadata;
}
void loop() void loop()
{ {
runASAP = false; runASAP = false;

View File

@ -62,3 +62,5 @@ extern uint32_t serialSinceMsec;
extern bool runASAP; extern bool runASAP;
void nrf52Setup(), esp32Setup(), nrf52Loop(), esp32Loop(), clearBonds(); void nrf52Setup(), esp32Setup(), nrf52Loop(), esp32Loop(), clearBonds();
meshtastic_DeviceMetadata getDeviceMetadata();

View File

@ -77,6 +77,8 @@ void MeshModule::callPlugins(const meshtastic_MeshPacket &mp, RxSource src)
currentReply = NULL; // No reply yet currentReply = NULL; // No reply yet
bool ignoreRequest = false; // No module asked to ignore the request yet
// Was this message directed to us specifically? Will be false if we are sniffing someone elses packets // Was this message directed to us specifically? Will be false if we are sniffing someone elses packets
auto ourNodeNum = nodeDB.getNodeNum(); auto ourNodeNum = nodeDB.getNodeNum();
bool toUs = mp.to == NODENUM_BROADCAST || mp.to == ourNodeNum; bool toUs = mp.to == NODENUM_BROADCAST || mp.to == ourNodeNum;
@ -135,7 +137,8 @@ void MeshModule::callPlugins(const meshtastic_MeshPacket &mp, RxSource src)
// any other node. // any other node.
if (mp.decoded.want_response && toUs && (getFrom(&mp) != ourNodeNum || mp.to == ourNodeNum) && !currentReply) { if (mp.decoded.want_response && toUs && (getFrom(&mp) != ourNodeNum || mp.to == ourNodeNum) && !currentReply) {
pi.sendResponse(mp); pi.sendResponse(mp);
LOG_INFO("Module '%s' sent a response\n", pi.name); ignoreRequest = ignoreRequest || pi.ignoreRequest; // If at least one module asks it, we may ignore a request
LOG_INFO("Asked module '%s' to send a response\n", pi.name);
} else { } else {
LOG_DEBUG("Module '%s' considered\n", pi.name); LOG_DEBUG("Module '%s' considered\n", pi.name);
} }
@ -162,8 +165,9 @@ void MeshModule::callPlugins(const meshtastic_MeshPacket &mp, RxSource src)
printPacket("Sending response", currentReply); printPacket("Sending response", currentReply);
service.sendToMesh(currentReply); service.sendToMesh(currentReply);
currentReply = NULL; currentReply = NULL;
} else if (mp.from != ourNodeNum) { } else if (mp.from != ourNodeNum && !ignoreRequest) {
// Note: if the message started with the local node we don't want to send a no response reply // Note: if the message started with the local node or a module asked to ignore the request, we don't want to send a
// no response reply
// No one wanted to reply to this requst, tell the requster that happened // No one wanted to reply to this requst, tell the requster that happened
LOG_DEBUG("No one responded, send a nak\n"); LOG_DEBUG("No one responded, send a nak\n");

View File

@ -94,6 +94,9 @@ class MeshModule
* flag */ * flag */
bool encryptedOk = false; bool encryptedOk = false;
/* We allow modules to ignore a request without sending an error if they have a specific reason for it. */
bool ignoreRequest = false;
/** If a bound channel name is set, we will only accept received packets that come in on that channel. /** If a bound channel name is set, we will only accept received packets that come in on that channel.
* A special exception (FIXME, not sure if this is a good idea) - packets that arrive on the local interface * A special exception (FIXME, not sure if this is a good idea) - packets that arrive on the local interface
* are allowed on any channel (this lets the local user do anything). * are allowed on any channel (this lets the local user do anything).

View File

@ -75,9 +75,13 @@ int MeshService::handleFromRadio(const meshtastic_MeshPacket *mp)
{ {
powerFSM.trigger(EVENT_PACKET_FOR_PHONE); // Possibly keep the node from sleeping powerFSM.trigger(EVENT_PACKET_FOR_PHONE); // Possibly keep the node from sleeping
printPacket("Forwarding to phone", mp);
nodeDB.updateFrom(*mp); // update our DB state based off sniffing every RX packet from the radio nodeDB.updateFrom(*mp); // update our DB state based off sniffing every RX packet from the radio
if (!nodeDB.getNode(mp->from)->has_user && nodeInfoModule) {
LOG_INFO("Heard a node we don't know, sending NodeInfo and asking for a response.\n");
nodeInfoModule->sendOurNodeInfo(mp->from, true);
}
printPacket("Forwarding to phone", mp);
sendToPhone((meshtastic_MeshPacket *)mp); sendToPhone((meshtastic_MeshPacket *)mp);
return 0; return 0;
@ -132,7 +136,7 @@ void MeshService::reloadOwner(bool shouldSave)
*/ */
void MeshService::handleToRadio(meshtastic_MeshPacket &p) void MeshService::handleToRadio(meshtastic_MeshPacket &p)
{ {
#ifdef ARCH_PORTDUINO #if defined(ARCH_PORTDUINO) && !HAS_RADIO
// Simulates device is receiving a packet via the LoRa chip // Simulates device is receiving a packet via the LoRa chip
if (p.decoded.portnum == meshtastic_PortNum_SIMULATOR_APP) { if (p.decoded.portnum == meshtastic_PortNum_SIMULATOR_APP) {
// Simulator packet (=Compressed packet) is encapsulated in a MeshPacket, so need to unwrap first // Simulator packet (=Compressed packet) is encapsulated in a MeshPacket, so need to unwrap first

View File

@ -10,7 +10,7 @@
#include "MeshTypes.h" #include "MeshTypes.h"
#include "Observer.h" #include "Observer.h"
#include "PointerQueue.h" #include "PointerQueue.h"
#ifdef ARCH_PORTDUINO #if defined(ARCH_PORTDUINO) && !HAS_RADIO
#include "../platform/portduino/SimRadio.h" #include "../platform/portduino/SimRadio.h"
#endif #endif

View File

@ -170,6 +170,8 @@ void NodeDB::installDefaultConfig()
config.lora.hop_limit = HOP_RELIABLE; config.lora.hop_limit = HOP_RELIABLE;
config.position.gps_enabled = true; config.position.gps_enabled = true;
config.position.position_broadcast_smart_enabled = true; config.position.position_broadcast_smart_enabled = true;
if (config.device.role != meshtastic_Config_DeviceConfig_Role_ROUTER)
config.device.node_info_broadcast_secs = 3 * 60 * 60;
config.device.serial_enabled = true; config.device.serial_enabled = true;
resetRadioConfig(); resetRadioConfig();
strncpy(config.network.ntp_server, "0.pool.ntp.org", 32); strncpy(config.network.ntp_server, "0.pool.ntp.org", 32);

View File

@ -6,6 +6,7 @@
#include "PowerFSM.h" #include "PowerFSM.h"
#include "RadioInterface.h" #include "RadioInterface.h"
#include "configuration.h" #include "configuration.h"
#include "main.h"
#include "xmodem.h" #include "xmodem.h"
#if FromRadio_size > MAX_TO_FROM_RADIO_SIZE #if FromRadio_size > MAX_TO_FROM_RADIO_SIZE
@ -120,6 +121,7 @@ bool PhoneAPI::handleToRadio(const uint8_t *buf, size_t bufLength)
* STATE_SEND_NODEINFO, // states progress in this order as the device sends to the client * STATE_SEND_NODEINFO, // states progress in this order as the device sends to the client
STATE_SEND_CONFIG, STATE_SEND_CONFIG,
STATE_SEND_MODULE_CONFIG, STATE_SEND_MODULE_CONFIG,
STATE_SEND_METADATA,
STATE_SEND_COMPLETE_ID, STATE_SEND_COMPLETE_ID,
STATE_SEND_PACKETS // send packets or debug strings STATE_SEND_PACKETS // send packets or debug strings
*/ */
@ -277,11 +279,15 @@ size_t PhoneAPI::getFromRadio(uint8_t *buf)
config_state++; config_state++;
// Advance when we have sent all of our ModuleConfig objects // Advance when we have sent all of our ModuleConfig objects
if (config_state > (_meshtastic_AdminMessage_ModuleConfigType_MAX + 1)) { if (config_state > (_meshtastic_AdminMessage_ModuleConfigType_MAX + 1)) {
state = STATE_SEND_COMPLETE_ID; state = STATE_SEND_METADATA;
config_state = 0; config_state = 0;
} }
break; break;
case STATE_SEND_METADATA:
fromRadioScratch.which_payload_variant = meshtastic_FromRadio_metadata_tag;
fromRadioScratch.metadata = getDeviceMetadata();
state = STATE_SEND_COMPLETE_ID;
break;
case STATE_SEND_COMPLETE_ID: case STATE_SEND_COMPLETE_ID:
LOG_INFO("getFromRadio=STATE_SEND_COMPLETE_ID\n"); LOG_INFO("getFromRadio=STATE_SEND_COMPLETE_ID\n");
fromRadioScratch.which_payload_variant = meshtastic_FromRadio_config_complete_id_tag; fromRadioScratch.which_payload_variant = meshtastic_FromRadio_config_complete_id_tag;
@ -361,6 +367,7 @@ bool PhoneAPI::available()
case STATE_SEND_CHANNELS: case STATE_SEND_CHANNELS:
case STATE_SEND_CONFIG: case STATE_SEND_CONFIG:
case STATE_SEND_MODULECONFIG: case STATE_SEND_MODULECONFIG:
case STATE_SEND_METADATA:
case STATE_SEND_COMPLETE_ID: case STATE_SEND_COMPLETE_ID:
return true; return true;

View File

@ -26,6 +26,7 @@ class PhoneAPI
STATE_SEND_CHANNELS, // Send all channels STATE_SEND_CHANNELS, // Send all channels
STATE_SEND_CONFIG, // Replacement for the old Radioconfig STATE_SEND_CONFIG, // Replacement for the old Radioconfig
STATE_SEND_MODULECONFIG, // Send Module specific config STATE_SEND_MODULECONFIG, // Send Module specific config
STATE_SEND_METADATA,
STATE_SEND_COMPLETE_ID, STATE_SEND_COMPLETE_ID,
STATE_SEND_PACKETS // send packets or debug strings STATE_SEND_PACKETS // send packets or debug strings
}; };

View File

@ -67,19 +67,12 @@ bool RF95Interface::init()
#endif #endif
setTransmitEnable(false); setTransmitEnable(false);
int res = lora->begin(getFreq(), bw, sf, cr, syncWord, power, currentLimit, preambleLength); int res = lora->begin(getFreq(), bw, sf, cr, syncWord, power, preambleLength);
LOG_INFO("RF95 init result %d\n", res); LOG_INFO("RF95 init result %d\n", res);
LOG_INFO("Frequency set to %f\n", getFreq()); LOG_INFO("Frequency set to %f\n", getFreq());
LOG_INFO("Bandwidth set to %f\n", bw); LOG_INFO("Bandwidth set to %f\n", bw);
LOG_INFO("Power output set to %d\n", power); LOG_INFO("Power output set to %d\n", power);
// current limit was removed from module' ctor
// override default value (60 mA)
res = lora->setCurrentLimit(currentLimit);
LOG_DEBUG("Current limit set to %f\n", currentLimit);
LOG_DEBUG("Current limit set result %d\n", res);
if (res == RADIOLIB_ERR_NONE) if (res == RADIOLIB_ERR_NONE)
res = lora->setCRC(RADIOLIB_SX126X_LORA_CRC_ON); res = lora->setCRC(RADIOLIB_SX126X_LORA_CRC_ON);

View File

@ -63,7 +63,7 @@ class RadioInterface
- Tx/Rx turnaround time (maximum of SX126x and SX127x); - Tx/Rx turnaround time (maximum of SX126x and SX127x);
- MAC processing time (measured on T-beam) */ - MAC processing time (measured on T-beam) */
uint32_t slotTimeMsec = 8.5 * pow(2, sf) / bw + 0.2 + 0.4 + 7; uint32_t slotTimeMsec = 8.5 * pow(2, sf) / bw + 0.2 + 0.4 + 7;
uint16_t preambleLength = 32; // 8 is default, but we use longer to increase the amount of sleep time when receiving uint16_t preambleLength = 16; // 8 is default, but we use longer to increase the amount of sleep time when receiving
const uint32_t PROCESSING_TIME_MSEC = const uint32_t PROCESSING_TIME_MSEC =
4500; // time to construct, process and construct a packet again (empirically determined) 4500; // time to construct, process and construct a packet again (empirically determined)
const uint8_t CWmin = 2; // minimum CWsize const uint8_t CWmin = 2; // minimum CWsize

View File

@ -6,7 +6,6 @@
#include <pb.h> #include <pb.h>
#include "meshtastic/channel.pb.h" #include "meshtastic/channel.pb.h"
#include "meshtastic/config.pb.h" #include "meshtastic/config.pb.h"
#include "meshtastic/device_metadata.pb.h"
#include "meshtastic/mesh.pb.h" #include "meshtastic/mesh.pb.h"
#include "meshtastic/module_config.pb.h" #include "meshtastic/module_config.pb.h"
#include "meshtastic/connection_status.pb.h" #include "meshtastic/connection_status.pb.h"
@ -67,6 +66,8 @@ typedef struct _meshtastic_HamParameters {
Please respect your local laws, regulations, and band plans. Please respect your local laws, regulations, and band plans.
Ensure your radio is capable of operating of the selected frequency before setting this. */ Ensure your radio is capable of operating of the selected frequency before setting this. */
float frequency; float frequency;
/* Optional short name of user */
char short_name[6];
} meshtastic_HamParameters; } meshtastic_HamParameters;
/* This message is handled by the Admin module and is responsible for all settings/channel read/write operations. /* This message is handled by the Admin module and is responsible for all settings/channel read/write operations.
@ -169,14 +170,15 @@ extern "C" {
/* Initializer values for message structs */ /* Initializer values for message structs */
#define meshtastic_AdminMessage_init_default {0, {0}} #define meshtastic_AdminMessage_init_default {0, {0}}
#define meshtastic_HamParameters_init_default {"", 0, 0} #define meshtastic_HamParameters_init_default {"", 0, 0, ""}
#define meshtastic_AdminMessage_init_zero {0, {0}} #define meshtastic_AdminMessage_init_zero {0, {0}}
#define meshtastic_HamParameters_init_zero {"", 0, 0} #define meshtastic_HamParameters_init_zero {"", 0, 0, ""}
/* Field tags (for use in manual encoding/decoding) */ /* Field tags (for use in manual encoding/decoding) */
#define meshtastic_HamParameters_call_sign_tag 1 #define meshtastic_HamParameters_call_sign_tag 1
#define meshtastic_HamParameters_tx_power_tag 2 #define meshtastic_HamParameters_tx_power_tag 2
#define meshtastic_HamParameters_frequency_tag 3 #define meshtastic_HamParameters_frequency_tag 3
#define meshtastic_HamParameters_short_name_tag 4
#define meshtastic_AdminMessage_get_channel_request_tag 1 #define meshtastic_AdminMessage_get_channel_request_tag 1
#define meshtastic_AdminMessage_get_channel_response_tag 2 #define meshtastic_AdminMessage_get_channel_response_tag 2
#define meshtastic_AdminMessage_get_owner_request_tag 3 #define meshtastic_AdminMessage_get_owner_request_tag 3
@ -259,7 +261,8 @@ X(a, STATIC, ONEOF, INT32, (payload_variant,nodedb_reset,nodedb_reset),
#define meshtastic_HamParameters_FIELDLIST(X, a) \ #define meshtastic_HamParameters_FIELDLIST(X, a) \
X(a, STATIC, SINGULAR, STRING, call_sign, 1) \ X(a, STATIC, SINGULAR, STRING, call_sign, 1) \
X(a, STATIC, SINGULAR, INT32, tx_power, 2) \ X(a, STATIC, SINGULAR, INT32, tx_power, 2) \
X(a, STATIC, SINGULAR, FLOAT, frequency, 3) X(a, STATIC, SINGULAR, FLOAT, frequency, 3) \
X(a, STATIC, SINGULAR, STRING, short_name, 4)
#define meshtastic_HamParameters_CALLBACK NULL #define meshtastic_HamParameters_CALLBACK NULL
#define meshtastic_HamParameters_DEFAULT NULL #define meshtastic_HamParameters_DEFAULT NULL
@ -272,7 +275,7 @@ extern const pb_msgdesc_t meshtastic_HamParameters_msg;
/* Maximum encoded size of messages (where known) */ /* Maximum encoded size of messages (where known) */
#define meshtastic_AdminMessage_size 234 #define meshtastic_AdminMessage_size 234
#define meshtastic_HamParameters_size 25 #define meshtastic_HamParameters_size 32
#ifdef __cplusplus #ifdef __cplusplus
} /* extern "C" */ } /* extern "C" */

View File

@ -1,12 +0,0 @@
/* Automatically generated nanopb constant definitions */
/* Generated by nanopb-0.4.7 */
#include "meshtastic/device_metadata.pb.h"
#if PB_PROTO_HEADER_VERSION != 40
#error Regenerate this file with the current version of nanopb generator.
#endif
PB_BIND(meshtastic_DeviceMetadata, meshtastic_DeviceMetadata, AUTO)

View File

@ -1,83 +0,0 @@
/* Automatically generated nanopb header */
/* Generated by nanopb-0.4.7 */
#ifndef PB_MESHTASTIC_MESHTASTIC_DEVICE_METADATA_PB_H_INCLUDED
#define PB_MESHTASTIC_MESHTASTIC_DEVICE_METADATA_PB_H_INCLUDED
#include <pb.h>
#include "meshtastic/config.pb.h"
#include "meshtastic/mesh.pb.h"
#if PB_PROTO_HEADER_VERSION != 40
#error Regenerate this file with the current version of nanopb generator.
#endif
/* Struct definitions */
/* Device metadata response */
typedef struct _meshtastic_DeviceMetadata {
/* Device firmware version string */
char firmware_version[18];
/* Device state version */
uint32_t device_state_version;
/* Indicates whether the device can shutdown CPU natively or via power management chip */
bool canShutdown;
/* Indicates that the device has native wifi capability */
bool hasWifi;
/* Indicates that the device has native bluetooth capability */
bool hasBluetooth;
/* Indicates that the device has an ethernet peripheral */
bool hasEthernet;
/* Indicates that the device's role in the mesh */
meshtastic_Config_DeviceConfig_Role role;
/* Indicates the device's current enabled position flags */
uint32_t position_flags;
/* Device hardware model */
meshtastic_HardwareModel hw_model;
} meshtastic_DeviceMetadata;
#ifdef __cplusplus
extern "C" {
#endif
/* Initializer values for message structs */
#define meshtastic_DeviceMetadata_init_default {"", 0, 0, 0, 0, 0, _meshtastic_Config_DeviceConfig_Role_MIN, 0, _meshtastic_HardwareModel_MIN}
#define meshtastic_DeviceMetadata_init_zero {"", 0, 0, 0, 0, 0, _meshtastic_Config_DeviceConfig_Role_MIN, 0, _meshtastic_HardwareModel_MIN}
/* Field tags (for use in manual encoding/decoding) */
#define meshtastic_DeviceMetadata_firmware_version_tag 1
#define meshtastic_DeviceMetadata_device_state_version_tag 2
#define meshtastic_DeviceMetadata_canShutdown_tag 3
#define meshtastic_DeviceMetadata_hasWifi_tag 4
#define meshtastic_DeviceMetadata_hasBluetooth_tag 5
#define meshtastic_DeviceMetadata_hasEthernet_tag 6
#define meshtastic_DeviceMetadata_role_tag 7
#define meshtastic_DeviceMetadata_position_flags_tag 8
#define meshtastic_DeviceMetadata_hw_model_tag 9
/* Struct field encoding specification for nanopb */
#define meshtastic_DeviceMetadata_FIELDLIST(X, a) \
X(a, STATIC, SINGULAR, STRING, firmware_version, 1) \
X(a, STATIC, SINGULAR, UINT32, device_state_version, 2) \
X(a, STATIC, SINGULAR, BOOL, canShutdown, 3) \
X(a, STATIC, SINGULAR, BOOL, hasWifi, 4) \
X(a, STATIC, SINGULAR, BOOL, hasBluetooth, 5) \
X(a, STATIC, SINGULAR, BOOL, hasEthernet, 6) \
X(a, STATIC, SINGULAR, UENUM, role, 7) \
X(a, STATIC, SINGULAR, UINT32, position_flags, 8) \
X(a, STATIC, SINGULAR, UENUM, hw_model, 9)
#define meshtastic_DeviceMetadata_CALLBACK NULL
#define meshtastic_DeviceMetadata_DEFAULT NULL
extern const pb_msgdesc_t meshtastic_DeviceMetadata_msg;
/* Defines for backwards compatibility with code written before nanopb-0.4.0 */
#define meshtastic_DeviceMetadata_fields &meshtastic_DeviceMetadata_msg
/* Maximum encoded size of messages (where known) */
#define meshtastic_DeviceMetadata_size 44
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif

View File

@ -48,6 +48,9 @@ PB_BIND(meshtastic_ToRadio, meshtastic_ToRadio, 2)
PB_BIND(meshtastic_Compressed, meshtastic_Compressed, AUTO) PB_BIND(meshtastic_Compressed, meshtastic_Compressed, AUTO)
PB_BIND(meshtastic_DeviceMetadata, meshtastic_DeviceMetadata, AUTO)

View File

@ -87,6 +87,10 @@ typedef enum _meshtastic_HardwareModel {
meshtastic_HardwareModel_HELTEC_WSL_V3 = 44, meshtastic_HardwareModel_HELTEC_WSL_V3 = 44,
/* New BETAFPV ELRS Micro TX Module 2.4G with ESP32 CPU */ /* New BETAFPV ELRS Micro TX Module 2.4G with ESP32 CPU */
meshtastic_HardwareModel_BETAFPV_2400_TX = 45, meshtastic_HardwareModel_BETAFPV_2400_TX = 45,
/* BetaFPV ExpressLRS "Nano" TX Module 900MHz with ESP32 CPU */
meshtastic_HardwareModel_BETAFPV_900_NANO_TX = 46,
/* B&Q Consulting Nano G1 Explorer: https://wiki.uniteng.com/en/meshtastic/nano-g1-explorer */
meshtastic_HardwareModel_NANO_G1_EXPLORER = 47,
/* Reserved ID For developing private Ports. These will show up in live traffic sparsely, so we can use a high number. Keep it within 8 bits. */ /* Reserved ID For developing private Ports. These will show up in live traffic sparsely, so we can use a high number. Keep it within 8 bits. */
meshtastic_HardwareModel_PRIVATE_HW = 255 meshtastic_HardwareModel_PRIVATE_HW = 255
} meshtastic_HardwareModel; } meshtastic_HardwareModel;
@ -637,6 +641,61 @@ typedef struct _meshtastic_QueueStatus {
uint32_t mesh_packet_id; uint32_t mesh_packet_id;
} meshtastic_QueueStatus; } meshtastic_QueueStatus;
/* Packets/commands to the radio will be written (reliably) to the toRadio characteristic.
Once the write completes the phone can assume it is handled. */
typedef struct _meshtastic_ToRadio {
pb_size_t which_payload_variant;
union {
/* Send this packet on the mesh */
meshtastic_MeshPacket packet;
/* Phone wants radio to send full node db to the phone, This is
typically the first packet sent to the radio when the phone gets a
bluetooth connection. The radio will respond by sending back a
MyNodeInfo, a owner, a radio config and a series of
FromRadio.node_infos, and config_complete
the integer you write into this field will be reported back in the
config_complete_id response this allows clients to never be confused by
a stale old partially sent config. */
uint32_t want_config_id;
/* Tell API server we are disconnecting now.
This is useful for serial links where there is no hardware/protocol based notification that the client has dropped the link.
(Sending this message is optional for clients) */
bool disconnect;
meshtastic_XModem xmodemPacket;
};
} meshtastic_ToRadio;
typedef PB_BYTES_ARRAY_T(237) meshtastic_Compressed_data_t;
/* Compressed message payload */
typedef struct _meshtastic_Compressed {
/* PortNum to determine the how to handle the compressed payload. */
meshtastic_PortNum portnum;
/* Compressed data. */
meshtastic_Compressed_data_t data;
} meshtastic_Compressed;
/* Device metadata response */
typedef struct _meshtastic_DeviceMetadata {
/* Device firmware version string */
char firmware_version[18];
/* Device state version */
uint32_t device_state_version;
/* Indicates whether the device can shutdown CPU natively or via power management chip */
bool canShutdown;
/* Indicates that the device has native wifi capability */
bool hasWifi;
/* Indicates that the device has native bluetooth capability */
bool hasBluetooth;
/* Indicates that the device has an ethernet peripheral */
bool hasEthernet;
/* Indicates that the device's role in the mesh */
meshtastic_Config_DeviceConfig_Role role;
/* Indicates the device's current enabled position flags */
uint32_t position_flags;
/* Device hardware model */
meshtastic_HardwareModel hw_model;
} meshtastic_DeviceMetadata;
/* Packets from the radio to the phone will appear on the fromRadio characteristic. /* Packets from the radio to the phone will appear on the fromRadio characteristic.
It will support READ and NOTIFY. When a new packet arrives the device will BLE notify? It will support READ and NOTIFY. When a new packet arrives the device will BLE notify?
It will sit in that descriptor until consumed by the phone, It will sit in that descriptor until consumed by the phone,
@ -677,42 +736,11 @@ typedef struct _meshtastic_FromRadio {
meshtastic_QueueStatus queueStatus; meshtastic_QueueStatus queueStatus;
/* File Transfer Chunk */ /* File Transfer Chunk */
meshtastic_XModem xmodemPacket; meshtastic_XModem xmodemPacket;
/* Device metadata message */
meshtastic_DeviceMetadata metadata;
}; };
} meshtastic_FromRadio; } meshtastic_FromRadio;
/* Packets/commands to the radio will be written (reliably) to the toRadio characteristic.
Once the write completes the phone can assume it is handled. */
typedef struct _meshtastic_ToRadio {
pb_size_t which_payload_variant;
union {
/* Send this packet on the mesh */
meshtastic_MeshPacket packet;
/* Phone wants radio to send full node db to the phone, This is
typically the first packet sent to the radio when the phone gets a
bluetooth connection. The radio will respond by sending back a
MyNodeInfo, a owner, a radio config and a series of
FromRadio.node_infos, and config_complete
the integer you write into this field will be reported back in the
config_complete_id response this allows clients to never be confused by
a stale old partially sent config. */
uint32_t want_config_id;
/* Tell API server we are disconnecting now.
This is useful for serial links where there is no hardware/protocol based notification that the client has dropped the link.
(Sending this message is optional for clients) */
bool disconnect;
meshtastic_XModem xmodemPacket;
};
} meshtastic_ToRadio;
typedef PB_BYTES_ARRAY_T(237) meshtastic_Compressed_data_t;
/* Compressed message payload */
typedef struct _meshtastic_Compressed {
/* PortNum to determine the how to handle the compressed payload. */
meshtastic_PortNum portnum;
/* Compressed data. */
meshtastic_Compressed_data_t data;
} meshtastic_Compressed;
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
@ -779,6 +807,9 @@ extern "C" {
#define meshtastic_Compressed_portnum_ENUMTYPE meshtastic_PortNum #define meshtastic_Compressed_portnum_ENUMTYPE meshtastic_PortNum
#define meshtastic_DeviceMetadata_role_ENUMTYPE meshtastic_Config_DeviceConfig_Role
#define meshtastic_DeviceMetadata_hw_model_ENUMTYPE meshtastic_HardwareModel
/* Initializer values for message structs */ /* Initializer values for message structs */
#define meshtastic_Position_init_default {0, 0, 0, 0, _meshtastic_Position_LocSource_MIN, _meshtastic_Position_AltSource_MIN, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} #define meshtastic_Position_init_default {0, 0, 0, 0, _meshtastic_Position_LocSource_MIN, _meshtastic_Position_AltSource_MIN, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
@ -795,6 +826,7 @@ extern "C" {
#define meshtastic_FromRadio_init_default {0, 0, {meshtastic_MeshPacket_init_default}} #define meshtastic_FromRadio_init_default {0, 0, {meshtastic_MeshPacket_init_default}}
#define meshtastic_ToRadio_init_default {0, {meshtastic_MeshPacket_init_default}} #define meshtastic_ToRadio_init_default {0, {meshtastic_MeshPacket_init_default}}
#define meshtastic_Compressed_init_default {_meshtastic_PortNum_MIN, {0, {0}}} #define meshtastic_Compressed_init_default {_meshtastic_PortNum_MIN, {0, {0}}}
#define meshtastic_DeviceMetadata_init_default {"", 0, 0, 0, 0, 0, _meshtastic_Config_DeviceConfig_Role_MIN, 0, _meshtastic_HardwareModel_MIN}
#define meshtastic_Position_init_zero {0, 0, 0, 0, _meshtastic_Position_LocSource_MIN, _meshtastic_Position_AltSource_MIN, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} #define meshtastic_Position_init_zero {0, 0, 0, 0, _meshtastic_Position_LocSource_MIN, _meshtastic_Position_AltSource_MIN, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
#define meshtastic_User_init_zero {"", "", "", {0}, _meshtastic_HardwareModel_MIN, 0} #define meshtastic_User_init_zero {"", "", "", {0}, _meshtastic_HardwareModel_MIN, 0}
#define meshtastic_RouteDiscovery_init_zero {0, {0, 0, 0, 0, 0, 0, 0, 0}} #define meshtastic_RouteDiscovery_init_zero {0, {0, 0, 0, 0, 0, 0, 0, 0}}
@ -809,6 +841,7 @@ extern "C" {
#define meshtastic_FromRadio_init_zero {0, 0, {meshtastic_MeshPacket_init_zero}} #define meshtastic_FromRadio_init_zero {0, 0, {meshtastic_MeshPacket_init_zero}}
#define meshtastic_ToRadio_init_zero {0, {meshtastic_MeshPacket_init_zero}} #define meshtastic_ToRadio_init_zero {0, {meshtastic_MeshPacket_init_zero}}
#define meshtastic_Compressed_init_zero {_meshtastic_PortNum_MIN, {0, {0}}} #define meshtastic_Compressed_init_zero {_meshtastic_PortNum_MIN, {0, {0}}}
#define meshtastic_DeviceMetadata_init_zero {"", 0, 0, 0, 0, 0, _meshtastic_Config_DeviceConfig_Role_MIN, 0, _meshtastic_HardwareModel_MIN}
/* Field tags (for use in manual encoding/decoding) */ /* Field tags (for use in manual encoding/decoding) */
#define meshtastic_Position_latitude_i_tag 1 #define meshtastic_Position_latitude_i_tag 1
@ -902,6 +935,21 @@ extern "C" {
#define meshtastic_QueueStatus_free_tag 2 #define meshtastic_QueueStatus_free_tag 2
#define meshtastic_QueueStatus_maxlen_tag 3 #define meshtastic_QueueStatus_maxlen_tag 3
#define meshtastic_QueueStatus_mesh_packet_id_tag 4 #define meshtastic_QueueStatus_mesh_packet_id_tag 4
#define meshtastic_ToRadio_packet_tag 1
#define meshtastic_ToRadio_want_config_id_tag 3
#define meshtastic_ToRadio_disconnect_tag 4
#define meshtastic_ToRadio_xmodemPacket_tag 5
#define meshtastic_Compressed_portnum_tag 1
#define meshtastic_Compressed_data_tag 2
#define meshtastic_DeviceMetadata_firmware_version_tag 1
#define meshtastic_DeviceMetadata_device_state_version_tag 2
#define meshtastic_DeviceMetadata_canShutdown_tag 3
#define meshtastic_DeviceMetadata_hasWifi_tag 4
#define meshtastic_DeviceMetadata_hasBluetooth_tag 5
#define meshtastic_DeviceMetadata_hasEthernet_tag 6
#define meshtastic_DeviceMetadata_role_tag 7
#define meshtastic_DeviceMetadata_position_flags_tag 8
#define meshtastic_DeviceMetadata_hw_model_tag 9
#define meshtastic_FromRadio_id_tag 1 #define meshtastic_FromRadio_id_tag 1
#define meshtastic_FromRadio_packet_tag 2 #define meshtastic_FromRadio_packet_tag 2
#define meshtastic_FromRadio_my_info_tag 3 #define meshtastic_FromRadio_my_info_tag 3
@ -914,12 +962,7 @@ extern "C" {
#define meshtastic_FromRadio_channel_tag 10 #define meshtastic_FromRadio_channel_tag 10
#define meshtastic_FromRadio_queueStatus_tag 11 #define meshtastic_FromRadio_queueStatus_tag 11
#define meshtastic_FromRadio_xmodemPacket_tag 12 #define meshtastic_FromRadio_xmodemPacket_tag 12
#define meshtastic_ToRadio_packet_tag 1 #define meshtastic_FromRadio_metadata_tag 13
#define meshtastic_ToRadio_want_config_id_tag 3
#define meshtastic_ToRadio_disconnect_tag 4
#define meshtastic_ToRadio_xmodemPacket_tag 5
#define meshtastic_Compressed_portnum_tag 1
#define meshtastic_Compressed_data_tag 2
/* Struct field encoding specification for nanopb */ /* Struct field encoding specification for nanopb */
#define meshtastic_Position_FIELDLIST(X, a) \ #define meshtastic_Position_FIELDLIST(X, a) \
@ -1075,7 +1118,8 @@ X(a, STATIC, ONEOF, BOOL, (payload_variant,rebooted,rebooted), 8) \
X(a, STATIC, ONEOF, MESSAGE, (payload_variant,moduleConfig,moduleConfig), 9) \ X(a, STATIC, ONEOF, MESSAGE, (payload_variant,moduleConfig,moduleConfig), 9) \
X(a, STATIC, ONEOF, MESSAGE, (payload_variant,channel,channel), 10) \ X(a, STATIC, ONEOF, MESSAGE, (payload_variant,channel,channel), 10) \
X(a, STATIC, ONEOF, MESSAGE, (payload_variant,queueStatus,queueStatus), 11) \ X(a, STATIC, ONEOF, MESSAGE, (payload_variant,queueStatus,queueStatus), 11) \
X(a, STATIC, ONEOF, MESSAGE, (payload_variant,xmodemPacket,xmodemPacket), 12) X(a, STATIC, ONEOF, MESSAGE, (payload_variant,xmodemPacket,xmodemPacket), 12) \
X(a, STATIC, ONEOF, MESSAGE, (payload_variant,metadata,metadata), 13)
#define meshtastic_FromRadio_CALLBACK NULL #define meshtastic_FromRadio_CALLBACK NULL
#define meshtastic_FromRadio_DEFAULT NULL #define meshtastic_FromRadio_DEFAULT NULL
#define meshtastic_FromRadio_payload_variant_packet_MSGTYPE meshtastic_MeshPacket #define meshtastic_FromRadio_payload_variant_packet_MSGTYPE meshtastic_MeshPacket
@ -1087,6 +1131,7 @@ X(a, STATIC, ONEOF, MESSAGE, (payload_variant,xmodemPacket,xmodemPacket),
#define meshtastic_FromRadio_payload_variant_channel_MSGTYPE meshtastic_Channel #define meshtastic_FromRadio_payload_variant_channel_MSGTYPE meshtastic_Channel
#define meshtastic_FromRadio_payload_variant_queueStatus_MSGTYPE meshtastic_QueueStatus #define meshtastic_FromRadio_payload_variant_queueStatus_MSGTYPE meshtastic_QueueStatus
#define meshtastic_FromRadio_payload_variant_xmodemPacket_MSGTYPE meshtastic_XModem #define meshtastic_FromRadio_payload_variant_xmodemPacket_MSGTYPE meshtastic_XModem
#define meshtastic_FromRadio_payload_variant_metadata_MSGTYPE meshtastic_DeviceMetadata
#define meshtastic_ToRadio_FIELDLIST(X, a) \ #define meshtastic_ToRadio_FIELDLIST(X, a) \
X(a, STATIC, ONEOF, MESSAGE, (payload_variant,packet,packet), 1) \ X(a, STATIC, ONEOF, MESSAGE, (payload_variant,packet,packet), 1) \
@ -1104,6 +1149,19 @@ X(a, STATIC, SINGULAR, BYTES, data, 2)
#define meshtastic_Compressed_CALLBACK NULL #define meshtastic_Compressed_CALLBACK NULL
#define meshtastic_Compressed_DEFAULT NULL #define meshtastic_Compressed_DEFAULT NULL
#define meshtastic_DeviceMetadata_FIELDLIST(X, a) \
X(a, STATIC, SINGULAR, STRING, firmware_version, 1) \
X(a, STATIC, SINGULAR, UINT32, device_state_version, 2) \
X(a, STATIC, SINGULAR, BOOL, canShutdown, 3) \
X(a, STATIC, SINGULAR, BOOL, hasWifi, 4) \
X(a, STATIC, SINGULAR, BOOL, hasBluetooth, 5) \
X(a, STATIC, SINGULAR, BOOL, hasEthernet, 6) \
X(a, STATIC, SINGULAR, UENUM, role, 7) \
X(a, STATIC, SINGULAR, UINT32, position_flags, 8) \
X(a, STATIC, SINGULAR, UENUM, hw_model, 9)
#define meshtastic_DeviceMetadata_CALLBACK NULL
#define meshtastic_DeviceMetadata_DEFAULT NULL
extern const pb_msgdesc_t meshtastic_Position_msg; extern const pb_msgdesc_t meshtastic_Position_msg;
extern const pb_msgdesc_t meshtastic_User_msg; extern const pb_msgdesc_t meshtastic_User_msg;
extern const pb_msgdesc_t meshtastic_RouteDiscovery_msg; extern const pb_msgdesc_t meshtastic_RouteDiscovery_msg;
@ -1118,6 +1176,7 @@ extern const pb_msgdesc_t meshtastic_QueueStatus_msg;
extern const pb_msgdesc_t meshtastic_FromRadio_msg; extern const pb_msgdesc_t meshtastic_FromRadio_msg;
extern const pb_msgdesc_t meshtastic_ToRadio_msg; extern const pb_msgdesc_t meshtastic_ToRadio_msg;
extern const pb_msgdesc_t meshtastic_Compressed_msg; extern const pb_msgdesc_t meshtastic_Compressed_msg;
extern const pb_msgdesc_t meshtastic_DeviceMetadata_msg;
/* Defines for backwards compatibility with code written before nanopb-0.4.0 */ /* Defines for backwards compatibility with code written before nanopb-0.4.0 */
#define meshtastic_Position_fields &meshtastic_Position_msg #define meshtastic_Position_fields &meshtastic_Position_msg
@ -1134,10 +1193,12 @@ extern const pb_msgdesc_t meshtastic_Compressed_msg;
#define meshtastic_FromRadio_fields &meshtastic_FromRadio_msg #define meshtastic_FromRadio_fields &meshtastic_FromRadio_msg
#define meshtastic_ToRadio_fields &meshtastic_ToRadio_msg #define meshtastic_ToRadio_fields &meshtastic_ToRadio_msg
#define meshtastic_Compressed_fields &meshtastic_Compressed_msg #define meshtastic_Compressed_fields &meshtastic_Compressed_msg
#define meshtastic_DeviceMetadata_fields &meshtastic_DeviceMetadata_msg
/* Maximum encoded size of messages (where known) */ /* Maximum encoded size of messages (where known) */
#define meshtastic_Compressed_size 243 #define meshtastic_Compressed_size 243
#define meshtastic_Data_size 270 #define meshtastic_Data_size 270
#define meshtastic_DeviceMetadata_size 44
#define meshtastic_FromRadio_size 330 #define meshtastic_FromRadio_size 330
#define meshtastic_LogRecord_size 81 #define meshtastic_LogRecord_size 81
#define meshtastic_MeshPacket_size 321 #define meshtastic_MeshPacket_size 321

View File

@ -490,19 +490,7 @@ void AdminModule::handleGetModuleConfig(const meshtastic_MeshPacket &req, const
void AdminModule::handleGetDeviceMetadata(const meshtastic_MeshPacket &req) void AdminModule::handleGetDeviceMetadata(const meshtastic_MeshPacket &req)
{ {
meshtastic_AdminMessage r = meshtastic_AdminMessage_init_default; meshtastic_AdminMessage r = meshtastic_AdminMessage_init_default;
r.get_device_metadata_response = getDeviceMetadata();
meshtastic_DeviceMetadata deviceMetadata;
strncpy(deviceMetadata.firmware_version, myNodeInfo.firmware_version, 18);
deviceMetadata.device_state_version = DEVICESTATE_CUR_VER;
deviceMetadata.canShutdown = pmu_found || HAS_CPU_SHUTDOWN;
deviceMetadata.hasBluetooth = HAS_BLUETOOTH;
deviceMetadata.hasWifi = HAS_WIFI;
deviceMetadata.hasEthernet = HAS_ETHERNET;
deviceMetadata.role = config.device.role;
deviceMetadata.position_flags = config.position.position_flags;
deviceMetadata.hw_model = HW_VENDOR;
r.get_device_metadata_response = deviceMetadata;
r.which_payload_variant = meshtastic_AdminMessage_get_device_metadata_response_tag; r.which_payload_variant = meshtastic_AdminMessage_get_device_metadata_response_tag;
myReply = allocDataProtobuf(r); myReply = allocDataProtobuf(r);
} }
@ -603,6 +591,7 @@ void AdminModule::handleSetHamMode(const meshtastic_HamParameters &p)
{ {
// Set call sign and override lora limitations for licensed use // Set call sign and override lora limitations for licensed use
strncpy(owner.long_name, p.call_sign, sizeof(owner.long_name)); strncpy(owner.long_name, p.call_sign, sizeof(owner.long_name));
strncpy(owner.short_name, p.short_name, sizeof(owner.short_name));
owner.is_licensed = true; owner.is_licensed = true;
config.lora.override_duty_cycle = true; config.lora.override_duty_cycle = true;
config.lora.tx_power = p.tx_power; config.lora.tx_power = p.tx_power;

View File

@ -14,8 +14,10 @@
#include "modules/TraceRouteModule.h" #include "modules/TraceRouteModule.h"
#include "modules/WaypointModule.h" #include "modules/WaypointModule.h"
#if HAS_TELEMETRY #if HAS_TELEMETRY
#include "modules/Telemetry/AirQualityTelemetry.h"
#include "modules/Telemetry/DeviceTelemetry.h" #include "modules/Telemetry/DeviceTelemetry.h"
#endif
#if HAS_SENSOR
#include "modules/Telemetry/AirQualityTelemetry.h"
#include "modules/Telemetry/EnvironmentTelemetry.h" #include "modules/Telemetry/EnvironmentTelemetry.h"
#endif #endif
#ifdef ARCH_ESP32 #ifdef ARCH_ESP32
@ -63,6 +65,8 @@ void setupModules()
#endif #endif
#if HAS_TELEMETRY #if HAS_TELEMETRY
new DeviceTelemetryModule(); new DeviceTelemetryModule();
#endif
#if HAS_SENSOR
new EnvironmentTelemetryModule(); new EnvironmentTelemetryModule();
if (nodeTelemetrySensorsMap[meshtastic_TelemetrySensorType_PMSA003I] > 0) { if (nodeTelemetrySensorsMap[meshtastic_TelemetrySensorType_PMSA003I] > 0) {
new AirQualityTelemetryModule(); new AirQualityTelemetryModule();

View File

@ -34,6 +34,7 @@ void NodeInfoModule::sendOurNodeInfo(NodeNum dest, bool wantReplies)
service.cancelSending(prevPacketId); service.cancelSending(prevPacketId);
meshtastic_MeshPacket *p = allocReply(); meshtastic_MeshPacket *p = allocReply();
if (p) { // Check whether we didn't ignore it
p->to = dest; p->to = dest;
p->decoded.want_response = wantReplies; p->decoded.want_response = wantReplies;
p->priority = meshtastic_MeshPacket_Priority_BACKGROUND; p->priority = meshtastic_MeshPacket_Priority_BACKGROUND;
@ -41,14 +42,25 @@ void NodeInfoModule::sendOurNodeInfo(NodeNum dest, bool wantReplies)
service.sendToMesh(p); service.sendToMesh(p);
} }
}
meshtastic_MeshPacket *NodeInfoModule::allocReply() meshtastic_MeshPacket *NodeInfoModule::allocReply()
{ {
uint32_t now = millis();
// If we sent our NodeInfo less than 1 min. ago, don't send it again as it may be still underway.
if (lastSentToMesh && (now - lastSentToMesh) < 60 * 1000) {
LOG_DEBUG("Sending NodeInfo will be ignored since we just sent it.\n");
ignoreRequest = true; // Mark it as ignored for MeshModule
return NULL;
} else {
ignoreRequest = false; // Don't ignore requests anymore
meshtastic_User &u = owner; meshtastic_User &u = owner;
LOG_INFO("sending owner %s/%s/%s\n", u.id, u.long_name, u.short_name); LOG_INFO("sending owner %s/%s/%s\n", u.id, u.long_name, u.short_name);
lastSentToMesh = now;
return allocDataProtobuf(u); return allocDataProtobuf(u);
} }
}
NodeInfoModule::NodeInfoModule() NodeInfoModule::NodeInfoModule()
: ProtobufModule("nodeinfo", meshtastic_PortNum_NODEINFO_APP, &meshtastic_User_msg), concurrency::OSThread("NodeInfoModule") : ProtobufModule("nodeinfo", meshtastic_PortNum_NODEINFO_APP, &meshtastic_User_msg), concurrency::OSThread("NodeInfoModule")

View File

@ -35,6 +35,9 @@ class NodeInfoModule : public ProtobufModule<meshtastic_User>, private concurren
/** Does our periodic broadcast */ /** Does our periodic broadcast */
virtual int32_t runOnce() override; virtual int32_t runOnce() override;
private:
uint32_t lastSentToMesh = 0; // Last time we sent our NodeInfo to the mesh
}; };
extern NodeInfoModule *nodeInfoModule; extern NodeInfoModule *nodeInfoModule;

View File

@ -10,7 +10,6 @@
int32_t AirQualityTelemetryModule::runOnce() int32_t AirQualityTelemetryModule::runOnce()
{ {
#ifndef ARCH_PORTDUINO
int32_t result = INT32_MAX; int32_t result = INT32_MAX;
/* /*
Uncomment the preferences below if you want to use the module Uncomment the preferences below if you want to use the module
@ -55,7 +54,6 @@ int32_t AirQualityTelemetryModule::runOnce()
} }
} }
return sendToPhoneIntervalMs; return sendToPhoneIntervalMs;
#endif
} }
bool AirQualityTelemetryModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, meshtastic_Telemetry *t) bool AirQualityTelemetryModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, meshtastic_Telemetry *t)

View File

@ -12,7 +12,7 @@ class DeviceTelemetryModule : private concurrency::OSThread, public ProtobufModu
: concurrency::OSThread("DeviceTelemetryModule"), : concurrency::OSThread("DeviceTelemetryModule"),
ProtobufModule("DeviceTelemetry", meshtastic_PortNum_TELEMETRY_APP, &meshtastic_Telemetry_msg) ProtobufModule("DeviceTelemetry", meshtastic_PortNum_TELEMETRY_APP, &meshtastic_Telemetry_msg)
{ {
setIntervalFromNow(10 * 1000); setIntervalFromNow(45 * 1000); // Wait until NodeInfo is sent
} }
virtual bool wantUIFrame() { return false; } virtual bool wantUIFrame() { return false; }

View File

@ -52,7 +52,6 @@ SHT31Sensor sht31Sensor;
int32_t EnvironmentTelemetryModule::runOnce() int32_t EnvironmentTelemetryModule::runOnce()
{ {
#ifndef ARCH_PORTDUINO
int32_t result = INT32_MAX; int32_t result = INT32_MAX;
/* /*
Uncomment the preferences below if you want to use the module Uncomment the preferences below if you want to use the module
@ -115,7 +114,6 @@ int32_t EnvironmentTelemetryModule::runOnce()
} }
} }
return sendToPhoneIntervalMs; return sendToPhoneIntervalMs;
#endif
} }
bool EnvironmentTelemetryModule::wantUIFrame() bool EnvironmentTelemetryModule::wantUIFrame()

View File

@ -27,6 +27,9 @@
#ifndef HAS_TELEMETRY #ifndef HAS_TELEMETRY
#define HAS_TELEMETRY 1 #define HAS_TELEMETRY 1
#endif #endif
#ifndef HAS_SENSOR
#define HAS_SENSOR 1
#endif
#ifndef HAS_RADIO #ifndef HAS_RADIO
#define HAS_RADIO 1 #define HAS_RADIO 1
#endif #endif

View File

@ -23,6 +23,9 @@
#ifndef HAS_TELEMETRY #ifndef HAS_TELEMETRY
#define HAS_TELEMETRY 1 #define HAS_TELEMETRY 1
#endif #endif
#ifndef HAS_SENSOR
#define HAS_SENSOR 1
#endif
#ifndef HAS_RADIO #ifndef HAS_RADIO
#define HAS_RADIO 1 #define HAS_RADIO 1
#endif #endif

View File

@ -2,7 +2,7 @@
#include "MeshService.h" #include "MeshService.h"
#include "Router.h" #include "Router.h"
SimRadio::SimRadio() SimRadio::SimRadio() : NotifiedWorkerThread("SimRadio")
{ {
instance = this; instance = this;
} }
@ -53,10 +53,7 @@ void SimRadio::startTransmitTimer(bool withDelay)
if (!txQueue.empty()) { if (!txQueue.empty()) {
uint32_t delayMsec = !withDelay ? 1 : getTxDelayMsec(); uint32_t delayMsec = !withDelay ? 1 : getTxDelayMsec();
// LOG_DEBUG("xmit timer %d\n", delay); // LOG_DEBUG("xmit timer %d\n", delay);
delay(delayMsec); notifyLater(delayMsec, TRANSMIT_DELAY_COMPLETED, false);
onNotify(TRANSMIT_DELAY_COMPLETED);
} else {
LOG_DEBUG("TX QUEUE EMPTY!\n");
} }
} }
@ -66,8 +63,7 @@ void SimRadio::startTransmitTimerSNR(float snr)
if (!txQueue.empty()) { if (!txQueue.empty()) {
uint32_t delayMsec = getTxDelayMsecWeighted(snr); uint32_t delayMsec = getTxDelayMsecWeighted(snr);
// LOG_DEBUG("xmit timer %d\n", delay); // LOG_DEBUG("xmit timer %d\n", delay);
delay(delayMsec); notifyLater(delayMsec, TRANSMIT_DELAY_COMPLETED, false);
onNotify(TRANSMIT_DELAY_COMPLETED);
} }
} }
@ -142,11 +138,12 @@ void SimRadio::onNotify(uint32_t notification)
switch (notification) { switch (notification) {
case ISR_TX: case ISR_TX:
handleTransmitInterrupt(); handleTransmitInterrupt();
LOG_DEBUG("tx complete - starting timer\n"); // LOG_DEBUG("tx complete - starting timer\n");
startTransmitTimer(); startTransmitTimer();
break; break;
case ISR_RX: case ISR_RX:
LOG_DEBUG("rx complete - starting timer\n"); // LOG_DEBUG("rx complete - starting timer\n");
startTransmitTimer();
break; break;
case TRANSMIT_DELAY_COMPLETED: case TRANSMIT_DELAY_COMPLETED:
LOG_DEBUG("delay done\n"); LOG_DEBUG("delay done\n");
@ -170,8 +167,7 @@ void SimRadio::onNotify(uint32_t notification)
uint32_t xmitMsec = getPacketTime(txp); uint32_t xmitMsec = getPacketTime(txp);
airTime->logAirtime(TX_LOG, xmitMsec); airTime->logAirtime(TX_LOG, xmitMsec);
delay(xmitMsec); // Model the time it is busy sending notifyLater(xmitMsec, ISR_TX, false); // Model the time it is busy sending
completeSending();
} }
} }
} else { } else {
@ -242,8 +238,7 @@ void SimRadio::handleReceiveInterrupt(meshtastic_MeshPacket *p)
xmitMsec = getPacketTime(length); xmitMsec = getPacketTime(length);
// LOG_DEBUG("Payload size %d vs length (includes header) %d\n", p->decoded.payload.size, length); // LOG_DEBUG("Payload size %d vs length (includes header) %d\n", p->decoded.payload.size, length);
meshtastic_MeshPacket *mp = packetPool.allocCopy(*p); // keep a copy in packtPool meshtastic_MeshPacket *mp = packetPool.allocCopy(*p); // keep a copy in packetPool
mp->which_payload_variant = meshtastic_MeshPacket_decoded_tag; // Mark that the payload is already decoded
printPacket("Lora RX", mp); printPacket("Lora RX", mp);

View File

@ -3,10 +3,11 @@
#include "MeshPacketQueue.h" #include "MeshPacketQueue.h"
#include "RadioInterface.h" #include "RadioInterface.h"
#include "api/WiFiServerAPI.h" #include "api/WiFiServerAPI.h"
#include "concurrency/NotifiedWorkerThread.h"
#include <RadioLib.h> #include <RadioLib.h>
class SimRadio : public RadioInterface class SimRadio : public RadioInterface, protected concurrency::NotifiedWorkerThread
{ {
enum PendingISR { ISR_NONE = 0, ISR_RX, ISR_TX, TRANSMIT_DELAY_COMPLETED }; enum PendingISR { ISR_NONE = 0, ISR_RX, ISR_TX, TRANSMIT_DELAY_COMPLETED };

View File

@ -2,15 +2,18 @@
#define ARCH_PORTDUINO #define ARCH_PORTDUINO
//
// defaults for NRF52 architecture
//
// //
// set HW_VENDOR // set HW_VENDOR
// //
#define HW_VENDOR meshtastic_HardwareModel_PORTDUINO #define HW_VENDOR meshtastic_HardwareModel_PORTDUINO
#define HAS_RTC 1 #ifndef HAS_WIFI
#define HAS_WIFI 1 #define HAS_WIFI 1
#endif
#ifndef HAS_RTC
#define HAS_RTC 1
#endif
#ifndef HAS_TELEMETRY
#define HAS_TELEMETRY 1
#endif

View File

@ -1,4 +1,4 @@
[VERSION] [VERSION]
major = 2 major = 2
minor = 0 minor = 0
build = 20 build = 21