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
32 changed files with 235 additions and 221 deletions

View File

@@ -490,19 +490,7 @@ void AdminModule::handleGetModuleConfig(const meshtastic_MeshPacket &req, const
void AdminModule::handleGetDeviceMetadata(const meshtastic_MeshPacket &req)
{
meshtastic_AdminMessage r = meshtastic_AdminMessage_init_default;
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.get_device_metadata_response = getDeviceMetadata();
r.which_payload_variant = meshtastic_AdminMessage_get_device_metadata_response_tag;
myReply = allocDataProtobuf(r);
}
@@ -603,6 +591,7 @@ void AdminModule::handleSetHamMode(const meshtastic_HamParameters &p)
{
// Set call sign and override lora limitations for licensed use
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;
config.lora.override_duty_cycle = true;
config.lora.tx_power = p.tx_power;

View File

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

View File

@@ -34,20 +34,32 @@ void NodeInfoModule::sendOurNodeInfo(NodeNum dest, bool wantReplies)
service.cancelSending(prevPacketId);
meshtastic_MeshPacket *p = allocReply();
p->to = dest;
p->decoded.want_response = wantReplies;
p->priority = meshtastic_MeshPacket_Priority_BACKGROUND;
prevPacketId = p->id;
if (p) { // Check whether we didn't ignore it
p->to = dest;
p->decoded.want_response = wantReplies;
p->priority = meshtastic_MeshPacket_Priority_BACKGROUND;
prevPacketId = p->id;
service.sendToMesh(p);
service.sendToMesh(p);
}
}
meshtastic_MeshPacket *NodeInfoModule::allocReply()
{
meshtastic_User &u = owner;
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;
LOG_INFO("sending owner %s/%s/%s\n", u.id, u.long_name, u.short_name);
return allocDataProtobuf(u);
LOG_INFO("sending owner %s/%s/%s\n", u.id, u.long_name, u.short_name);
lastSentToMesh = now;
return allocDataProtobuf(u);
}
}
NodeInfoModule::NodeInfoModule()

View File

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

View File

@@ -10,7 +10,6 @@
int32_t AirQualityTelemetryModule::runOnce()
{
#ifndef ARCH_PORTDUINO
int32_t result = INT32_MAX;
/*
Uncomment the preferences below if you want to use the module
@@ -55,7 +54,6 @@ int32_t AirQualityTelemetryModule::runOnce()
}
}
return sendToPhoneIntervalMs;
#endif
}
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"),
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; }

View File

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