void setup() { Serial.begin(115200); // Initialize the output variables as outputs pinMode(output5, OUTPUT); pinMode(output4, OUTPUT); // Set outputs to LOW digitalWrite(output5, LOW); digitalWrite(output4, LOW); // Connect to Wi-Fi network with SSID and password Serial.print("Connecting to "); Serial.println(ssid); //WiFi.begin(ssid, password); setupWiFi(); server.begin(); // while (WiFi.status() != WL_CONNECTED) { // delay(500); // Serial.print("."); // } // WiFiClient client = server.available(); // if (!client) { // return; // } }
void WiFiManager::startWebConfig() { DEBUG_PRINT(""); display.print("WiFi connected"); DEBUG_PRINT("WiFi connected"); DEBUG_PRINT(WiFi.localIP()); DEBUG_PRINT(WiFi.softAPIP()); if (!mdns.begin(_apName, WiFi.localIP())) { DEBUG_PRINT("Error setting up MDNS responder!"); display.print("mDNS error"); while(1) { delay(1000); } } DEBUG_PRINT("mDNS responder started"); // Start the server server_s.begin(); display.print("Server started"); DEBUG_PRINT("Server started"); while(serverLoop() == WM_WAIT) { //looping } display.print("All done. Bye."); DEBUG_PRINT("Setup done"); delay(10000); ESP.reset(); }
void WiFiManager::startWebConfig() { DEBUG_PRINT(""); DEBUG_PRINT("WiFi connected"); DEBUG_PRINT(WiFi.localIP()); DEBUG_PRINT(WiFi.softAPIP()); if (!mdns.begin(_apName, WiFi.localIP())) { DEBUG_PRINT("Error setting up MDNS responder!"); while (1) { delay(1000); } } DEBUG_PRINT("mDNS responder started"); // Start the server server.begin(); DEBUG_PRINT("Server started"); while (serverLoop() == WM_WAIT) { //looping if(timeout > 0 && start + timeout < millis()) { //we passed timeout value, release DEBUG_PRINT("timeout reached"); return; } } DEBUG_PRINT("Setup done"); delay(5000); ESP.reset(); }
void Con::handleWiFiConnect(){ this->printf("handleWiFiConnect %d\n",this->curType&CON_TCP); if (this->curType&CON_TCP){ ConSrv.begin(); ConSrv.setNoDelay(true); } }
void setup() { pinMode(enA, OUTPUT); pinMode(enB, OUTPUT); pinMode(dirA, OUTPUT); pinMode(dirB, OUTPUT); setupWiFi(); server.begin(); #ifdef DEBUG delay(2000); #endif Serial.begin(115200); #ifdef DEBUG delay(250); Serial.println(); Serial.println("Hello"); Serial.flush(); delay(750); Serial.print("IP address"); Serial.println(WiFi.localIP()); delay(500); #endif }
void start_server() { Serial.print("\nMAC: "); Serial.println(WiFi.macAddress()); Serial.print("\nSSID: "); Serial.println(ssid); WiFi.begin(ssid, password); while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); } server.begin(); delay(10000); Serial.print("\nIP: "); Serial.println(WiFi.localIP()); }
void WiFiStart() { ulReconncount++; while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); } Serial.println(""); Serial.println("WiFi connected"); // Start the server server.begin(); Serial.println("Server started"); // Print the IP address Serial.println(WiFi.localIP()); }
void mainsetup() { // setup globals ulReqcount = 0; ulReconncount = 0; WiFiStart(); delay(1); server.begin(); // allocate ram for data storage uint32_t free = system_get_free_heap_size() - KEEP_MEM_FREE; ulNoMeasValues = free / (sizeof(float) * 5 + sizeof(unsigned long)); // humidity & temp --> 2 + time pulTime = new unsigned long[ulNoMeasValues]; pfTemp1 = new float[ulNoMeasValues]; pfTemp2 = new float[ulNoMeasValues]; pfTemp3 = new float[ulNoMeasValues]; pfTemp4 = new float[ulNoMeasValues]; if (pulTime == NULL || pfTemp1 == NULL || pfTemp2 == NULL || pfTemp3 == NULL || pfTemp4 == NULL) { ulNoMeasValues = 0; Serial.println("Error in memory allocation!"); } else { Serial.print("Allocated storage for "); Serial.print(ulNoMeasValues); Serial.println(" data points."); float fMeasDelta_sec = MEAS_SPAN_H * 3600. / ulNoMeasValues; ulMeasDelta_ms = ( (unsigned long)(fMeasDelta_sec + 0.5) ) * 1000; // round to full sec Serial.print("Measurements will happen each "); Serial.print(ulMeasDelta_ms); Serial.println(" ms."); ulNextMeas_ms = millis() + ulMeasDelta_ms; } }
void setup() { Serial.begin(115200); pixels.begin(); pixels.setBrightness(BASE_BRIGHTNESS); reset_pixels(); Serial.println(); Serial.print("Connecting to "); Serial.println(ssid); WiFi.mode(WIFI_STA); WiFi.begin(ssid, password); WiFi.hostname(HOSTNAME); while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); } Serial.println("WiFi connected"); Serial.println(WiFi.localIP()); if (!MDNS.begin(HOSTNAME)) { update_pixel(0, 200, 0, 0); Serial.println("Error setting up MDNS responder!"); while (1) { delay(1000); } } Serial.println("mDNS responder started"); update_pixel(0, 0, 200, 0); pixels.show(); server.begin(); MDNS.addService("http", "tcp", 80); }
void setup() { Serial.begin(115200); // Initialize the output variables as outputs pinMode(output5, OUTPUT); pinMode(output4, OUTPUT); // Set outputs to LOW digitalWrite(output5, LOW); digitalWrite(output4, LOW); // Connect to Wi-Fi network with SSID and password Serial.print("Connecting to "); Serial.println(ssid); WiFi.begin(ssid, password); while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); } // Print local IP address and start web server Serial.println(""); Serial.println("WiFi connected."); Serial.println("IP address: "); Serial.println(WiFi.localIP()); server.begin(); }
void apmode(){ WiFi.disconnect(); WiFi.mode(WIFI_AP); WiFi.softAP("ESP Arduino","password"); server.begin();//so that was important }
void setup() { #ifdef ESP8266_WiFi String mdns_id; mdns_id = eepromManager.fetchmDNSName(); if(mdns_id.length()<=0) mdns_id = "ESP" + String(ESP.getChipId()); // If we're going to set up WiFi, let's get to it WiFiManager wifiManager; wifiManager.setConfigPortalTimeout(5*60); // Time out after 5 minutes so that we can keep managing temps wifiManager.setDebugOutput(false); // In case we have a serial connection to BrewPi // The main purpose of this is to set a boolean value which will allow us to know we // just saved a new configuration (as opposed to rebooting normally) wifiManager.setSaveConfigCallback(saveConfigCallback); // The third parameter we're passing here (mdns_id.c_str()) is the default name that will appear on the form. // It's nice, but it means the user gets no actual prompt for what they're entering. WiFiManagerParameter custom_mdns_name("mdns", "Device (mDNS) Name", mdns_id.c_str(), 20); wifiManager.addParameter(&custom_mdns_name); wifiManager.autoConnect(); // Launch captive portal with auto generated name ESP + ChipID // Alright. We're theoretically connected here (or we timed out). // If we connected, then let's save the mDNS name if (shouldSaveConfig) { // If the mDNS name is valid, save it. if (isValidmDNSName(custom_mdns_name.getValue())) { eepromManager.savemDNSName(custom_mdns_name.getValue()); } else { // If the mDNS name is invalid, reset the WiFi configuration and restart the ESP8266 WiFi.disconnect(true); delay(2000); handleReset(); } } // Regardless of the above, we need to set the mDNS name and announce it if (!MDNS.begin(mdns_id.c_str())) { // TODO - Do something about it or log it or something } #endif #if BREWPI_BUZZER buzzer.init(); buzzer.beep(2, 500); #endif piLink.init(); #ifdef ESP8266_WiFi // If we're using WiFi, initialize the bridge server.begin(); server.setNoDelay(true); // mDNS will stop responding after awhile unless we query the specific service we want MDNS.addService("brewpi", "tcp", 23); MDNS.addServiceTxt("brewpi", "tcp", "board", "ESP8266"); MDNS.addServiceTxt("brewpi", "tcp", "branch", "legacy"); MDNS.addServiceTxt("brewpi", "tcp", "version", VERSION_STRING); MDNS.addServiceTxt("brewpi", "tcp", "revision", FIRMWARE_REVISION); #endif bool initialize = !eepromManager.hasSettings(); if(initialize) { eepromManager.zapEeprom(); // Writes all the empty files to SPIFFS logInfo(INFO_EEPROM_INITIALIZED); } logDebug("started"); tempControl.init(); settingsManager.loadSettings(); #if BREWPI_SIMULATE simulator.step(); // initialize the filters with the assigned initial temp value tempControl.beerSensor->init(); tempControl.fridgeSensor->init(); #endif display.init(); #ifdef ESP8266_WiFi display.printWiFi(); // Print the WiFi info (mDNS name & IP address) delay(8000); display.clear(); #endif display.printStationaryText(); display.printState(); // rotaryEncoder.init(); logDebug("init complete"); }
void cTcpTrace::begin() { tcpTraceServer.begin(); }