Beispiel #1
0
/// Called on idle. Do any checks required for this device
void net_cc3000_idle(JsNetwork *net) {
  cc3000_spi_check();

  if (networkState == NETWORKSTATE_INVOLUNTARY_DISCONNECT) {
    JsVar *wlanObj = jsvObjectGetChild(execInfo.hiddenRoot, CC3000_OBJ_NAME, 0);
    if (wlanObj) {
      jswrap_wlan_reconnect(wlanObj);
      jsvUnLock(wlanObj);
      cc3000_spi_check();
    }
  }
}
Beispiel #2
0
/// 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;
}
Beispiel #3
0
/// 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;
}