Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- _debugCom->println("Booting...");
- int testSpeeds[] = {9600, 300, 115200, 57600};
- for (int i=0; i < sizeof(testSpeeds); i++){
- _wifiCom->begin(testSpeeds[i]);
- if(this->wifiCommand("AT", 1000, 1)) {
- _debugCom->println("Wifi interface ready");
- }
- else {
- _wifiCom->end();
- continue;
- }
- }
- bool wifiCommand(String cmd, int timeout, int retry) {
- _debugCom->println(cmd);
- unsigned long time;
- time = millis();
- _wifiCom->println(cmd);
- int tries = 1;
- while(1) {
- if(_wifiCom->find("OK")) {
- return true;
- break;
- }
- if((retry != 0) && (tries > retry))
- return false;
- if(millis() - time > timeout) {
- _wifiCom->println(cmd);
- time = millis();
- tries += 1;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement