kopia lustrzana https://github.com/sh123/esp32_loraprs
Use code 6 for SetHardware and code 7 for signal report
rodzic
87b737b4f3
commit
d8f64d6f21
|
@ -65,7 +65,7 @@ bool Processor::processCommand(byte rxByte) {
|
|||
state_ = State::GetData;
|
||||
dataType_ = DataType::Raw;
|
||||
break;
|
||||
case Cmd::RadioControl:
|
||||
case Cmd::SetHardware:
|
||||
state_ = State::GetData;
|
||||
dataType_ = DataType::Control;
|
||||
cmdBuffer_.clear();
|
||||
|
|
|
@ -28,19 +28,11 @@ protected:
|
|||
};
|
||||
|
||||
enum Cmd {
|
||||
|
||||
// generic
|
||||
Data = 0x00,
|
||||
P = 0x02,
|
||||
SlotTime = 0x03,
|
||||
|
||||
// extended to modem
|
||||
RadioControl = 0x10,
|
||||
|
||||
// extended from modem
|
||||
RadioSignalLevel = 0x30,
|
||||
|
||||
// end of cmds
|
||||
SetHardware = 0x06,
|
||||
SignalReport = 0x07,
|
||||
NoCmd = 0x80
|
||||
};
|
||||
|
||||
|
|
|
@ -234,12 +234,12 @@ void Service::onAprsisDataAvailable()
|
|||
|
||||
void Service::sendSignalReportEvent(int rssi, float snr)
|
||||
{
|
||||
struct SignalLevelEvent event;
|
||||
struct SignalReport signalReport;
|
||||
|
||||
event.rssi = htobe16(rssi);
|
||||
event.snr = htobe16(snr * 100);
|
||||
signalReport.rssi = htobe16(rssi);
|
||||
signalReport.snr = htobe16(snr * 100);
|
||||
|
||||
serialSend(Cmd::RadioSignalLevel, (const byte *)&event, sizeof(SignalLevelEvent));
|
||||
serialSend(Cmd::SignalReport, (const byte *)&signalReport, sizeof(SignalReport));
|
||||
}
|
||||
|
||||
bool Service::sendAX25ToLora(const AX25::Payload &payload)
|
||||
|
@ -372,16 +372,16 @@ void Service::onControlCommand(Cmd cmd, byte value)
|
|||
|
||||
void Service::onRadioControlCommand(const std::vector<byte> &rawCommand) {
|
||||
|
||||
if (config_.EnableKissExtensions && rawCommand.size() == sizeof(ControlCommand)) {
|
||||
const struct ControlCommand * controlCommand = reinterpret_cast<const struct ControlCommand*>(rawCommand.data());
|
||||
if (config_.EnableKissExtensions && rawCommand.size() == sizeof(SetHardware)) {
|
||||
const struct SetHardware * setHardware = reinterpret_cast<const struct SetHardware*>(rawCommand.data());
|
||||
|
||||
config_.LoraFreq = be32toh(controlCommand->freq);
|
||||
config_.LoraBw = be32toh(controlCommand->bw);
|
||||
config_.LoraSf = be16toh(controlCommand->sf);
|
||||
config_.LoraCodingRate = be16toh(controlCommand->cr);
|
||||
config_.LoraPower = be16toh(controlCommand->pwr);
|
||||
config_.LoraSync = be16toh(controlCommand->sync);
|
||||
config_.LoraEnableCrc = controlCommand->crc;
|
||||
config_.LoraFreq = be32toh(setHardware->freq);
|
||||
config_.LoraBw = be32toh(setHardware->bw);
|
||||
config_.LoraSf = be16toh(setHardware->sf);
|
||||
config_.LoraCodingRate = be16toh(setHardware->cr);
|
||||
config_.LoraPower = be16toh(setHardware->pwr);
|
||||
config_.LoraSync = be16toh(setHardware->sync);
|
||||
config_.LoraEnableCrc = setHardware->crc;
|
||||
|
||||
setupLora(config_.LoraFreq, config_.LoraBw, config_.LoraSf,
|
||||
config_.LoraCodingRate, config_.LoraPower, config_.LoraSync, config_.LoraEnableCrc);
|
||||
|
|
|
@ -60,12 +60,7 @@ protected:
|
|||
virtual void onRadioControlCommand(const std::vector<byte> &command);
|
||||
|
||||
private:
|
||||
struct SignalLevelEvent {
|
||||
int16_t rssi;
|
||||
int16_t snr;
|
||||
} __attribute__((packed));
|
||||
|
||||
struct ControlCommand {
|
||||
struct SetHardware {
|
||||
uint32_t freq;
|
||||
uint32_t bw;
|
||||
uint16_t sf;
|
||||
|
@ -75,6 +70,11 @@ private:
|
|||
uint8_t crc;
|
||||
} __attribute__((packed));
|
||||
|
||||
struct SignalReport {
|
||||
int16_t rssi;
|
||||
int16_t snr;
|
||||
} __attribute__((packed));
|
||||
|
||||
private:
|
||||
const String CfgLoraprsVersion = "LoRAPRS 0.1";
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue