mirror of
https://github.com/meshtastic/firmware.git
synced 2025-06-25 22:20:27 +00:00
Merge branch 'master' into master
This commit is contained in:
commit
315cfe4f2d
@ -45,6 +45,18 @@ Recommended settings for a sender at different radio settings:
|
|||||||
Medium ... range_test_plugin_sender = 15
|
Medium ... range_test_plugin_sender = 15
|
||||||
Short Fast ... range_test_plugin_sender = 15
|
Short Fast ... range_test_plugin_sender = 15
|
||||||
|
|
||||||
|
## Python API Examples
|
||||||
|
|
||||||
|
### Sender
|
||||||
|
|
||||||
|
meshtastic --set range_test_plugin_enabled 1
|
||||||
|
meshtastic --set range_test_plugin_sender 60
|
||||||
|
|
||||||
|
### Receiver
|
||||||
|
|
||||||
|
meshtastic --set range_test_plugin_enabled 1
|
||||||
|
meshtastic --set range_test_plugin_save 1
|
||||||
|
|
||||||
## Other things to keep in mind
|
## Other things to keep in mind
|
||||||
|
|
||||||
Be sure to turn off either the plugin configured as a sender or the device where the plugin setup as sender when not in use. This will use a lot of time on air and will spam your channel.
|
Be sure to turn off either the plugin configured as a sender or the device where the plugin setup as sender when not in use. This will use a lot of time on air and will spam your channel.
|
||||||
|
@ -26,26 +26,23 @@ int32_t StoreForwardPlugin::runOnce()
|
|||||||
without having to configure it from the PythonAPI or WebUI.
|
without having to configure it from the PythonAPI or WebUI.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// radioConfig.preferences.store_forward_plugin_enabled = 1;
|
radioConfig.preferences.store_forward_plugin_enabled = 1;
|
||||||
// radioConfig.preferences.is_router = 1;
|
radioConfig.preferences.is_router = 0;
|
||||||
|
|
||||||
if (radioConfig.preferences.store_forward_plugin_enabled) {
|
if (radioConfig.preferences.store_forward_plugin_enabled) {
|
||||||
|
|
||||||
if (firstTime) {
|
if (firstTime) {
|
||||||
|
|
||||||
/*
|
firstTime = 0;
|
||||||
*/
|
|
||||||
|
|
||||||
if (radioConfig.preferences.is_router) {
|
if (radioConfig.preferences.is_router) {
|
||||||
DEBUG_MSG("Initializing Store & Forward Plugin - Enabled\n");
|
DEBUG_MSG("Initializing Store & Forward Plugin - Enabled as Router\n");
|
||||||
// Router
|
// Router
|
||||||
if (ESP.getPsramSize()) {
|
if (ESP.getPsramSize()) {
|
||||||
if (ESP.getFreePsram() >= 2048 * 1024) {
|
if (ESP.getFreePsram() >= 2048 * 1024) {
|
||||||
// Do the startup here
|
// Do the startup here
|
||||||
storeForwardPluginRadio = new StoreForwardPluginRadio();
|
storeForwardPluginRadio = new StoreForwardPluginRadio();
|
||||||
|
|
||||||
firstTime = 0;
|
|
||||||
|
|
||||||
this->populatePSRAM();
|
this->populatePSRAM();
|
||||||
|
|
||||||
// packetHistory[0].bytes;
|
// packetHistory[0].bytes;
|
||||||
@ -66,21 +63,30 @@ int32_t StoreForwardPlugin::runOnce()
|
|||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
DEBUG_MSG("Initializing Store & Forward Plugin - Enabled but is_router is not turned on.\n");
|
DEBUG_MSG("Initializing Store & Forward Plugin - Enabled as Client\n");
|
||||||
DEBUG_MSG(
|
return (5 * 1000);
|
||||||
"Initializing Store & Forward Plugin - If you want to use this plugin, you must also turn on is_router.\n");
|
|
||||||
// Non-Router
|
|
||||||
|
|
||||||
return (30 * 1000);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// What do we do if it's not our first time?
|
|
||||||
|
|
||||||
// Maybe some cleanup functions?
|
if (radioConfig.preferences.is_router) {
|
||||||
this->sawNodeReport();
|
// Maybe some cleanup functions?
|
||||||
this->historyReport();
|
this->sawNodeReport();
|
||||||
return (10 * 1000);
|
this->historyReport();
|
||||||
|
return (10 * 1000);
|
||||||
|
} else {
|
||||||
|
/*
|
||||||
|
* If the plugin is turned on and is_router is not enabled, then we'll send a heartbeat every
|
||||||
|
* few minutes.
|
||||||
|
*/
|
||||||
|
|
||||||
|
DEBUG_MSG("Store & Forward Plugin - Sending heartbeat\n");
|
||||||
|
|
||||||
|
// storeForwardPluginRadio->sendPayloadHeartbeat();
|
||||||
|
storeForwardPluginRadio->sendPayload();
|
||||||
|
|
||||||
|
return (1 * 60 * 1000);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@ -220,15 +226,32 @@ void StoreForwardPlugin::sawNodeReport()
|
|||||||
|
|
||||||
MeshPacket *StoreForwardPluginRadio::allocReply()
|
MeshPacket *StoreForwardPluginRadio::allocReply()
|
||||||
{
|
{
|
||||||
|
//auto reply = allocDataPacket(); // Allocate a packet for sending
|
||||||
auto reply = allocDataPacket(); // Allocate a packet for sending
|
//return reply;
|
||||||
|
|
||||||
return reply;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void StoreForwardPluginRadio::sendPayload(NodeNum dest, bool wantReplies)
|
void StoreForwardPluginRadio::sendPayload(NodeNum dest, bool wantReplies)
|
||||||
{
|
{
|
||||||
MeshPacket *p = allocReply();
|
MeshPacket *p = this->allocReply();
|
||||||
|
/*
|
||||||
|
p->to = dest;
|
||||||
|
p->decoded.want_response = wantReplies;
|
||||||
|
|
||||||
|
p->want_ack = true;
|
||||||
|
*/
|
||||||
|
// static char heartbeatString[20];
|
||||||
|
// snprintf(heartbeatString, sizeof(heartbeatString), "1");
|
||||||
|
|
||||||
|
// p->decoded.data.payload.size = strlen(heartbeatString); // You must specify how many bytes are in the reply
|
||||||
|
// memcpy(p->decoded.data.payload.bytes, "1", 1);
|
||||||
|
|
||||||
|
// service.sendToMesh(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
void StoreForwardPluginRadio::sendPayloadHeartbeat(NodeNum dest, bool wantReplies)
|
||||||
|
{
|
||||||
|
DEBUG_MSG("Sending S&F Heartbeat\n");
|
||||||
|
MeshPacket *p = this->allocReply();
|
||||||
p->to = dest;
|
p->to = dest;
|
||||||
p->decoded.want_response = wantReplies;
|
p->decoded.want_response = wantReplies;
|
||||||
|
|
||||||
@ -283,7 +306,7 @@ bool StoreForwardPluginRadio::handleReceived(const MeshPacket &mp)
|
|||||||
|
|
||||||
if ((millis() - sawTime) > STOREFORWARD_SEND_HISTORY_SHORT) {
|
if ((millis() - sawTime) > STOREFORWARD_SEND_HISTORY_SHORT) {
|
||||||
// Node has been away for a while.
|
// Node has been away for a while.
|
||||||
storeForwardPlugin->historySend(sawTime, getFrom(&mp));
|
storeForwardPlugin->historySend(sawTime, mp.from);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,6 +63,11 @@ class StoreForwardPluginRadio : public SinglePortPlugin
|
|||||||
*/
|
*/
|
||||||
void sendPayload(NodeNum dest = NODENUM_BROADCAST, bool wantReplies = false);
|
void sendPayload(NodeNum dest = NODENUM_BROADCAST, bool wantReplies = false);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send our payload into the mesh
|
||||||
|
*/
|
||||||
|
void sendPayloadHeartbeat(NodeNum dest = NODENUM_BROADCAST, bool wantReplies = false);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual MeshPacket *allocReply();
|
virtual MeshPacket *allocReply();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user