kopia lustrzana https://github.com/sh123/esp32_loraprs
Remove some magic constants
rodzic
8df912facf
commit
3d6e059420
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
namespace LoraPrs {
|
namespace LoraPrs {
|
||||||
|
|
||||||
byte Service::rxBuf_[256];
|
byte Service::rxBuf_[CfgMaxPacketSize];
|
||||||
|
|
||||||
#ifdef USE_RADIOLIB
|
#ifdef USE_RADIOLIB
|
||||||
#pragma message("Using RadioLib")
|
#pragma message("Using RadioLib")
|
||||||
|
@ -409,7 +409,7 @@ void Service::onAprsisDataAvailable()
|
||||||
if (c == '\r') continue;
|
if (c == '\r') continue;
|
||||||
if (c == '\n') break;
|
if (c == '\n') break;
|
||||||
aprsisData += c;
|
aprsisData += c;
|
||||||
if (aprsisData.length() >= CfgMaxAprsInMessageSize) {
|
if (aprsisData.length() >= CfgMaxPacketSize) {
|
||||||
LOG_WARN("APRS-IS incoming message is too long, skipping tail");
|
LOG_WARN("APRS-IS incoming message is too long, skipping tail");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -441,15 +441,12 @@ void Service::sendSignalReportEvent(int rssi, float snr)
|
||||||
bool Service::sendAX25ToLora(const AX25::Payload &payload)
|
bool Service::sendAX25ToLora(const AX25::Payload &payload)
|
||||||
{
|
{
|
||||||
int bytesWritten;
|
int bytesWritten;
|
||||||
byte buf[CfgMaxAX25PayloadSize];
|
byte buf[CfgMaxPacketSize];
|
||||||
|
|
||||||
// TNC2 text mode
|
// TNC2 text mode
|
||||||
if (config_.EnableTextPackets) {
|
if (config_.EnableTextPackets) {
|
||||||
String textPayload = payload.ToString();
|
String textPayload = payload.ToString();
|
||||||
bytesWritten = textPayload.length();
|
bytesWritten = textPayload.length() > CfgMaxPacketSize ? CfgMaxPacketSize : textPayload.length();
|
||||||
if (bytesWritten > CfgMaxAX25PayloadSize) {
|
|
||||||
bytesWritten = CfgMaxAX25PayloadSize;
|
|
||||||
}
|
|
||||||
textPayload.getBytes(buf, bytesWritten);
|
textPayload.getBytes(buf, bytesWritten);
|
||||||
buf[bytesWritten-1] = '\0';
|
buf[bytesWritten-1] = '\0';
|
||||||
|
|
||||||
|
@ -528,8 +525,8 @@ void Service::processIncomingRawPacketAsServer(const byte *packet, int packetLen
|
||||||
|
|
||||||
// try to parse as text for clients, who submit plain text
|
// try to parse as text for clients, who submit plain text
|
||||||
if (!payload.IsValid() && config_.EnableTextPackets) {
|
if (!payload.IsValid() && config_.EnableTextPackets) {
|
||||||
char buf[CfgMaxAX25PayloadSize];
|
char buf[CfgMaxPacketSize];
|
||||||
int cpySize = packetLength > CfgMaxAX25PayloadSize ? CfgMaxAX25PayloadSize : packetLength;
|
int cpySize = packetLength > CfgMaxPacketSize ? CfgMaxPacketSize : packetLength;
|
||||||
memcpy(buf, packet, cpySize);
|
memcpy(buf, packet, cpySize);
|
||||||
buf[cpySize-1] = '\0';
|
buf[cpySize-1] = '\0';
|
||||||
payload = AX25::Payload(String((char*)buf));
|
payload = AX25::Payload(String((char*)buf));
|
||||||
|
|
|
@ -120,8 +120,7 @@ private:
|
||||||
const int CfgConnRetryMs = 500; // connection retry delay, e.g. wifi
|
const int CfgConnRetryMs = 500; // connection retry delay, e.g. wifi
|
||||||
const int CfgPollDelayMs = 5; // main loop delay
|
const int CfgPollDelayMs = 5; // main loop delay
|
||||||
const int CfgConnRetryMaxTimes = 10; // number of connection retries
|
const int CfgConnRetryMaxTimes = 10; // number of connection retries
|
||||||
const int CfgMaxAX25PayloadSize = 512; // maximum ax25 payload size
|
static const int CfgMaxPacketSize = 256; // maximum packet size
|
||||||
const int CfgMaxAprsInMessageSize = 255; // maximum aprsis to rf message size
|
|
||||||
|
|
||||||
// csma parameters, overriden with KISS commands
|
// csma parameters, overriden with KISS commands
|
||||||
const long CfgCsmaPersistence = 100; // 255 for real time, lower for higher traffic
|
const long CfgCsmaPersistence = 100; // 255 for real time, lower for higher traffic
|
||||||
|
@ -145,10 +144,10 @@ private:
|
||||||
long previousBeaconMs_;
|
long previousBeaconMs_;
|
||||||
|
|
||||||
// peripherals
|
// peripherals
|
||||||
static byte rxBuf_[256];
|
static byte rxBuf_[CfgMaxPacketSize];
|
||||||
#ifdef USE_RADIOLIB
|
#ifdef USE_RADIOLIB
|
||||||
static bool interruptEnabled_;
|
static bool interruptEnabled_;
|
||||||
CircularBuffer<uint8_t, 256> txQueue_;
|
CircularBuffer<uint8_t, CfgMaxPacketSize> txQueue_;
|
||||||
static std::shared_ptr<MODULE_NAME> radio_;
|
static std::shared_ptr<MODULE_NAME> radio_;
|
||||||
#endif
|
#endif
|
||||||
BluetoothSerial serialBt_;
|
BluetoothSerial serialBt_;
|
||||||
|
|
Ładowanie…
Reference in New Issue