mirror of
https://github.com/anklimov/lighthub
synced 2025-12-10 05:39:51 +03:00
Controllino support added
This commit is contained in:
@@ -324,15 +324,17 @@ if((wifiMulti.run() == WL_CONNECTED)) lanStatus=1;
|
|||||||
int port = 1883;
|
int port = 1883;
|
||||||
char empty = 0;
|
char empty = 0;
|
||||||
char *user = ∅
|
char *user = ∅
|
||||||
char *password = ∅
|
char passwordBuf[16]="";
|
||||||
|
char *password = passwordBuf;
|
||||||
|
|
||||||
|
|
||||||
if (!mqttClient.connected() && mqttArr && ((n = aJson.getArraySize(mqttArr)) > 1)) {
|
if (!mqttClient.connected() && mqttArr && ((n = aJson.getArraySize(mqttArr)) > 1)) {
|
||||||
char *client_id = aJson.getArrayItem(mqttArr, 0)->valuestring;
|
char *client_id = aJson.getArrayItem(mqttArr, 0)->valuestring;
|
||||||
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 (n >= 5) password = aJson.getArrayItem(mqttArr, 4)->valuestring;
|
if (!loadFlash(OFFSET_MQTT_PWD, passwordBuf,sizeof(passwordBuf)) && (n >= 5))
|
||||||
|
password = aJson.getArrayItem(mqttArr, 4)->valuestring;
|
||||||
|
|
||||||
mqttClient.setServer(servername, port);
|
mqttClient.setServer(servername, port);
|
||||||
mqttClient.setCallback(mqttCallback);
|
mqttClient.setCallback(mqttCallback);
|
||||||
@@ -772,6 +774,13 @@ void cmdFunctionIp(int arg_cnt, char **args)
|
|||||||
Serial.println(F("Saved"));
|
Serial.println(F("Saved"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void cmdFunctionPwd(int arg_cnt, char **args)
|
||||||
|
//(char* tokens)
|
||||||
|
{ char empty[]="";
|
||||||
|
if (arg_cnt)
|
||||||
|
saveFlash(OFFSET_MQTT_PWD,args[1]);
|
||||||
|
else saveFlash(OFFSET_MQTT_PWD,empty);
|
||||||
|
}
|
||||||
|
|
||||||
void cmdFunctionSetMac(int arg_cnt, char **args) {
|
void cmdFunctionSetMac(int arg_cnt, char **args) {
|
||||||
|
|
||||||
@@ -955,12 +964,21 @@ int getConfig(int arg_cnt, char **args)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void preTransmission() {
|
void preTransmission() {
|
||||||
|
#ifdef CONTROLLINO
|
||||||
|
// set DE and RE on HIGH
|
||||||
|
PORTJ |= B01100000;
|
||||||
|
#else
|
||||||
digitalWrite(TXEnablePin, 1);
|
digitalWrite(TXEnablePin, 1);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void postTransmission() {
|
void postTransmission() {
|
||||||
//modbusSerial.flush();
|
#ifdef CONTROLLINO
|
||||||
|
// set DE and RE on LOW
|
||||||
|
PORTJ &= B10011111;
|
||||||
|
#else
|
||||||
digitalWrite(TXEnablePin, 0);
|
digitalWrite(TXEnablePin, 0);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
//#define PIO_SRC_REV commit 8034a6b765229d94a94d90fd08dd9588acf5f3da Author: livello <livello@bk.ru> Date: Wed Mar 28 02:35:50 2018 +0300 refactoring
|
//#define PIO_SRC_REV commit 8034a6b765229d94a94d90fd08dd9588acf5f3da Author: livello <livello@bk.ru> Date: Wed Mar 28 02:35:50 2018 +0300 refactoring
|
||||||
|
|
||||||
@@ -981,7 +999,14 @@ void setup_main() {
|
|||||||
loadConfigFromEEPROM(0, NULL);
|
loadConfigFromEEPROM(0, NULL);
|
||||||
|
|
||||||
#ifdef _modbus
|
#ifdef _modbus
|
||||||
pinMode(TXEnablePin, OUTPUT);
|
#ifdef CONTROLLINO
|
||||||
|
//set PORTJ pin 5,6 direction (RE,DE)
|
||||||
|
DDRJ |= B01100000;
|
||||||
|
//set RE,DE on LOW
|
||||||
|
PORTJ &= B10011111;
|
||||||
|
#else
|
||||||
|
pinMode(TXEnablePin, OUTPUT);
|
||||||
|
#endif
|
||||||
modbusSerial.begin(MODBUS_SERIAL_BAUD);
|
modbusSerial.begin(MODBUS_SERIAL_BAUD);
|
||||||
node.idle(&modbusIdle);
|
node.idle(&modbusIdle);
|
||||||
// Callbacks allow us to configure the RS485 transceiver correctly
|
// Callbacks allow us to configure the RS485 transceiver correctly
|
||||||
@@ -1097,6 +1122,7 @@ void setupCmdArduino() {
|
|||||||
cmdAdd("kill", cmdFunctionKill);
|
cmdAdd("kill", cmdFunctionKill);
|
||||||
cmdAdd("req", cmdFunctionReq);
|
cmdAdd("req", cmdFunctionReq);
|
||||||
cmdAdd("ip", cmdFunctionIp);
|
cmdAdd("ip", cmdFunctionIp);
|
||||||
|
cmdAdd("pwd", cmdFunctionPwd);
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop_main() {
|
void loop_main() {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
// Configuration of drivers enabled
|
// Configuration of drivers enabled
|
||||||
#ifndef PIO_SRC_REV
|
#ifndef PIO_SRC_REV
|
||||||
#define PIO_SRC_REV v0.998
|
#define PIO_SRC_REV v0.999
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define TXEnablePin 13
|
#define TXEnablePin 13
|
||||||
@@ -83,7 +83,11 @@
|
|||||||
|
|
||||||
#if defined(__AVR__)
|
#if defined(__AVR__)
|
||||||
//All options available
|
//All options available
|
||||||
|
#ifdef CONTROLLINO
|
||||||
|
#define modbusSerial Serial3
|
||||||
|
#else
|
||||||
#define modbusSerial Serial2
|
#define modbusSerial Serial2
|
||||||
|
#endif
|
||||||
#define dmxin DMXSerial
|
#define dmxin DMXSerial
|
||||||
#define dmxout DmxSimple
|
#define dmxout DmxSimple
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -63,6 +63,30 @@ lib_deps =
|
|||||||
; 161
|
; 161
|
||||||
; 322
|
; 322
|
||||||
|
|
||||||
|
[env:controllino]
|
||||||
|
platform = atmelavr
|
||||||
|
board = megaatmega2560
|
||||||
|
framework = arduino
|
||||||
|
;lib_ldf_mode = chain+
|
||||||
|
build_flags = !echo -n "-DPIO_SRC_REV="$(git rev-parse --short HEAD)
|
||||||
|
build_flags = -D CONTROLLINO -D DMX_DISABLE -D OWIRE_DISABLE -D CUSTOM_FIRMWARE_MAC=de:ad:be:ef:fe:07
|
||||||
|
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/Ethernet
|
||||||
|
https://github.com/PaulStoffregen/SPI.git
|
||||||
|
https://github.com/knolleary/pubsubclient.git
|
||||||
|
https://github.com/anklimov/Artnet.git
|
||||||
|
FastLED
|
||||||
|
; 161
|
||||||
|
; 322
|
||||||
|
|
||||||
[env:due-5500]
|
[env:due-5500]
|
||||||
platform = atmelsam
|
platform = atmelsam
|
||||||
framework = arduino
|
framework = arduino
|
||||||
|
|||||||
Reference in New Issue
Block a user