| LightHub v4.0.0 Smarthome controller firmware

Macros | Enumerations | Functions | Variables
main.cpp File Reference
`#include "main.h"`
`#include "statusled.h"`
`#include "flashstream.h"`
`#include "config.h"`
`#include <Dhcp.h>`

## Macros
#define | ESP_EEPROM_SIZE 4096-10

## Enumerations
enum | heaterMode { HEATER_HEAT, HEATER_OFF, HEATER_ERROR }

## Functions
PubSubClient | mqttClient (ethClient)
void | cleanConf ()
bool | isNotRetainingStatus ()
uint16_t | httpHandler (Client &client, String request, uint8_t method, long contentLength, bool authorized, String &response)
int | inTopic (char *topic, topicType tt)
void | mqttCallback (char *topic, byte *payload, unsigned int length)
void | printMACAddress ()
char * | getStringFromConfig (aJsonObject *a, int i)
char * | getStringFromConfig (aJsonObject *a, char *name)
void | setupOTA (void)
void | setupSyslog ()
lan_status | lanLoop ()
void | onMQTTConnect ()
void | ip_ready_config_loaded_connecting_to_broker ()
void | onInitialStateInitLAN ()
void | resetHard ()
void | Changed (int i, DeviceAddress addr, float currentTemp)
int | cmdFunctionHelp (int arg_cnt, char **args)
void | printCurentLanConfig ()
int | cmdFunctionKill (int arg_cnt, char **args)
int | cmdFunctionReboot (int arg_cnt, char **args)
void | applyConfig ()
void | printConfigSummary ()
int | cmdFunctionLoad (int arg_cnt, char **args)
int | loadConfigFromEEPROM ()
int | cmdFunctionSave (int arg_cnt, char **args)
int | cmdFunctionLoglevel (int arg_cnt, char **args)
int | cmdFunctionIp (int arg_cnt, char **args)
int | cmdFunctionClearEEPROM (int arg_cnt, char **args)
int | cmdFunctionPwd (int arg_cnt, char **args)
int | cmdFunctionOTAPwd (int arg_cnt, char **args)
int | cmdFunctionSetMac (int arg_cnt, char **args)
int | cmdFunctionGet (int arg_cnt, char **args)
void | printBool (bool arg)
void | headerHandlerProc (String header)
int | loadConfigFromHttp ()
void | preTransmission ()
void | postTransmission ()
void | TimerHandler (void)
void | setup_main ()
void | printFirmwareVersionAndBuildOptions ()
void | publishStat ()
void | setupMacAddress ()
void | setupCmdArduino ()
void | loop_main ()
void | owIdle (void)
void | ethernetIdle (void)
void | modbusIdle (void)
void | inputLoop (short cause)
void | inputSetup (void)
void | pollingLoop (void)
void | thermoRelay (int pin, heaterMode on)
void | thermoLoop (void)

## Variables
Streamlog debugSerial & | debugSerialPort
flashStream | sysConfStream
long | timer0_overflow_count
EthernetClient | ethClient
StatusLED | statusLED (ledRED)
lan_status | lanStatus = INITIAL_STATE
const char configserver[] | PROGMEM = CONFIG_SERVER
char * | deviceName = NULL
aJsonObject * | topics = NULL
aJsonObject * | root = NULL
aJsonObject * | items = NULL
aJsonObject * | inputs = NULL
aJsonObject * | mqttArr = NULL
aJsonObject * | modbusObj = NULL
aJsonObject * | owArr = NULL
aJsonObject * | dmxArr = NULL
volatile uint32_t | timerPollingCheck = 0
volatile uint32_t | timerInputCheck = 0
volatile uint32_t | timerLanCheckTime = 0
volatile uint32_t | timerThermostatCheck = 0
volatile uint32_t | timerSensorCheck =0
volatile unsigned long | timerCount =0
volatile int16_t | timerNumber =-1
volatile int8_t | timerHandlerBusy =0
aJsonObject * | pollingItem = NULL
bool | owReady = false
bool | configOk = false
bool | configLoaded = false
bool | initializedListeners = false
volatile int8_t | ethernetIdleCount =0
volatile int8_t | configLocked = 0
ModbusMaster | node
bool | wifiInitialized
int8_t | mqttErrorRate =0
const char * | headerKeys [] ={"ETag"}
volatile int8_t | inputLoopBusy = 0

## Macro Definition Documentation

## ◆ ESP_EEPROM_SIZE

#define ESP_EEPROM_SIZE 4096-10

## Enumeration Type Documentation

## ◆ heaterMode

enum heaterMode

Enumerator
HEATER_HEAT |
HEATER_OFF |
HEATER_ERROR |

## Function Documentation

## ◆ applyConfig()

void applyConfig | ( |  | ) |

## ◆ Changed()

void Changed | ( | int | i,
|  | DeviceAddress | addr,
|  | float | currentTemp
| ) |  |

## ◆ cleanConf()

void cleanConf | ( |  | ) |

## ◆ cmdFunctionClearEEPROM()

int cmdFunctionClearEEPROM | ( | int | arg_cnt,
|  | char ** | args
| ) |  |

## ◆ cmdFunctionGet()

int cmdFunctionGet | ( | int | arg_cnt,
|  | char ** | args
| ) |  |

## ◆ cmdFunctionHelp()

int cmdFunctionHelp | ( | int | arg_cnt,
|  | char ** | args
| ) |  |

## ◆ cmdFunctionIp()

int cmdFunctionIp | ( | int | arg_cnt,
|  | char ** | args
| ) |  |

## ◆ cmdFunctionKill()

int cmdFunctionKill | ( | int | arg_cnt,
|  | char ** | args
| ) |  |

## ◆ cmdFunctionLoad()

int cmdFunctionLoad | ( | int | arg_cnt,
|  | char ** | args
| ) |  |

## ◆ cmdFunctionLoglevel()

int cmdFunctionLoglevel | ( | int | arg_cnt,
|  | char ** | args
| ) |  |

## ◆ cmdFunctionOTAPwd()

int cmdFunctionOTAPwd | ( | int | arg_cnt,
|  | char ** | args
| ) |  |

## ◆ cmdFunctionPwd()

int cmdFunctionPwd | ( | int | arg_cnt,
|  | char ** | args
| ) |  |

## ◆ cmdFunctionReboot()

int cmdFunctionReboot | ( | int | arg_cnt,
|  | char ** | args
| ) |  |

## ◆ cmdFunctionSave()

int cmdFunctionSave | ( | int | arg_cnt,
|  | char ** | args
| ) |  |

## ◆ cmdFunctionSetMac()

int cmdFunctionSetMac | ( | int | arg_cnt,
|  | char ** | args
| ) |  |

## ◆ ethernetIdle()

void ethernetIdle | ( | void |  | ) |

## ◆ getStringFromConfig() [1/2]

char* getStringFromConfig | ( | aJsonObject * | a,
|  | char * | name
| ) |  |

## ◆ getStringFromConfig() [2/2]

char* getStringFromConfig | ( | aJsonObject * | a,
|  | int | i
| ) |  |

## ◆ headerHandlerProc()

void headerHandlerProc | ( | String | header | ) |

## ◆ httpHandler()

uint16_t httpHandler | ( | Client & | client,
|  | String | request,
|  | uint8_t | method,
|  | long | contentLength,
|  | bool | authorized,
|  | String & | response
| ) |  |

## ◆ inputLoop()

void inputLoop | ( | short | cause | ) |

## ◆ inputSetup()

void inputSetup | ( | void |  | ) |

## ◆ inTopic()

int inTopic | ( | char * | topic,
|  | topicType | tt
| ) |  |

## ◆ ip_ready_config_loaded_connecting_to_broker()

void ip_ready_config_loaded_connecting_to_broker | ( |  | ) |

## ◆ isNotRetainingStatus()

bool isNotRetainingStatus | ( |  | ) |

## ◆ lanLoop()

lan_status lanLoop | ( |  | ) |

## ◆ loadConfigFromEEPROM()

int loadConfigFromEEPROM | ( |  | ) |

## ◆ loadConfigFromHttp()

int loadConfigFromHttp | ( |  | ) |

## ◆ loop_main()

void loop_main | ( |  | ) |

## ◆ modbusIdle()

void modbusIdle | ( | void |  | ) |

## ◆ mqttCallback()

void mqttCallback | ( | char * | topic,
|  | byte * | payload,
|  | unsigned int | length
| ) |  |

## ◆ mqttClient()

PubSubClient mqttClient | ( | ethClient |  | ) |

## ◆ onInitialStateInitLAN()

void onInitialStateInitLAN | ( |  | ) |

## ◆ onMQTTConnect()

void onMQTTConnect | ( |  | ) |

strncat(buf,item->name,sizeof(buf)); strncat(buf,",",sizeof(buf));

mqttClient.publish(topic,buf,true);

## ◆ owIdle()

void owIdle | ( | void |  | ) |

## ◆ pollingLoop()

void pollingLoop | ( | void |  | ) |

## ◆ postTransmission()

void postTransmission | ( |  | ) |

## ◆ preTransmission()

void preTransmission | ( |  | ) |

## ◆ printBool()

void printBool | ( | bool | arg | ) |

## ◆ printConfigSummary()

void printConfigSummary | ( |  | ) |

## ◆ printCurentLanConfig()

void printCurentLanConfig | ( |  | ) |

## ◆ printFirmwareVersionAndBuildOptions()

void printFirmwareVersionAndBuildOptions | ( |  | ) |

## ◆ printMACAddress()

void printMACAddress | ( |  | ) |

## ◆ publishStat()

void publishStat | ( |  | ) |

## ◆ resetHard()

void resetHard | ( |  | ) |

## ◆ setup_main()

void setup_main | ( |  | ) |

## ◆ setupCmdArduino()

void setupCmdArduino | ( |  | ) |

## ◆ setupMacAddress()

void setupMacAddress | ( |  | ) |

## ◆ setupOTA()

void setupOTA | ( | void |  | ) |

## ◆ setupSyslog()

void setupSyslog | ( |  | ) |

## ◆ thermoLoop()

void thermoLoop | ( | void |  | ) |

## ◆ thermoRelay()

void thermoRelay | ( | int | pin,
|  | heaterMode | on
| ) |  |

## ◆ TimerHandler()

void TimerHandler | ( | void |  | ) |

## Variable Documentation

## ◆ configLoaded

bool configLoaded = false

## ◆ configLocked

volatile int8_t configLocked = 0

## ◆ configOk

bool configOk = false

## ◆ debugSerialPort

Streamlog infoSerial& debugSerialPort

## ◆ deviceName

char* deviceName = NULL

## ◆ dmxArr

aJsonObject* dmxArr = NULL

## ◆ ethClient

EthernetClient ethClient

## ◆ ethernetIdleCount

volatile int8_t ethernetIdleCount =0

## ◆ headerKeys

const char* headerKeys[] ={"ETag"}

## ◆ initializedListeners

bool initializedListeners = false

## ◆ inputLoopBusy

volatile int8_t inputLoopBusy = 0

## ◆ inputs

aJsonObject* inputs = NULL

## ◆ items

aJsonObject* items = NULL

## ◆ lanStatus

lan_status lanStatus = INITIAL_STATE

## ◆ modbusObj

aJsonObject* modbusObj = NULL

## ◆ mqttArr

aJsonObject* mqttArr = NULL

## ◆ mqttErrorRate

int8_t mqttErrorRate =0

## ◆ node

ModbusMaster node

## ◆ owArr

aJsonObject* owArr = NULL

## ◆ owReady

bool owReady = false

## ◆ pollingItem

aJsonObject* pollingItem = NULL

## ◆ PROGMEM

const char verval_P [] PROGMEM = CONFIG_SERVER

## ◆ root

aJsonObject* root = NULL

## ◆ statusLED

StatusLED statusLED(ledRED)

## ◆ sysConfStream

systemConfig sysConf & sysConfStream

## ◆ timer0_overflow_count

long timer0_overflow_count
| extern

## ◆ timerCount

volatile unsigned long timerCount =0

## ◆ timerHandlerBusy

volatile int8_t timerHandlerBusy =0

## ◆ timerInputCheck

volatile uint32_t timerInputCheck = 0

## ◆ timerLanCheckTime

volatile uint32_t timerLanCheckTime = 0

## ◆ timerNumber

volatile int16_t timerNumber =-1

## ◆ timerPollingCheck

volatile uint32_t timerPollingCheck = 0

## ◆ timerSensorCheck

volatile uint32_t timerSensorCheck =0

## ◆ timerThermostatCheck

volatile uint32_t timerThermostatCheck = 0

## ◆ topics

aJsonObject* topics = NULL

## ◆ wifiInitialized

bool wifiInitialized