kopia lustrzana https://github.com/meshtastic/firmware
factor out sendTelemetry function
rodzic
3e46ba6840
commit
b61ba1a3c5
|
@ -1 +1 @@
|
|||
Subproject commit d191975ebc572527c6d9eec48d5b0a1e3331999f
|
||||
Subproject commit 8f4faf76e52c2ef63c582c26642d312d9781b7c0
|
|
@ -336,18 +336,7 @@ int32_t SerialModule::runOnce()
|
|||
m.variant.environment_metrics.wind_lull, m.variant.environment_metrics.wind_gust,
|
||||
m.variant.environment_metrics.voltage);
|
||||
|
||||
meshtastic_MeshPacket *p = router->allocForSending();
|
||||
|
||||
p->decoded.portnum = meshtastic_PortNum_TELEMETRY_APP;
|
||||
|
||||
p->decoded.payload.size = pb_encode_to_bytes(p->decoded.payload.bytes, sizeof(p->decoded.payload.bytes),
|
||||
&meshtastic_Telemetry_msg, &m);
|
||||
|
||||
LOG_INFO("payload size : %i\n", p->decoded.payload.size);
|
||||
p->to = NODENUM_BROADCAST;
|
||||
p->decoded.want_response = false;
|
||||
p->priority = meshtastic_MeshPacket_Priority_RELIABLE;
|
||||
service.sendToMesh(p, RX_SRC_LOCAL, true);
|
||||
sendTelemetry(m);
|
||||
|
||||
// reset counters and gust/lull
|
||||
velSum = velCount = dirCount = 0;
|
||||
|
@ -373,6 +362,27 @@ int32_t SerialModule::runOnce()
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends telemetry packet over the mesh network.
|
||||
*
|
||||
* @param m The telemetry data to be sent
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @throws None
|
||||
*/
|
||||
void SerialModule::sendTelemetry(meshtastic_Telemetry m)
|
||||
{
|
||||
meshtastic_MeshPacket *p = router->allocForSending();
|
||||
p->decoded.portnum = meshtastic_PortNum_TELEMETRY_APP;
|
||||
p->decoded.payload.size =
|
||||
pb_encode_to_bytes(p->decoded.payload.bytes, sizeof(p->decoded.payload.bytes), &meshtastic_Telemetry_msg, &m);
|
||||
p->to = NODENUM_BROADCAST;
|
||||
p->decoded.want_response = false;
|
||||
p->priority = meshtastic_MeshPacket_Priority_RELIABLE;
|
||||
service.sendToMesh(p, RX_SRC_LOCAL, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Allocates a new mesh packet for use as a reply to a received packet.
|
||||
*
|
||||
|
|
|
@ -28,6 +28,7 @@ class SerialModule : public StreamAPI, private concurrency::OSThread
|
|||
|
||||
private:
|
||||
uint32_t getBaudRate();
|
||||
void sendTelemetry(meshtastic_Telemetry m);
|
||||
};
|
||||
|
||||
extern SerialModule *serialModule;
|
||||
|
|
Ładowanie…
Reference in New Issue