Advertisement
Guest User

Untitled

a guest
Aug 27th, 2015
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.85 KB | None | 0 0
  1. _debugCom->println("Booting...");
  2.   int testSpeeds[] = {9600, 300, 115200, 57600};
  3.   for (int i=0; i < sizeof(testSpeeds); i++){
  4.     _wifiCom->begin(testSpeeds[i]);
  5.     if(this->wifiCommand("AT", 1000, 1)) {
  6.       _debugCom->println("Wifi interface ready");
  7.     }
  8.     else {
  9.       _wifiCom->end();
  10.       continue;
  11.     }
  12.   }
  13.  
  14.  
  15.     bool wifiCommand(String cmd, int timeout, int retry) {
  16.       _debugCom->println(cmd);
  17.       unsigned long time;
  18.       time = millis();
  19.       _wifiCom->println(cmd);
  20.       int tries = 1;
  21.       while(1) {
  22.         if(_wifiCom->find("OK")) {
  23.           return true;
  24.           break;  
  25.         }
  26.         if((retry != 0) && (tries > retry))
  27.           return false;
  28.         if(millis() - time > timeout) {
  29.           _wifiCom->println(cmd);
  30.           time = millis();
  31.           tries += 1;
  32.         }
  33.       }
  34.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement