mirror of
https://github.com/anklimov/lighthub
synced 2025-12-06 19:59:50 +03:00
Merge branch 'my_master' into patch
# Conflicts: # README.md # build_flags_template.sh # compiled/Mega2560/Wiz5100/firmware.hex # compiled/Mega2560/Wiz5500/firmware.hex # lighthub/main.cpp # lighthub/main.h # lighthub/options.h # platformio.ini
This commit is contained in:
@@ -110,13 +110,9 @@ pio init --ide [atom|clion|codeblocks|eclipse|emacs|netbeans|qtcreator|sublimete
|
|||||||
```
|
```
|
||||||
Set custom build flags. first make your own copy of template
|
Set custom build flags. first make your own copy of template
|
||||||
```bash
|
```bash
|
||||||
cp build_flags_template.sh my_build_flags.sh
|
cp custom_build_flags_template.py my_custom_build_flags.py
|
||||||
```
|
```
|
||||||
then edit, change or comment unnecessary sections and source it
|
then edit, change or comment unnecessary sections and source it
|
||||||
```bash
|
|
||||||
nano my_build_flags.sh
|
|
||||||
source my_build_flags.sh
|
|
||||||
```
|
|
||||||
build and upload firmware for due|megaatmega2560|esp8266 board
|
build and upload firmware for due|megaatmega2560|esp8266 board
|
||||||
```bash
|
```bash
|
||||||
pio run -e due|megaatmega2560|esp8266 -t upload
|
pio run -e due|megaatmega2560|esp8266 -t upload
|
||||||
@@ -144,9 +140,11 @@ platformio device monitor -b 115200
|
|||||||
* MODBUS_DISABLE // disable Modbus support
|
* MODBUS_DISABLE // disable Modbus support
|
||||||
* OWIRE_DISABLE // disable OneWire support
|
* OWIRE_DISABLE // disable OneWire support
|
||||||
* ARTNET_ENABLE //Enable Artnet protocol support
|
* ARTNET_ENABLE //Enable Artnet protocol support
|
||||||
|
* DAVR_DMXOUT_PIN=18 // Set Pin for DMXOUT on megaatmega2560
|
||||||
* CONTROLLINO //Change Modbus port, direction pins and Wiznet SS pins to be working on [Controllino](http://controllino.biz/)
|
* CONTROLLINO //Change Modbus port, direction pins and Wiznet SS pins to be working on [Controllino](http://controllino.biz/)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Default compilation behavior:
|
# Default compilation behavior:
|
||||||
* Config server: lazyhome.ru
|
* Config server: lazyhome.ru
|
||||||
* Watchdog enabled
|
* Watchdog enabled
|
||||||
|
|||||||
@@ -1,23 +0,0 @@
|
|||||||
#! /bin/bash
|
|
||||||
# usage:
|
|
||||||
# first make your own copy of template
|
|
||||||
# cp build_flags_template.sh my_build_flags.sh
|
|
||||||
# then edit, change or comment something
|
|
||||||
# nano my_build_flags.sh
|
|
||||||
# and source it
|
|
||||||
# source my_build_flags.sh
|
|
||||||
export FLAGS="-DMY_CONFIG_SERVER=lazyhome.ru"
|
|
||||||
export FLAGS="$FLAGS -DWATCH_DOG_TICKER_DISABLE"
|
|
||||||
export FLAGS="$FLAGS -DUSE_1W_PIN=12"
|
|
||||||
export FLAGS="$FLAGS -DSD_CARD_INSERTED"
|
|
||||||
export FLAGS="$FLAGS -DSERIAL_BAUD=115200"
|
|
||||||
export FLAGS="$FLAGS -DWiz5500"
|
|
||||||
export FLAGS="$FLAGS -DDISABLE_FREERAM_PRINT"
|
|
||||||
export FLAGS="$FLAGS -DCUSTOM_FIRMWARE_MAC=de:ad:be:ef:fe:00"
|
|
||||||
export FLAGS="$FLAGS -DDMX_DISABLE"
|
|
||||||
export FLAGS="$FLAGS -DMODBUS_DISABLE"
|
|
||||||
export FLAGS="$FLAGS -DOWIRE_DISABLE"
|
|
||||||
export FLAGS="$FLAGS -DARTNET_ENABLE"
|
|
||||||
export FLAGS="$FLAGS -DCONTROLLINO"
|
|
||||||
export PLATFORMIO_BUILD_FLAGS="$FLAGS"
|
|
||||||
unset FLAGS
|
|
||||||
25
custom_build_flags_template.py
Normal file
25
custom_build_flags_template.py
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
# usage:
|
||||||
|
# first make your own copy of template
|
||||||
|
# cp custom_build_flags_template.py my_custom_build_flags.py
|
||||||
|
# then edit, change or comment something
|
||||||
|
|
||||||
|
import os
|
||||||
|
print("==============================================Custom build flags are:=====================================================")
|
||||||
|
FLAGS="-DMY_CONFIG_SERVER=lazyhome.ru"
|
||||||
|
FLAGS+=" -DWATCH_DOG_TICKER_DISABLE"
|
||||||
|
FLAGS+=" -DUSE_1W_PIN=12"
|
||||||
|
FLAGS+=" -DSD_CARD_INSERTED"
|
||||||
|
FLAGS+=" -DSERIAL_BAUD=115200"
|
||||||
|
FLAGS+=" -DWiz5500"
|
||||||
|
FLAGS+=" -DDISABLE_FREERAM_PRINT"
|
||||||
|
FLAGS+=" -DCUSTOM_FIRMWARE_MAC=de:ad:be:ef:fe:00"
|
||||||
|
FLAGS+=" -DDMX_DISABLE"
|
||||||
|
FLAGS+=" -DMODBUS_DISABLE"
|
||||||
|
FLAGS+=" -DOWIRE_DISABLE"
|
||||||
|
FLAGS+=" -DARTNET_ENABLE"
|
||||||
|
FLAGS+=" -DCONTROLLINO"
|
||||||
|
FLAGS+=" -DAVR_DMXOUT_PIN=18"
|
||||||
|
|
||||||
|
print(FLAGS)
|
||||||
|
print("==============================================Custom build flags END=====================================================")
|
||||||
|
os.environ["PLATFORMIO_BUILD_FLAGS"] = FLAGS
|
||||||
@@ -225,11 +225,11 @@ dmxin.begin();
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void DMXoutSetup(int channels,int pin)
|
void DMXoutSetup(int channels)
|
||||||
{
|
{
|
||||||
#ifdef _dmxout
|
#ifdef _dmxout
|
||||||
#if defined(__AVR__)
|
#if defined(__AVR__)
|
||||||
DmxSimple.usePin(pin);
|
DmxSimple.usePin(AVR_DMXOUT_PIN);
|
||||||
DmxSimple.maxChannel(channels);
|
DmxSimple.maxChannel(channels);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ extern aJsonObject *dmxArr;
|
|||||||
|
|
||||||
void DMXput(void);
|
void DMXput(void);
|
||||||
void DMXinSetup(int channels);
|
void DMXinSetup(int channels);
|
||||||
void DMXoutSetup(int channels,int pin);
|
void DMXoutSetup(int channels);
|
||||||
void ArtnetSetup();
|
void ArtnetSetup();
|
||||||
void DMXCheck(void);
|
void DMXCheck(void);
|
||||||
int itemCtrl2(char* name,int r,int g, int b, int w);
|
int itemCtrl2(char* name,int r,int g, int b, int w);
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ EthernetClient ethClient;
|
|||||||
|
|
||||||
const char outprefix[] PROGMEM = OUTTOPIC;
|
const char outprefix[] PROGMEM = OUTTOPIC;
|
||||||
const char inprefix[] PROGMEM = INTOPIC;
|
const char inprefix[] PROGMEM = INTOPIC;
|
||||||
const char configServerPrecompiled[] PROGMEM = CONFIG_SERVER;
|
const char configserver[] PROGMEM = CONFIG_SERVER;
|
||||||
|
|
||||||
|
|
||||||
aJsonObject *root = NULL;
|
aJsonObject *root = NULL;
|
||||||
@@ -113,7 +113,10 @@ byte mac[6];
|
|||||||
PubSubClient mqttClient(ethClient);
|
PubSubClient mqttClient(ethClient);
|
||||||
|
|
||||||
|
|
||||||
void watchdogSetup(void) {} //Do not remove - strong re-definition WDT Init for DUE
|
void watchdogSetup(void) {
|
||||||
|
//Serial.begin(115200);
|
||||||
|
//Serial.println("Watchdog armed.");
|
||||||
|
} //Do not remove - strong re-definition WDT Init for DUE
|
||||||
|
|
||||||
|
|
||||||
// MQTT Callback routine
|
// MQTT Callback routine
|
||||||
@@ -277,10 +280,10 @@ if((wifiMulti.run() == WL_CONNECTED)) lanStatus=1;
|
|||||||
IPAddress mask;
|
IPAddress mask;
|
||||||
int res = 1;
|
int res = 1;
|
||||||
Serial.println(F("Starting lan"));
|
Serial.println(F("Starting lan"));
|
||||||
if (loadIPAddressFromFlash(OFFSET_IP, ip))
|
if (loadFlash(OFFSET_IP,ip))
|
||||||
if (loadIPAddressFromFlash(OFFSET_DNS, dns))
|
if (loadFlash(OFFSET_DNS,dns))
|
||||||
if (loadIPAddressFromFlash(OFFSET_GW, gw))
|
if (loadFlash(OFFSET_GW,gw))
|
||||||
if (loadIPAddressFromFlash(OFFSET_MASK, mask)) Ethernet.begin(mac,ip,dns,gw,mask);
|
if (loadFlash(OFFSET_MASK,mask)) Ethernet.begin(mac,ip,dns,gw,mask);
|
||||||
else Ethernet.begin(mac,ip,dns,gw);
|
else Ethernet.begin(mac,ip,dns,gw);
|
||||||
else Ethernet.begin(mac,ip,dns);
|
else Ethernet.begin(mac,ip,dns);
|
||||||
else Ethernet.begin(mac,ip);
|
else Ethernet.begin(mac,ip);
|
||||||
@@ -332,7 +335,7 @@ if((wifiMulti.run() == WL_CONNECTED)) lanStatus=1;
|
|||||||
char *servername = aJson.getArrayItem(mqttArr, 1)->valuestring;
|
char *servername = aJson.getArrayItem(mqttArr, 1)->valuestring;
|
||||||
if (n >= 3) port = aJson.getArrayItem(mqttArr, 2)->valueint;
|
if (n >= 3) port = aJson.getArrayItem(mqttArr, 2)->valueint;
|
||||||
if (n >= 4) user = aJson.getArrayItem(mqttArr, 3)->valuestring;
|
if (n >= 4) user = aJson.getArrayItem(mqttArr, 3)->valuestring;
|
||||||
if (!loadStringFromFlash(OFFSET_MQTT_PWD, passwordBuf, sizeof(passwordBuf)) && (n >= 5))
|
if (!loadFlash(OFFSET_MQTT_PWD, passwordBuf,sizeof(passwordBuf)) && (n >= 5))
|
||||||
{
|
{
|
||||||
password = aJson.getArrayItem(mqttArr, 4)->valuestring;
|
password = aJson.getArrayItem(mqttArr, 4)->valuestring;
|
||||||
Serial.println(F("Using MQTT password from config"));
|
Serial.println(F("Using MQTT password from config"));
|
||||||
@@ -431,15 +434,17 @@ if((wifiMulti.run() == WL_CONNECTED)) lanStatus=1;
|
|||||||
wdt_dis();
|
wdt_dis();
|
||||||
if (lanStatus > 0)
|
if (lanStatus > 0)
|
||||||
switch (Ethernet.maintain()) {
|
switch (Ethernet.maintain()) {
|
||||||
case NO_LINK:
|
case NO_LINK:
|
||||||
Serial.println(F("No link"));
|
Serial.println(F("No link"));
|
||||||
if (mqttClient.connected()) mqttClient.disconnect();
|
if (mqttClient.connected()) mqttClient.disconnect();
|
||||||
|
lanCheck = millis() + 30000;
|
||||||
lanStatus = -10;
|
lanStatus = -10;
|
||||||
break;
|
break;
|
||||||
case DHCP_CHECK_RENEW_FAIL:
|
case DHCP_CHECK_RENEW_FAIL:
|
||||||
//renewed fail
|
//renewed fail
|
||||||
Serial.println(F("Error: renewed fail"));
|
Serial.println(F("Error: renewed fail"));
|
||||||
if (mqttClient.connected()) mqttClient.disconnect();
|
if (mqttClient.connected()) mqttClient.disconnect();
|
||||||
|
lanCheck = millis() + 1000;
|
||||||
lanStatus = -10;
|
lanStatus = -10;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -451,6 +456,7 @@ if((wifiMulti.run() == WL_CONNECTED)) lanStatus=1;
|
|||||||
case DHCP_CHECK_REBIND_FAIL:
|
case DHCP_CHECK_REBIND_FAIL:
|
||||||
Serial.println(F("Error: rebind fail"));
|
Serial.println(F("Error: rebind fail"));
|
||||||
if (mqttClient.connected()) mqttClient.disconnect();
|
if (mqttClient.connected()) mqttClient.disconnect();
|
||||||
|
lanCheck = millis() + 1000;
|
||||||
lanStatus = -10;
|
lanStatus = -10;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -583,25 +589,25 @@ void cmdFunctionKill(int arg_cnt, char **args) {
|
|||||||
|
|
||||||
void applyConfig() {
|
void applyConfig() {
|
||||||
if (!root) return;
|
if (!root) return;
|
||||||
|
#ifdef _dmxin
|
||||||
|
int itemsCount;
|
||||||
|
dmxArr = aJson.getObjectItem(root, "dmxin");
|
||||||
|
if (dmxArr && (itemsCount = aJson.getArraySize(dmxArr))) {
|
||||||
|
DMXinSetup(itemsCount * 4);
|
||||||
|
Serial.print(F("DMX in started. Channels:"));
|
||||||
|
Serial.println(itemsCount * 4);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
#ifdef _dmxout
|
#ifdef _dmxout
|
||||||
int maxChannels;
|
int maxChannels;
|
||||||
aJsonObject *dmxoutArr = aJson.getObjectItem(root, "dmx");
|
aJsonObject *dmxoutArr = aJson.getObjectItem(root, "dmx");
|
||||||
if (dmxoutArr && aJson.getArraySize(dmxoutArr) == 2) {
|
if (dmxoutArr && aJson.getArraySize(dmxoutArr) >=1 ) {
|
||||||
DMXoutSetup(maxChannels = aJson.getArrayItem(dmxoutArr, 1)->valueint,
|
DMXoutSetup(maxChannels = aJson.getArrayItem(dmxoutArr, 1)->valueint);
|
||||||
aJson.getArrayItem(dmxoutArr, 0)->valueint);
|
//,aJson.getArrayItem(dmxoutArr, 0)->valueint);
|
||||||
Serial.print(F("DMX out started. Channels: "));
|
Serial.print(F("DMX out started. Channels: "));
|
||||||
Serial.println(maxChannels);
|
Serial.println(maxChannels);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef _dmxin
|
|
||||||
int itemsCount;
|
|
||||||
dmxArr = aJson.getObjectItem(root, "dmxin");
|
|
||||||
if (dmxArr && (itemsCount = aJson.getArraySize(dmxArr))) {
|
|
||||||
DMXinSetup(itemsCount * 4);
|
|
||||||
Serial.print(F("DMX in started. Channels:"));
|
|
||||||
Serial.println(itemsCount * 4);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#ifdef _modbus
|
#ifdef _modbus
|
||||||
modbusArr = aJson.getObjectItem(root, "modbus");
|
modbusArr = aJson.getObjectItem(root, "modbus");
|
||||||
#endif
|
#endif
|
||||||
@@ -766,17 +772,13 @@ void cmdFunctionIp(int arg_cnt, char **args)
|
|||||||
IPAddress ip;
|
IPAddress ip;
|
||||||
DNSClient dns;
|
DNSClient dns;
|
||||||
switch (arg_cnt) {
|
switch (arg_cnt) {
|
||||||
case 5: if (dns.inet_aton(args[4],ip)) saveIPAddressToFlash(OFFSET_MASK, ip); else
|
case 5: if (dns.inet_aton(args[4],ip)) saveFlash(OFFSET_MASK,ip); else saveFlash(OFFSET_MASK,ip0);
|
||||||
saveIPAddressToFlash(OFFSET_MASK, ip0);
|
case 4: if (dns.inet_aton(args[3],ip)) saveFlash(OFFSET_GW,ip); else saveFlash(OFFSET_GW,ip0);
|
||||||
case 4: if (dns.inet_aton(args[3],ip)) saveIPAddressToFlash(OFFSET_GW, ip); else
|
case 3: if (dns.inet_aton(args[2],ip)) saveFlash(OFFSET_DNS,ip); else saveFlash(OFFSET_DNS,ip0);
|
||||||
saveIPAddressToFlash(OFFSET_GW, ip0);
|
case 2: if (dns.inet_aton(args[1],ip)) saveFlash(OFFSET_IP,ip); else saveFlash(OFFSET_IP,ip0);
|
||||||
case 3: if (dns.inet_aton(args[2],ip)) saveIPAddressToFlash(OFFSET_DNS, ip); else
|
|
||||||
saveIPAddressToFlash(OFFSET_DNS, ip0);
|
|
||||||
case 2: if (dns.inet_aton(args[1],ip)) saveIPAddressToFlash(OFFSET_IP, ip); else
|
|
||||||
saveIPAddressToFlash(OFFSET_IP, ip0);
|
|
||||||
break;
|
break;
|
||||||
case 1: //dynamic IP
|
case 1: //dynamic IP
|
||||||
saveIPAddressToFlash(OFFSET_IP, ip0);
|
saveFlash(OFFSET_IP,ip0);
|
||||||
}
|
}
|
||||||
Serial.println(F("Saved"));
|
Serial.println(F("Saved"));
|
||||||
}
|
}
|
||||||
@@ -785,8 +787,8 @@ void cmdFunctionPwd(int arg_cnt, char **args)
|
|||||||
//(char* tokens)
|
//(char* tokens)
|
||||||
{ char empty[]="";
|
{ char empty[]="";
|
||||||
if (arg_cnt)
|
if (arg_cnt)
|
||||||
saveStringToFlash(OFFSET_MQTT_PWD, args[1]);
|
saveFlash(OFFSET_MQTT_PWD,args[1]);
|
||||||
else saveStringToFlash(OFFSET_MQTT_PWD, empty);
|
else saveFlash(OFFSET_MQTT_PWD,empty);
|
||||||
Serial.println(F("Password updated"));
|
Serial.println(F("Password updated"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -819,7 +821,7 @@ void cmdFunctionGet(int arg_cnt, char **args) {
|
|||||||
void printBool(bool arg) { (arg) ? Serial.println(F("on")) : Serial.println(F("off")); }
|
void printBool(bool arg) { (arg) ? Serial.println(F("on")) : Serial.println(F("off")); }
|
||||||
|
|
||||||
|
|
||||||
void saveStringToFlash(short n, char *str) {
|
void saveFlash(short n, char *str) {
|
||||||
short i;
|
short i;
|
||||||
short len=strlen(str);
|
short len=strlen(str);
|
||||||
if (len>31) len=31;
|
if (len>31) len=31;
|
||||||
@@ -827,20 +829,20 @@ void saveStringToFlash(short n, char *str) {
|
|||||||
EEPROM.write(n+len,0);
|
EEPROM.write(n+len,0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int loadStringFromFlash(short offset, char *str, short numBytes) {
|
int loadFlash(short n, char *str, short l) {
|
||||||
short i;
|
short i;
|
||||||
uint8_t ch = EEPROM.read(offset);
|
uint8_t ch = EEPROM.read(n);
|
||||||
if (!ch || (ch == 0xff)) return 0;
|
if (!ch || (ch == 0xff)) return 0;
|
||||||
for (i=0;i<numBytes-1 && (str[i] = EEPROM.read(offset++));i++);
|
for (i=0;i<l-1 && (str[i] = EEPROM.read(n++));i++);
|
||||||
str[i]=0;
|
str[i]=0;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void saveIPAddressToFlash(short n, IPAddress &ip) {
|
void saveFlash(short n, IPAddress& ip) {
|
||||||
for(int i=0;i<4;i++) EEPROM.write(n++,ip[i]);
|
for(int i=0;i<4;i++) EEPROM.write(n++,ip[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
int loadIPAddressFromFlash(short n, IPAddress &ip) {
|
int loadFlash(short n, IPAddress& ip) {
|
||||||
for(int i=0;i<4;i++) ip[i]=EEPROM.read(n++);
|
for(int i=0;i<4;i++) ip[i]=EEPROM.read(n++);
|
||||||
if (ip[0] && (ip[0] != 0xff)) return 1;
|
if (ip[0] && (ip[0] != 0xff)) return 1;
|
||||||
return 0;
|
return 0;
|
||||||
@@ -853,13 +855,13 @@ int getConfig(int arg_cnt, char **args)
|
|||||||
|
|
||||||
int responseStatusCode = 0;
|
int responseStatusCode = 0;
|
||||||
char ch;
|
char ch;
|
||||||
char URI[CONFIG_URI_LENGTH];
|
char URI[40];
|
||||||
char configServer[CONFIG_SERVER_ADDRESS_LENGTH]="";
|
char configServer[32]="";
|
||||||
if (arg_cnt > 1) {
|
if (arg_cnt > 1) {
|
||||||
strncpy(configServer, args[1], sizeof(configServer) - 1);
|
strncpy(configServer, args[1], sizeof(configServer) - 1);
|
||||||
saveStringToFlash(OFFSET_CONFIGSERVER, configServer);
|
saveFlash(OFFSET_CONFIGSERVER, configServer);
|
||||||
} else if (!loadStringFromFlash(OFFSET_CONFIGSERVER, configServer))
|
} else if (!loadFlash(OFFSET_CONFIGSERVER, configServer))
|
||||||
strncpy_P(configServer,configServerPrecompiled,sizeof(configServer));
|
strncpy_P(configServer,configserver,sizeof(configServer));
|
||||||
|
|
||||||
snprintf(URI, sizeof(URI), "/%02x-%02x-%02x-%02x-%02x-%02x.config.json", mac[0], mac[1], mac[2], mac[3], mac[4],
|
snprintf(URI, sizeof(URI), "/%02x-%02x-%02x-%02x-%02x-%02x.config.json", mac[0], mac[1], mac[2], mac[3], mac[4],
|
||||||
mac[5]);
|
mac[5]);
|
||||||
@@ -869,9 +871,10 @@ int getConfig(int arg_cnt, char **args)
|
|||||||
|
|
||||||
#if defined(__AVR__)
|
#if defined(__AVR__)
|
||||||
FILE *result;
|
FILE *result;
|
||||||
|
//byte hserver[] = { 192,168,88,2 };
|
||||||
wdt_dis();
|
wdt_dis();
|
||||||
|
|
||||||
HTTPClient hclient(configServer, CONFIG_SERVER_PORT);
|
HTTPClient hclient(configServer, 80);
|
||||||
// FILE is the return STREAM type of the HTTPClient
|
// FILE is the return STREAM type of the HTTPClient
|
||||||
result = hclient.getURI(URI);
|
result = hclient.getURI(URI);
|
||||||
responseStatusCode = hclient.getLastReturnCode();
|
responseStatusCode = hclient.getLastReturnCode();
|
||||||
@@ -921,9 +924,9 @@ int getConfig(int arg_cnt, char **args)
|
|||||||
//Non AVR code
|
//Non AVR code
|
||||||
String response;
|
String response;
|
||||||
EthernetClient configEthClient;
|
EthernetClient configEthClient;
|
||||||
HttpClient htclient = HttpClient(configEthClient, configServer, CONFIG_SERVER_PORT);
|
HttpClient htclient = HttpClient(configEthClient, configServer, 80);
|
||||||
//htclient.stop(); //_socket =MAX
|
//htclient.stop(); //_socket =MAX
|
||||||
htclient.setHttpResponseTimeout(CONFIG_SERVER_RESPONSE_TIMEOUT);
|
htclient.setHttpResponseTimeout(4000);
|
||||||
wdt_res();
|
wdt_res();
|
||||||
//Serial.println("making GET request");get
|
//Serial.println("making GET request");get
|
||||||
htclient.beginRequest();
|
htclient.beginRequest();
|
||||||
@@ -987,9 +990,10 @@ void postTransmission() {
|
|||||||
digitalWrite(TXEnablePin, 0);
|
digitalWrite(TXEnablePin, 0);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
//#define PIO_SRC_REV commit 8034a6b765229d94a94d90fd08dd9588acf5f3da Author: livello <livello@bk.ru> Date: Wed Mar 28 02:35:50 2018 +0300 refactoring
|
||||||
|
|
||||||
void setup_main() {
|
void setup_main() {
|
||||||
setupCmdArduino();
|
setupCmdArduino();
|
||||||
printFirmwareVersionAndBuildOptions();
|
printFirmwareVersionAndBuildOptions();
|
||||||
|
|
||||||
#ifdef SD_CARD_INSERTED
|
#ifdef SD_CARD_INSERTED
|
||||||
@@ -1036,7 +1040,7 @@ pinMode(TXEnablePin, OUTPUT);
|
|||||||
SPI.begin();
|
SPI.begin();
|
||||||
while (Ethernet.maintain() == NO_LINK && millis()<3000UL) {delay(500);Serial.print(F("."));}
|
while (Ethernet.maintain() == NO_LINK && millis()<3000UL) {delay(500);Serial.print(F("."));}
|
||||||
*/
|
*/
|
||||||
//delay(1000); //Wiz5500
|
delay(500); //Wiz5500
|
||||||
//TODO: checkForRemoteSketchUpdate();
|
//TODO: checkForRemoteSketchUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1120,6 +1124,7 @@ void setupMacAddress() {
|
|||||||
|
|
||||||
void setupCmdArduino() {
|
void setupCmdArduino() {
|
||||||
cmdInit(uint32_t(SERIAL_BAUD));
|
cmdInit(uint32_t(SERIAL_BAUD));
|
||||||
|
Serial.println(F(">>>"));
|
||||||
cmdAdd("help", cmdFunctionHelp);
|
cmdAdd("help", cmdFunctionHelp);
|
||||||
cmdAdd("save", cmdFunctionSave);
|
cmdAdd("save", cmdFunctionSave);
|
||||||
cmdAdd("load", cmdFunctionLoad);
|
cmdAdd("load", cmdFunctionLoad);
|
||||||
|
|||||||
@@ -90,11 +90,7 @@
|
|||||||
|
|
||||||
#ifdef SD_CARD_INSERTED
|
#ifdef SD_CARD_INSERTED
|
||||||
#include "sd_card_w5100.h"
|
#include "sd_card_w5100.h"
|
||||||
#endif //SD_CARD_INSERTED
|
#endif
|
||||||
|
|
||||||
#ifdef DHT_ENABLE
|
|
||||||
#include <DHT.h>
|
|
||||||
#endif //DHT_ENABLE/**/
|
|
||||||
|
|
||||||
#ifdef _artnet
|
#ifdef _artnet
|
||||||
extern Artnet *artnet;
|
extern Artnet *artnet;
|
||||||
@@ -144,13 +140,13 @@ void cmdFunctionGet(int arg_cnt, char **args);
|
|||||||
|
|
||||||
void printBool(bool arg);
|
void printBool(bool arg);
|
||||||
|
|
||||||
void saveStringToFlash(short n, char *str);
|
void saveFlash(short n, char *str);
|
||||||
|
|
||||||
int loadStringFromFlash(short offset, char *str, short numBytes = 32);
|
int loadFlash(short n, char *str, short l=32);
|
||||||
|
|
||||||
void saveIPAddressToFlash(short n, IPAddress &ip);
|
void saveFlash(short n, IPAddress& ip);
|
||||||
|
|
||||||
int loadIPAddressFromFlash(short n, IPAddress &ip);
|
int loadFlash(short n, IPAddress& ip);
|
||||||
|
|
||||||
int getConfig(int arg_cnt=0, char **args=NULL);
|
int getConfig(int arg_cnt=0, char **args=NULL);
|
||||||
|
|
||||||
|
|||||||
@@ -5,13 +5,14 @@
|
|||||||
|
|
||||||
#define TXEnablePin 13
|
#define TXEnablePin 13
|
||||||
|
|
||||||
|
#ifndef AVR_DMXOUT_PIN
|
||||||
|
#define AVR_DMXOUT_PIN 3
|
||||||
|
#endif
|
||||||
|
|
||||||
#define T_ATTEMPTS 200
|
#define T_ATTEMPTS 200
|
||||||
#define IET_TEMP 0
|
#define IET_TEMP 0
|
||||||
#define IET_ATTEMPTS 1
|
#define IET_ATTEMPTS 1
|
||||||
|
|
||||||
#define MQTT_SUBJECT_LENGTH 20
|
|
||||||
#define MQTT_TOPIC_LENGTH 20
|
|
||||||
|
|
||||||
#define THERMO_GIST_CELSIUS 2
|
#define THERMO_GIST_CELSIUS 2
|
||||||
#define THERMO_OVERHEAT_CELSIUS 38
|
#define THERMO_OVERHEAT_CELSIUS 38
|
||||||
#define FM_OVERHEAT_CELSIUS 40.
|
#define FM_OVERHEAT_CELSIUS 40.
|
||||||
@@ -31,17 +32,6 @@
|
|||||||
#define INTERVAL_POLLING 100
|
#define INTERVAL_POLLING 100
|
||||||
#define THERMOSTAT_CHECK_PERIOD 5000
|
#define THERMOSTAT_CHECK_PERIOD 5000
|
||||||
|
|
||||||
#define CONFIG_SERVER_ADDRESS_LENGTH 32
|
|
||||||
#define CONFIG_URI_LENGTH 40
|
|
||||||
#define CONFIG_SERVER_RESPONSE_TIMEOUT 4000
|
|
||||||
#define CONFIG_SERVER_PORT 80
|
|
||||||
|
|
||||||
#ifndef MY_CONFIG_SERVER
|
|
||||||
#define CONFIG_SERVER "lazyhome.ru"
|
|
||||||
#else
|
|
||||||
#define CONFIG_SERVER QUOTE(MY_CONFIG_SERVER)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef MODBUS_SERIAL_BAUD
|
#ifndef MODBUS_SERIAL_BAUD
|
||||||
#define MODBUS_SERIAL_BAUD 9600
|
#define MODBUS_SERIAL_BAUD 9600
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -13,13 +13,13 @@ env_default =
|
|||||||
; megaatmega2560
|
; megaatmega2560
|
||||||
due
|
due
|
||||||
; esp8266
|
; esp8266
|
||||||
|
|
||||||
[env:due]
|
[env:due]
|
||||||
platform = atmelsam
|
platform = atmelsam
|
||||||
framework = arduino
|
framework = arduino
|
||||||
board = due
|
board = due
|
||||||
lib_ldf_mode = chain+
|
lib_ldf_mode = chain+
|
||||||
build_flags = !echo -n "-DPIO_SRC_REV="$(git rev-parse --short HEAD)
|
build_flags = !echo -n "-DPIO_SRC_REV="$(git log --pretty=format:%h_%ad -1 --date=short)
|
||||||
|
extra_scripts = pre:my_custom_build_flags.py
|
||||||
lib_deps =
|
lib_deps =
|
||||||
https://github.com/sebnil/DueFlashStorage
|
https://github.com/sebnil/DueFlashStorage
|
||||||
https://github.com/anklimov/Arduino-Temperature-Control-Library.git
|
https://github.com/anklimov/Arduino-Temperature-Control-Library.git
|
||||||
@@ -31,15 +31,11 @@ lib_deps =
|
|||||||
https://github.com/anklimov/ModbusMaster
|
https://github.com/anklimov/ModbusMaster
|
||||||
https://github.com/anklimov/Ethernet
|
https://github.com/anklimov/Ethernet
|
||||||
https://github.com/anklimov/Ethernet2
|
https://github.com/anklimov/Ethernet2
|
||||||
; https://github.com/PaulStoffregen/SPI.git
|
|
||||||
https://github.com/knolleary/pubsubclient.git
|
https://github.com/knolleary/pubsubclient.git
|
||||||
https://github.com/anklimov/Artnet.git
|
https://github.com/anklimov/Artnet.git
|
||||||
FastLED
|
FastLED
|
||||||
SD
|
SD
|
||||||
SdFat
|
SdFat
|
||||||
https://github.com/adafruit/Adafruit_Sensor.git
|
|
||||||
; DHT sensor library@1.3.0
|
|
||||||
https://github.com/adafruit/DHT-sensor-library
|
|
||||||
|
|
||||||
|
|
||||||
[env:megaatmega2560]
|
[env:megaatmega2560]
|
||||||
@@ -47,7 +43,8 @@ platform = atmelavr
|
|||||||
board = megaatmega2560
|
board = megaatmega2560
|
||||||
framework = arduino
|
framework = arduino
|
||||||
;lib_ldf_mode = chain+
|
;lib_ldf_mode = chain+
|
||||||
build_flags = !echo -n "-DPIO_SRC_REV="$(git rev-parse --short HEAD)
|
build_flags = !echo -n "-DPIO_SRC_REV="$(git log --pretty=format:%h_%ad -1 --date=short)
|
||||||
|
extra_scripts = pre:my_custom_build_flags.py
|
||||||
lib_deps =
|
lib_deps =
|
||||||
https://github.com/anklimov/Arduino-Temperature-Control-Library.git
|
https://github.com/anklimov/Arduino-Temperature-Control-Library.git
|
||||||
https://github.com/anklimov/DS2482_OneWire
|
https://github.com/anklimov/DS2482_OneWire
|
||||||
@@ -64,18 +61,15 @@ lib_deps =
|
|||||||
https://github.com/anklimov/Artnet.git
|
https://github.com/anklimov/Artnet.git
|
||||||
FastLED
|
FastLED
|
||||||
EEPROM
|
EEPROM
|
||||||
SD
|
|
||||||
SdFat
|
extra_scripts = pre:my_custom_build_flags.py
|
||||||
https://github.com/adafruit/Adafruit_Sensor.git
|
|
||||||
; DHT sensor library@1.3.0
|
|
||||||
https://github.com/adafruit/DHT-sensor-library
|
|
||||||
|
|
||||||
[env:esp8266]
|
[env:esp8266]
|
||||||
platform = espressif8266
|
platform = espressif8266
|
||||||
framework = arduino
|
framework = arduino
|
||||||
board = nodemcuv2
|
board = nodemcuv2
|
||||||
build_flags = !echo -n "-DPIO_SRC_REV="$(git rev-parse --short HEAD)
|
|
||||||
lib_ldf_mode = chain+
|
lib_ldf_mode = chain+
|
||||||
|
extra_scripts = pre:my_custom_build_flags.py
|
||||||
lib_deps =
|
lib_deps =
|
||||||
https://github.com/anklimov/Arduino-Temperature-Control-Library.git
|
https://github.com/anklimov/Arduino-Temperature-Control-Library.git
|
||||||
https://github.com/anklimov/DS2482_OneWire
|
https://github.com/anklimov/DS2482_OneWire
|
||||||
|
|||||||
Reference in New Issue
Block a user