kopia lustrzana https://github.com/sh123/esp32_loraprs
Add ability to disable KISS and run in TNC2 mode
rodzic
a1c8f2761c
commit
55d74c04e4
|
@ -70,12 +70,11 @@ 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
|
||||
|
||||
cfg.EnableTextPackets = CFG_TEXT_PACKETS; // enables text packets and disables KISS+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;
|
||||
|
|
|
@ -7,31 +7,41 @@ CircularBuffer<uint8_t, Processor::CfgRigToSerialQueueSize> Processor::rigToSeri
|
|||
CircularBuffer<uint8_t, Processor::CfgRigToSerialQueueSize> Processor::rigToSerialQueueIndex_;
|
||||
|
||||
Processor::Processor()
|
||||
: state_(State::GetStart)
|
||||
: disableKiss_(false)
|
||||
, isRawIdle_(true)
|
||||
, state_(State::GetStart)
|
||||
{
|
||||
}
|
||||
|
||||
void Processor::sendRigToSerial(Cmd cmd, const byte *packet, int packetLength) {
|
||||
onSerialTx((byte)Marker::Fend);
|
||||
onSerialTx((byte)cmd);
|
||||
|
||||
for (int i = 0; i < packetLength; i++) {
|
||||
byte rxByte = packet[i];
|
||||
|
||||
if (rxByte == Marker::Fend) {
|
||||
onSerialTx((byte)Marker::Fesc);
|
||||
onSerialTx((byte)Marker::Tfend);
|
||||
}
|
||||
else if (rxByte == Marker::Fesc) {
|
||||
onSerialTx((byte)Marker::Fesc);
|
||||
onSerialTx((byte)Marker::Tfesc);
|
||||
}
|
||||
else {
|
||||
if (disableKiss_) {
|
||||
for (int i = 0; i < packetLength; i++) {
|
||||
byte rxByte = packet[i];
|
||||
onSerialTx(rxByte);
|
||||
}
|
||||
}
|
||||
// FIXME, need to check if '\0' or '\n' should be added
|
||||
} else {
|
||||
onSerialTx((byte)Marker::Fend);
|
||||
onSerialTx((byte)cmd);
|
||||
|
||||
onSerialTx((byte)Marker::Fend);
|
||||
for (int i = 0; i < packetLength; i++) {
|
||||
byte rxByte = packet[i];
|
||||
|
||||
if (rxByte == Marker::Fend) {
|
||||
onSerialTx((byte)Marker::Fesc);
|
||||
onSerialTx((byte)Marker::Tfend);
|
||||
}
|
||||
else if (rxByte == Marker::Fesc) {
|
||||
onSerialTx((byte)Marker::Fesc);
|
||||
onSerialTx((byte)Marker::Tfesc);
|
||||
}
|
||||
else {
|
||||
onSerialTx(rxByte);
|
||||
}
|
||||
}
|
||||
|
||||
onSerialTx((byte)Marker::Fend);
|
||||
}
|
||||
}
|
||||
|
||||
void ICACHE_RAM_ATTR Processor::queueRigToSerialIsr(Cmd cmd, const byte *packet, int packetLength) {
|
||||
|
@ -49,27 +59,35 @@ void ICACHE_RAM_ATTR Processor::queueRigToSerialIsr(Cmd cmd, const byte *packet,
|
|||
|
||||
void Processor::queueSerialToRig(Cmd cmd, const byte *packet, int packetLength) {
|
||||
bool result = 1;
|
||||
result &= serialToRigQueue_.unshift(Marker::Fend);
|
||||
result &= serialToRigQueue_.unshift(cmd);
|
||||
|
||||
for (int i = 0; i < packetLength; i++) {
|
||||
byte rxByte = packet[i];
|
||||
|
||||
if (rxByte == Marker::Fend) {
|
||||
result &= serialToRigQueue_.unshift(Marker::Fesc);
|
||||
result &= serialToRigQueue_.unshift(Marker::Tfend);
|
||||
}
|
||||
else if (rxByte == Marker::Fesc) {
|
||||
result &= serialToRigQueue_.unshift(Marker::Fesc);
|
||||
result &= serialToRigQueue_.unshift(Marker::Tfesc);
|
||||
}
|
||||
else {
|
||||
if (disableKiss_) {
|
||||
for (int i = 0; i < packetLength; i++) {
|
||||
byte rxByte = packet[i];
|
||||
result &= serialToRigQueue_.unshift(rxByte);
|
||||
}
|
||||
// FIXME, need to check if '\0' or '\n' should be added
|
||||
} else {
|
||||
result &= serialToRigQueue_.unshift(Marker::Fend);
|
||||
result &= serialToRigQueue_.unshift(cmd);
|
||||
|
||||
for (int i = 0; i < packetLength; i++) {
|
||||
byte rxByte = packet[i];
|
||||
|
||||
if (rxByte == Marker::Fend) {
|
||||
result &= serialToRigQueue_.unshift(Marker::Fesc);
|
||||
result &= serialToRigQueue_.unshift(Marker::Tfend);
|
||||
}
|
||||
else if (rxByte == Marker::Fesc) {
|
||||
result &= serialToRigQueue_.unshift(Marker::Fesc);
|
||||
result &= serialToRigQueue_.unshift(Marker::Tfesc);
|
||||
}
|
||||
else {
|
||||
result &= serialToRigQueue_.unshift(rxByte);
|
||||
}
|
||||
}
|
||||
|
||||
result &= serialToRigQueue_.unshift(Marker::Fend);
|
||||
}
|
||||
|
||||
result &= serialToRigQueue_.unshift(Marker::Fend);
|
||||
|
||||
if (!result) {
|
||||
LOG_WARN("Serial to rig queue overflow!");
|
||||
}
|
||||
|
@ -187,8 +205,25 @@ void Processor::processData(byte rxByte) {
|
|||
}
|
||||
}
|
||||
|
||||
bool Processor::receiveByte(byte rxByte) {
|
||||
bool Processor::receiveByteRaw(byte rxByte)
|
||||
{
|
||||
if (isRawIdle_) {
|
||||
if (!onRigTxBegin()) {
|
||||
return false;
|
||||
}
|
||||
isRawIdle_ = false;
|
||||
}
|
||||
onRigTx(rxByte);
|
||||
// FIXME, need to check if '\n' is marker too
|
||||
if (rxByte == '\0') {
|
||||
onRigTxEnd();
|
||||
isRawIdle_ = true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Processor::receiveByteKiss(byte rxByte)
|
||||
{
|
||||
switch (state_) {
|
||||
case State::GetStart:
|
||||
if (rxByte == Marker::Fend) {
|
||||
|
@ -237,4 +272,12 @@ bool Processor::receiveByte(byte rxByte) {
|
|||
return true;
|
||||
}
|
||||
|
||||
bool Processor::receiveByte(byte rxByte) {
|
||||
|
||||
if (disableKiss_) {
|
||||
return receiveByteRaw(rxByte);
|
||||
}
|
||||
return receiveByteKiss(rxByte);
|
||||
}
|
||||
|
||||
} // kiss
|
||||
|
|
|
@ -78,10 +78,17 @@ protected:
|
|||
|
||||
private:
|
||||
bool receiveByte(byte rxByte);
|
||||
bool receiveByteRaw(byte rxByte);
|
||||
bool receiveByteKiss(byte rxByte);
|
||||
|
||||
void processData(byte rxByte);
|
||||
bool processCommand(byte rxByte);
|
||||
|
||||
protected:
|
||||
bool disableKiss_;
|
||||
|
||||
private:
|
||||
bool isRawIdle_;
|
||||
State state_;
|
||||
DataType dataType_;
|
||||
std::vector<byte> cmdBuffer_;
|
||||
|
|
|
@ -31,6 +31,7 @@ void Service::setup(const Config &conf)
|
|||
{
|
||||
config_ = conf;
|
||||
previousBeaconMs_ = 0;
|
||||
disableKiss_ = conf.EnableTextPackets;
|
||||
|
||||
LOG_SET_OPTION(false, false, true); // disable file, line, enable func
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue