mirror of
https://github.com/anklimov/lighthub
synced 2025-12-12 14:49:50 +03:00
MQTT subscribe fix, AnalogIn fix, first attempt to compile for NRF5
This commit is contained in:
@@ -332,9 +332,9 @@ void Input::contactPoll() {
|
||||
WiringPinMode inputPinMode;
|
||||
#endif
|
||||
#if defined(__SAM3X8E__)||defined(ARDUINO_ARCH_AVR)||defined(ARDUINO_ARCH_ESP8266)||defined(ARDUINO_ARCH_ESP32)
|
||||
uint32_t inputPinMode;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
uint32_t inputPinMode;
|
||||
uint8_t inputOnLevel;
|
||||
if (inType & IN_ACTIVE_HIGH) {
|
||||
inputOnLevel = HIGH;
|
||||
@@ -375,10 +375,10 @@ void Input::analogPoll() {
|
||||
#if defined(ARDUINO_ARCH_STM32F1)
|
||||
WiringPinMode inputPinMode;
|
||||
#endif
|
||||
#if defined(__SAM3X8E__)||defined(ARDUINO_ARCH_AVR)||defined(ARDUINO_ARCH_ESP8266)||defined(ARDUINO_ARCH_ESP32)
|
||||
uint32_t inputPinMode;
|
||||
#endif
|
||||
|
||||
#if defined(__SAM3X8E__)||defined(ARDUINO_ARCH_AVR)||defined(ARDUINO_ARCH_ESP8266)||defined(ARDUINO_ARCH_ESP32)
|
||||
#endif
|
||||
uint32_t inputPinMode;
|
||||
if (inType & IN_ACTIVE_HIGH) {
|
||||
inputPinMode = INPUT;
|
||||
} else {
|
||||
@@ -389,24 +389,25 @@ void Input::analogPoll() {
|
||||
// Mapping
|
||||
if (inputMap && inputMap->type == aJson_Array)
|
||||
{
|
||||
int max;
|
||||
if (aJson.getArraySize(inputMap)>=4)
|
||||
mappedInputVal = map (mappedInputVal,
|
||||
aJson.getArrayItem(inputMap, 0)->valueint,
|
||||
aJson.getArrayItem(inputMap, 1)->valueint,
|
||||
aJson.getArrayItem(inputMap, 2)->valueint,
|
||||
aJson.getArrayItem(inputMap, 3)->valueint);
|
||||
max=aJson.getArrayItem(inputMap, 3)->valueint);
|
||||
if (aJson.getArraySize(inputMap)==5) Noize = aJson.getArrayItem(inputMap, 4)->valueint;
|
||||
|
||||
if (mappedInputVal>max) mappedInputVal=max;
|
||||
if (aJson.getArraySize(inputMap)==2)
|
||||
{
|
||||
simple = 1;
|
||||
if (mappedInputVal < aJson.getArrayItem(inputMap, 0)->valueint) mappedInputVal = 0;
|
||||
else if (mappedInputVal > aJson.getArrayItem(inputMap, 1)->valueint) mappedInputVal = 1;
|
||||
else mappedInputVal = -1;
|
||||
else return;
|
||||
}
|
||||
}
|
||||
if (simple) {
|
||||
if (mappedInputVal!=-1 && mappedInputVal != store->currentValue)
|
||||
if (mappedInputVal != store->currentValue)
|
||||
{
|
||||
onContactChanged(mappedInputVal);
|
||||
store->currentValue = mappedInputVal;
|
||||
|
||||
@@ -218,7 +218,7 @@ int Item::Ctrl(char * payload, boolean send){
|
||||
case -1: //Not known command
|
||||
case -2: //JSON input (not implemented yet
|
||||
break;
|
||||
#if not defined(ARDUINO_ARCH_ESP32) and not defined(ESP8266) and not defined(ARDUINO_ARCH_STM32F1)
|
||||
#if not defined(ARDUINO_ARCH_ESP32) and not defined(ESP8266) and not defined(ARDUINO_ARCH_STM32F1) and not defined(DMX_DISABLE)
|
||||
case -3: //RGB color in #RRGGBB notation
|
||||
{
|
||||
CRGB rgb;
|
||||
|
||||
@@ -109,6 +109,12 @@ WiFiClient ethClient;
|
||||
EthernetClient ethClient;
|
||||
#endif
|
||||
|
||||
#ifdef NRF5
|
||||
#include <NRFFlashStorage.h>
|
||||
NRFFlashStorage EEPROM;
|
||||
EthernetClient ethClient;
|
||||
#endif
|
||||
|
||||
#ifdef SYSLOG_ENABLE
|
||||
#include <Syslog.h>
|
||||
EthernetUDP udpSyslogClient;
|
||||
@@ -491,12 +497,13 @@ void ip_ready_config_loaded_connecting_to_broker() {
|
||||
|
||||
strncpy_P(buf, outprefix, sizeof(buf));
|
||||
strncat(buf, "#", sizeof(buf));
|
||||
mqttClient.subscribe(buf,MQTTQOS1);
|
||||
mqttClient.subscribe(buf);
|
||||
|
||||
//Subscribing for command topics
|
||||
strncpy_P(buf, inprefix, sizeof(buf));
|
||||
strncat(buf, "#", sizeof(buf));
|
||||
mqttClient.subscribe(buf,MQTTQOS1);
|
||||
Serial.println(buf);
|
||||
mqttClient.subscribe(buf);
|
||||
|
||||
//restoreState();
|
||||
onMQTTConnect();
|
||||
@@ -738,7 +745,7 @@ void cmdFunctionKill(int arg_cnt, char **args) {
|
||||
|
||||
void cmdFunctionReboot(int arg_cnt, char **args) {
|
||||
debugSerial<<F("Soft rebooting...");
|
||||
softRebootFunc();
|
||||
//// softRebootFunc();
|
||||
}
|
||||
|
||||
void applyConfig() {
|
||||
|
||||
@@ -29,6 +29,12 @@
|
||||
#define wdt_dis()
|
||||
#endif
|
||||
|
||||
#if defined(NRF5)
|
||||
#define wdt_res()
|
||||
#define wdt_en()
|
||||
#define wdt_dis()
|
||||
#endif
|
||||
|
||||
//#if defined(ESP8266)
|
||||
//#define wdt_res()
|
||||
//#define wdt_en()
|
||||
@@ -66,7 +72,7 @@
|
||||
#include <ModbusMaster.h>
|
||||
#endif
|
||||
|
||||
#ifndef ARDUINO_ARCH_STM32F1
|
||||
#ifndef DMX_DISABLE
|
||||
#include "FastLED.h"
|
||||
#endif
|
||||
|
||||
@@ -108,7 +114,7 @@
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(ARDUINO_ARCH_AVR) || defined(__SAM3X8E__) || defined(ESP8266)
|
||||
#if defined(ARDUINO_ARCH_AVR) || defined(__SAM3X8E__) || defined(ESP8266) || defined(NRF5)
|
||||
#ifdef Wiz5500
|
||||
#include <Ethernet2.h>
|
||||
#else
|
||||
|
||||
@@ -66,7 +66,7 @@
|
||||
#endif
|
||||
|
||||
#ifndef OUTTOPIC
|
||||
#define OUTTOPIC "homie/s_out/"
|
||||
#define OUTTOPIC "/myhome/s_out/"
|
||||
#endif
|
||||
|
||||
#ifndef CMDTOPIC
|
||||
|
||||
@@ -110,7 +110,7 @@ unsigned long freeRam() {
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(__SAM3X8E__)
|
||||
#if defined(__SAM3X8E__)
|
||||
extern char _end;
|
||||
extern "C" char *sbrk(int i);
|
||||
|
||||
@@ -126,6 +126,23 @@ unsigned long freeRam() {
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(NRF5)
|
||||
extern char _end;
|
||||
extern "C" char *sbrk(int i);
|
||||
|
||||
unsigned long freeRam() {
|
||||
char *ramstart = (char *) 0x20070000;
|
||||
char *ramend = (char *) 0x20088000;
|
||||
char *heapend = sbrk(0);
|
||||
register char *stack_ptr asm( "sp" );
|
||||
//struct mallinfo mi = mallinfo();
|
||||
|
||||
return stack_ptr - heapend;// + mi.fordblks;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
void parseBytes(const char *str, char separator, byte *bytes, int maxBytes, int base) {
|
||||
for (int i = 0; i < maxBytes; i++) {
|
||||
bytes[i] = strtoul(str, NULL, base); // Convert byte
|
||||
|
||||
Reference in New Issue
Block a user