-
-
Save gadget-man/5a3e91e66b393fea3acef677924b202e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <mgos.h> | |
#include "wifi_common.h" | |
#if CS_PLATFORM == CS_P_ESP8266 | |
int8_t wifi_station_get_rssi(void); | |
uint8_t wifi_get_channel(void); | |
#elif CS_PLATFORM == CS_P_ESP32 | |
#include <esp_wifi.h> | |
#endif | |
const struct wifi_info *get_wifi_info() { | |
static struct wifi_info info; | |
info.rssi = 0; | |
info.channel = 0; | |
#if CS_PLATFORM == CS_P_ESP8266 | |
info.rssi = wifi_station_get_rssi(); | |
info.channel = wifi_get_channel(); | |
#elif CS_PLATFORM == CS_P_ESP32 | |
wifi_ap_record_t wifidata; | |
esp_wifi_sta_get_ap_info(&wifidata); | |
if (wifidata.primary != 0) { | |
info.rssi = wifidata.rssi; | |
info.channel = wifidata.primary; | |
} | |
#endif | |
return &info; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment