/// 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("Looks like CC3000 has died again. Power cycling...\n"); jspSetInterrupted(false); // remove all existing connections networkState = NETWORKSTATE_OFFLINE; // ensure we don't try and send the CC3k anything httpKill(net); httpInit(); // power cycle JsVar *wlan = jsvObjectGetChild(execInfo.root, CC3000_OBJ_NAME, 0); if (wlan) { jswrap_wlan_reconnect(wlan); jsvUnLock(wlan); } else jsErrorInternal("No CC3000 object!\n"); // jswrap_wlan_reconnect could fail, which would mean we have to do this all over again } return hadErrors; }
/*JSON{ "type":"kill", "generate" : "jswrap_http_kill" }*/ void jswrap_http_kill() { JsNetwork net; if (!networkGetFromVar(&net)) return; httpKill(&net); networkFree(&net); }