Version 2.2 (with OTA)
This commit is contained in:
		
							parent
							
								
									b6c04fad6b
								
							
						
					
					
						commit
						5885345140
					
				
							
								
								
									
										19
									
								
								src/main.cpp
									
									
									
									
									
								
							
							
						
						
									
										19
									
								
								src/main.cpp
									
									
									
									
									
								
							| 
						 | 
				
			
			@ -1,13 +1,19 @@
 | 
			
		|||
#include <Arduino.h>
 | 
			
		||||
#include <ESP8266WiFi.h>
 | 
			
		||||
#include <ESP8266HTTPClient.h>
 | 
			
		||||
#include <WiFiClient.h>
 | 
			
		||||
#include <WiFiUdp.h>
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
#include <ArduinoOTA.h>
 | 
			
		||||
 | 
			
		||||
#include <DNSServer.h>
 | 
			
		||||
#include <ESP8266WebServer.h>
 | 
			
		||||
#include <WiFiManager.h>
 | 
			
		||||
 | 
			
		||||
#define FIRMWARE "2.2"
 | 
			
		||||
#define BOARD "ESP8266 Dev"
 | 
			
		||||
#define SERVICE "LEDController"
 | 
			
		||||
const String STATUSURL = "http://moon.basement.lan/l/boardstatus.php";
 | 
			
		||||
 | 
			
		||||
// The GPIO pin numbers for the three colors. Make sure these match your wiring/schematic.
 | 
			
		||||
#define GPIO_RED 13
 | 
			
		||||
#define GPIO_GREEN 12
 | 
			
		||||
| 
						 | 
				
			
			@ -120,6 +126,16 @@ void inline blueBlinkISR(void) {
 | 
			
		|||
   timer0_write(ESP.getCycleCount() + 40000000);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void sendDeviceStatus() {
 | 
			
		||||
   WiFiClient client;
 | 
			
		||||
   HTTPClient http;
 | 
			
		||||
   http.begin(client, STATUSURL.c_str());
 | 
			
		||||
   http.addHeader("Content-Type", "application/x-www-form-urlencoded");
 | 
			
		||||
   String httpData = "mac=" + WiFi.macAddress() + "&board=" + BOARD + "&firmware=" + FIRMWARE + "&service=" + SERVICE;
 | 
			
		||||
   int httpResponseCode = http.POST(httpData);
 | 
			
		||||
   http.end();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Set up our initial states and WiFi
 | 
			
		||||
void setup() {
 | 
			
		||||
   // Set the three color PWM pins to output
 | 
			
		||||
| 
						 | 
				
			
			@ -155,6 +171,7 @@ void setup() {
 | 
			
		|||
   timer0_write(ESP.getCycleCount() + 1000);
 | 
			
		||||
   interrupts();
 | 
			
		||||
   wifiManager.autoConnect("JaJLEDController");
 | 
			
		||||
   sendDeviceStatus();
 | 
			
		||||
   ArduinoOTA.onStart([]() {
 | 
			
		||||
      String type;
 | 
			
		||||
      if ( ArduinoOTA.getCommand() == U_FLASH )
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue
	
	Block a user