pull/25/head
sh123 2021-10-21 20:27:49 +03:00
rodzic 42395ab18c
commit 5bd632a73c
2 zmienionych plików z 18 dodań i 17 usunięć

Wyświetl plik

@ -212,7 +212,7 @@ void Service::setupBt(const String &btName)
} }
void Service::loop() void Service::loop()
{ {
if (needsWifi() && WiFi.status() != WL_CONNECTED) { if (needsWifi() && WiFi.status() != WL_CONNECTED) {
reconnectWifi(); reconnectWifi();
} }
@ -544,25 +544,23 @@ void Service::onRigTxEnd()
} }
} }
WiFiClient Service::getClient() bool Service::getClient(WiFiClient &activeClient)
{ {
if (config_.KissEnableTcpIp) { if (config_.KissEnableTcpIp) {
WiFiClient client = kissServer_->available(); WiFiClient wifiClient = kissServer_->available();
if (client) { if (wifiClient && wifiClient.connected()) {
activeClient = wifiClient;
if (client.connected()) { return true;
Serial.println("Connected to client");
}
return client;
} }
} }
return 0; return false;
} }
void Service::onSerialTx(byte b) void Service::onSerialTx(byte b)
{ {
if (WiFiClient client = getClient()) { WiFiClient wifiClient;
client.write(b); if (getClient(wifiClient)) {
wifiClient.write(b);
} }
else if (config_.BtEnableBle) { else if (config_.BtEnableBle) {
serialBLE_.write(b); serialBLE_.write(b);
@ -574,8 +572,10 @@ void Service::onSerialTx(byte b)
bool Service::onSerialRxHasData() bool Service::onSerialRxHasData()
{ {
if (WiFiClient client = getClient()) { WiFiClient wifiClient;
return client.available(); if (getClient(wifiClient)) {
Serial.println("!!!");
return wifiClient.available();
} }
else if (config_.BtEnableBle) { else if (config_.BtEnableBle) {
return serialBLE_.available(); return serialBLE_.available();
@ -589,8 +589,9 @@ bool Service::onSerialRx(byte *b)
{ {
int rxResult; int rxResult;
if (WiFiClient client = getClient()) { WiFiClient wifiClient;
rxResult = client.read(); if (getClient(wifiClient)) {
rxResult = wifiClient.read();
} }
else { else {
rxResult = config_.BtEnableBle rxResult = config_.BtEnableBle

Wyświetl plik

@ -49,7 +49,7 @@ private:
#endif #endif
void onAprsisDataAvailable(); void onAprsisDataAvailable();
WiFiClient getClient(); bool getClient(WiFiClient &activeClient);
void sendSignalReportEvent(int rssi, float snr); void sendSignalReportEvent(int rssi, float snr);
void sendPeriodicBeacon(); void sendPeriodicBeacon();