bool AFramework::MTempMaster::networkConfig(){ AString dataRcv; if(!m_flag){ return false; } msg("Configurazione\nRete..."); if(prepareAp(_MTEMP_SSID_AP, _MTEMP_PWD_AP, _MTEMP_PORT_AP)){ msg("In attesa di\nConnessioni...", 0); while(1){ if(m_wifi->waitForData(dataRcv)){ if(dataRcv.contains(_MTEMP_CONF)){ msg("Dati ricevuti,\nSalvataggio..."); if(saveNetworkConfig(dataRcv)){ msg("Salvataggio ok!", 0); if(m_wifi->send(_MTEMP_BOARD_OK)){ if(defaultProgram()){ msg("Avvio tra\n1 secondo..."); return true; }else{ msg("Errore!"); return false; } } }else{ m_wifi->send(_MTEMP_BOARD_FAIL); msg("Errore\nConfigurazione!"); return false; } } } } } }
void SmartMote::wasSuccess(const AString & str){ if(str.contains("OK")){ for(uint8 i = 0; i < 4; i++){ turnOffGreen(); System::delay(125); turnOnGreen(); System::delay(125); } }else{ for(uint8 i = 0; i < 4; i++){ turnOnRed(); System::delay(125); turnOffRed(); System::delay(125); } } }
void Data::parse_line(AString line) { line = line.strip(" \t"); if (line.startswith("#")) return; if (line.contains('=')) { std::vector<AString> vec = line.split("="); vec[0] = vec[0].strip(" "); if (vec[1].contains('#')) vec[1] = vec[1].lpartition("#")[0]; vec[1] = vec[1].strip(" "); values[current_category][vec[0]] = vec[1]; } else { if (line.startswith("[")) { current_category = line.strip("[]"); } } //if (line.length() == 0) return; //int stage = 0; //AString field; //AString value; //AString category; //for (unsigned int i = 0; i < line.length(); i++) { //char c = line[i]; //if (stage == 0) { //if ( (c == ' ') || (c == '\t') ) //continue; //else if (c == '=') //stage = 1; //else if (c == '#') //return; //else if (c == '[') //stage = 3; //else //field += c; //} //else if (stage == 1) { //if ( (c == ' ') || (c == '\t') ) //continue; //else { //stage = 2; //value += c; //} //} //else if (stage == 2) { //value += c; //} //else if (stage == 3) { //if ( c == ']' ) { //current_category = category; //return; //} //else //category += c; //} //} //this->values[current_category][field] = value; }