Exemple #1
0
/*JSON{ "type":"method",
         "class" : "WLAN", "name" : "reconnect",
         "generate" : "jswrap_wlan_reconnect",
         "description" : "Completely uninitialise and power down the CC3000, then reconnect to the old access point."
}*/
void jswrap_wlan_reconnect(JsVar *wlanObj) {
  JsVar *ap = jsvObjectGetChild(wlanObj,JS_HIDDEN_CHAR_STR"AP", 0);
  JsVar *key = jsvObjectGetChild(wlanObj,JS_HIDDEN_CHAR_STR"KEY", 0);
  JsVar *cb = jsvObjectGetChild(wlanObj,CC3000_ON_STATE_CHANGE, 0);
  jswrap_wlan_disconnect(wlanObj);
  jswrap_wlan_connect(wlanObj, ap, key, cb);
  jsvUnLock(ap);
  jsvUnLock(key);
  jsvUnLock(cb);
}
/*JSON{
  "type" : "method",
  "class" : "WLAN",
  "name" : "reconnect",
  "generate" : "jswrap_wlan_reconnect"
}
Completely uninitialise and power down the CC3000, then reconnect to the old access point.
*/
void jswrap_wlan_reconnect(JsVar *wlanObj) {
  JsNetwork net;
  if (!networkGetFromVar(&net)) return;

  JsVar *ap = jsvObjectGetChild(wlanObj,JS_HIDDEN_CHAR_STR"AP", 0);
  JsVar *key = jsvObjectGetChild(wlanObj,JS_HIDDEN_CHAR_STR"KEY", 0);
  JsVar *cb = jsvObjectGetChild(wlanObj,CC3000_ON_STATE_CHANGE, 0);
  jswrap_wlan_disconnect(wlanObj);
  jswrap_wlan_connect(wlanObj, ap, key, cb);
  jsvUnLock3(ap, key, cb);

  networkFree(&net);
}