kopia lustrzana https://github.com/sh123/esp32_loraprs
Small refactoring
rodzic
5f4b5a7ddb
commit
c2e65d9bf6
|
@ -46,7 +46,8 @@ private:
|
||||||
bool reconnectAprsis();
|
bool reconnectAprsis();
|
||||||
void attachKissNetworkClient();
|
void attachKissNetworkClient();
|
||||||
|
|
||||||
bool isRigRxBusy() const;
|
inline bool isRigRxBusy() const { return config_.LoraUseCad && rigIsRxActive_; }
|
||||||
|
|
||||||
void onRigTaskRxPacket();
|
void onRigTaskRxPacket();
|
||||||
void onRigTaskTxPacket();
|
void onRigTaskTxPacket();
|
||||||
static void rigTask(void *self);
|
static void rigTask(void *self);
|
||||||
|
|
|
@ -282,31 +282,34 @@ void Service::setupBt(const String &btName)
|
||||||
|
|
||||||
void Service::loop()
|
void Service::loop()
|
||||||
{
|
{
|
||||||
|
// wifi connectivity check
|
||||||
if (needsWifi() && WiFi.status() != WL_CONNECTED) {
|
if (needsWifi() && WiFi.status() != WL_CONNECTED) {
|
||||||
reconnectWifi();
|
reconnectWifi();
|
||||||
}
|
}
|
||||||
|
// aprs connectivity check
|
||||||
if (needsAprsis() && !aprsisConnection_.connected() && config_.EnablePersistentAprsConnection) {
|
if (needsAprsis() && !aprsisConnection_.connected() && config_.EnablePersistentAprsConnection) {
|
||||||
reconnectAprsis();
|
reconnectAprsis();
|
||||||
}
|
}
|
||||||
|
// tcp/ip kiss client connectivity check
|
||||||
if (config_.KissEnableTcpIp) {
|
if (config_.KissEnableTcpIp) {
|
||||||
attachKissNetworkClient();
|
attachKissNetworkClient();
|
||||||
}
|
}
|
||||||
|
|
||||||
// RX path, Rig -> Serial
|
// RX path, Rig -> Serial
|
||||||
bool isRigToSerialProcessed = false;
|
if (!processRigToSerial()) {
|
||||||
isRigToSerialProcessed = processRigToSerial();
|
|
||||||
|
|
||||||
// TX path, Serial -> Rig
|
|
||||||
if (!isRigToSerialProcessed) {
|
|
||||||
|
|
||||||
|
// TX path, Serial -> Rig
|
||||||
long currentTime = millis();
|
long currentTime = millis();
|
||||||
if (!isRigRxBusy() && currentTime > csmaSlotTimePrev_ + csmaSlotTime_ && random(0, 255) < csmaP_) {
|
if (!isRigRxBusy() && currentTime > csmaSlotTimePrev_ + csmaSlotTime_ && random(0, 255) < csmaP_) {
|
||||||
|
// new data from aprsis
|
||||||
if (aprsisConnection_.available() > 0) {
|
if (aprsisConnection_.available() > 0) {
|
||||||
onAprsisDataAvailable();
|
onAprsisDataAvailable();
|
||||||
}
|
}
|
||||||
|
// periodic beacon
|
||||||
if (needsBeacon()) {
|
if (needsBeacon()) {
|
||||||
sendPeriodicBeacon();
|
sendPeriodicBeacon();
|
||||||
}
|
}
|
||||||
|
// tx if data available
|
||||||
processSerialToRig();
|
processSerialToRig();
|
||||||
csmaSlotTimePrev_ = currentTime;
|
csmaSlotTimePrev_ = currentTime;
|
||||||
}
|
}
|
||||||
|
@ -318,10 +321,6 @@ void Service::loop()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Service::isRigRxBusy() const {
|
|
||||||
return config_.LoraUseCad && rigIsRxActive_;
|
|
||||||
}
|
|
||||||
|
|
||||||
ICACHE_RAM_ATTR void Service::onRigIsrRxPacket() {
|
ICACHE_RAM_ATTR void Service::onRigIsrRxPacket() {
|
||||||
BaseType_t xHigherPriorityTaskWoken;
|
BaseType_t xHigherPriorityTaskWoken;
|
||||||
if (rigIsRxIsrEnabled_) {
|
if (rigIsRxIsrEnabled_) {
|
||||||
|
|
Ładowanie…
Reference in New Issue