Example #1
0
const char* WiFlyDevice::newConnect(const char* ssid, const char* pass) {
  write("$$$");
  
  write("set wlan join 0");
  write("set ip dhcp 1");
  write("set ip localport 80");
  write("set comm remote 0");

  uart.write("set wlan ssid ");
  write(ssid);
  uart.write("set wlan passphrase ");
  write(pass);
  uart.println("join");
  const char* ip = waitForIP();
  write("exit");
  return ip;
}
/*!
* This method joins the WifiBee to the network.
* @return `true` if the network was successfully joined,
* otherwise `false`.
*/
bool Sodaq_WifiBee::connect()
{
  println("wifi.setmode(wifi.STATION)");
  skipTillPrompt(LUA_PROMPT, RESPONSE_TIMEOUT);

  print("wifi.sta.config(\"");
  print(_APN);
  print("\",\"");
  print(_password);
  println("\")");
  skipTillPrompt(LUA_PROMPT, RESPONSE_TIMEOUT);

  println("wifi.sta.connect()");
  skipTillPrompt(LUA_PROMPT, RESPONSE_TIMEOUT);

  return waitForIP(WIFI_CONNECT_TIMEOUT);
}