mirror of
https://github.com/anklimov/lighthub
synced 2026-10-28 11:15:00 +00:00
uartBridge refactored & cross-compiled. new Mega dev
This commit is contained in:
@@ -6,4 +6,5 @@
|
|||||||
-DOTA
|
-DOTA
|
||||||
-DSTATUSLED
|
-DSTATUSLED
|
||||||
#-DPID_DISABLE
|
#-DPID_DISABLE
|
||||||
|
-DUARTBRIDGE_ENABLE
|
||||||
|
|
||||||
|
|||||||
@@ -13,4 +13,5 @@
|
|||||||
-DAC_DISABLE
|
-DAC_DISABLE
|
||||||
-DSYSLOG_ENABLE
|
-DSYSLOG_ENABLE
|
||||||
-DPID_DISABLE
|
-DPID_DISABLE
|
||||||
-DWiz5100
|
-DWiz5100
|
||||||
|
-DMOTOR_DISABLE
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
|
||||||
|
#-DMODBUS_DIMMER_PARAM=SERIAL_8E1
|
||||||
|
#-DAVR_DMXOUT_PIN=18
|
||||||
|
-DDMX_DISABLE
|
||||||
|
-DMODBUS_DISABLE
|
||||||
|
-DMBUS_DISABLE
|
||||||
|
-DOWIRE_DISABLE
|
||||||
|
-DDHT_DISABLE
|
||||||
|
-DCOUNTER_DISABLE
|
||||||
|
-DNO_HOMIE
|
||||||
|
-DCSSHDC_DISABLE
|
||||||
|
-DSPILED_DISABLE
|
||||||
|
-DAC_DISABLE
|
||||||
|
-DSYSLOG_ENABLE
|
||||||
|
-DPID_DISABLE
|
||||||
|
-DOTA
|
||||||
|
-DMOTOR_DISABLE
|
||||||
|
#-DWiz5100
|
||||||
@@ -0,0 +1,61 @@
|
|||||||
|
:020000023000CC
|
||||||
|
:10FC000002C0EFC037C1112484B7882369F0982F50
|
||||||
|
:10FC10009A70923049F081FF02C097EF94BF282E6E
|
||||||
|
:10FC200080E002D10C94000085E08093810082E0A6
|
||||||
|
:10FC30008093C00088E18093C1008CE08093C40071
|
||||||
|
:10FC400086E08093C2008EE0EFD0279A84E023EC18
|
||||||
|
:10FC50003FEF91E0309385002093840096BBB09BEA
|
||||||
|
:10FC6000FECF1F9AA8954091C00047FD02C0815069
|
||||||
|
:10FC700089F7CED0813479F4CBD0C82FDBD0C2380D
|
||||||
|
:10FC800011F480E004C088E0C13809F083E0B9D005
|
||||||
|
:10FC900080E1B7D0EECF823419F484E1D3D0F8CF2D
|
||||||
|
:10FCA000853411F485E0FACF853581F4B1D0E82EA2
|
||||||
|
:10FCB000AFD0F82E87FF07C08BB781608BBFEE0CEB
|
||||||
|
:10FCC000FF1CB8D0E5CF8BB78E7FF8CF863579F49F
|
||||||
|
:10FCD0009FD08D3451F49CD0CBB79AD0C170880F8F
|
||||||
|
:10FCE0008C2B8BBF81E0AED0CCCF83E0FCCF8436B1
|
||||||
|
:10FCF00009F046C08DD0C82FD0E0DC2FCC2788D0AB
|
||||||
|
:10FD0000C82B86D0D82E5E018EEFB81A00E012E024
|
||||||
|
:10FD10004801EFEF8E1A9E0A7BD0F80180838401A0
|
||||||
|
:10FD20008A149B04A9F786D0F5E410E000E0DF1602
|
||||||
|
:10FD300009F150E040E063E0C70153D08701C12CD6
|
||||||
|
:10FD400092E0D92EF601419151916F0161E0C80115
|
||||||
|
:10FD500048D00E5F1F4F2297A9F750E040E065E0C2
|
||||||
|
:10FD6000C7013FD095CF6081C8018E0D9F1D01D185
|
||||||
|
:10FD70000F5F1F4FF801FE5FC017D107A1F788CFB3
|
||||||
|
:10FD8000843701F545D0C82FD0E0DC2FCC2740D0F8
|
||||||
|
:10FD9000C82B3ED0D82E4ED08701F5E4DF120BC021
|
||||||
|
:10FDA000CE0DDF1DC801DDD02CD00F5F1F4FC01757
|
||||||
|
:10FDB000D107C1F76DCFF80187918F0122D021972C
|
||||||
|
:10FDC000D1F766CF853739F435D08EE11AD088E97E
|
||||||
|
:10FDD00018D081E05CCF813509F073CF88E024D062
|
||||||
|
:10FDE00070CFFC010A0167BFE895112407B600FC3B
|
||||||
|
:10FDF000FDCF667029F0452B19F481E187BFE895A6
|
||||||
|
:10FE000008959091C00095FFFCCF8093C60008959F
|
||||||
|
:10FE10008091C00087FFFCCF8091C00084FD01C0AD
|
||||||
|
:10FE2000A8958091C6000895E0E6F0E098E19083FF
|
||||||
|
:10FE300080830895EDDF803219F088E0F5DFFFCF91
|
||||||
|
:10FE400084E1DFCFCF93C82FE3DFC150E9F7CF9133
|
||||||
|
:10FE5000F1CFCF92DF92EF92FF92DC01CB01642FC2
|
||||||
|
:10FE60006D01EE24FF24CBBEA901FF90EF90DF903F
|
||||||
|
:10FE7000CF90B7CF2F923F924F925F926F927F9227
|
||||||
|
:10FE80008F929F92AF92BF92CF92DF92EF92FF92AA
|
||||||
|
:10FE90000F931F93CF93DF9300D0CDB7DEB7180138
|
||||||
|
:10FEA000E9826B017C0110E000E029013A014C1865
|
||||||
|
:10FEB0005D086E087F0846015701840C951CA61C3E
|
||||||
|
:10FEC000B71C0215130531F489818823A1F188E05C
|
||||||
|
:10FED000ABDFFFCF30E020E043E0C701B601B9DF80
|
||||||
|
:10FEE00080E890E09B838A83ABBEF4012791369132
|
||||||
|
:10FEF000C501B401641975098609970941E0A9DFB4
|
||||||
|
:10FF00008A819B8101979B838A8392E0890E911C51
|
||||||
|
:10FF1000A11CB11C8A819B81892B31F730E020E044
|
||||||
|
:10FF200045E0C701B60195DF9FEFD91AE90AF90A42
|
||||||
|
:10FF30000F5F1F4FC0CF0F900F900F90DF91CF91A9
|
||||||
|
:10FF40001F910F91FF90EF90DF90CF90BF90AF90F7
|
||||||
|
:10FF50009F908F907F906F905F904F903F902F90E9
|
||||||
|
:10FF60000895F999FECF92BD81BDF89A992780B581
|
||||||
|
:10FF70000895262FF999FECF1FBA92BD81BD20BDED
|
||||||
|
:0EFF80000FB6F894FA9AF99A0FBE01960895FA
|
||||||
|
:02FFFE000008F9
|
||||||
|
:040000033000FC00CD
|
||||||
|
:00000001FF
|
||||||
+7220
-7135
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,5 +1 @@
|
|||||||
<<<<<<< HEAD
|
|
||||||
..\tools\win\arduinoOTA.exe -address 192.168.88.21 -port 65280 -username arduino -password password -sketch firmware.bin -b -upload /sketch
|
|
||||||
=======
|
|
||||||
..\tools\win\arduinoOTA.exe -address 192.168.88.21 -port 65280 -username arduino -password password -sketch firmware.bin -b -upload /sketch
|
..\tools\win\arduinoOTA.exe -address 192.168.88.21 -port 65280 -username arduino -password password -sketch firmware.bin -b -upload /sketch
|
||||||
>>>>>>> 9b164a1dfc40ee0e8f29dbedff4f3954edf55d76
|
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 64 KiB |
@@ -0,0 +1,62 @@
|
|||||||
|
{
|
||||||
|
"syslog":["192.168.88.2"],
|
||||||
|
"mqtt1":["esp32","m2m.eclipse.org"],
|
||||||
|
"mqtt":["elevator","192.168.88.2"],
|
||||||
|
"mqtt4":["esp32","test.mosquitto.org"],
|
||||||
|
"dmx":[30],
|
||||||
|
"items": {
|
||||||
|
"relay1":[6,32],
|
||||||
|
"relay2":[6,33],
|
||||||
|
"relays":[7,["relay1","relay2"]],
|
||||||
|
"sensair1":[44,[254,
|
||||||
|
"sensair",
|
||||||
|
{"co2":{"emit":"co2"}},
|
||||||
|
{"mode":"auto"}
|
||||||
|
]
|
||||||
|
],
|
||||||
|
"elevator":[15,{"baud":9600,"serial":"8N1","ip":"192.168.88.255","port":502}],
|
||||||
|
|
||||||
|
"aaa1":[44,[254,
|
||||||
|
"aaa",
|
||||||
|
{"aaa1":{"emit":"aaa2"}},
|
||||||
|
{"mode":"auto"}
|
||||||
|
]
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"modbus":
|
||||||
|
{
|
||||||
|
"aaa":
|
||||||
|
{"baud":19200,
|
||||||
|
"poll":{"irs":[1]},
|
||||||
|
"par":{
|
||||||
|
"aaa1":{"ir":1}
|
||||||
|
}
|
||||||
|
|
||||||
|
},
|
||||||
|
"sensair":{"baud":9600,
|
||||||
|
"poll":{"irs":[[0,3],21,[25,30]],"regs":[0,1,31],"delay":1000},
|
||||||
|
"par":{
|
||||||
|
"co2":{"ir":3},
|
||||||
|
"meterStat":{"ir":0},
|
||||||
|
"alarmStat":{"ir":1},
|
||||||
|
"outStat":{"ir":0},
|
||||||
|
"pwm":{"ir":21},
|
||||||
|
"typeid":{"ir":25,"type":"u32"},
|
||||||
|
"mapver":{"ir":27},
|
||||||
|
"fwver":{"ir":28},
|
||||||
|
"sensorid":{"ir":29,"type":"u32"},
|
||||||
|
"ack":{"reg":0},
|
||||||
|
"command":{"reg":1},
|
||||||
|
"abc":{"reg":31}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
"in":{ "34":{"item":"relays","emit":"myhome/in/bedr","scmd":"TOGGLE","rcmd":""},
|
||||||
|
|
||||||
|
"17":{"T":64,"emit":"analog","map":[0,1024,0,100,15]}
|
||||||
|
}
|
||||||
|
}
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+6512
-6384
File diff suppressed because it is too large
Load Diff
+6246
-6098
File diff suppressed because it is too large
Load Diff
+5321
-5287
File diff suppressed because it is too large
Load Diff
Executable
BIN
Binary file not shown.
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1 @@
|
|||||||
|
..\tools\win\arduinoOTA.exe -address 192.168.88.21 -port 65280 -username arduino -password password -sketch firmware.bin -b -upload /sketch
|
||||||
Executable
+1
@@ -0,0 +1 @@
|
|||||||
|
../tools/mac/arduinoOTA -address 192.168.88.67 -port 65280 -username arduino -password password -sketch firmware.bin -b -upload /sketch
|
||||||
+5260
-5125
File diff suppressed because it is too large
Load Diff
Binary file not shown.
@@ -2,6 +2,8 @@ cp ../.pio/build/due/firmware.bin due
|
|||||||
cp ../.pio/build/controllino/firmware.hex controllino
|
cp ../.pio/build/controllino/firmware.hex controllino
|
||||||
cp ../.pio/build/m5stack/firmware.bin m5stack
|
cp ../.pio/build/m5stack/firmware.bin m5stack
|
||||||
cp ../.pio/build/mega2560slim-5100/firmware.hex mega2560slim-5100
|
cp ../.pio/build/mega2560slim-5100/firmware.hex mega2560slim-5100
|
||||||
|
cp ../.pio/build/mega2560slim2/firmware.hex mega2560slim2
|
||||||
|
cp ../.pio/build/mega2560slim2/firmware.bin mega2560slim2
|
||||||
cp ../.pio/build/due-5100/firmware.bin due-5100
|
cp ../.pio/build/due-5100/firmware.bin due-5100
|
||||||
cp ../.pio/build/mega2560-5100/firmware.hex mega2560-5100
|
cp ../.pio/build/mega2560-5100/firmware.hex mega2560-5100
|
||||||
cp ../.pio/build/due-5500/firmware.bin due-5500
|
cp ../.pio/build/due-5500/firmware.bin due-5500
|
||||||
|
|||||||
+66
-39
@@ -82,7 +82,6 @@ EthernetClient ethClient;
|
|||||||
|
|
||||||
#if defined(OTA)
|
#if defined(OTA)
|
||||||
#include <ArduinoOTA.h>
|
#include <ArduinoOTA.h>
|
||||||
//bool OTA_initialized=false;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__SAM3X8E__)
|
#if defined(__SAM3X8E__)
|
||||||
@@ -103,6 +102,7 @@ NRFFlashStorage EEPROM;
|
|||||||
|
|
||||||
#ifdef SYSLOG_ENABLE
|
#ifdef SYSLOG_ENABLE
|
||||||
#include <Syslog.h>
|
#include <Syslog.h>
|
||||||
|
|
||||||
#ifndef WIFI_ENABLE
|
#ifndef WIFI_ENABLE
|
||||||
EthernetUDP udpSyslogClient;
|
EthernetUDP udpSyslogClient;
|
||||||
#else
|
#else
|
||||||
@@ -121,7 +121,7 @@ Streamlog errorSerial(&debugSerialPort,LOG_ERROR, ledRED);
|
|||||||
Streamlog infoSerial (&debugSerialPort,LOG_INFO);
|
Streamlog infoSerial (&debugSerialPort,LOG_INFO);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
statusLED LED(ledRED);
|
StatusLED statusLED(ledRED);
|
||||||
|
|
||||||
|
|
||||||
lan_status lanStatus = INITIAL_STATE;
|
lan_status lanStatus = INITIAL_STATE;
|
||||||
@@ -271,7 +271,7 @@ void mqttCallback(char *topic, byte *payload, unsigned int length) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
LED.flash(ledBLUE);
|
statusLED.flash(ledBLUE);
|
||||||
for (unsigned int i = 0; i < length; i++)
|
for (unsigned int i = 0; i < length; i++)
|
||||||
debugSerial<<((char) payload[i]);
|
debugSerial<<((char) payload[i]);
|
||||||
debugSerial<<endl;
|
debugSerial<<endl;
|
||||||
@@ -378,23 +378,40 @@ if (element && element->type == aJson_String) return element->valuestring;
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(ARDUINO_ARCH_ESP32) || defined(ESP8266)
|
|
||||||
#define flashStorage InternalStorage
|
|
||||||
#else
|
|
||||||
InternalStorageClass flashStorage(EEPROM_offsetJSON);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void setupOTA(void)
|
|
||||||
{
|
|
||||||
#ifdef OTA
|
#ifdef OTA
|
||||||
//if (OTA_initialized) return;
|
#if (defined(ARDUINO_ARCH_ESP32) || defined(ESP8266))
|
||||||
// ArduinoOTA.end();
|
void setupOTA(void)
|
||||||
// start the OTEthernet library with internal (flash) based storage
|
{
|
||||||
ArduinoOTA.begin(Ethernet.localIP(), "Lighthub", "password", flashStorage);
|
|
||||||
infoSerial<<F("OTA initialized\n");
|
ArduinoOTA.begin(Ethernet.localIP(), "Lighthub", "password", InternalStorage);
|
||||||
//OTA_initialized=true;
|
infoSerial<<F("OTA initialized\n");
|
||||||
|
|
||||||
|
}
|
||||||
|
#elif defined (ARDUINO_ARCH_AVR)
|
||||||
|
InternalStorageAVRClass flashStorage;
|
||||||
|
void setupOTA(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
ArduinoOTA.begin(Ethernet.localIP(), "Lighthub", "password", flashStorage);
|
||||||
|
infoSerial<<F("OTA initialized\n");
|
||||||
|
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
InternalStorageClass flashStorage(EEPROM_offsetJSON);
|
||||||
|
void setupOTA(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
ArduinoOTA.begin(Ethernet.localIP(), "Lighthub", "password", flashStorage);
|
||||||
|
infoSerial<<F("OTA initialized\n");
|
||||||
|
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#else
|
||||||
|
void setupOTA(void) {};
|
||||||
#endif
|
#endif
|
||||||
}
|
|
||||||
|
|
||||||
void setupSyslog()
|
void setupSyslog()
|
||||||
{
|
{
|
||||||
@@ -414,7 +431,7 @@ void setupSyslog()
|
|||||||
char *syslogServer = getStringFromConfig(udpSyslogArr, 0);
|
char *syslogServer = getStringFromConfig(udpSyslogArr, 0);
|
||||||
if (n>1) syslogPort = aJson.getArrayItem(udpSyslogArr, 1)->valueint;
|
if (n>1) syslogPort = aJson.getArrayItem(udpSyslogArr, 1)->valueint;
|
||||||
|
|
||||||
inet_ntoa_r(Ethernet.localIP(),syslogDeviceHostname,sizeof(syslogDeviceHostname));
|
_inet_ntoa_r(Ethernet.localIP(),syslogDeviceHostname,sizeof(syslogDeviceHostname));
|
||||||
infoSerial<<F("Syslog params:")<<syslogServer<<":"<<syslogPort<<":"<<syslogDeviceHostname<<endl;
|
infoSerial<<F("Syslog params:")<<syslogServer<<":"<<syslogPort<<":"<<syslogDeviceHostname<<endl;
|
||||||
udpSyslog.server(syslogServer, syslogPort);
|
udpSyslog.server(syslogServer, syslogPort);
|
||||||
udpSyslog.deviceHostname(syslogDeviceHostname);
|
udpSyslog.deviceHostname(syslogDeviceHostname);
|
||||||
@@ -439,8 +456,8 @@ lan_status lanLoop() {
|
|||||||
switch (lanStatus) {
|
switch (lanStatus) {
|
||||||
|
|
||||||
case INITIAL_STATE:
|
case INITIAL_STATE:
|
||||||
// LED.set(ledRED|((configLoaded)?ledBLINK:0));
|
// statusLED.set(ledRED|((configLoaded)?ledBLINK:0));
|
||||||
LED.set(ledRED|((configLoaded)?ledBLINK:0));
|
statusLED.set(ledRED|((configLoaded)?ledBLINK:0));
|
||||||
|
|
||||||
#if defined(WIFI_ENABLE)
|
#if defined(WIFI_ENABLE)
|
||||||
onInitialStateInitLAN(); // Moves state to AWAITING_ADDRESS or HAVE_IP_ADDRESS
|
onInitialStateInitLAN(); // Moves state to AWAITING_ADDRESS or HAVE_IP_ADDRESS
|
||||||
@@ -485,7 +502,7 @@ lan_status lanLoop() {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case LIBS_INITIALIZED:
|
case LIBS_INITIALIZED:
|
||||||
LED.set(ledRED|ledGREEN|((configLoaded)?ledBLINK:0));
|
statusLED.set(ledRED|ledGREEN|((configLoaded)?ledBLINK:0));
|
||||||
if (configLocked) return LIBS_INITIALIZED;
|
if (configLocked) return LIBS_INITIALIZED;
|
||||||
|
|
||||||
if (!configOk)
|
if (!configOk)
|
||||||
@@ -496,7 +513,7 @@ lan_status lanLoop() {
|
|||||||
|
|
||||||
case IP_READY_CONFIG_LOADED_CONNECTING_TO_BROKER:
|
case IP_READY_CONFIG_LOADED_CONNECTING_TO_BROKER:
|
||||||
wdt_res();
|
wdt_res();
|
||||||
LED.set(ledRED|ledGREEN|((configLoaded)?ledBLINK:0));
|
statusLED.set(ledRED|ledGREEN|((configLoaded)?ledBLINK:0));
|
||||||
ip_ready_config_loaded_connecting_to_broker();
|
ip_ready_config_loaded_connecting_to_broker();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -517,7 +534,7 @@ lan_status lanLoop() {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case OPERATION:
|
case OPERATION:
|
||||||
LED.set(ledGREEN|((configLoaded)?ledBLINK:0));
|
statusLED.set(ledGREEN|((configLoaded)?ledBLINK:0));
|
||||||
if (!mqttClient.connected()) lanStatus = IP_READY_CONFIG_LOADED_CONNECTING_TO_BROKER;//2;
|
if (!mqttClient.connected()) lanStatus = IP_READY_CONFIG_LOADED_CONNECTING_TO_BROKER;//2;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -525,7 +542,7 @@ lan_status lanLoop() {
|
|||||||
//if (mqttClient.connected()) mqttClient.disconnect(); // Hmm hungs then cable disconnected
|
//if (mqttClient.connected()) mqttClient.disconnect(); // Hmm hungs then cable disconnected
|
||||||
timerLanCheckTime = millis();// + 5000;
|
timerLanCheckTime = millis();// + 5000;
|
||||||
lanStatus = REINIT;
|
lanStatus = REINIT;
|
||||||
LED.set(ledRED|((configLoaded)?ledBLINK:0));
|
statusLED.set(ledRED|((configLoaded)?ledBLINK:0));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case REINIT: // Pause and re-init LAN
|
case REINIT: // Pause and re-init LAN
|
||||||
@@ -831,7 +848,9 @@ void onInitialStateInitLAN() {
|
|||||||
WiFi.mode(WIFI_STA); // ESP 32 - WiFi.disconnect(); instead
|
WiFi.mode(WIFI_STA); // ESP 32 - WiFi.disconnect(); instead
|
||||||
infoSerial<<F("WIFI AP/Password:")<<QUOTE(ESP_WIFI_AP)<<F("/")<<QUOTE(ESP_WIFI_PWD)<<endl;
|
infoSerial<<F("WIFI AP/Password:")<<QUOTE(ESP_WIFI_AP)<<F("/")<<QUOTE(ESP_WIFI_PWD)<<endl;
|
||||||
|
|
||||||
|
#ifndef ARDUINO_ARCH_ESP32
|
||||||
wifi_set_macaddr(STATION_IF,mac); //ESP32 to check
|
wifi_set_macaddr(STATION_IF,mac); //ESP32 to check
|
||||||
|
#endif
|
||||||
|
|
||||||
WiFi.begin(QUOTE(ESP_WIFI_AP), QUOTE(ESP_WIFI_PWD));
|
WiFi.begin(QUOTE(ESP_WIFI_AP), QUOTE(ESP_WIFI_PWD));
|
||||||
|
|
||||||
@@ -1276,16 +1295,16 @@ void cmdFunctionIp(int arg_cnt, char **args)
|
|||||||
|
|
||||||
// switch (arg_cnt) {
|
// switch (arg_cnt) {
|
||||||
// case 5:
|
// case 5:
|
||||||
if (arg_cnt>4 && inet_aton(args[4], ip)) saveFlash(OFFSET_MASK, ip);
|
if (arg_cnt>4 && _inet_aton(args[4], ip)) saveFlash(OFFSET_MASK, ip);
|
||||||
else saveFlash(OFFSET_MASK, ip0);
|
else saveFlash(OFFSET_MASK, ip0);
|
||||||
// case 4:
|
// case 4:
|
||||||
if (arg_cnt>3 && inet_aton(args[3], ip)) saveFlash(OFFSET_GW, ip);
|
if (arg_cnt>3 && _inet_aton(args[3], ip)) saveFlash(OFFSET_GW, ip);
|
||||||
else saveFlash(OFFSET_GW, ip0);
|
else saveFlash(OFFSET_GW, ip0);
|
||||||
// case 3:
|
// case 3:
|
||||||
if (arg_cnt>2 && inet_aton(args[2], ip)) saveFlash(OFFSET_DNS, ip);
|
if (arg_cnt>2 && _inet_aton(args[2], ip)) saveFlash(OFFSET_DNS, ip);
|
||||||
else saveFlash(OFFSET_DNS, ip0);
|
else saveFlash(OFFSET_DNS, ip0);
|
||||||
// case 2:
|
// case 2:
|
||||||
if (arg_cnt>1 && inet_aton(args[1], ip)) saveFlash(OFFSET_IP, ip);
|
if (arg_cnt>1 && _inet_aton(args[1], ip)) saveFlash(OFFSET_IP, ip);
|
||||||
else saveFlash(OFFSET_IP, ip0);
|
else saveFlash(OFFSET_IP, ip0);
|
||||||
// break;
|
// break;
|
||||||
|
|
||||||
@@ -1422,15 +1441,18 @@ lan_status loadConfigFromHttp(int arg_cnt, char **args)
|
|||||||
//if (freeRam()<512) cleanConf();
|
//if (freeRam()<512) cleanConf();
|
||||||
|
|
||||||
HTTPClient hclient(configServer, 80);
|
HTTPClient hclient(configServer, 80);
|
||||||
|
debugSerial<<F("free ")<<freeRam()<<endl;delay(100);
|
||||||
// FILE is the return STREAM type of the HTTPClient
|
// FILE is the return STREAM type of the HTTPClient
|
||||||
configStream = hclient.getURI(URI);
|
configStream = hclient.getURI(URI);
|
||||||
|
debugSerial<<F("hclient")<<endl;delay(100);
|
||||||
responseStatusCode = hclient.getLastReturnCode();
|
responseStatusCode = hclient.getLastReturnCode();
|
||||||
|
debugSerial<<F("retcode ")<<responseStatusCode<<endl;delay(100);
|
||||||
//wdt_en();
|
//wdt_en();
|
||||||
|
|
||||||
if (configStream != NULL) {
|
if (configStream != NULL) {
|
||||||
if (responseStatusCode == 200) {
|
if (responseStatusCode == 200) {
|
||||||
|
|
||||||
infoSerial<<F("got Config\n");
|
infoSerial<<F("got Config\n"); delay(500);
|
||||||
char c;
|
char c;
|
||||||
aJsonFileStream as = aJsonFileStream(configStream);
|
aJsonFileStream as = aJsonFileStream(configStream);
|
||||||
noInterrupts();
|
noInterrupts();
|
||||||
@@ -1519,10 +1541,11 @@ lan_status loadConfigFromHttp(int arg_cnt, char **args)
|
|||||||
|
|
||||||
#if defined(ARDUINO_ARCH_ESP8266) || defined(ARDUINO_ARCH_ESP32) //|| defined (NRF5)
|
#if defined(ARDUINO_ARCH_ESP8266) || defined(ARDUINO_ARCH_ESP32) //|| defined (NRF5)
|
||||||
HTTPClient httpClient;
|
HTTPClient httpClient;
|
||||||
|
WiFiClient wifiClient;
|
||||||
String fullURI = "http://";
|
String fullURI = "http://";
|
||||||
fullURI+=configServer;
|
fullURI+=configServer;
|
||||||
fullURI+=URI;
|
fullURI+=URI;
|
||||||
httpClient.begin(fullURI);
|
httpClient.begin(wifiClient,fullURI);
|
||||||
int httpResponseCode = httpClient.GET();
|
int httpResponseCode = httpClient.GET();
|
||||||
if (httpResponseCode > 0) {
|
if (httpResponseCode > 0) {
|
||||||
infoSerial.printf("[HTTP] GET... code: %d\n", httpResponseCode);
|
infoSerial.printf("[HTTP] GET... code: %d\n", httpResponseCode);
|
||||||
@@ -1786,11 +1809,16 @@ infoSerial<<F("\n(-)PID");
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef SYSLOG_ENABLE
|
#ifdef SYSLOG_ENABLE
|
||||||
//udpSyslogClient.begin(SYSLOG_LOCAL_SOCKET);
|
|
||||||
infoSerial<<F("\n(+)SYSLOG");
|
infoSerial<<F("\n(+)SYSLOG");
|
||||||
#else
|
#else
|
||||||
infoSerial<<F("\n(-)SYSLOG");
|
infoSerial<<F("\n(-)SYSLOG");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef UARTBRIDGE_ENABLE
|
||||||
|
infoSerial<<F("\n(+)UARTBRIDGE");
|
||||||
|
#else
|
||||||
|
infoSerial<<F("\n(-)UARTBRIDGE");
|
||||||
|
#endif
|
||||||
infoSerial<<endl;
|
infoSerial<<endl;
|
||||||
|
|
||||||
// WDT_Disable( WDT ) ;
|
// WDT_Disable( WDT ) ;
|
||||||
@@ -1888,8 +1916,8 @@ void setupCmdArduino() {
|
|||||||
cmdAdd("reboot",cmdFunctionReboot);
|
cmdAdd("reboot",cmdFunctionReboot);
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop_main() {
|
void loop_main() {
|
||||||
LED.poll();
|
statusLED.poll();
|
||||||
|
|
||||||
#if defined(M5STACK)
|
#if defined(M5STACK)
|
||||||
// Initialize the M5Stack object
|
// Initialize the M5Stack object
|
||||||
@@ -1900,7 +1928,7 @@ void loop_main() {
|
|||||||
wdt_res();
|
wdt_res();
|
||||||
yield();
|
yield();
|
||||||
cmdPoll();
|
cmdPoll();
|
||||||
if (lanLoop() > HAVE_IP_ADDRESS) {
|
if (lanLoop() > HAVE_IP_ADDRESS) {
|
||||||
mqttClient.loop();
|
mqttClient.loop();
|
||||||
|
|
||||||
#if defined(OTA)
|
#if defined(OTA)
|
||||||
@@ -1967,7 +1995,7 @@ ethernetIdleCount--;
|
|||||||
};
|
};
|
||||||
|
|
||||||
void modbusIdle(void) {
|
void modbusIdle(void) {
|
||||||
LED.poll();
|
statusLED.poll();
|
||||||
yield();
|
yield();
|
||||||
cmdPoll();
|
cmdPoll();
|
||||||
wdt_res();
|
wdt_res();
|
||||||
@@ -2065,9 +2093,9 @@ configLocked--;
|
|||||||
|
|
||||||
|
|
||||||
void pollingLoop(void) {
|
void pollingLoop(void) {
|
||||||
|
if (!items) return;
|
||||||
// FAST POLLINT - as often AS possible every item
|
// FAST POLLINT - as often AS possible every item
|
||||||
configLocked++;
|
configLocked++;
|
||||||
if (items) {
|
|
||||||
aJsonObject * item = items->child;
|
aJsonObject * item = items->child;
|
||||||
while (items && item)
|
while (items && item)
|
||||||
if (item->type == aJson_Array && aJson.getArraySize(item)>1) {
|
if (item->type == aJson_Array && aJson.getArraySize(item)>1) {
|
||||||
@@ -2078,7 +2106,6 @@ if (items) {
|
|||||||
yield();
|
yield();
|
||||||
item = item->next;
|
item = item->next;
|
||||||
} //if
|
} //if
|
||||||
}
|
|
||||||
configLocked--;
|
configLocked--;
|
||||||
// SLOW POLLING
|
// SLOW POLLING
|
||||||
boolean done = false;
|
boolean done = false;
|
||||||
|
|||||||
@@ -356,7 +356,7 @@ return is8bit;
|
|||||||
|
|
||||||
//if (readModbus(registerFrom,MODBUS_HOLDING_REG_TYPE,registerTo-registerFrom+1))
|
//if (readModbus(registerFrom,MODBUS_HOLDING_REG_TYPE,registerTo-registerFrom+1))
|
||||||
if (readModbus(registerFrom,regType,registerTo-registerFrom+1))
|
if (readModbus(registerFrom,regType,registerTo-registerFrom+1))
|
||||||
{
|
{ debugSerial<<endl;
|
||||||
for(int i=registerFrom;i<=registerTo;i++)
|
for(int i=registerFrom;i<=registerTo;i++)
|
||||||
{
|
{
|
||||||
findRegister(i,i-registerFrom,regType);
|
findRegister(i,i-registerFrom,regType);
|
||||||
@@ -382,7 +382,6 @@ if ((store->pollingRegisters || store->pollingIrs) && !modbusBusy && (Status() =
|
|||||||
modbusSerial.begin(store->baud, static_cast <USARTClass::USARTModes> (store->serialParam));
|
modbusSerial.begin(store->baud, static_cast <USARTClass::USARTModes> (store->serialParam));
|
||||||
#elif defined (ARDUINO_ARCH_ESP8266)
|
#elif defined (ARDUINO_ARCH_ESP8266)
|
||||||
modbusSerial.begin(store->baud, static_cast <SerialConfig>(store->serialParam));
|
modbusSerial.begin(store->baud, static_cast <SerialConfig>(store->serialParam));
|
||||||
Serial1.begin()
|
|
||||||
#elif defined (ESP32)
|
#elif defined (ESP32)
|
||||||
//modbusSerial.begin(store->baud, store->serialParam);
|
//modbusSerial.begin(store->baud, store->serialParam);
|
||||||
//delay(100);
|
//delay(100);
|
||||||
|
|||||||
@@ -7,71 +7,37 @@
|
|||||||
#include "Streaming.h"
|
#include "Streaming.h"
|
||||||
|
|
||||||
#include "item.h"
|
#include "item.h"
|
||||||
#include <ModbusMaster.h>
|
//#include <ModbusMaster.h>
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include <HardwareSerial.h>
|
#include <HardwareSerial.h>
|
||||||
|
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
|
|
||||||
#if defined (ESP32)
|
|
||||||
#include <AsyncUDP.h>
|
#include <Udp.h>
|
||||||
AsyncUDP udp;
|
#ifndef WIFI_ENABLE
|
||||||
AsyncUDPMessage udpMessageA;
|
EthernetUDP udpClientA;
|
||||||
AsyncUDPMessage udpMessageB;
|
EthernetUDP udpClientB;
|
||||||
|
#else
|
||||||
|
WiFiUDP udpClientA;
|
||||||
|
WiFiUDP udpClientB;
|
||||||
|
#endif
|
||||||
|
|
||||||
IPAddress targetIP;
|
IPAddress targetIP;
|
||||||
uint16_t targetPort=5555;
|
uint16_t targetPort=5555;
|
||||||
#endif
|
|
||||||
|
|
||||||
|
short halfduplex=1;
|
||||||
|
bool udpdump=false;
|
||||||
uint32_t timerA = 0;
|
uint32_t timerA = 0;
|
||||||
uint32_t timerB = 0;
|
uint32_t timerB = 0;
|
||||||
|
uint16_t sizeA = 0;
|
||||||
|
uint16_t sizeB = 0;
|
||||||
|
|
||||||
|
//extern aJsonObject *modbusObj;
|
||||||
|
//extern ModbusMaster node;
|
||||||
|
//extern short modbusBusy;
|
||||||
|
//extern void modbusIdle(void) ;
|
||||||
|
|
||||||
extern aJsonObject *modbusObj;
|
|
||||||
extern ModbusMaster node;
|
|
||||||
extern short modbusBusy;
|
|
||||||
extern void modbusIdle(void) ;
|
|
||||||
|
|
||||||
/*
|
|
||||||
struct reg_t
|
|
||||||
{
|
|
||||||
const char verb[4];
|
|
||||||
const uint8_t id;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
#define PAR_I16 1
|
|
||||||
#define PAR_I32 2
|
|
||||||
#define PAR_U16 3
|
|
||||||
#define PAR_U32 4
|
|
||||||
#define PAR_I8H 5
|
|
||||||
#define PAR_I8L 6
|
|
||||||
#define PAR_U8H 7
|
|
||||||
#define PAR_U8L 8
|
|
||||||
#define PAR_TENS 9
|
|
||||||
|
|
||||||
const reg_t regSize_P[] PROGMEM =
|
|
||||||
{
|
|
||||||
{ "i16", (uint8_t) PAR_I16 },
|
|
||||||
{ "i32", (uint8_t) PAR_I32 },
|
|
||||||
{ "u16", (uint8_t) PAR_U16 },
|
|
||||||
{ "u32", (uint8_t) PAR_U32 },
|
|
||||||
{ "i8h", (uint8_t) PAR_I8H },
|
|
||||||
{ "i8l", (uint8_t) PAR_I8L },
|
|
||||||
{ "u8h", (uint8_t) PAR_U8H },
|
|
||||||
{ "u8l", (uint8_t) PAR_U8L },
|
|
||||||
{ "x10", (uint8_t) PAR_TENS }
|
|
||||||
} ;
|
|
||||||
#define regSizeNum sizeof(regSize_P)/sizeof(reg_t)
|
|
||||||
|
|
||||||
int str2regSize(char * str)
|
|
||||||
{
|
|
||||||
for(uint8_t i=0; i<regSizeNum && str;i++)
|
|
||||||
if (strcmp_P(str, regSize_P[i].verb) == 0)
|
|
||||||
return pgm_read_byte_near(®Size_P[i].id);
|
|
||||||
return (int) PAR_I16;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
bool out_UARTbridge::getConfig()
|
bool out_UARTbridge::getConfig()
|
||||||
{
|
{
|
||||||
@@ -106,11 +72,20 @@ bool out_UARTbridge::getConfig()
|
|||||||
|
|
||||||
aJsonObject * debugIPObj=aJson.getObjectItem(item->itemArg, "ip");
|
aJsonObject * debugIPObj=aJson.getObjectItem(item->itemArg, "ip");
|
||||||
aJsonObject * debugPortObj=aJson.getObjectItem(item->itemArg, "port");
|
aJsonObject * debugPortObj=aJson.getObjectItem(item->itemArg, "port");
|
||||||
|
aJsonObject * hdObj=aJson.getObjectItem(item->itemArg, "hd");
|
||||||
|
|
||||||
if (debugIPObj)
|
if (debugIPObj)
|
||||||
|
{
|
||||||
_inet_aton(debugIPObj->valuestring, targetIP);
|
_inet_aton(debugIPObj->valuestring, targetIP);
|
||||||
|
if (udpClientA.begin(SOURCE_PORT_A) && udpClientB.begin(SOURCE_PORT_B)) udpdump=true;
|
||||||
|
else {
|
||||||
|
udpClientA.stop(); udpClientB.stop(); udpdump=false;
|
||||||
|
errorSerial<<F("No sockets available, udpdump disabled")<<endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (debugPortObj) targetPort = debugPortObj->valueint;
|
if (debugPortObj) targetPort = debugPortObj->valueint;
|
||||||
|
if (hdObj) halfduplex = hdObj->valueint;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -125,7 +100,12 @@ if (!store)
|
|||||||
{ errorSerial<<F("UARTbridge: Out of memory")<<endl;
|
{ errorSerial<<F("UARTbridge: Out of memory")<<endl;
|
||||||
return 0;}
|
return 0;}
|
||||||
|
|
||||||
//store->timestamp=millisNZ();
|
|
||||||
|
sizeA=0;
|
||||||
|
sizeB=0;
|
||||||
|
timerA=0;
|
||||||
|
timerB=0;
|
||||||
|
|
||||||
if (getConfig())
|
if (getConfig())
|
||||||
{
|
{
|
||||||
infoSerial<<F("UARTbridge config loaded ")<< item->itemArr->name<<endl;
|
infoSerial<<F("UARTbridge config loaded ")<< item->itemArr->name<<endl;
|
||||||
@@ -143,6 +123,10 @@ else
|
|||||||
int out_UARTbridge::Stop()
|
int out_UARTbridge::Stop()
|
||||||
{
|
{
|
||||||
Serial.println("UARTbridge De-Init");
|
Serial.println("UARTbridge De-Init");
|
||||||
|
|
||||||
|
udpClientA.stop();
|
||||||
|
udpClientB.stop();
|
||||||
|
udpdump=false;
|
||||||
|
|
||||||
delete store;
|
delete store;
|
||||||
item->setPersistent(NULL);
|
item->setPersistent(NULL);
|
||||||
@@ -157,11 +141,75 @@ if (store)
|
|||||||
return CST_UNKNOWN;
|
return CST_UNKNOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void flushA()
|
||||||
|
{
|
||||||
|
if (sizeA)
|
||||||
|
{
|
||||||
|
if (lanStatus>=HAVE_IP_ADDRESS && udpdump) udpClientA.endPacket();
|
||||||
|
debugSerial<<endl;
|
||||||
|
}
|
||||||
|
timerA=0;
|
||||||
|
sizeA=0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void flushB()
|
||||||
|
{
|
||||||
|
if (sizeB)
|
||||||
|
{
|
||||||
|
if (lanStatus>=HAVE_IP_ADDRESS && udpdump) udpClientB.endPacket();
|
||||||
|
debugSerial<<endl;
|
||||||
|
}
|
||||||
|
timerB=0;
|
||||||
|
sizeB=0;
|
||||||
|
}
|
||||||
|
|
||||||
int out_UARTbridge::Poll(short cause)
|
int out_UARTbridge::Poll(short cause)
|
||||||
{
|
{
|
||||||
uint8_t chA;
|
uint8_t chA;
|
||||||
uint8_t chB;
|
uint8_t chB;
|
||||||
|
|
||||||
|
while (MODULE_UATRBRIDGE_UARTA.available() || MODULE_UATRBRIDGE_UARTB.available())
|
||||||
|
{
|
||||||
|
|
||||||
|
if (MODULE_UATRBRIDGE_UARTA.available())
|
||||||
|
{
|
||||||
|
if (!sizeA)
|
||||||
|
{
|
||||||
|
if (lanStatus>=HAVE_IP_ADDRESS && udpdump) udpClientA.beginPacket(targetIP, targetPort);
|
||||||
|
if (halfduplex) flushB();
|
||||||
|
}
|
||||||
|
|
||||||
|
timerA=millisNZ();
|
||||||
|
////if (timerB) return 1;
|
||||||
|
chA=MODULE_UATRBRIDGE_UARTA.read();
|
||||||
|
MODULE_UATRBRIDGE_UARTB.write(chA);
|
||||||
|
debugSerial<<F("<")<<((chA<16)?"0":"")<<_HEX(chA);
|
||||||
|
if (lanStatus>=HAVE_IP_ADDRESS && udpdump) {udpClientA.write(chA);}
|
||||||
|
sizeA++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (MODULE_UATRBRIDGE_UARTB.available())
|
||||||
|
{
|
||||||
|
if (!sizeB)
|
||||||
|
{
|
||||||
|
if (lanStatus>=HAVE_IP_ADDRESS && udpdump) udpClientB.beginPacket(targetIP, targetPort);
|
||||||
|
if (halfduplex) flushA();
|
||||||
|
}
|
||||||
|
timerB=millisNZ();
|
||||||
|
////if (timerA) return 1;
|
||||||
|
chB=MODULE_UATRBRIDGE_UARTB.read();
|
||||||
|
MODULE_UATRBRIDGE_UARTA.write(chB);
|
||||||
|
debugSerial<<F(">")<<((chB<16)?"0":"")<<_HEX(chB);
|
||||||
|
if (lanStatus>=HAVE_IP_ADDRESS && udpdump) {udpClientB.write(chB);};
|
||||||
|
sizeB++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((timerA && (isTimeOver(timerA,millis(),PDELAY)) || sizeA>=MAX_PDU)) flushA();
|
||||||
|
if ((timerB && (isTimeOver(timerB,millis(),PDELAY)) || sizeB>=MAX_PDU)) flushB();
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
if ((lanStatus>=HAVE_IP_ADDRESS) && udpMessageA.length() && (isTimeOver(timerA,millis(),PDELAY) || timerB))
|
if ((lanStatus>=HAVE_IP_ADDRESS) && udpMessageA.length() && (isTimeOver(timerA,millis(),PDELAY) || timerB))
|
||||||
{
|
{
|
||||||
udp.sendTo(udpMessageA,targetIP,targetPort);
|
udp.sendTo(udpMessageA,targetIP,targetPort);
|
||||||
@@ -201,19 +249,8 @@ if ((lanStatus>=HAVE_IP_ADDRESS) && udpMessageB.length() && (isTimeOver(timerB,m
|
|||||||
udpMessageB.write(chB);
|
udpMessageB.write(chB);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
while (MODULE_UATRBRIDGE_UARTB.available())
|
|
||||||
{
|
|
||||||
chB=MODULE_UATRBRIDGE_UARTB.read();
|
|
||||||
MODULE_UATRBRIDGE_UARTA.write(chB);
|
|
||||||
debugSerial<<F(">")<<((chB<10)?"0":"")<<_HEX(chB);
|
|
||||||
udpMessageB.write(chB);
|
|
||||||
timerB=millisNZ();
|
|
||||||
}
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return 1;//store->pollingInterval;
|
return 1;//store->pollingInterval;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,10 @@
|
|||||||
#define serialParamType uint16_t
|
#define serialParamType uint16_t
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define SOURCE_PORT_A 5551
|
||||||
|
#define SOURCE_PORT_B 5552
|
||||||
|
#define MAX_PDU 1024
|
||||||
|
|
||||||
#ifndef MODULE_UATRBRIDGE_UARTA
|
#ifndef MODULE_UATRBRIDGE_UARTA
|
||||||
#define MODULE_UATRBRIDGE_UARTA Serial1
|
#define MODULE_UATRBRIDGE_UARTA Serial1
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ e-mail anklimov@gmail.com
|
|||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
|
|
||||||
statusLED::statusLED(uint8_t pattern)
|
StatusLED::StatusLED(uint8_t pattern)
|
||||||
{
|
{
|
||||||
#if defined (STATUSLED)
|
#if defined (STATUSLED)
|
||||||
pinMode(pinRED, OUTPUT);
|
pinMode(pinRED, OUTPUT);
|
||||||
@@ -33,7 +33,7 @@ statusLED::statusLED(uint8_t pattern)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void statusLED::show (uint8_t pattern)
|
void StatusLED::show (uint8_t pattern)
|
||||||
{
|
{
|
||||||
#if defined (STATUSLED)
|
#if defined (STATUSLED)
|
||||||
digitalWrite(pinRED,(pattern & ledRED)?HIGH:LOW );
|
digitalWrite(pinRED,(pattern & ledRED)?HIGH:LOW );
|
||||||
@@ -42,7 +42,7 @@ void statusLED::show (uint8_t pattern)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void statusLED::set (uint8_t pattern)
|
void StatusLED::set (uint8_t pattern)
|
||||||
{
|
{
|
||||||
#if defined (STATUSLED)
|
#if defined (STATUSLED)
|
||||||
short newStat = pattern & ledParams;
|
short newStat = pattern & ledParams;
|
||||||
@@ -56,7 +56,7 @@ void statusLED::set (uint8_t pattern)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void statusLED::flash(uint8_t pattern)
|
void StatusLED::flash(uint8_t pattern)
|
||||||
{
|
{
|
||||||
#if defined (STATUSLED)
|
#if defined (STATUSLED)
|
||||||
show(pattern);
|
show(pattern);
|
||||||
@@ -64,7 +64,7 @@ void statusLED::flash(uint8_t pattern)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void statusLED::poll()
|
void StatusLED::poll()
|
||||||
{
|
{
|
||||||
#if defined (STATUSLED)
|
#if defined (STATUSLED)
|
||||||
if (curStat & ledFlash)
|
if (curStat & ledFlash)
|
||||||
|
|||||||
@@ -30,16 +30,22 @@ e-mail anklimov@gmail.com
|
|||||||
#define ledFlash 32
|
#define ledFlash 32
|
||||||
#define ledHidden 64
|
#define ledHidden 64
|
||||||
|
|
||||||
|
#if defined(ARDUINO_ARCH_AVR)
|
||||||
|
#define pinRED 47
|
||||||
|
#define pinGREEN 48
|
||||||
|
#define pinBLUE 49
|
||||||
|
#else
|
||||||
#define pinRED 50
|
#define pinRED 50
|
||||||
#define pinGREEN 51
|
#define pinGREEN 51
|
||||||
#define pinBLUE 52
|
#define pinBLUE 52
|
||||||
|
#endif
|
||||||
|
|
||||||
#define ledDelayms 1000UL
|
#define ledDelayms 1000UL
|
||||||
#define ledFastDelayms 300UL
|
#define ledFastDelayms 300UL
|
||||||
|
|
||||||
class statusLED {
|
class StatusLED {
|
||||||
public:
|
public:
|
||||||
statusLED(uint8_t pattern = 0);
|
StatusLED(uint8_t pattern = 0);
|
||||||
void set (uint8_t pattern);
|
void set (uint8_t pattern);
|
||||||
void show (uint8_t pattern);
|
void show (uint8_t pattern);
|
||||||
void poll();
|
void poll();
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
#include "statusled.h"
|
#include "statusled.h"
|
||||||
|
|
||||||
#if defined (STATUSLED)
|
#if defined (STATUSLED)
|
||||||
extern statusLED LED;
|
extern StatusLED statusLED;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef SYSLOG_ENABLE
|
#ifdef SYSLOG_ENABLE
|
||||||
@@ -77,7 +77,7 @@ if (syslogInitialized)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined (STATUSLED)
|
#if defined (STATUSLED)
|
||||||
if ((ch=='\n') && ledPattern) LED.flash(ledPattern);
|
if ((ch=='\n') && ledPattern) statusLED.flash(ledPattern);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (serialPort) return serialPort->write(ch);
|
if (serialPort) return serialPort->write(ch);
|
||||||
|
|||||||
+7
-5
@@ -685,14 +685,14 @@ unsigned long millisNZ(uint8_t shift)
|
|||||||
return now;
|
return now;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct serial_t
|
struct serial_st
|
||||||
{
|
{
|
||||||
const char verb[4];
|
const char verb[4];
|
||||||
const serialParamType mode;
|
const serialParamType mode;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
const serial_t serialModes_P[] PROGMEM =
|
const serial_st serialModes_P[] PROGMEM =
|
||||||
{
|
{
|
||||||
{ "8E1", (serialParamType) SERIAL_8E1},//(uint16_t) US_MR_CHRL_8_BIT | US_MR_NBSTOP_1_BIT | UART_MR_PAR_EVEN },
|
{ "8E1", (serialParamType) SERIAL_8E1},//(uint16_t) US_MR_CHRL_8_BIT | US_MR_NBSTOP_1_BIT | UART_MR_PAR_EVEN },
|
||||||
{ "8N1", (serialParamType) SERIAL_8N1},
|
{ "8N1", (serialParamType) SERIAL_8N1},
|
||||||
@@ -703,16 +703,18 @@ const serial_t serialModes_P[] PROGMEM =
|
|||||||
// { "8M1", SERIAL_8M1},
|
// { "8M1", SERIAL_8M1},
|
||||||
// { "8S1", SERIAL_8S1},
|
// { "8S1", SERIAL_8S1},
|
||||||
{ "7E1", (serialParamType) SERIAL_7E1},//(uint16_t) US_MR_CHRL_8_BIT | US_MR_NBSTOP_1_BIT | UART_MR_PAR_EVEN },
|
{ "7E1", (serialParamType) SERIAL_7E1},//(uint16_t) US_MR_CHRL_8_BIT | US_MR_NBSTOP_1_BIT | UART_MR_PAR_EVEN },
|
||||||
{ "7N1", (serialParamType) SERIAL_7N1},
|
|
||||||
{ "7E2", (serialParamType) SERIAL_7E2},
|
{ "7E2", (serialParamType) SERIAL_7E2},
|
||||||
{ "7N2", (serialParamType) SERIAL_7N2},
|
|
||||||
{ "7O1", (serialParamType) SERIAL_7O1},
|
{ "7O1", (serialParamType) SERIAL_7O1},
|
||||||
{ "7O2", (serialParamType) SERIAL_7O2}
|
{ "7O2", (serialParamType) SERIAL_7O2}
|
||||||
|
#ifndef ARDUINO_ARCH_STM32
|
||||||
|
,{ "7N1", (serialParamType) SERIAL_7N1}
|
||||||
|
,{ "7N2", (serialParamType) SERIAL_7N2}
|
||||||
|
#endif
|
||||||
// { "7M1", SERIAL_7M1},
|
// { "7M1", SERIAL_7M1},
|
||||||
// { "7S1", SERIAL_7S1}
|
// { "7S1", SERIAL_7S1}
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
#define serialModesNum sizeof(serialModes_P)/sizeof(serial_t)
|
#define serialModesNum sizeof(serialModes_P)/sizeof(serial_st)
|
||||||
|
|
||||||
serialParamType str2SerialParam(char * str)
|
serialParamType str2SerialParam(char * str)
|
||||||
{ debugSerial<<str<<F(" =>");
|
{ debugSerial<<str<<F(" =>");
|
||||||
|
|||||||
+2
-2
@@ -60,8 +60,8 @@ void parseBytes(const char* str, char separator, byte* bytes, int maxBytes, int
|
|||||||
int log(const char *str, ...);
|
int log(const char *str, ...);
|
||||||
void printFloatValueToStr(float value, char *valstr);
|
void printFloatValueToStr(float value, char *valstr);
|
||||||
void ReadUniqueID( uint32_t * pdwUniqueID );
|
void ReadUniqueID( uint32_t * pdwUniqueID );
|
||||||
int inet_aton(const char* aIPAddrString, IPAddress& aResult);
|
int _inet_aton(const char* aIPAddrString, IPAddress& aResult);
|
||||||
char *inet_ntoa_r(IPAddress addr, char *buf, int buflen);
|
char *_inet_ntoa_r(IPAddress addr, char *buf, int buflen);
|
||||||
void printIPAddress(IPAddress ipAddress);
|
void printIPAddress(IPAddress ipAddress);
|
||||||
char* setTopic(char* buf, int8_t buflen, topicType tt, const char* suffix = NULL);
|
char* setTopic(char* buf, int8_t buflen, topicType tt, const char* suffix = NULL);
|
||||||
void printUlongValueToStr(char *valstr, unsigned long value);
|
void printUlongValueToStr(char *valstr, unsigned long value);
|
||||||
|
|||||||
+115
-6
@@ -12,9 +12,16 @@
|
|||||||
src_dir = lighthub
|
src_dir = lighthub
|
||||||
default_envs =
|
default_envs =
|
||||||
; ****** UNCOMMENT single environment name for target platform below *******
|
; ****** UNCOMMENT single environment name for target platform below *******
|
||||||
; Arduino Mega (without onewire) + Ethernet shield Wiznet 5100
|
|
||||||
|
; Arduino Mega compact build + Ethernet shield Wiznet 5100, 1-wire, thermostates.
|
||||||
|
; Without DMX, Wiznet 5100 network driver
|
||||||
; mega2560slim-5100
|
; mega2560slim-5100
|
||||||
|
|
||||||
|
; Another Arduino Mega compact build without 1-wire, DMX, but with OTA
|
||||||
|
; OPTIBOOT bootloader required! https://github.com/MCUdude/MegaCore
|
||||||
|
; universal Wiznet network driver
|
||||||
|
; mega2560slim2
|
||||||
|
|
||||||
; Arduino Mega + Ethernet shield Wiznet 5100
|
; Arduino Mega + Ethernet shield Wiznet 5100
|
||||||
; mega2560-5100
|
; mega2560-5100
|
||||||
|
|
||||||
@@ -28,7 +35,7 @@ default_envs =
|
|||||||
; due-5100
|
; due-5100
|
||||||
|
|
||||||
; Generic DUE
|
; Generic DUE
|
||||||
; due
|
; due
|
||||||
; Arduino DUE + Ethernet shield Wiznet 5500
|
; Arduino DUE + Ethernet shield Wiznet 5500
|
||||||
; due-5500
|
; due-5500
|
||||||
|
|
||||||
@@ -173,7 +180,11 @@ monitor_filters = esp32_exception_decoder
|
|||||||
build_type = debug
|
build_type = debug
|
||||||
board = esp32-evb
|
board = esp32-evb
|
||||||
monitor_baud = 115200
|
monitor_baud = 115200
|
||||||
upload_speed = 115200
|
;upload_speed = 115200
|
||||||
|
;upload_command = arduinoOTA -address 192.168.88.60 -port 65280 -username arduino -password password -b -upload /sketch -sketch $SOURCE;sleep 5
|
||||||
|
upload_command = arduinoOTA -address 192.168.11.230 -port 65280 -username arduino -password password -b -upload /sketch -sketch $SOURCE;sleep 5
|
||||||
|
upload_protocol = custom
|
||||||
|
|
||||||
build_flags = !python get_build_flags.py esp32-wifi
|
build_flags = !python get_build_flags.py esp32-wifi
|
||||||
lib_ignore =
|
lib_ignore =
|
||||||
;COMMENT/UNCOMMENT next line for software 1-wire driver on/off
|
;COMMENT/UNCOMMENT next line for software 1-wire driver on/off
|
||||||
@@ -220,6 +231,7 @@ lib_deps =
|
|||||||
https://github.com/adafruit/Adafruit-MCP23017-Arduino-Library
|
https://github.com/adafruit/Adafruit-MCP23017-Arduino-Library
|
||||||
https://github.com/arcao/Syslog.git
|
https://github.com/arcao/Syslog.git
|
||||||
br3ttb/PID@^1.2.1
|
br3ttb/PID@^1.2.1
|
||||||
|
|
||||||
monitor_speed = 115200
|
monitor_speed = 115200
|
||||||
|
|
||||||
[env:due-5100]
|
[env:due-5100]
|
||||||
@@ -359,7 +371,7 @@ lib_deps =
|
|||||||
https://github.com/anklimov/CmdArduino
|
https://github.com/anklimov/CmdArduino
|
||||||
https://github.com/anklimov/ModbusMaster
|
https://github.com/anklimov/ModbusMaster
|
||||||
https://github.com/anklimov/DMXSerial
|
https://github.com/anklimov/DMXSerial
|
||||||
https://github.com/anklimov/Ethernet
|
https://github.com/anklimov/Ethernet5100
|
||||||
;5100 lib have ~90 bytes less footprint of RAM
|
;5100 lib have ~90 bytes less footprint of RAM
|
||||||
https://github.com/knolleary/pubsubclient.git
|
https://github.com/knolleary/pubsubclient.git
|
||||||
https://github.com/anklimov/Artnet.git
|
https://github.com/anklimov/Artnet.git
|
||||||
@@ -376,6 +388,67 @@ lib_deps =
|
|||||||
br3ttb/PID@^1.2.1
|
br3ttb/PID@^1.2.1
|
||||||
monitor_speed = 115200
|
monitor_speed = 115200
|
||||||
|
|
||||||
|
|
||||||
|
[env:mega2560slim2]
|
||||||
|
platform = atmelavr
|
||||||
|
;For OTA programming - generating bin image
|
||||||
|
extra_scripts = post:toBin.py
|
||||||
|
;OptiBoot setting
|
||||||
|
board = ATmega2560
|
||||||
|
;was megaatmega2560 for conventional bootloader
|
||||||
|
; Clock frequency in [Hz]
|
||||||
|
board_build.f_cpu = 16000000L
|
||||||
|
|
||||||
|
; BUILD OPTIONS
|
||||||
|
; Comment out to enable LTO (this line unflags it)
|
||||||
|
;build_unflags = -flto - not working without LTO!
|
||||||
|
|
||||||
|
upload_protocol = arduino
|
||||||
|
board_upload.speed = ${env:fuses_bootloader.board_bootloader.speed}
|
||||||
|
framework = arduino
|
||||||
|
build_flags = !python get_build_flags.py mega2560slim2
|
||||||
|
lib_ignore =
|
||||||
|
;DS2482_OneWire //UNCOMMENT for software 1-wire driver
|
||||||
|
DHT sensor library for ESPx
|
||||||
|
DmxDue
|
||||||
|
DueFlashStorage
|
||||||
|
WifiManager
|
||||||
|
Ethernet3
|
||||||
|
Ethernet2
|
||||||
|
HTTPClient
|
||||||
|
NRFFlashStorage
|
||||||
|
WebServer
|
||||||
|
UIPEthernet
|
||||||
|
ESP_EEPROM
|
||||||
|
M5Stack
|
||||||
|
lib_deps =
|
||||||
|
https://github.com/anklimov/Arduino-Temperature-Control-Library.git
|
||||||
|
https://github.com/anklimov/DS2482_OneWire
|
||||||
|
https://github.com/anklimov/DmxSimple
|
||||||
|
https://github.com/anklimov/httpClient
|
||||||
|
https://github.com/anklimov/aJson
|
||||||
|
https://github.com/anklimov/CmdArduino
|
||||||
|
https://github.com/anklimov/ModbusMaster
|
||||||
|
https://github.com/anklimov/DMXSerial
|
||||||
|
;https://github.com/anklimov/Ethernet5100
|
||||||
|
;5100 lib have ~90 bytes less footprint of RAM
|
||||||
|
https://github.com/anklimov/Ethernet.git
|
||||||
|
https://github.com/knolleary/pubsubclient.git
|
||||||
|
;https://github.com/anklimov/Artnet.git
|
||||||
|
FastLED@3.3.2
|
||||||
|
Adafruit Unified Sensor
|
||||||
|
DHT sensor library
|
||||||
|
https://github.com/arcao/Syslog.git
|
||||||
|
Streaming
|
||||||
|
ClosedCube HDC1080
|
||||||
|
SparkFun CCS811 Arduino Library@~1.0.7
|
||||||
|
Adafruit NeoPixel
|
||||||
|
https://github.com/anklimov/ArduinoOTA
|
||||||
|
https://github.com/adafruit/Adafruit-MCP23017-Arduino-Library
|
||||||
|
br3ttb/PID@^1.2.1
|
||||||
|
monitor_speed = 115200
|
||||||
|
|
||||||
|
|
||||||
[env:mega2560-5500]
|
[env:mega2560-5500]
|
||||||
platform = atmelavr
|
platform = atmelavr
|
||||||
board = megaatmega2560
|
board = megaatmega2560
|
||||||
@@ -591,8 +664,8 @@ board = due
|
|||||||
monitor_baud = 115200
|
monitor_baud = 115200
|
||||||
build_flags = !python get_build_flags.py lighthub21
|
build_flags = !python get_build_flags.py lighthub21
|
||||||
;upload_command = arduinoOTA -address 192.168.11.172 -port 65280 -username arduino -password password -b -upload /sketch -sketch $SOURCE ;sleep 4
|
;upload_command = arduinoOTA -address 192.168.11.172 -port 65280 -username arduino -password password -b -upload /sketch -sketch $SOURCE ;sleep 4
|
||||||
upload_command = arduinoOTA -address 192.168.88.64 -port 65280 -username arduino -password password -b -upload /sketch -sketch $SOURCE;sleep 4
|
;upload_command = arduinoOTA -address 192.168.88.45 -port 65280 -username arduino -password password -b -upload /sketch -sketch $SOURCE;sleep 4
|
||||||
upload_protocol = custom
|
;upload_protocol = custom
|
||||||
lib_ignore =
|
lib_ignore =
|
||||||
;DS2482_OneWire //UNCOMMENT for software 1-wire driver
|
;DS2482_OneWire //UNCOMMENT for software 1-wire driver
|
||||||
DHT sensor library for ESPx
|
DHT sensor library for ESPx
|
||||||
@@ -738,3 +811,39 @@ lib_deps =
|
|||||||
SPI
|
SPI
|
||||||
br3ttb/PID@^1.2.1
|
br3ttb/PID@^1.2.1
|
||||||
monitor_speed = 115200
|
monitor_speed = 115200
|
||||||
|
|
||||||
|
; Run the following command to upload with this environment
|
||||||
|
; pio run -e Upload_ISP -t upload
|
||||||
|
[env:Upload_ISP]
|
||||||
|
platform = atmelavr
|
||||||
|
framework = arduino
|
||||||
|
; Custom upload procedure
|
||||||
|
upload_protocol = custom
|
||||||
|
; Avrdude upload flags
|
||||||
|
upload_flags =
|
||||||
|
-C$PROJECT_PACKAGES_DIR/tool-avrdude/avrdude.conf
|
||||||
|
-p$BOARD_MCU
|
||||||
|
-PUSB
|
||||||
|
-cusbasp
|
||||||
|
; Avrdude upload command
|
||||||
|
upload_command = avrdude $UPLOAD_FLAGS -U flash:w:$SOURCE:i
|
||||||
|
|
||||||
|
|
||||||
|
; Run the following command to set fuses
|
||||||
|
; pio run -e fuses_bootloader -t fuses
|
||||||
|
; Run the following command to set fuses + burn bootloader
|
||||||
|
; pio run -e fuses_bootloader -t bootloader
|
||||||
|
[env:fuses_bootloader]
|
||||||
|
platform = atmelavr
|
||||||
|
framework = arduino
|
||||||
|
board_hardware.oscillator = external ; Oscillator type
|
||||||
|
board_hardware.uart = uart0 ; Set UART to use for serial upload
|
||||||
|
board_bootloader.speed = 115200 ; Set bootloader baud rate
|
||||||
|
board_hardware.bod = 2.7v ; Set brown-out detection
|
||||||
|
board_hardware.eesave = yes ; Preserve EEPROM when uploading using programmer
|
||||||
|
upload_protocol = usbasp ; Use the USBasp as programmer
|
||||||
|
upload_flags = ; Select USB as upload port and divide the SPI clock by 8
|
||||||
|
-PUSB
|
||||||
|
-B8
|
||||||
|
|
||||||
|
;; End of OPTIBOOT stuff
|
||||||
|
|||||||
Reference in New Issue
Block a user