Add MediaMesh radio2 presets and automatic media routing
This commit is contained in:
1 parent
38f68596f7
commit
53c7bb141a
14 files changed
+358
-19
No files matched your search
@@ -42,9 +42,17 @@ inline TrafficKind rawTrafficKind(const uint8_t* data, size_t length) {
|
||||
return TrafficKind::Other;
|
||||
}
|
||||
|
||||
inline uint8_t trafficPolicy(TrafficKind kind, uint8_t media, uint8_t ssh) {
|
||||
return kind == TrafficKind::Media ? media
|
||||
inline uint8_t trafficPolicy(TrafficKind kind, uint8_t media, uint8_t ssh,
|
||||
const RadioProfiles* profiles = nullptr) {
|
||||
const uint8_t policy = kind == TrafficKind::Media ? media
|
||||
: kind == TrafficKind::Ssh ? ssh : static_cast<uint8_t>(RADIO_TX_AUTO);
|
||||
// Keep media off the main mesh whenever the second MeshCore profile can TX.
|
||||
// An explicit radio2 choice also pins queued packets if radio2 is disabled
|
||||
// before they reach Dispatcher, rather than falling back onto the main mesh.
|
||||
return kind == TrafficKind::Media && policy == RADIO_TX_AUTO && profiles
|
||||
&& profiles->canTransmit(1)
|
||||
&& profiles->params(1).protocol == RadioProfileProtocol::MeshCore
|
||||
? static_cast<uint8_t>(RADIO_TX_SECONDARY) : policy;
|
||||
}
|
||||
|
||||
inline uint8_t trafficTransmitMask(uint8_t policy, const RadioProfiles* profiles) {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "FleetCommand.h"
|
||||
#include "RadioProfilePresets.h"
|
||||
#include <SHA256.h>
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
@@ -598,7 +599,8 @@ bool FleetCommand::commandAllowed(const char* command) {
|
||||
: (get || del) && scheduleSelector(arguments, scheduled_secondary);
|
||||
}
|
||||
if (kind == CommandKind::Radio) {
|
||||
return get ? !*arguments : set && radioTuple(arguments, key_length == 10);
|
||||
return get ? !*arguments : set && ((key_length == 6
|
||||
&& cli::radio2PresetTuple(arguments)) || radioTuple(arguments, key_length == 10));
|
||||
}
|
||||
if (kind == CommandKind::RadioStatus) return get && !*arguments;
|
||||
if (kind == CommandKind::Cross) {
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include "CarrierWaveCLI.h"
|
||||
#endif
|
||||
#include "RadioProfileCommandUtils.h"
|
||||
#include "RadioProfilePresets.h"
|
||||
#include "FilePresence.h"
|
||||
#include "PersistentStoreFormat.h"
|
||||
#include "radiolib/RXPowerSaving.h"
|
||||
@@ -1005,6 +1006,10 @@ bool RadioProfileCLI::handle(const char* command, char* reply, size_t capacity,
|
||||
return true;
|
||||
}
|
||||
if (verb != Set) { cli::formatError(reply, capacity, "invalid radio2 command"); return true; }
|
||||
if (base) {
|
||||
const char* preset = cli::radio2PresetTuple(args);
|
||||
if (preset) args = preset;
|
||||
}
|
||||
char local[140];
|
||||
if (strlen(args) >= sizeof(local)) { cli::formatError(reply, capacity, "params too long"); return true; }
|
||||
strcpy(local, args);
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
#pragma once
|
||||
#include <string.h>
|
||||
|
||||
namespace mesh { namespace cli {
|
||||
|
||||
// Use the ordinary tuple path for validation, persistence and remote replies.
|
||||
inline const char* radio2PresetTuple(const char* name) {
|
||||
if (!strcmp(name, "mediamesh")) return "911.150,250,7,5,rxtx,auto";
|
||||
if (!strcmp(name, "mediamesh-range")) return "911.150,125,7,5,rxtx,auto";
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
} }
|
||||
Reference in new issue
Block a user