kopia lustrzana https://github.com/sh123/esp32_loraprs
Add configuration flag to allow text aprs messaging
rodzic
d4da05aae0
commit
a1c8f2761c
|
@ -14,6 +14,31 @@ Payload::Payload(const String &textPayload)
|
|||
isValid_ = fromString(textPayload);
|
||||
}
|
||||
|
||||
Payload::Payload(const Payload &payload)
|
||||
: isValid_(payload.isValid_)
|
||||
, srcCall_(payload.srcCall_)
|
||||
, dstCall_(payload.dstCall_)
|
||||
, rptCallsCount_(payload.rptCallsCount_)
|
||||
, info_(payload.info_)
|
||||
{
|
||||
for (int i = 0; i < rptCallsCount_; i++) {
|
||||
rptCalls_[i] = payload.rptCalls_[i];
|
||||
}
|
||||
}
|
||||
|
||||
Payload& Payload::operator=(const Payload &payload)
|
||||
{
|
||||
isValid_ = payload.isValid_;
|
||||
srcCall_ = payload.srcCall_;
|
||||
dstCall_ = payload.dstCall_;
|
||||
rptCallsCount_ = payload.rptCallsCount_;
|
||||
info_ = payload.info_;
|
||||
for (int i = 0; i < rptCallsCount_; i++) {
|
||||
rptCalls_[i] = payload.rptCalls_[i];
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
void Payload::Dump()
|
||||
{
|
||||
LOG_INFO("valid: ", isValid_);
|
||||
|
@ -65,7 +90,7 @@ int Payload::ToBinary(byte *txPayload, int bufferLength) const
|
|||
return (int)(txPtr-txPayload);
|
||||
}
|
||||
|
||||
String Payload::ToString(const String &customComment)
|
||||
String Payload::ToString(const String &customComment) const
|
||||
{
|
||||
String txt = srcCall_.ToString() + String(">") + dstCall_.ToString();
|
||||
|
||||
|
|
|
@ -13,10 +13,12 @@ class Payload
|
|||
public:
|
||||
Payload(const String &textPayload);
|
||||
Payload(const byte *rxPayload, int payloadLength);
|
||||
Payload(const Payload &payload);
|
||||
Payload& operator=(const Payload &payload);
|
||||
|
||||
inline bool IsValid() const { return isValid_; }
|
||||
|
||||
String ToString(const String &customComment=String());
|
||||
String ToString(const String &customComment=String()) const;
|
||||
int ToBinary(byte *txPayload, int bufferLength) const;
|
||||
|
||||
bool Digirepeat(const Callsign &ownCallsign);
|
||||
|
|
1
config.h
1
config.h
|
@ -65,6 +65,7 @@
|
|||
#define CFG_RF_TO_IS true // forward packets from radio to internet
|
||||
#define CFG_IS_TO_RF false // forward packets from internet to radio basedon CFG_APRS_FILTER
|
||||
#define CFG_BEACON false // enable perdiodc beacon from CFG_APRS_RAW_BKN
|
||||
#define CFG_TEXT_PACKETS false // enable aprs text packets instead of binary for interoperability with other projects (disables ax.25)
|
||||
|
||||
// frequency correction for narrow band bandwidths
|
||||
#define CFG_FREQ_CORR false // true - correct own frequency based on received packet
|
||||
|
|
|
@ -70,8 +70,12 @@ void initializeConfig(LoraPrs::Config &cfg) {
|
|||
cfg.EnableIsToRf = CFG_IS_TO_RF; // send data from aprsis to rf
|
||||
cfg.EnableRepeater = CFG_DIGIREPEAT; // digirepeat incoming packets
|
||||
cfg.EnableBeacon = CFG_BEACON; // enable periodic AprsRawBeacon beacon to rf and aprsis if rf to aprsis is enabled
|
||||
cfg.EnableTextPackets = CFG_TEXT_PACKETS; // enables text packets and disables AX25 binary frames for interoperability
|
||||
|
||||
// kiss
|
||||
cfg.KissEnableExtensions = CFG_KISS_EXTENSIONS; // radio control and signal reports
|
||||
cfg.KissEnableTcpIp = CFG_KISS_TCP_IP; // enable KISS ovr TCP/IP as a server
|
||||
|
||||
|
||||
// external ptt control
|
||||
cfg.PttEnable = CFG_PTT_ENABLE;
|
||||
|
|
|
@ -62,6 +62,7 @@ struct Config
|
|||
bool EnableIsToRf; // true - enable APRS-IS to RF submission
|
||||
bool EnableRepeater; // true - digirepeat incoming packets based on WIDEn-n paths
|
||||
bool EnableBeacon; // true - send AprsRawBeacon to RF and APRS-IS if EnableRfToIs is true
|
||||
bool EnableTextPackets; // true - use text plain messages insead of AX25 binary frames for interoperability with other projects
|
||||
|
||||
// external ptt tx control
|
||||
bool PttEnable; // true - enable external ptt control
|
||||
|
|
|
@ -411,11 +411,22 @@ void Service::sendSignalReportEvent(int rssi, float snr)
|
|||
|
||||
bool Service::sendAX25ToLora(const AX25::Payload &payload)
|
||||
{
|
||||
int bytesWritten;
|
||||
byte buf[CfgMaxAX25PayloadSize];
|
||||
int bytesWritten = payload.ToBinary(buf, sizeof(buf));
|
||||
if (bytesWritten <= 0) {
|
||||
LOG_WARN("Failed to serialize payload");
|
||||
return false;
|
||||
if (config_.EnableTextPackets) {
|
||||
String textPayload = payload.ToString();
|
||||
bytesWritten = textPayload.length();
|
||||
if (bytesWritten > CfgMaxAX25PayloadSize) {
|
||||
bytesWritten = CfgMaxAX25PayloadSize;
|
||||
}
|
||||
textPayload.getBytes(buf, bytesWritten);
|
||||
buf[bytesWritten-1] = '\0';
|
||||
} else {
|
||||
bytesWritten = payload.ToBinary(buf, sizeof(buf));
|
||||
if (bytesWritten <= 0) {
|
||||
LOG_WARN("Failed to serialize payload");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
queueSerialToRig(Cmd::Data, buf, bytesWritten);
|
||||
return true;
|
||||
|
@ -475,8 +486,14 @@ void Service::loraReceive(int packetSize)
|
|||
|
||||
void Service::processIncomingRawPacketAsServer(const byte *packet, int packetLength) {
|
||||
|
||||
// create from binary AX25
|
||||
AX25::Payload payload(packet, packetLength);
|
||||
|
||||
// try to parse as text for clients, who submit plain text
|
||||
if (!payload.IsValid() && config_.EnableTextPackets && packet[packetLength - 1] == '\0') {
|
||||
payload = AX25::Payload(String((char*)packet));
|
||||
}
|
||||
|
||||
if (payload.IsValid()) {
|
||||
|
||||
#ifdef USE_RADIOLIB
|
||||
|
|
Ładowanie…
Reference in New Issue