mirror of
https://github.com/okalachev/flix.git
synced 2026-06-28 05:56:44 +00:00
Fix and improve wifi subsystem
Fix a fault when wifi is disabled (udp can't be used without wifi). Print RSSI and channel in wifi command.
This commit is contained in:
@@ -24,6 +24,8 @@ void setupWiFi() {
|
|||||||
WiFi.softAP(storage.getString("WIFI_AP_SSID", "flix").c_str(), storage.getString("WIFI_AP_PASS", "flixwifi").c_str());
|
WiFi.softAP(storage.getString("WIFI_AP_SSID", "flix").c_str(), storage.getString("WIFI_AP_PASS", "flixwifi").c_str());
|
||||||
} else if (wifiMode == W_STA) {
|
} else if (wifiMode == W_STA) {
|
||||||
WiFi.begin(storage.getString("WIFI_STA_SSID", "").c_str(), storage.getString("WIFI_STA_PASS", "").c_str());
|
WiFi.begin(storage.getString("WIFI_STA_SSID", "").c_str(), storage.getString("WIFI_STA_PASS", "").c_str());
|
||||||
|
} else {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
WiFi.setSleep(false); // disable power save
|
WiFi.setSleep(false); // disable power save
|
||||||
udp.begin(udpLocalPort);
|
udp.begin(udpLocalPort);
|
||||||
@@ -37,6 +39,7 @@ void sendWiFi(const uint8_t *buf, int len) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int receiveWiFi(uint8_t *buf, int len) {
|
int receiveWiFi(uint8_t *buf, int len) {
|
||||||
|
if (WiFi.softAPgetStationNum() == 0 && !WiFi.isConnected()) return 0;
|
||||||
udp.parsePacket();
|
udp.parsePacket();
|
||||||
if (udp.remoteIP()) udpRemoteIP = udp.remoteIP();
|
if (udp.remoteIP()) udpRemoteIP = udp.remoteIP();
|
||||||
return udp.read(buf, len);
|
return udp.read(buf, len);
|
||||||
@@ -57,10 +60,12 @@ void printWiFiInfo() {
|
|||||||
print("SSID: %s\n", WiFi.SSID().c_str());
|
print("SSID: %s\n", WiFi.SSID().c_str());
|
||||||
print("Password: ***\n");
|
print("Password: ***\n");
|
||||||
print("IP: %s\n", WiFi.localIP().toString().c_str());
|
print("IP: %s\n", WiFi.localIP().toString().c_str());
|
||||||
|
print("RSSI: %d dBm\n", WiFi.RSSI());
|
||||||
} else {
|
} else {
|
||||||
print("Mode: Disabled\n");
|
print("Mode: Disabled\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
print("Channel: %d\n", WiFi.channel());
|
||||||
print("Remote IP: %s\n", udpRemoteIP.toString().c_str());
|
print("Remote IP: %s\n", udpRemoteIP.toString().c_str());
|
||||||
print("MAVLink connected: %d\n", mavlinkConnected);
|
print("MAVLink connected: %d\n", mavlinkConnected);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user