void init() { Serial.begin(115200); debug("Starting..."); pinMode(FIRST_RUN_PIN, INPUT); web_run(); if(digitalRead(FIRST_RUN_PIN) && AppSettings.load()){ debugf("SSID:%s PASS:%s", AppSettings.ssid.c_str(), AppSettings.password.c_str()); WifiStation.config(AppSettings.ssid.c_str(), AppSettings.password.c_str()); WifiStation.waitConnection(on_wifi_connected); driver_init(); } else { first_run(); } }
int main(int argc, char** argv) { int rc; const char* port = "80"; struct engine* eng; while ((rc = getopt(argc, argv, "hp:")) != -1) { switch (rc) { case 'p': port = optarg; break; case 'h': usage(0); break; default: usage(2); break; } } if (pal_init(&pal)) return -1; eng = engine_init(&pal); rc = web_init(eng, port); if (rc) { LOG(("Web server failed to start: (%d) %s\n", rc, strerror(rc))); return rc; } LOG(("Running engine\n")); web_run(); engine_run(); web_destroy(); engine_destroy(); pal_destroy(&pal); LOG(("Exited gracefully\n")); return 0; }