mirror of
https://github.com/anklimov/lighthub
synced 2025-12-11 14:19:50 +03:00
ESP8266 and Wiznet 5500 raw support
This commit is contained in:
@@ -180,7 +180,7 @@ for (int i=1; i<17; i++) {Serial.print(dmxin.read(i));Serial.print(";");}
|
||||
}
|
||||
|
||||
|
||||
void onDmxFrame(uint16_t universe, uint16_t length, uint8_t sequence, uint8_t* data)
|
||||
void onDmxFrame(uint16_t universe, uint16_t length, uint8_t sequence, uint8_t* data, IPAddress remoteIP)
|
||||
{
|
||||
#ifdef _dmxout
|
||||
for (int i = 0 ; i < length && i<MAX_CHANNELS ; i++)
|
||||
|
||||
54
lighthub/esp.cpp
Normal file
54
lighthub/esp.cpp
Normal file
@@ -0,0 +1,54 @@
|
||||
#include "options.h"
|
||||
#ifdef __ESP__
|
||||
#include "esp.h"
|
||||
|
||||
ESP8266WiFiMulti wifiMulti;
|
||||
WiFiClient ethClient;
|
||||
|
||||
char mqtt_password[16];
|
||||
|
||||
//default custom static IP
|
||||
//char static_ip[16] = "10.0.1.56";
|
||||
//char static_gw[16] = "10.0.1.1";
|
||||
//char static_sn[16] = "255.255.255.0";
|
||||
|
||||
//flag for saving data
|
||||
bool shouldSaveConfig = false;
|
||||
|
||||
//callback notifying us of the need to save config
|
||||
void saveConfigCallback () {
|
||||
Serial.println("Should save config");
|
||||
shouldSaveConfig = true;
|
||||
}
|
||||
|
||||
|
||||
void espSetup () {
|
||||
Serial.println("Setting up Wifi");
|
||||
shouldSaveConfig = true;
|
||||
//WiFiManager
|
||||
|
||||
WiFiManagerParameter custom_mqtt_password("", "mqtt password", mqtt_password, 16);
|
||||
//Local intialization. Once its business is done, there is no need to keep it around
|
||||
WiFiManager wifiManager;
|
||||
|
||||
wifiManager.setSaveConfigCallback(saveConfigCallback);
|
||||
|
||||
wifiManager.addParameter(&custom_mqtt_password);
|
||||
wifiManager.setMinimumSignalQuality();
|
||||
|
||||
if (!wifiManager.autoConnect()) {
|
||||
Serial.println("failed to connect and hit timeout");
|
||||
delay(3000);
|
||||
//reset and try again, or maybe put it to deep sleep
|
||||
ESP.reset();
|
||||
delay(5000);
|
||||
}
|
||||
|
||||
//if you get here you have connected to the WiFi
|
||||
Serial.println("connected...yeey :)");
|
||||
|
||||
//read updated parameters
|
||||
strcpy(mqtt_password, custom_mqtt_password.getValue());
|
||||
|
||||
}
|
||||
#endif
|
||||
24
lighthub/esp.h
Normal file
24
lighthub/esp.h
Normal file
@@ -0,0 +1,24 @@
|
||||
#include <ESP8266WiFi.h>
|
||||
//needed for library
|
||||
#include <DNSServer.h>
|
||||
#include <ESP8266WebServer.h>
|
||||
#include <WiFiManager.h> //https://github.com/tzapu/WiFiManager
|
||||
#include <ESP8266WiFiMulti.h>
|
||||
|
||||
extern ESP8266WiFiMulti wifiMulti;
|
||||
extern WiFiClient ethClient;
|
||||
//WiFiManager wifiManager;
|
||||
|
||||
//define your default values here, if there are different values in config.json, they are overwritten.
|
||||
//length should be max size + 1
|
||||
extern char mqtt_password[16];
|
||||
|
||||
//default custom static IP
|
||||
//char static_ip[16] = "10.0.1.56";
|
||||
//char static_gw[16] = "10.0.1.1";
|
||||
//char static_sn[16] = "255.255.255.0";
|
||||
|
||||
//flag for saving data
|
||||
extern bool shouldSaveConfig;
|
||||
|
||||
void espSetup ();
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user