Last active
May 2, 2018 11:29
-
-
Save MaBecker/0f4dee709808287af9c1ea4093e2bb1e to your computer and use it in GitHub Desktop.
function: jswrap_wifi_save.c
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
void jswrap_wifi_save(JsVar *what) { | |
DBGV("> Wifi.save\n"); | |
JsVar *o = jsvNewObject(); | |
if (!o) return; | |
if (jsvIsString(what) && jsvIsStringEqual(what, "clear")) { | |
JsVar *name = jsvNewFromString(WIFI_CONFIG_STORAGE_NAME); | |
jswrap_storage_erase(name); | |
jsvUnLock(name); | |
DBG("Wifi.save(clear)\n"); | |
return; | |
} | |
// station stuff | |
struct station_config sta_config; | |
wifi_station_get_config(&sta_config); | |
jsvObjectSetChildAndUnLock(o, "ssid", jsvNewFromString((char *)sta_config.ssid)); | |
jsvObjectSetChildAndUnLock(o, "password", jsvNewFromString((char *)sta_config.password)); | |
jsvObjectSetChildAndUnLock(o, "mode", jsvNewFromInteger(wifi_get_opmode())); | |
jsvObjectSetChildAndUnLock(o, "phyMode", jsvNewFromInteger(wifi_get_phy_mode())); | |
jsvObjectSetChildAndUnLock(o, "sleepType", jsvNewFromInteger(wifi_get_sleep_type())); | |
char *hostname = wifi_station_get_hostname(); | |
if (hostname) jsvObjectSetChildAndUnLock(o, "hostname", jsvNewFromString((char *) hostname)); | |
// softap stuff | |
struct softap_config ap_config; | |
wifi_softap_get_config(&ap_config); | |
jsvObjectSetChildAndUnLock(o, "ssidAP", jsvNewFromString((char *)ap_config.ssid)); | |
jsvObjectSetChildAndUnLock(o, "passwordAP", jsvNewFromString((char *) ap_config.password)); | |
jsvObjectSetChildAndUnLock(o, "authmodeAP", jsvNewFromInteger(ap_config.authmode)); | |
jsvObjectSetChildAndUnLock(o, "hiddenAP", jsvNewFromInteger(ap_config.ssid_hidden)); | |
savedMode = wifi_get_opmode(); | |
// save object | |
JsVar *name = jsvNewFromString(WIFI_CONFIG_STORAGE_NAME); | |
//JsVar *arr = jsvNewArray(&o,1); | |
jswrap_storage_erase(name); | |
jswrap_storage_write(name,o,0,0); | |
//jsvUnLock3(arr,name,o); | |
jsvUnLock2(name,o); | |
DBGV("< Wifi.save: write completed\n"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment