Created
February 16, 2020 16:42
-
-
Save nliviu/65bef49ca7a09bf47449055239cc0fe9 to your computer and use it in GitHub Desktop.
This file contains 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