|
|
|
@ -243,8 +243,8 @@ void Service::setupRig(long loraFreq, long bw, int sf, int cr, int pwr, int sync
|
|
|
|
|
#else
|
|
|
|
|
#pragma message("Using SX127X")
|
|
|
|
|
LOG_INFO("Using SX127X module");
|
|
|
|
|
if (isIsrInstalled_) radio_->clearDio0Action();
|
|
|
|
|
radio_->setDio0Action(onRigIsrRxPacket);
|
|
|
|
|
if (isIsrInstalled_) rig_->clearDio0Action();
|
|
|
|
|
rig_->setDio0Action(onRigIsrRxPacket);
|
|
|
|
|
isIsrInstalled_ = true;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
@ -326,8 +326,7 @@ ICACHE_RAM_ATTR void Service::onRigIsrRxPacket() {
|
|
|
|
|
BaseType_t xHigherPriorityTaskWoken;
|
|
|
|
|
if (rigIsRxIsrEnabled_) {
|
|
|
|
|
rigIsRxActive_ = true;
|
|
|
|
|
uint32_t radioReceiveBit = RadioTaskBits::Receive;
|
|
|
|
|
xTaskNotifyFromISR(rigTaskHandle_, radioReceiveBit, eSetBits, &xHigherPriorityTaskWoken);
|
|
|
|
|
xTaskNotifyFromISR(rigTaskHandle_, RadioTaskBits::Receive, eSetBits, &xHigherPriorityTaskWoken);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -337,10 +336,10 @@ void Service::rigTask(void *self) {
|
|
|
|
|
uint32_t commandBits = 0;
|
|
|
|
|
xTaskNotifyWaitIndexed(0, 0x00, ULONG_MAX, &commandBits, portMAX_DELAY);
|
|
|
|
|
if (commandBits & RadioTaskBits::Receive) {
|
|
|
|
|
((Service*)self)->onRigTaskRxPacket();
|
|
|
|
|
static_cast<Service*>(self)->onRigTaskRxPacket();
|
|
|
|
|
}
|
|
|
|
|
else if (commandBits & RadioTaskBits::Transmit) {
|
|
|
|
|
((Service*)self)->onRigTaskTxPacket();
|
|
|
|
|
static_cast<Service*>(self)->onRigTaskTxPacket();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -471,7 +470,7 @@ void Service::sendSignalReportEvent(int rssi, float snr)
|
|
|
|
|
|
|
|
|
|
bool Service::sendModemTelemetryTimer(void *param)
|
|
|
|
|
{
|
|
|
|
|
((Service *)param)->sendModemTelemetry();
|
|
|
|
|
static_cast<Service*>(param)->sendModemTelemetry();
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -526,7 +525,7 @@ void Service::performFrequencyCorrection() {
|
|
|
|
|
#ifdef USE_SX126X
|
|
|
|
|
long frequencyErrorHz = 0;
|
|
|
|
|
#else
|
|
|
|
|
long frequencyErrorHz = radio_->getFrequencyError();
|
|
|
|
|
long frequencyErrorHz = rig_->getFrequencyError();
|
|
|
|
|
#endif
|
|
|
|
|
if (abs(frequencyErrorHz) > config_.AutoFreqCorrectionDeltaHz) {
|
|
|
|
|
config_.LoraFreqRx -= frequencyErrorHz;
|
|
|
|
@ -536,7 +535,7 @@ void Service::performFrequencyCorrection() {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Service::setFreq(long loraFreq) const {
|
|
|
|
|
rig_->setFrequency((float)config_.LoraFreqRx / 1e6);
|
|
|
|
|
rig_->setFrequency((float)loraFreq / 1e6);
|
|
|
|
|
int state = rig_->startReceive();
|
|
|
|
|
if (state != RADIOLIB_ERR_NONE) {
|
|
|
|
|
LOG_ERROR("Start receive error:", state);
|
|
|
|
@ -563,7 +562,7 @@ void Service::processIncomingRawPacketAsServer(const byte *packet, int packetLen
|
|
|
|
|
#ifdef USE_SX126X
|
|
|
|
|
long frequencyError = 0;
|
|
|
|
|
#else
|
|
|
|
|
long frequencyError = radio_->getFrequencyError();
|
|
|
|
|
long frequencyError = rig_->getFrequencyError();
|
|
|
|
|
#endif
|
|
|
|
|
String signalReport = String("rssi: ") +
|
|
|
|
|
String(snr < 0 ? rssi + snr : rssi) +
|
|
|
|
@ -736,7 +735,9 @@ void Service::onRadioControlCommand(const std::vector<byte> &rawCommand) {
|
|
|
|
|
LOG_INFO("Setting new radio parameters");
|
|
|
|
|
const struct SetHardware * setHardware = reinterpret_cast<const struct SetHardware*>(rawCommand.data());
|
|
|
|
|
|
|
|
|
|
// TODO, add support for split set hardware
|
|
|
|
|
config_.LoraFreqRx = be32toh(setHardware->freq);
|
|
|
|
|
config_.LoraFreqTx = be32toh(setHardware->freq);
|
|
|
|
|
config_.LoraBw = be32toh(setHardware->bw);
|
|
|
|
|
config_.LoraSf = be16toh(setHardware->sf);
|
|
|
|
|
config_.LoraCodingRate = be16toh(setHardware->cr);
|
|
|
|
|