/*JSON{ "type" : "kill", "generate" : "jswrap_net_kill" }*/ void jswrap_net_kill() { JsNetwork net; if (networkWasCreated()) { if (!networkGetFromVar(&net)) return; socketKill(&net); networkFree(&net); } }
/// Call just before returning to idle loop. This checks for errors and tries to recover. Returns true if no errors. bool net_cc3000_checkError(JsNetwork *net) { bool hadErrors = false; while (jspIsInterrupted()) { hadErrors = true; jsiConsolePrint("CC3000 WiFi is not responding. Power cycling...\n"); jspSetInterrupted(false); // remove all existing connections networkState = NETWORKSTATE_OFFLINE; // ensure we don't try and send the CC3k anything socketKill(net); socketInit(); // power cycle JsVar *wlan = jsvObjectGetChild(execInfo.hiddenRoot, CC3000_OBJ_NAME, 0); if (wlan) { jswrap_wlan_reconnect(wlan); jsvUnLock(wlan); } else jsExceptionHere(JSET_INTERNALERROR, "No CC3000 object!\n"); // jswrap_wlan_reconnect could fail, which would mean we have to do this all over again } return hadErrors; }