Created
February 17, 2020 05:27
-
-
Save nliviu/47054ddc7cd972d599eb9b00a6951c09 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" | |
#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 | |
/* | |
* mJS | |
* | |
* let getWifiStaChannel = ffi('int get_wifi_sta_channel()'); | |
* | |
*/ | |
int get_wifi_sta_channel(void) { | |
int channel = 0; | |
#if CS_PLATFORM == CS_P_ESP8266 | |
channel = wifi_get_channel(); | |
#elif CS_PLATFORM == CS_P_ESP32 | |
wifi_ap_record_t wifidata; | |
int ret = esp_wifi_sta_get_ap_info(&wifidata); | |
if (ret == 0) { | |
channel = wifidata.primary; | |
} | |
#endif | |
return channel; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment