|
LightHub 4.6.0
Open-source smart home controller firmware
|
#include "utils.h"#include "options.h"#include "stdarg.h"#include <Wire.h>#include "main.h"#include "item.h"#include <PubSubClient.h>#include <HardwareSerial.h>#include "templateStr.h"Classes | |
| struct | serial_st |
Macros | |
| #define | ARDBUFFER 16 |
| #define | serialModesNum sizeof(serialModes_P)/sizeof(serial_st) |
Functions | |
| void | PrintBytes (uint8_t *addr, uint8_t count, bool newline) |
| void | SetBytes (uint8_t *addr, uint8_t count, char *out) |
| byte | HEX2DEC (char i, bool *err) |
| bool | SetAddr (char *in, uint8_t *addr) |
| long | getIntFromStr (char **chan) |
| itemCmd | getNumber (char **chan) |
| void | parseBytes (const char *str, char separator, byte *bytes, int maxBytes, int base) |
| void | printFloatValueToStr (char *valstr, float value) |
| int | log (const char *str,...) |
| __attribute__ ((section(".ramfunc"))) uint32_t ReadUniqueID(uint32_t *pdwUniqueID) | |
| int | _inet_aton (const char *aIPAddrString, IPAddress &aResult) |
| char * | _inet_ntoa_r (IPAddress addr, char *buf, int buflen) |
| String | toString (const IPAddress &address) |
| void | printIPAddress (IPAddress ipAddress) |
| char * | setTopic (char *buf, int8_t buflen, topicType tt, const char *suffix) |
| void | printUlongValueToStr (char *valstr, unsigned long value) |
| void | scan_i2c_bus () |
| bool | isTimeOver (uint32_t timestamp, uint32_t currTime, uint32_t time, uint32_t modulo) |
| bool | executeCommand (aJsonObject *cmd, int8_t toggle) |
| bool | executeCommand (aJsonObject *cmd, int8_t toggle, itemCmd _itemCmd, aJsonObject *defaultItem, aJsonObject *defaultEmit, aJsonObject *defaultCan) |
| Execute a JSON command object: control an item (Ctrl), publish an emit topic (MQTT) and/or send a CAN command. | |
| itemCmd | mapInt (int32_t arg, aJsonObject *map) |
| uint32_t | millisNZ (uint8_t shift, uint32_t mask) |
| serialParamType | str2SerialParam (char *str) |
| bool | getPinVal (uint8_t pin) |
| bool | checkToken (char *token, char *data) |
| bool | isProtectedPin (short pin) |
| bool | i2cReset () |
| char * | getStringFromJson (aJsonObject *a, int i) |
| char * | getStringFromJson (aJsonObject *a, const char *name) |
| long | getIntFromJson (aJsonObject *a, int i, long def) |
| long | getIntFromJson (aJsonObject *a, const char *name, long def) |
| long | getIntFromJson (aJsonObject *a, const char *name, int i, long def) |
| float | getFloatFromJson (aJsonObject *a, int i, float def) |
| float | getFloatFromJson (aJsonObject *a, const char *name, float def) |
| float | getFloatFromJson (aJsonObject *a, const char *name, int i, float def) |
| aJsonObject * | getCreateObject (aJsonObject *a, int n) |
| aJsonObject * | getCreateObject (aJsonObject *a, const char *name) |
| void | setupInPin (short pin) |
| bool | readInPin (short pin) |
| void | writeOutPin (short pin, bool val) |
Variables | |
| PubSubClient | mqttClient |
| int8_t | ethernetIdleCount |
| int8_t | configLocked |
| const char outTopic[] | PROGMEM = OUTTOPIC |
| char * | deviceName |
| aJsonObject * | topics |
| const char | HEXSTR [] = "0123456789ABCDEF" |
| #define ARDBUFFER 16 |
| #define serialModesNum sizeof(serialModes_P)/sizeof(serial_st) |
| __attribute__ | ( | (section(".ramfunc")) | ) |
| int _inet_aton | ( | const char * | aIPAddrString, |
| IPAddress & | aResult ) |
Convert an IP address string to an IPAddress.
| char * _inet_ntoa_r | ( | IPAddress | addr, |
| char * | buf, | ||
| int | buflen ) |
Same as ipaddr_ntoa, but reentrant since a user-supplied buffer is used.
| addr | ip address in network order to convert |
| buf | target buffer where the string is stored |
| buflen | length of buf |
Convert an IPAddress to a string in buf.
| bool checkToken | ( | char * | token, |
| char * | data ) |
Validate an authorization token against data.
| bool executeCommand | ( | aJsonObject * | cmd, |
| int8_t | toggle = -1 ) |
Execute a JSON command object with an empty itemCmd.
| toggle | - 0: use icmd/ecmd, 1: use irev/erev, -1: no toggle |
| bool executeCommand | ( | aJsonObject * | cmd, |
| int8_t | toggle, | ||
| itemCmd | _itemCmd, | ||
| aJsonObject * | defaultItem = NULL, | ||
| aJsonObject * | defaultEmit = NULL, | ||
| aJsonObject * | defaultCan = NULL ) |
Execute a JSON command object: control an item (Ctrl), publish an emit topic (MQTT) and/or send a CAN command.
| cmd | - command object: array (iterate), object with item/emit/can/ icmd/irev/ecmd/erev/act fields, or a legacy string |
| toggle | - 0: use icmd/ecmd, 1: use irev/erev, -1: no toggle |
| _itemCmd | - itemCmd value to send when no command string is given |
| defaultItem/defaultEmit/defaultCan | - fallback targets |
ChangeMe - if no '/' in addr - template not working
| aJsonObject * getCreateObject | ( | aJsonObject * | a, |
| const char * | name ) |
| aJsonObject * getCreateObject | ( | aJsonObject * | a, |
| int | n ) |
| float getFloatFromJson | ( | aJsonObject * | a, |
| const char * | name, | ||
| float | def = 0.0 ) |
| float getFloatFromJson | ( | aJsonObject * | a, |
| const char * | name, | ||
| int | i, | ||
| float | def ) |
| float getFloatFromJson | ( | aJsonObject * | a, |
| int | i, | ||
| float | def = 0.0 ) |
| long getIntFromJson | ( | aJsonObject * | a, |
| const char * | name, | ||
| int | i, | ||
| long | def ) |
| long getIntFromJson | ( | aJsonObject * | a, |
| const char * | name, | ||
| long | def = 0 ) |
| long getIntFromJson | ( | aJsonObject * | a, |
| int | i, | ||
| long | def = 0 ) |
| long getIntFromStr | ( | char ** | chan | ) |
Parse an integer from *chan, advancing the pointer past it (after ',').
| itemCmd getNumber | ( | char ** | chan | ) |
Parse a typed number (int / tens / float) from *chan into an itemCmd.
| bool getPinVal | ( | uint8_t | pin | ) |
| char * getStringFromJson | ( | aJsonObject * | a, |
| const char * | name ) |
| char * getStringFromJson | ( | aJsonObject * | a, |
| int | i ) |
| byte HEX2DEC | ( | char | i, |
| bool * | err ) |
Convert one hex digit to decimal, setting err on failure.
| bool i2cReset | ( | ) |
Recover the I2C bus by toggling SCL.
| bool isProtectedPin | ( | short | pin | ) |
| bool isTimeOver | ( | uint32_t | timestamp, |
| uint32_t | currTime, | ||
| uint32_t | time, | ||
| uint32_t | modulo = 0 ) |
| int log | ( | const char * | str, |
| ... ) |
Log a formatted message to the debug serial.
| uint32_t millisNZ | ( | uint8_t | shift = 0, |
| uint32_t | mask = 0xFFFFFFFFUL ) |
| void parseBytes | ( | const char * | str, |
| char | separator, | ||
| byte * | bytes, | ||
| int | maxBytes, | ||
| int | base ) |
Parse a delimited hex string into a byte array.
| void PrintBytes | ( | uint8_t * | addr, |
| uint8_t | count, | ||
| bool | newline ) |
Print count bytes from addr to the debug serial as hex.
| void printFloatValueToStr | ( | char * | valstr, |
| float | value ) |
Convert a float to a fixed-format string for MQTT publishing.
| void printIPAddress | ( | IPAddress | ipAddress | ) |
Print an IP address to the debug serial.
| void printUlongValueToStr | ( | char * | valstr, |
| unsigned long | value ) |
Convert an unsigned long to a string for MQTT publishing.
| bool readInPin | ( | short | pin | ) |
| void scan_i2c_bus | ( | ) |
Scan the I2C bus and log the found devices.
| bool SetAddr | ( | char * | in, |
| uint8_t * | addr ) |
Parse a hex string (AA:BB:...) into a MAC/EUI byte buffer.
| void SetBytes | ( | uint8_t * | addr, |
| uint8_t | count, | ||
| char * | out ) |
Format count bytes from addr as a hex string into out.
| char * setTopic | ( | char * | buf, |
| int8_t | buflen, | ||
| topicType | tt, | ||
| const char * | suffix = NULL ) |
Build the full MQTT topic prefix of the given type in buf.
| void setupInPin | ( | short | pin | ) |
Configure a pin as an input.
| serialParamType str2SerialParam | ( | char * | str | ) |
Parse a serial parameter string (e.g. baud rate / parity) to its code.
| String toString | ( | const IPAddress & | address | ) |
| void writeOutPin | ( | short | pin, |
| bool | val ) |
Write a value to an output pin.
|
extern |
|
extern |
|
extern |
| const char HEXSTR[] = "0123456789ABCDEF" |
|
extern |
|
extern |