mirror of
https://github.com/anklimov/lighthub
synced 2026-01-28 17:19:06 +03:00
Merge pull request #33 from livello/IS-ENC
lib_ignore, build_flags, DHT, counter, domoticz, WITH_PRINTEX_LIB, arduino_arch,
This commit is contained in:
7
.gitignore
vendored
7
.gitignore
vendored
@@ -3,3 +3,10 @@
|
||||
.clang_complete
|
||||
.gcc-flags.json
|
||||
CMakeListsPrivate.txt
|
||||
build_flags_due.sh
|
||||
build_flags_esp32.sh
|
||||
build_flags_esp8266.sh
|
||||
build_flags_stm32.sh
|
||||
build_flags_due-5500.sh
|
||||
build_flags_mega2560.sh
|
||||
build_flags_controllino.sh
|
||||
@@ -151,11 +151,11 @@ platformio device monitor -b 115200
|
||||
* ESP_WIFI_AP=MYAP // esp wifi access point name
|
||||
* ESP_WIFI_PWD=MYPWD // esp wifi access point password
|
||||
* WIFI_MANAGER_DISABLE //Disable wifi manager for esp8266
|
||||
* DHT_DISABLE //disable DHT Input support
|
||||
* DHT_COUNTER_DISABLE //disable DHT, Counter, Uptime input support (for RAM savings on mega2560)
|
||||
* RESTART_LAN_ON_MQTT_ERRORS //reinit LAN if many mqtt errors occured
|
||||
* WITH_STREAMING_LIB use streaming libriary for serial debug output otherwise use PrintEx library
|
||||
* DEVICE_NAME short handy device name which is used instead of mac for download config http://{MY_CONFIG_SERVER}/{DEVICE_NAME}_config.json
|
||||
* SYSLOG_ENABLE enable UDP SYSLOG support feature(under DEVELOPMENT) that must be configured through config file
|
||||
* WITH_PRINTEX_LIB use PrintEx library (develop experimental feature)
|
||||
|
||||
|
||||
|
||||
@@ -176,11 +176,11 @@ platformio device monitor -b 115200
|
||||
* Defailt MQTT input topic: /myhome/in
|
||||
* Default MQTT topic to publish device status: /myhome/s_out
|
||||
* Default Alarm output topic /alarm
|
||||
* DHT support enabled
|
||||
* DHT, Counter, Uptime support enabled
|
||||
* Wifi manager for esp8266 enabled
|
||||
* RESTART_LAN_ON_MQTT_ERRORS disabled
|
||||
* WITH_STREAMING_LIB disabled
|
||||
* DEVICE_NAME disabled
|
||||
* SYSLOG_ENABLE disabled
|
||||
* WITH_PRINTEX_LIB diabled, using Streaming library
|
||||
|
||||
If you've using Arduino IDE to compile & flash firmware, it will use Default options above and you will not able to configure additional compilers options except edit "options.h" file
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
#! /bin/bash
|
||||
# usage:
|
||||
# first make your own copy of template
|
||||
# cp build_flags_template.sh build_flags_ENVNAME.sh
|
||||
# then edit, change or comment something
|
||||
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:ff"
|
||||
# export FLAGS="$FLAGS -DDMX_DISABLE"
|
||||
# export FLAGS="$FLAGS -DARTNET_ENABLE"
|
||||
# export FLAGS="$FLAGS -DMODBUS_DISABLE"
|
||||
# export FLAGS="$FLAGS -DOWIRE_DISABLE"
|
||||
# export FLAGS="$FLAGS -DAVR_DMXOUT_PIN=18"
|
||||
# export FLAGS="$FLAGS -DLAN_INIT_DELAY=2000"
|
||||
# export FLAGS="$FLAGS -DCONTROLLINO"
|
||||
# export FLAGS="$FLAGS -DESP_WIFI_AP=MYAP"
|
||||
# export FLAGS="$FLAGS -DESP_WIFI_PWD=MYPWD"
|
||||
# export FLAGS="$FLAGS -DWIFI_MANAGER_DISABLE"
|
||||
# export FLAGS="$FLAGS -DDHT_DISABLE"
|
||||
# export FLAGS="$FLAGS -DRESET_PIN=5"
|
||||
# export FLAGS="$FLAGS -DDHCP_RETRY_INTERVAL=60000"
|
||||
# export FLAGS="$FLAGS -DRESTART_LAN_ON_MQTT_ERRORS"
|
||||
# export FLAGS="$FLAGS -DW5500_CS_PIN=53"
|
||||
export FLAGS="$FLAGS -DWITH_STREAMING_LIB"
|
||||
export FLAGS="$FLAGS -DPIO_SRC_REV="$(git log --pretty=format:%h_%ad -1 --date=short)
|
||||
echo $FLAGS
|
||||
@@ -1,31 +0,0 @@
|
||||
#! /bin/bash
|
||||
# usage:
|
||||
# first make your own copy of template
|
||||
# cp build_flags_template.sh build_flags_ENVNAME.sh
|
||||
# then edit, change or comment something
|
||||
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:fe"
|
||||
# export FLAGS="$FLAGS -DDMX_DISABLE"
|
||||
# export FLAGS="$FLAGS -DARTNET_ENABLE"
|
||||
# export FLAGS="$FLAGS -DMODBUS_DISABLE"
|
||||
# export FLAGS="$FLAGS -DOWIRE_DISABLE"
|
||||
# export FLAGS="$FLAGS -DAVR_DMXOUT_PIN=18"
|
||||
# export FLAGS="$FLAGS -DLAN_INIT_DELAY=2000"
|
||||
# export FLAGS="$FLAGS -DCONTROLLINO"
|
||||
# export FLAGS="$FLAGS -DESP_WIFI_AP=MYAP"
|
||||
# export FLAGS="$FLAGS -DESP_WIFI_PWD=MYPWD"
|
||||
# export FLAGS="$FLAGS -DWIFI_MANAGER_DISABLE"
|
||||
export FLAGS="$FLAGS -DDHT_DISABLE"
|
||||
# export FLAGS="$FLAGS -DRESET_PIN=5"
|
||||
# export FLAGS="$FLAGS -DDHCP_RETRY_INTERVAL=60000"
|
||||
# export FLAGS="$FLAGS -DRESTART_LAN_ON_MQTT_ERRORS"
|
||||
# export FLAGS="$FLAGS -DW5500_CS_PIN=53"
|
||||
export FLAGS="$FLAGS -DWITH_STREAMING_LIB"
|
||||
export FLAGS="$FLAGS -DPIO_SRC_REV="$(git log --pretty=format:%h_%ad -1 --date=short)
|
||||
echo $FLAGS
|
||||
@@ -1,32 +0,0 @@
|
||||
#! /bin/bash
|
||||
# usage:
|
||||
# first make your own copy of template
|
||||
# cp build_flags_template.sh build_flags_ENVNAME.sh
|
||||
# then edit, change or comment something
|
||||
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:ed"
|
||||
# export FLAGS="$FLAGS -DDMX_DISABLE"
|
||||
# export FLAGS="$FLAGS -DARTNET_ENABLE"
|
||||
# export FLAGS="$FLAGS -DMODBUS_DISABLE"
|
||||
export FLAGS="$FLAGS -DOWIRE_DISABLE"
|
||||
# export FLAGS="$FLAGS -DAVR_DMXOUT_PIN=18"
|
||||
# export FLAGS="$FLAGS -DLAN_INIT_DELAY=2000"
|
||||
# export FLAGS="$FLAGS -DCONTROLLINO"
|
||||
# export FLAGS="$FLAGS -DESP_WIFI_AP=MYAP"
|
||||
# export FLAGS="$FLAGS -DESP_WIFI_PWD=MYPWD"
|
||||
# export FLAGS="$FLAGS -DWIFI_MANAGER_DISABLE"
|
||||
export FLAGS="$FLAGS -DDHT_DISABLE"
|
||||
# export FLAGS="$FLAGS -DRESET_PIN=5"
|
||||
# export FLAGS="$FLAGS -DDHCP_RETRY_INTERVAL=60000"
|
||||
# export FLAGS="$FLAGS -DRESTART_LAN_ON_MQTT_ERRORS"
|
||||
# export FLAGS="$FLAGS -DW5500_CS_PIN=53"
|
||||
# export FLAGS="$FLAGS -DINTERVAL_CHECK_INPUT=20"
|
||||
# export FLAGS="$FLAGS -DMODBUS_DIMMER_PARAM=SERIAL_8N1"
|
||||
export FLAGS="$FLAGS -DPIO_SRC_REV="$(git log --pretty=format:%h_%ad -1 --date=short)
|
||||
echo $FLAGS
|
||||
8
check_custom_build_flags_controllino.sh
Executable file
8
check_custom_build_flags_controllino.sh
Executable file
@@ -0,0 +1,8 @@
|
||||
#! /bin/bash
|
||||
export FLAGS="$FLAGS -DCONTROLLINO"
|
||||
export FLAGS="$FLAGS -DCUSTOM_FIRMWARE_MAC=de:ad:be:ef:fe:07"
|
||||
CUSTOM_BUILD_FLAGS_FILE=custom-build-flags/build_flags_controllino.sh
|
||||
if [ -f $CUSTOM_BUILD_FLAGS_FILE ]; then
|
||||
source $CUSTOM_BUILD_FLAGS_FILE
|
||||
fi
|
||||
echo $FLAGS
|
||||
8
check_custom_build_flags_due-5500.sh
Executable file
8
check_custom_build_flags_due-5500.sh
Executable file
@@ -0,0 +1,8 @@
|
||||
#! /bin/bash
|
||||
export FLAGS="$FLAGS -DWiz5500"
|
||||
export FLAGS="$FLAGS -DARTNET_ENABLE"
|
||||
CUSTOM_BUILD_FLAGS_FILE=custom-build-flags/build_flags_due-5500.sh
|
||||
if [ -f $CUSTOM_BUILD_FLAGS_FILE ]; then
|
||||
source $CUSTOM_BUILD_FLAGS_FILE
|
||||
fi
|
||||
echo $FLAGS
|
||||
6
check_custom_build_flags_due.sh
Executable file
6
check_custom_build_flags_due.sh
Executable file
@@ -0,0 +1,6 @@
|
||||
#! /bin/bash
|
||||
CUSTOM_BUILD_FLAGS_FILE=custom-build-flags/build_flags_due.sh
|
||||
if [ -f $CUSTOM_BUILD_FLAGS_FILE ]; then
|
||||
source $CUSTOM_BUILD_FLAGS_FILE
|
||||
fi
|
||||
echo $FLAGS
|
||||
6
check_custom_build_flags_esp32.sh
Executable file
6
check_custom_build_flags_esp32.sh
Executable file
@@ -0,0 +1,6 @@
|
||||
#! /bin/bash
|
||||
CUSTOM_BUILD_FLAGS_FILE=custom-build-flags/build_flags_esp32.sh
|
||||
if [ -f $CUSTOM_BUILD_FLAGS_FILE ]; then
|
||||
source $CUSTOM_BUILD_FLAGS_FILE
|
||||
fi
|
||||
echo $FLAGS
|
||||
6
check_custom_build_flags_esp8266.sh
Executable file
6
check_custom_build_flags_esp8266.sh
Executable file
@@ -0,0 +1,6 @@
|
||||
#! /bin/bash
|
||||
CUSTOM_BUILD_FLAGS_FILE=custom-build-flags/build_flags_esp8266.sh
|
||||
if [ -f $CUSTOM_BUILD_FLAGS_FILE ]; then
|
||||
source $CUSTOM_BUILD_FLAGS_FILE
|
||||
fi
|
||||
echo $FLAGS
|
||||
6
check_custom_build_flags_mega2560-net.sh
Executable file
6
check_custom_build_flags_mega2560-net.sh
Executable file
@@ -0,0 +1,6 @@
|
||||
#! /bin/bash
|
||||
CUSTOM_BUILD_FLAGS_FILE=custom-build-flags/build_flags_mega2560-net.sh
|
||||
if [ -f $CUSTOM_BUILD_FLAGS_FILE ]; then
|
||||
source $CUSTOM_BUILD_FLAGS_FILE
|
||||
fi
|
||||
echo $FLAGS
|
||||
9
check_custom_build_flags_mega2560.sh
Executable file
9
check_custom_build_flags_mega2560.sh
Executable file
@@ -0,0 +1,9 @@
|
||||
#! /bin/bash
|
||||
CUSTOM_BUILD_FLAGS_FILE="custom-build-flags/build_flags_mega2560.sh"
|
||||
#CUSTOM_BUILD_FLAGS_FILE="custom-build-flags/build_flags_$PIOENV.sh"
|
||||
#echo $PIOENV > custom-build-flags/1.txt
|
||||
#TODO: make one file for all envs
|
||||
if [ -f $CUSTOM_BUILD_FLAGS_FILE ]; then
|
||||
source $CUSTOM_BUILD_FLAGS_FILE
|
||||
fi
|
||||
echo $FLAGS
|
||||
6
check_custom_build_flags_stm32.sh
Executable file
6
check_custom_build_flags_stm32.sh
Executable file
@@ -0,0 +1,6 @@
|
||||
#! /bin/bash
|
||||
CUSTOM_BUILD_FLAGS_FILE=custom-build-flags/build_flags_stm32.sh
|
||||
if [ -f $CUSTOM_BUILD_FLAGS_FILE ]; then
|
||||
source $CUSTOM_BUILD_FLAGS_FILE
|
||||
fi
|
||||
echo $FLAGS
|
||||
31
custom-build-flags/build_flags_controllino.sh
Executable file
31
custom-build-flags/build_flags_controllino.sh
Executable file
@@ -0,0 +1,31 @@
|
||||
#! /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=lighthub.elistech.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=C2:3E:1f:03:1B:1E"
|
||||
# export FLAGS="$FLAGS -DDMX_DISABLE"
|
||||
# export FLAGS="$FLAGS -DMODBUS_DISABLE"
|
||||
# export FLAGS="$FLAGS -DOWIRE_DISABLE"
|
||||
#export FLAGS="$FLAGS -DAVR_DMXOUT_PIN=18"
|
||||
#export FLAGS="$FLAGS -DCONTROLLINO"
|
||||
# export FLAGS="$FLAGS -DRESET_PIN=8"
|
||||
export FLAGS="$FLAGS -DLAN_INIT_DELAY=2000"
|
||||
# export FLAGS="$FLAGS -DESP_WIFI_AP=vent"
|
||||
# export FLAGS="$FLAGS -DESP_WIFI_PWD=kk007remont"
|
||||
# export FLAGS="$FLAGS -DSYSLOG_ENABLE"
|
||||
export FLAGS="$FLAGS -DDEVICE_NAME=kk007_mega2560"
|
||||
export FLAGS="$FLAGS -DDHT_COUNTER_DISABLE"
|
||||
#export FLAGS="$FLAGS -DWITH_DOMOTICZ"
|
||||
#export FLAGS="$FLAGS -DWITH_PRINTEX_LIB"
|
||||
export FLAGS="$FLAGS -DPIO_SRC_REV="$(git log --pretty=format:%h_%ad -1 --date=short)
|
||||
@@ -20,12 +20,13 @@
|
||||
# export FLAGS="$FLAGS -DESP_WIFI_AP=MYAP"
|
||||
# export FLAGS="$FLAGS -DESP_WIFI_PWD=MYPWD"
|
||||
# export FLAGS="$FLAGS -DWIFI_MANAGER_DISABLE"
|
||||
# export FLAGS="$FLAGS -DDHT_DISABLE"
|
||||
# export FLAGS="$FLAGS -DRESET_PIN=5"
|
||||
# export FLAGS="$FLAGS -DDHCP_RETRY_INTERVAL=60000"
|
||||
# export FLAGS="$FLAGS -DRESTART_LAN_ON_MQTT_ERRORS"
|
||||
# export FLAGS="$FLAGS -DW5500_CS_PIN=53"
|
||||
#export FLAGS="$FLAGS -DSYSLOG_ENABLE"
|
||||
#export FLAGS="$FLAGS -DDEVICE_NAME=MYDEVICE"
|
||||
#export FLAGS="$FLAGS -DDHT_COUNTER_DISABLE"
|
||||
#export FLAGS="$FLAGS -DWITH_PRINTEX_LIB"
|
||||
export FLAGS="$FLAGS -DPIO_SRC_REV="$(git log --pretty=format:%h_%ad -1 --date=short)
|
||||
echo $FLAGS
|
||||
@@ -23,7 +23,7 @@ e-mail anklimov@gmail.com
|
||||
#include "options.h"
|
||||
|
||||
#ifdef _dmxin
|
||||
#if defined(__AVR__)
|
||||
#if defined(ARDUINO_ARCH_AVR)
|
||||
#include <DMXSerial.h>
|
||||
#endif
|
||||
#endif
|
||||
@@ -207,7 +207,7 @@ void DMXinSetup(int channels)
|
||||
|
||||
#if defined(_dmxin)
|
||||
DMXin = new uint8_t [channels];
|
||||
#if defined(__AVR__)
|
||||
#if defined(ARDUINO_ARCH_AVR)
|
||||
DMXSerial.init(DMXReceiver,0,channels);
|
||||
if (DMXSerial.getBuffer()) {Serial.print(F("Init in ch:"));Serial.println(channels);} else Serial.println(F("DMXin Buffer alloc err"));
|
||||
//DMXSerial.maxChannel(channels);
|
||||
@@ -230,7 +230,7 @@ dmxin.begin();
|
||||
void DMXoutSetup(int channels)
|
||||
{
|
||||
#ifdef _dmxout
|
||||
#if defined(__AVR__)
|
||||
#if defined(ARDUINO_ARCH_AVR)
|
||||
DmxSimple.usePin(AVR_DMXOUT_PIN);
|
||||
DmxSimple.maxChannel(channels);
|
||||
#endif
|
||||
|
||||
@@ -33,7 +33,7 @@ e-mail anklimov@gmail.com
|
||||
|
||||
#if defined(_dmxout)
|
||||
|
||||
#if defined(__AVR__)
|
||||
#if defined(ARDUINO_ARCH_AVR)
|
||||
#include <DmxSimple.h>
|
||||
#define DmxWrite DmxSimple.write
|
||||
#endif
|
||||
@@ -56,7 +56,7 @@ extern Artnet *artnet;
|
||||
#endif
|
||||
|
||||
#ifdef _dmxin
|
||||
#if defined(__AVR__)
|
||||
#if defined(ARDUINO_ARCH_AVR)
|
||||
#include <DMXSerial.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -23,9 +23,10 @@ e-mail anklimov@gmail.com
|
||||
#include "utils.h"
|
||||
#include <PubSubClient.h>
|
||||
|
||||
#ifndef DHT_DISABLE
|
||||
#if defined(ESP8266) || defined(ARDUINO_ARCH_ESP32)
|
||||
#ifndef DHT_COUNTER_DISABLE
|
||||
#if defined(ARDUINO_ARCH_ESP8266) || defined(ARDUINO_ARCH_ESP32)
|
||||
#include <DHTesp.h>
|
||||
|
||||
#else
|
||||
#include "DHT.h"
|
||||
#endif
|
||||
@@ -33,14 +34,14 @@ e-mail anklimov@gmail.com
|
||||
|
||||
extern PubSubClient mqttClient;
|
||||
|
||||
#ifndef DHT_COUNTER_DISABLE
|
||||
static volatile unsigned long nextPollMillisValue[5];
|
||||
static volatile int nextPollMillisPin[5] = {0,0,0,0,0};
|
||||
|
||||
#if defined(__AVR__)
|
||||
#if defined(ARDUINO_ARCH_AVR)
|
||||
static volatile long counter_value[6];
|
||||
#endif
|
||||
|
||||
#if defined(ESP8266)
|
||||
#if defined(ARDUINO_ARCH_ESP8266)
|
||||
static volatile long counter_value[6];
|
||||
#endif
|
||||
|
||||
@@ -53,6 +54,9 @@ static short counter_irq_map[54];
|
||||
static long counter_value[54];
|
||||
static int counters_count;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
Input::Input(char * name) //Constructor
|
||||
{
|
||||
if (name)
|
||||
@@ -87,31 +91,24 @@ void Input::Parse()
|
||||
store = NULL;
|
||||
inType = 0;
|
||||
pin = 0;
|
||||
|
||||
if (inputObj && (inputObj->type == aJson_Object)) {
|
||||
aJsonObject *s;
|
||||
|
||||
s = aJson.getObjectItem(inputObj, "T");
|
||||
if (s) inType = static_cast<uint8_t>(s->valueint);
|
||||
|
||||
pin = static_cast<uint8_t>(atoi(inputObj->name));
|
||||
|
||||
s = aJson.getObjectItem(inputObj, "S");
|
||||
if (!s) {
|
||||
Serial.print(F("In: "));
|
||||
Serial.print(pin);
|
||||
Serial.print(F("/"));
|
||||
Serial.println(inType);
|
||||
debugSerial<<F("In: ")<<pin<<F("/")<<inType<<endl;
|
||||
aJson.addNumberToObject(inputObj, "S", 0);
|
||||
s = aJson.getObjectItem(inputObj, "S");
|
||||
}
|
||||
|
||||
if (s) store = (inStore *) &s->valueint;
|
||||
}
|
||||
}
|
||||
|
||||
int Input::poll() {
|
||||
if (!isValid()) return -1;
|
||||
#ifndef DHT_COUNTER_DISABLE
|
||||
if (inType & IN_DHT22)
|
||||
dht22Poll();
|
||||
else if (inType & IN_COUNTER)
|
||||
@@ -121,13 +118,16 @@ int Input::poll() {
|
||||
else
|
||||
contactPoll();
|
||||
return 0;
|
||||
#endif
|
||||
contactPoll();
|
||||
}
|
||||
|
||||
#ifndef DHT_COUNTER_DISABLE
|
||||
void Input::counterPoll() {
|
||||
if(nextPollTime()>millis())
|
||||
return;
|
||||
if (store->logicState == 0) {
|
||||
#if defined(__AVR__)
|
||||
#if defined(ARDUINO_ARCH_AVR)
|
||||
#define interrupt_number pin
|
||||
if (interrupt_number >= 0 && interrupt_number < 6) {
|
||||
const short mega_interrupt_array[6] = {2, 3, 21, 20, 19, 18};
|
||||
@@ -150,7 +150,7 @@ void Input::counterPoll() {
|
||||
return;
|
||||
}
|
||||
long counterValue = counter_value[pin];
|
||||
Serial.print(F("IN:"));Serial.print(pin);Serial.print(F(" Counter type. val="));Serial.print(counterValue);
|
||||
debugSerial<<F("IN:")<<(pin)<<F(" Counter type. val=")<<counterValue;
|
||||
|
||||
aJsonObject *emit = aJson.getObjectItem(inputObj, "emit");
|
||||
if (emit) {
|
||||
@@ -160,16 +160,18 @@ void Input::counterPoll() {
|
||||
sprintf(valstr, "%d", counterValue);
|
||||
mqttClient.publish(addrstr, valstr);
|
||||
setNextPollTime(millis() + DHT_POLL_DELAY_DEFAULT);
|
||||
Serial.print(F(" NextPollMillis="));Serial.println(nextPollTime());
|
||||
debugSerial<<F(" NextPollMillis=")<<nextPollTime();
|
||||
}
|
||||
else
|
||||
Serial.print(F(" No emit data!"));
|
||||
debugSerial<<F(" No emit data!");
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef DHT_COUNTER_DISABLE
|
||||
void Input::attachInterruptPinIrq(int realPin, int irq) {
|
||||
pinMode(realPin, INPUT);
|
||||
int real_irq;
|
||||
#if defined(__AVR__)
|
||||
#if defined(ARDUINO_ARCH_AVR)
|
||||
real_irq = irq;
|
||||
#endif
|
||||
#if defined(__SAM3X8E__)
|
||||
@@ -200,32 +202,39 @@ void Input::attachInterruptPinIrq(int realPin, int irq) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Input::dht22Poll() {
|
||||
#ifndef DHT_DISABLE
|
||||
if(nextPollTime()>millis())
|
||||
if (nextPollTime() > millis())
|
||||
return;
|
||||
#if defined(ESP8266) || defined(ARDUINO_ARCH_ESP32)
|
||||
#if defined(ARDUINO_ARCH_ESP8266) || defined(ARDUINO_ARCH_ESP32)
|
||||
DHTesp dhtSensor;
|
||||
dhtSensor.setup(pin, DHTesp::DHT22);
|
||||
TempAndHumidity dhtSensorData = dhtSensor.getTempAndHumidity();
|
||||
float temp = dhtSensorData.temperature;
|
||||
float humidity = dhtSensorData.humidity;
|
||||
float temp = roundf(dhtSensorData.temperature * 10) / 10;
|
||||
float humidity = roundf(dhtSensorData.humidity);
|
||||
#else
|
||||
DHT dht(pin, DHT22);
|
||||
float temp = dht.readTemperature();
|
||||
float humidity = dht.readHumidity();
|
||||
#endif
|
||||
aJsonObject *emit = aJson.getObjectItem(inputObj, "emit");
|
||||
Serial.print(F("IN:"));
|
||||
Serial.print(pin);
|
||||
Serial.print(F(" DHT22 type. T="));
|
||||
Serial.print(temp);
|
||||
Serial.print(F("°C H="));
|
||||
Serial.print(humidity);
|
||||
Serial.print(F("%"));
|
||||
debugSerial << F("IN:") << pin << F(" DHT22 type. T=") << temp << F("°C H=") << humidity << F("%");
|
||||
if (emit && temp && humidity && temp == temp && humidity == humidity) {
|
||||
char valstr[10];
|
||||
char addrstr[100] = "";
|
||||
#ifdef WITH_DOMOTICZ
|
||||
aJsonObject *idx = aJson.getObjectItem(inputObj, "idx");
|
||||
if (idx && idx->valuestring) {//DOMOTICZ json format support
|
||||
debugSerial << endl << idx->valuestring << F(" Domoticz valstr:");
|
||||
char valstr[50];
|
||||
sprintf(valstr, "{\"idx\":%s,\"svalue\":\"%.1f;%.0f;0\"}", idx->valuestring, temp, humidity);
|
||||
debugSerial << valstr;
|
||||
mqttClient.publish(emit->valuestring, valstr);
|
||||
setNextPollTime(millis() + DHT_POLL_DELAY_DEFAULT);
|
||||
debugSerial << F(" NextPollMillis=") << nextPollTime() << endl;
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
char valstr[10];
|
||||
strcat(addrstr, emit->valuestring);
|
||||
strcat(addrstr, "T");
|
||||
printFloatValueToStr(temp, valstr);
|
||||
@@ -233,12 +242,11 @@ void Input::dht22Poll() {
|
||||
addrstr[strlen(addrstr) - 1] = 'H';
|
||||
printFloatValueToStr(humidity, valstr);
|
||||
mqttClient.publish(addrstr, valstr);
|
||||
|
||||
setNextPollTime(millis() + DHT_POLL_DELAY_DEFAULT);
|
||||
Serial.print(" NextPollMillis=");
|
||||
Serial.println(nextPollTime());
|
||||
debugSerial << F(" NextPollMillis=") << nextPollTime() << endl;
|
||||
} else
|
||||
setNextPollTime(millis() + DHT_POLL_DELAY_DEFAULT / 3);
|
||||
#endif
|
||||
}
|
||||
|
||||
unsigned long Input::nextPollTime() const {
|
||||
@@ -253,6 +261,7 @@ unsigned long Input::nextPollTime() const {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void Input::setNextPollTime(unsigned long pollTime) {
|
||||
for (int i = 0; i < 5; i++) {
|
||||
if (nextPollMillisPin[i] == pin) {
|
||||
@@ -266,6 +275,50 @@ void Input::setNextPollTime(unsigned long pollTime) {
|
||||
}
|
||||
}
|
||||
|
||||
void Input::uptimePoll() {
|
||||
if(nextPollTime()>millis())
|
||||
return;
|
||||
aJsonObject *emit = aJson.getObjectItem(inputObj, "emit");
|
||||
if (emit) {
|
||||
char valstr[11];
|
||||
// printUlongValueToStr(valstr,millis());
|
||||
printUlongValueToStr(valstr,millis());
|
||||
mqttClient.publish(emit->valuestring, valstr);
|
||||
}
|
||||
setNextPollTime(millis() +UPTIME_POLL_DELAY_DEFAULT);
|
||||
}
|
||||
|
||||
void Input::onCounterChanged(int i) {
|
||||
#if defined(__SAM3X8E__)
|
||||
counter_value[counter_irq_map[i]]++;
|
||||
#endif
|
||||
|
||||
#if defined(ARDUINO_ARCH_AVR)
|
||||
counter_value[i]++;
|
||||
#endif
|
||||
}
|
||||
|
||||
void Input::onCounterChanged0() {
|
||||
onCounterChanged(0);
|
||||
}
|
||||
void Input::onCounterChanged1() {
|
||||
onCounterChanged(1);
|
||||
}
|
||||
void Input::onCounterChanged2() {
|
||||
onCounterChanged(2);
|
||||
}
|
||||
void Input::onCounterChanged3() {
|
||||
onCounterChanged(3);
|
||||
}
|
||||
void Input::onCounterChanged4() {
|
||||
onCounterChanged(4);
|
||||
}
|
||||
void Input::onCounterChanged5() {
|
||||
onCounterChanged(5);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
void Input::contactPoll() {
|
||||
@@ -273,7 +326,7 @@ void Input::contactPoll() {
|
||||
#if defined(ARDUINO_ARCH_STM32F1)
|
||||
WiringPinMode inputPinMode;
|
||||
#endif
|
||||
#if defined(__SAM3X8E__)||defined(__AVR__)||defined(ESP8266)||defined(ARDUINO_ARCH_ESP32)
|
||||
#if defined(__SAM3X8E__)||defined(ARDUINO_ARCH_AVR)||defined(ARDUINO_ARCH_ESP8266)||defined(ARDUINO_ARCH_ESP32)
|
||||
uint32_t inputPinMode;
|
||||
#endif
|
||||
|
||||
@@ -307,85 +360,54 @@ void Input::contactPoll() {
|
||||
store->bounce = SAME_STATE_ATTEMPTS;
|
||||
}
|
||||
|
||||
void Input::uptimePoll() {
|
||||
if(nextPollTime()>millis())
|
||||
return;
|
||||
|
||||
|
||||
void Input::onContactChanged(int newValue) {
|
||||
debugSerial << F("IN:") << (pin) << F("=") << newValue << endl;
|
||||
aJsonObject *item = aJson.getObjectItem(inputObj, "item");
|
||||
aJsonObject *scmd = aJson.getObjectItem(inputObj, "scmd");
|
||||
aJsonObject *rcmd = aJson.getObjectItem(inputObj, "rcmd");
|
||||
aJsonObject *emit = aJson.getObjectItem(inputObj, "emit");
|
||||
if (emit) {
|
||||
char valstr[11];
|
||||
// printUlongValueToStr(valstr,millis());
|
||||
printUlongValueToStr(valstr,millis());
|
||||
mqttClient.publish(emit->valuestring, valstr);
|
||||
#ifdef WITH_DOMOTICZ
|
||||
aJsonObject *idx = aJson.getObjectItem(inputObj, "idx");
|
||||
if (idx->valuestring) {
|
||||
debugSerial << endl << idx->valuestring << F(" Domoticz valstr:");
|
||||
char valstr[80];
|
||||
char *switchCmd;
|
||||
(newValue)? sprintf(valstr, "{\"command\":\"switchlight\",\"idx\":%s,\"switchcmd\":\"On\"}", idx->valuestring)
|
||||
: sprintf(valstr,"{\"command\":\"switchlight\",\"idx\":%s,\"switchcmd\":\"Off\"}",idx->valuestring);
|
||||
debugSerial << valstr;
|
||||
mqttClient.publish(emit->valuestring, valstr);
|
||||
} else
|
||||
#endif
|
||||
if (newValue) { //send set command
|
||||
if (!scmd) mqttClient.publish(emit->valuestring, "ON", true);
|
||||
else if (strlen(scmd->valuestring))
|
||||
mqttClient.publish(emit->valuestring, scmd->valuestring, true);
|
||||
} else { //send reset command
|
||||
if (!rcmd) mqttClient.publish(emit->valuestring, "OFF", true);
|
||||
else if (strlen(rcmd->valuestring))mqttClient.publish(emit->valuestring, rcmd->valuestring, true);
|
||||
}
|
||||
}
|
||||
setNextPollTime(millis() +UPTIME_POLL_DELAY_DEFAULT);
|
||||
}
|
||||
|
||||
void Input::onContactChanged(int val)
|
||||
{
|
||||
Serial.print(F("IN:")); Serial.print(pin);Serial.print(F("="));Serial.println(val);
|
||||
aJsonObject * item = aJson.getObjectItem(inputObj,"item");
|
||||
aJsonObject * scmd = aJson.getObjectItem(inputObj,"scmd");
|
||||
aJsonObject * rcmd = aJson.getObjectItem(inputObj,"rcmd");
|
||||
aJsonObject * emit = aJson.getObjectItem(inputObj,"emit");
|
||||
|
||||
if (emit)
|
||||
{
|
||||
|
||||
if (val)
|
||||
{ //send set command
|
||||
if (!scmd) mqttClient.publish(emit->valuestring,"ON",true); else if (strlen(scmd->valuestring)) mqttClient.publish(emit->valuestring,scmd->valuestring,true);
|
||||
if (item) {
|
||||
Item it(item->valuestring);
|
||||
if (it.isValid()) {
|
||||
if (newValue) { //send set command
|
||||
if (!scmd) it.Ctrl(CMD_ON, 0, NULL, true);
|
||||
else if (strlen(scmd->valuestring))
|
||||
it.Ctrl(scmd->valuestring, true);
|
||||
} else { //send reset command
|
||||
if (!rcmd) it.Ctrl(CMD_OFF, 0, NULL, true);
|
||||
else if (strlen(rcmd->valuestring))
|
||||
it.Ctrl(rcmd->valuestring, true);
|
||||
}
|
||||
else
|
||||
{ //send reset command
|
||||
if (!rcmd) mqttClient.publish(emit->valuestring,"OFF",true); else if (strlen(rcmd->valuestring)) mqttClient.publish(emit->valuestring,rcmd->valuestring,true);
|
||||
}
|
||||
}
|
||||
|
||||
if (item)
|
||||
{
|
||||
Item it(item->valuestring);
|
||||
if (it.isValid())
|
||||
{
|
||||
if (val)
|
||||
{ //send set command
|
||||
if (!scmd) it.Ctrl(CMD_ON,0,NULL,true); else if (strlen(scmd->valuestring)) it.Ctrl(scmd->valuestring,true);
|
||||
}
|
||||
else
|
||||
{ //send reset command
|
||||
if (!rcmd) it.Ctrl(CMD_OFF,0,NULL,true); else if (strlen(rcmd->valuestring)) it.Ctrl(rcmd->valuestring,true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Input::onCounterChanged(int i) {
|
||||
#if defined(__SAM3X8E__)
|
||||
counter_value[counter_irq_map[i]]++;
|
||||
#endif
|
||||
|
||||
#if defined(__AVR__)
|
||||
counter_value[i]++;
|
||||
#endif
|
||||
}
|
||||
|
||||
void Input::onCounterChanged0() {
|
||||
onCounterChanged(0);
|
||||
}
|
||||
void Input::onCounterChanged1() {
|
||||
onCounterChanged(1);
|
||||
}
|
||||
void Input::onCounterChanged2() {
|
||||
onCounterChanged(2);
|
||||
}
|
||||
void Input::onCounterChanged3() {
|
||||
onCounterChanged(3);
|
||||
}
|
||||
void Input::onCounterChanged4() {
|
||||
onCounterChanged(4);
|
||||
}
|
||||
void Input::onCounterChanged5() {
|
||||
onCounterChanged(5);
|
||||
}
|
||||
|
||||
void Input::printUlongValueToStr(char *valstr, unsigned long value) {
|
||||
char buf[11];
|
||||
|
||||
@@ -91,7 +91,7 @@ public:
|
||||
|
||||
boolean isValid();
|
||||
|
||||
void onContactChanged(int val);
|
||||
void onContactChanged(int newValue);
|
||||
|
||||
int poll();
|
||||
|
||||
|
||||
@@ -891,7 +891,7 @@ int Item::VacomSetHeat(int addr, int8_t val, int8_t cmd) {
|
||||
int Item::modbusDimmerSet(int addr, uint16_t _reg, int _regType, int _mask, uint16_t value) {
|
||||
|
||||
if (_regType != MODBUS_COIL_REG_TYPE || _regType != MODBUS_HOLDING_REG_TYPE) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (modbusBusy) {
|
||||
@@ -933,7 +933,7 @@ int Item::modbusDimmerSet(int addr, uint16_t _reg, int _regType, int _mask, uint
|
||||
default:
|
||||
Serial.println(F("Not supported reg type"));
|
||||
}
|
||||
|
||||
|
||||
modbusBusy = 0;
|
||||
}
|
||||
|
||||
@@ -1051,7 +1051,7 @@ boolean Item::checkModbusRetry() {
|
||||
if (cmd & CMD_RETRY) { // if last sending attempt of command was failed
|
||||
int val = getVal();
|
||||
Serial.println(F("Retrying CMD"));
|
||||
|
||||
|
||||
cmd &= ~CMD_RETRY; // Clean retry flag
|
||||
Ctrl(cmd,1,&val); // Execute command again
|
||||
return true;
|
||||
@@ -1062,13 +1062,13 @@ return false;
|
||||
int Item::checkModbusDimmer() {
|
||||
if (modbusBusy) return -1;
|
||||
if (checkModbusRetry()) return -2;
|
||||
|
||||
|
||||
short numpar = 0;
|
||||
if ((itemArg->type != aJson_Array) || ((numpar = aJson.getArraySize(itemArg)) < 2)) {
|
||||
Serial.println(F("Illegal arguments"));
|
||||
return -3;
|
||||
}
|
||||
|
||||
|
||||
modbusBusy = 1;
|
||||
|
||||
uint8_t result;
|
||||
|
||||
@@ -68,20 +68,13 @@ PWM Out
|
||||
#include "main.h"
|
||||
#include "options.h"
|
||||
#include "utils.h"
|
||||
#ifdef WITH_STREAMING_LIB
|
||||
#include "Streaming.h"
|
||||
#else
|
||||
#include "PrintEx.h"
|
||||
using namespace ios;
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(__SAM3X8E__)
|
||||
DueFlashStorage EEPROM;
|
||||
EthernetClient ethClient;
|
||||
#endif
|
||||
|
||||
#if defined(__AVR__)
|
||||
#if defined(ARDUINO_ARCH_AVR)
|
||||
EthernetClient ethClient;
|
||||
#endif
|
||||
|
||||
@@ -209,20 +202,20 @@ void mqttCallback(char *topic, byte *payload, unsigned int length) {
|
||||
|
||||
void printIPAddress(IPAddress ipAddress) {
|
||||
for (byte i = 0; i < 4; i++)
|
||||
#ifdef WITH_STREAMING_LIB
|
||||
(i < 3) ? debugSerial << _DEC(ipAddress[i]) << F(".") : debugSerial << _DEC(ipAddress[i]) << F(", ");
|
||||
#else
|
||||
#ifdef WITH_PRINTEX_LIB
|
||||
(i < 3) ? debugSerial << (ipAddress[i]) << F(".") : debugSerial << (ipAddress[i])<<F(", ");
|
||||
#else
|
||||
(i < 3) ? debugSerial << _DEC(ipAddress[i]) << F(".") : debugSerial << _DEC(ipAddress[i]) << F(", ");
|
||||
#endif
|
||||
}
|
||||
|
||||
void printMACAddress() {
|
||||
debugSerial<<F("Configured MAC:");
|
||||
for (byte i = 0; i < 6; i++)
|
||||
#ifdef WITH_STREAMING_LIB
|
||||
(i < 5) ?debugSerial<<_HEX(mac[i])<<F(":"):debugSerial<<_HEX(mac[i])<<endl;
|
||||
#else
|
||||
#ifdef WITH_PRINTEX_LIB
|
||||
(i < 5) ?debugSerial<<hex <<(mac[i])<<F(":"):debugSerial<<hex<<(mac[i])<<endl;
|
||||
#else
|
||||
(i < 5) ?debugSerial<<_HEX(mac[i])<<F(":"):debugSerial<<_HEX(mac[i])<<endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -299,7 +292,7 @@ lan_status lanLoop() {
|
||||
|
||||
|
||||
{
|
||||
#if defined(__AVR__) || defined(__SAM3X8E__)
|
||||
#if defined(ARDUINO_ARCH_AVR) || defined(__SAM3X8E__)
|
||||
wdt_dis();
|
||||
if (lanStatus > 0)
|
||||
switch (Ethernet.maintain()) {
|
||||
@@ -445,17 +438,14 @@ void onInitialStateInitLAN() {
|
||||
if(!wifiInitialized) {
|
||||
WiFi.mode(WIFI_STA);
|
||||
WiFi.disconnect();
|
||||
debugSerial<<F("WIFI AP/Password:"));
|
||||
debugSerial<<QUOTE(ESP_WIFI_AP));
|
||||
debugSerial<<F("/"));
|
||||
debugSerial<<QUOTE(ESP_WIFI_PWD));
|
||||
debugSerial<<F("WIFI AP/Password:")<<QUOTE(ESP_WIFI_AP)<<F("/")<<QUOTE(ESP_WIFI_PWD);
|
||||
WiFi.begin(QUOTE(ESP_WIFI_AP), QUOTE(ESP_WIFI_PWD));
|
||||
|
||||
int wifi_connection_wait = 10000;
|
||||
while (WiFi.status() != WL_CONNECTED && wifi_connection_wait > 0) {
|
||||
delay(500);
|
||||
wifi_connection_wait -= 500;
|
||||
debugSerial<<".");
|
||||
debugSerial<<".";
|
||||
}
|
||||
wifiInitialized = true;
|
||||
}
|
||||
@@ -463,18 +453,16 @@ void onInitialStateInitLAN() {
|
||||
|
||||
#if defined(ARDUINO_ARCH_ESP32) || defined(ARDUINO_ARCH_ESP8266)
|
||||
if (WiFi.status() == WL_CONNECTED) {
|
||||
debugSerial<<F("WiFi connected. IP address: ");
|
||||
debugSerial<<WiFi.localIP();
|
||||
debugSerial<<F("WiFi connected. IP address: ")<<WiFi.localIP();
|
||||
lanStatus = HAVE_IP_ADDRESS;//1;
|
||||
} else
|
||||
{
|
||||
|
||||
debugSerial<<F("Problem with WiFi!");
|
||||
nextLanCheckTime = millis() + DHCP_RETRY_INTERVAL/5;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(__AVR__) || defined(__SAM3X8E__)||defined(ARDUINO_ARCH_STM32F1)
|
||||
#if defined(ARDUINO_ARCH_AVR) || defined(__SAM3X8E__)||defined(ARDUINO_ARCH_STM32F1)
|
||||
#ifdef W5500_CS_PIN
|
||||
Ethernet.w5500_cspin = W5500_CS_PIN;
|
||||
debugSerial<<F("Use W5500 pin: ");
|
||||
@@ -505,7 +493,7 @@ void onInitialStateInitLAN() {
|
||||
else {
|
||||
debugSerial<<"\nNo IP data found in flash\n";
|
||||
wdt_dis();
|
||||
#if defined(__AVR__) || defined(__SAM3X8E__)
|
||||
#if defined(ARDUINO_ARCH_AVR) || defined(__SAM3X8E__)
|
||||
res = Ethernet.begin(mac, 12000);
|
||||
#endif
|
||||
#if defined(ARDUINO_ARCH_STM32F1)
|
||||
@@ -537,7 +525,7 @@ void softRebootFunc() {
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(__AVR__) || defined(__SAM3X8E__)
|
||||
#if defined(ARDUINO_ARCH_AVR) || defined(__SAM3X8E__)
|
||||
void (*softRebootFunc)(void) = 0;
|
||||
|
||||
void printCurentLanConfig();
|
||||
@@ -926,7 +914,7 @@ lan_status loadConfigFromHttp(int arg_cnt, char **args)
|
||||
#endif
|
||||
debugSerial<<F("Config URI: http://")<<configServer<<URI<<eol;
|
||||
|
||||
#if defined(__AVR__)
|
||||
#if defined(ARDUINO_ARCH_AVR)
|
||||
FILE *configStream;
|
||||
//byte hserver[] = { 192,168,88,2 };
|
||||
wdt_dis();
|
||||
@@ -1171,10 +1159,10 @@ void printFirmwareVersionAndBuildOptions() {
|
||||
#else
|
||||
debugSerial<<F("\n(+)OWIRE");
|
||||
#endif
|
||||
#ifndef DHT_DISABLE
|
||||
debugSerial<<F("\n(+)DHT");
|
||||
#ifndef DHT_COUNTER_DISABLE
|
||||
debugSerial<<F("\n(+)DHT COUNTER");
|
||||
#else
|
||||
debugSerial<<F("\n(-)DHT");
|
||||
debugSerial<<F("\n(-)DHT COUNTER");
|
||||
#endif
|
||||
|
||||
#ifdef SD_CARD_INSERTED
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
//#define wdt_en()
|
||||
//#define wdt_dis()
|
||||
//#endif
|
||||
#if defined(__AVR__)
|
||||
#if defined(ARDUINO_ARCH_AVR)
|
||||
#if defined(WATCH_DOG_TICKER_DISABLE)
|
||||
#define wdt_en() wdt_disable()
|
||||
#define wdt_dis() wdt_disable()
|
||||
@@ -75,7 +75,7 @@
|
||||
#include <ArduinoHttpClient.h>
|
||||
#endif
|
||||
|
||||
#if defined(__AVR__)
|
||||
#if defined(ARDUINO_ARCH_AVR)
|
||||
#include "HTTPClient.h"
|
||||
#include <avr/pgmspace.h>
|
||||
#include <avr/wdt.h>
|
||||
@@ -104,7 +104,7 @@
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(__AVR__) || defined(__SAM3X8E__) || defined(ESP8266)
|
||||
#if defined(ARDUINO_ARCH_AVR) || defined(__SAM3X8E__) || defined(ESP8266)
|
||||
#ifdef Wiz5500
|
||||
#include <Ethernet2.h>
|
||||
#else
|
||||
|
||||
@@ -101,7 +101,7 @@
|
||||
#define LAN_INIT_DELAY 500
|
||||
#endif
|
||||
|
||||
#if defined(__AVR__)
|
||||
#if defined(ARDUINO_ARCH_AVR)
|
||||
//All options available
|
||||
#ifdef CONTROLLINO
|
||||
#define modbusSerial Serial3
|
||||
@@ -121,7 +121,6 @@
|
||||
#if defined(ARDUINO_ARCH_ESP8266)
|
||||
#undef _dmxin
|
||||
#undef _modbus
|
||||
#define WITH_STREAMING_LIB
|
||||
|
||||
#ifndef DMX_DISABLE
|
||||
#define _espdmx
|
||||
@@ -129,6 +128,9 @@
|
||||
#define modbusSerial Serial1
|
||||
#endif
|
||||
|
||||
#if defined(ARDUINO_ARCH_ESP32)
|
||||
#endif
|
||||
|
||||
#ifndef _dmxout
|
||||
#undef _artnet
|
||||
#endif
|
||||
|
||||
@@ -86,7 +86,7 @@ unsigned long freeRam ()
|
||||
{return system_get_free_heap_size();}
|
||||
#endif
|
||||
|
||||
#if defined(__AVR__)
|
||||
#if defined(ARDUINO_ARCH_AVR)
|
||||
unsigned long freeRam ()
|
||||
{
|
||||
extern int __heap_start, *__brkval;
|
||||
@@ -141,7 +141,7 @@ void printFloatValueToStr(float value, char *valstr) {
|
||||
#if defined(ESP8266) || defined(ARDUINO_ARCH_ESP32)
|
||||
sprintf(valstr, "%2.1f", value);
|
||||
#endif
|
||||
#if defined(__AVR__)
|
||||
#if defined(ARDUINO_ARCH_AVR)
|
||||
sprintf(valstr, "%d", (int)value);
|
||||
int fractional = 10.0*((float)abs(value)-(float)abs((int)value));
|
||||
int val_len =strlen(valstr);
|
||||
|
||||
@@ -24,6 +24,13 @@ e-mail anklimov@gmail.com
|
||||
#define VAR_NAME_VALUE(var) #var "=" VALUE(var)
|
||||
|
||||
#include <Arduino.h>
|
||||
#include "options.h"
|
||||
#ifdef WITH_PRINTEX_LIB
|
||||
#include "PrintEx.h"
|
||||
using namespace ios;
|
||||
#else
|
||||
#include "Streaming.h"
|
||||
#endif
|
||||
|
||||
void PrintBytes(uint8_t* addr, uint8_t count, bool newline);
|
||||
void SetBytes(uint8_t* addr, uint8_t count, char * out);
|
||||
|
||||
2
mosquitto_examples.sh
Normal file
2
mosquitto_examples.sh
Normal file
@@ -0,0 +1,2 @@
|
||||
#!/usr/bin/env bash
|
||||
mosquitto_pub -t 'domoticz/in' -h broker_url -p port -u user -P pass -m '{"command": "udevice", "idx": 20, "svalue": "15"}'
|
||||
160
platformio.ini
160
platformio.ini
@@ -9,8 +9,8 @@
|
||||
; http://docs.platformio.org/page/projectconf.html
|
||||
[platformio]
|
||||
src_dir = lighthub
|
||||
env_default =
|
||||
megaatmega2560
|
||||
;env_default =
|
||||
; megaatmega2560
|
||||
; megaatmega2560-net
|
||||
; due
|
||||
; esp8266
|
||||
@@ -20,19 +20,27 @@ env_default =
|
||||
; controllino
|
||||
; stm32
|
||||
|
||||
;build_dir = !sh pioenvs.sh ${platformio.env_default}
|
||||
;libdeps_dir = !sh piolibdeps.sh ${platformio.env_default}
|
||||
;build_dir = /tmp/pioenvs
|
||||
;libdeps_dir = /tmp/piolibdeps
|
||||
|
||||
[env:esp32]
|
||||
platform = espressif32
|
||||
framework = arduino
|
||||
board = pico32
|
||||
lib_ldf_mode = chain+
|
||||
build_flags = !sh build_flags_esp32.sh
|
||||
build_flags = !bash check_custom_build_flags_esp32.sh
|
||||
lib_ignore =
|
||||
DmxSimple
|
||||
DMXSerial
|
||||
DmxDue
|
||||
DueFlashStorage
|
||||
SD
|
||||
SdFat
|
||||
httpClient
|
||||
WifiManager
|
||||
Ethernet
|
||||
lib_deps =
|
||||
https://github.com/anklimov/Arduino-Temperature-Control-Library.git
|
||||
https://github.com/anklimov/DS2482_OneWire
|
||||
ESP8266HTTPClient
|
||||
Ethernet3
|
||||
https://github.com/anklimov/aJson
|
||||
https://github.com/anklimov/CmdArduino
|
||||
@@ -44,40 +52,20 @@ lib_deps =
|
||||
DHT sensor library for ESPx
|
||||
DHT sensor library
|
||||
Streaming
|
||||
https://github.com/Chris--A/PrintEx.git
|
||||
|
||||
[env:stm32]
|
||||
platform = ststm32
|
||||
framework = arduino
|
||||
board = nucleo_f103rb
|
||||
upload_protocol = stlink
|
||||
debug_tool = stlink
|
||||
extra_scripts = pre:!pre_stm32.sh
|
||||
;lib_ldf_mode = chain+
|
||||
build_flags = !sh build_flags_stm32.sh
|
||||
lib_deps =
|
||||
DallasTemperature
|
||||
https://github.com/anklimov/aJson
|
||||
https://github.com/anklimov/CmdArduino
|
||||
ArduinoHttpClient
|
||||
https://github.com/anklimov/ModbusMaster
|
||||
; https://github.com/Serasidis/Ethernet_STM.git
|
||||
; https://github.com/livello/Ethernet_STM.git
|
||||
https://github.com/knolleary/pubsubclient.git
|
||||
Adafruit Unified Sensor
|
||||
DHT sensor library
|
||||
; https://github.com/anklimov/DMXSerial
|
||||
; Syslog
|
||||
; https://github.com/No3x/Syslog.git
|
||||
https://github.com/arcao/Syslog.git
|
||||
; UIPEthernet
|
||||
https://github.com/livello/PrintEx#is-select-redecl
|
||||
|
||||
[env:due]
|
||||
platform = atmelsam
|
||||
framework = arduino
|
||||
board = due
|
||||
lib_ldf_mode = chain+
|
||||
build_flags = !sh build_flags_due.sh
|
||||
build_flags = !bash check_custom_build_flags_due.sh
|
||||
lib_ignore =
|
||||
DHT sensor library for ESPx
|
||||
DMXSerial
|
||||
DmxSimple
|
||||
httpClient
|
||||
ESPDMX
|
||||
WifiManager
|
||||
lib_deps =
|
||||
https://github.com/sebnil/DueFlashStorage
|
||||
https://github.com/anklimov/Arduino-Temperature-Control-Library.git
|
||||
@@ -96,6 +84,7 @@ lib_deps =
|
||||
Adafruit Unified Sensor
|
||||
DHT sensor library
|
||||
https://github.com/arcao/Syslog.git
|
||||
Streaming
|
||||
|
||||
|
||||
[env:megaatmega2560]
|
||||
@@ -103,9 +92,15 @@ platform = atmelavr
|
||||
board = megaatmega2560
|
||||
;upload_port = net:192.168.88.31:23
|
||||
framework = arduino
|
||||
;lib_ldf_mode = chain+
|
||||
build_flags = !sh build_flags_mega2560.sh
|
||||
build_flags = !bash check_custom_build_flags_mega2560.sh
|
||||
lib_ignore =
|
||||
DHT sensor library for ESPx
|
||||
DmxDue
|
||||
DueFlashStorage
|
||||
WifiManager
|
||||
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
|
||||
@@ -113,7 +108,6 @@ lib_deps =
|
||||
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
|
||||
@@ -122,14 +116,20 @@ lib_deps =
|
||||
DHT sensor library
|
||||
https://github.com/arcao/Syslog.git
|
||||
Streaming
|
||||
https://github.com/Chris--A/PrintEx.git
|
||||
|
||||
[env:esp8266]
|
||||
platform = espressif8266
|
||||
framework = arduino
|
||||
board = nodemcuv2
|
||||
lib_ldf_mode = chain+
|
||||
build_flags = !sh build_flags_esp8266.sh
|
||||
build_flags = !bash check_custom_build_flags_esp8266.sh
|
||||
lib_ignore =
|
||||
DmxSimple
|
||||
DMXSerial
|
||||
DmxDue
|
||||
DueFlashStorage
|
||||
SD
|
||||
SdFat
|
||||
httpClient
|
||||
lib_deps =
|
||||
https://github.com/anklimov/Arduino-Temperature-Control-Library.git
|
||||
https://github.com/anklimov/DS2482_OneWire
|
||||
@@ -146,7 +146,6 @@ lib_deps =
|
||||
DHT sensor library
|
||||
WifiManager
|
||||
https://github.com/arcao/Syslog.git
|
||||
https://github.com/livello/PrintEx.git#is-select-redecl
|
||||
Streaming
|
||||
|
||||
[env:megaatmega2560-net]
|
||||
@@ -154,8 +153,13 @@ platform = atmelavr
|
||||
board = megaatmega2560
|
||||
framework = arduino
|
||||
upload_port = net:192.168.88.2:23000
|
||||
build_flags = !sh build_flags_mega2560-net.sh
|
||||
;lib_ldf_mode = chain+
|
||||
build_flags = !bash check_custom_build_flags_mega2560-net.sh
|
||||
lib_ignore =
|
||||
DHT sensor library for ESPx
|
||||
DmxDue
|
||||
DueFlashStorage
|
||||
ESP-Dmx
|
||||
WifiManager
|
||||
lib_deps =
|
||||
https://github.com/anklimov/Arduino-Temperature-Control-Library.git
|
||||
https://github.com/anklimov/DS2482_OneWire
|
||||
@@ -166,7 +170,6 @@ lib_deps =
|
||||
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
|
||||
@@ -180,9 +183,18 @@ lib_deps =
|
||||
platform = atmelsam
|
||||
framework = arduino
|
||||
board = due
|
||||
;lib_ldf_mode = chain+
|
||||
build_flags = -D Wiz5500 -D ARTNET_ENABLE
|
||||
build_flags = !sh build_flags_due-5500.sh
|
||||
build_flags = !bash check_custom_build_flags_due-5500.sh
|
||||
lib_ignore =
|
||||
DHT sensor library for ESPx
|
||||
https://github.com/anklimov/Ethernet
|
||||
ESP-Dmx
|
||||
DMXSerial
|
||||
ESPDMX
|
||||
WifiManager
|
||||
DmxSimple
|
||||
httpClient
|
||||
Ethernet
|
||||
|
||||
lib_deps =
|
||||
https://github.com/sebnil/DueFlashStorage
|
||||
https://github.com/anklimov/Arduino-Temperature-Control-Library.git
|
||||
@@ -202,16 +214,19 @@ lib_deps =
|
||||
DHT sensor library
|
||||
https://github.com/arcao/Syslog.git
|
||||
Streaming
|
||||
; PrintEx
|
||||
https://github.com/livello/PrintEx.git#is-select-redecl
|
||||
https://github.com/livello/PrintEx#is-select-redecl
|
||||
|
||||
[env:controllino]
|
||||
platform = atmelavr
|
||||
board = megaatmega2560
|
||||
framework = arduino
|
||||
;lib_ldf_mode = chain+
|
||||
build_flags = !echo -n "-DPIO_SRC_REV="$(git log --pretty=format:%h_%ad -1 --date=short)
|
||||
build_flags = -D CONTROLLINO -D CUSTOM_FIRMWARE_MAC=de:ad:be:ef:fe:07
|
||||
build_flags = !bash check_custom_build_flags_controllino.sh
|
||||
lib_ignore =
|
||||
DHT sensor library for ESPx
|
||||
DmxDue
|
||||
DueFlashStorage
|
||||
ESP-Dmx
|
||||
WifiManager
|
||||
lib_deps =
|
||||
https://github.com/anklimov/Arduino-Temperature-Control-Library.git
|
||||
https://github.com/anklimov/DS2482_OneWire
|
||||
@@ -222,10 +237,45 @@ lib_deps =
|
||||
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
|
||||
EEPROM
|
||||
Adafruit Unified Sensor
|
||||
DHT sensor library
|
||||
Streaming
|
||||
https://github.com/livello/PrintEx#is-select-redecl
|
||||
|
||||
;TODO:STM32 compilation problems
|
||||
;[env:stm32]
|
||||
;platform = ststm32
|
||||
;framework = arduino
|
||||
;board = nucleo_f103rb
|
||||
;upload_protocol = stlink
|
||||
;debug_tool = stlink
|
||||
;build_flags = !bash check_custom_build_flags_stm32.sh
|
||||
;lib_ignore =
|
||||
; DHT sensor library for ESPx
|
||||
; DmxDue
|
||||
; DueFlashStorage
|
||||
; ESP-Dmx
|
||||
; WifiManager
|
||||
; FastLED
|
||||
; Ethernet
|
||||
;lib_deps =
|
||||
; DallasTemperature
|
||||
; https://github.com/anklimov/aJson
|
||||
; https://github.com/anklimov/CmdArduino
|
||||
; ArduinoHttpClient
|
||||
; https://github.com/anklimov/ModbusMaster
|
||||
;; https://github.com/Serasidis/Ethernet_STM.git
|
||||
;; https://github.com/livello/Ethernet_STM.git
|
||||
; https://github.com/knolleary/pubsubclient.git
|
||||
; Adafruit Unified Sensor
|
||||
; DHT sensor library
|
||||
;; https://github.com/anklimov/DMXSerial
|
||||
;; Syslog
|
||||
;; https://github.com/No3x/Syslog.git
|
||||
; https://github.com/arcao/Syslog.git
|
||||
;; UIPEthernet
|
||||
; Streaming
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
#! /bin/bash
|
||||
rm /tmp/piolibdeps -Rf
|
||||
mkdir /tmp/piolibdeps_stm32
|
||||
ln -s /tmp/piolibdeps_stm32 /tmp/piolibdeps
|
||||
Reference in New Issue
Block a user