Skip to content

Commit b89a136

Browse files
committed
Handle control data escape
1 parent 0a43429 commit b89a136

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

include/loraprs_service.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ class Service : virtual public Kiss::Processor
109109
uint32_t freqRx;
110110
uint32_t freqTx;
111111
uint8_t modType;
112-
uint16_t pwr;
112+
int16_t pwr;
113113
uint32_t bw;
114114
uint16_t sf;
115115
uint16_t cr;

src/kiss_processor.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -280,11 +280,19 @@ bool Processor::receiveByteKiss(byte rxByte)
280280
break;
281281
case State::Escape:
282282
if (rxByte == Marker::Tfend) {
283-
onRigTx((byte)Marker::Fend);
283+
if (dataType_ == DataType::Raw) {
284+
onRigTx((byte)Marker::Fend);
285+
} else if (dataType_ == DataType::Control) {
286+
cmdBuffer_.push_back((byte)Marker::Fend);
287+
}
284288
state_ = State::GetData;
285289
}
286290
else if (rxByte == Marker::Tfesc) {
287-
onRigTx((byte)Marker::Fesc);
291+
if (dataType_ == DataType::Raw) {
292+
onRigTx((byte)Marker::Fesc);
293+
} else if (dataType_ == DataType::Control) {
294+
cmdBuffer_.push_back((byte)Marker::Fesc);
295+
}
288296
state_ = State::GetData;
289297
}
290298
else if (rxByte != Marker::Fend) {

src/loraprs_service.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -788,7 +788,7 @@ void Service::onRadioControlCommand(const std::vector<byte> &rawCommand) {
788788
config_.LoraBw = be32toh(setHardware->bw);
789789
config_.LoraSf = be16toh(setHardware->sf);
790790
config_.LoraCodingRate = be16toh(setHardware->cr);
791-
config_.LoraPower = be16toh(setHardware->pwr);
791+
config_.LoraPower = (int16_t)be16toh(setHardware->pwr);
792792
config_.LoraSync = be16toh(setHardware->sync);
793793
config_.FskBitRate = (float)be32toh(setHardware->fskBitRate) / 1e3;
794794
config_.FskFreqDev = (float)be32toh(setHardware->fskFreqDev) / 1e3;
@@ -803,7 +803,7 @@ void Service::onRadioControlCommand(const std::vector<byte> &rawCommand) {
803803
config_.LoraCodingRate, config_.LoraPower, config_.LoraSync, crcType, config_.LoraExplicit);
804804
}
805805
} else {
806-
LOG_ERROR("Radio control command of wrong size");
806+
LOG_ERROR("Radio control command of wrong size", rawCommand.size());
807807
}
808808
}
809809

0 commit comments

Comments
 (0)