|
@ -8,58 +8,106 @@ extern "C" { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------- |
|
|
// ----------------------------------------------------------------------------- |
|
|
// EEPROM_ROTATE |
|
|
|
|
|
|
|
|
// API |
|
|
// ----------------------------------------------------------------------------- |
|
|
// ----------------------------------------------------------------------------- |
|
|
#include <EEPROM_Rotate.h> |
|
|
|
|
|
EEPROM_Rotate EEPROMr; |
|
|
|
|
|
|
|
|
#if WEB_SUPPORT |
|
|
|
|
|
typedef std::function<void(char *, size_t)> api_get_callback_f; |
|
|
|
|
|
typedef std::function<void(const char *)> api_put_callback_f; |
|
|
|
|
|
void apiRegister(const char * key, api_get_callback_f getFn, api_put_callback_f putFn = NULL); |
|
|
|
|
|
#else |
|
|
|
|
|
#define api_get_callback_f void * |
|
|
|
|
|
#define api_put_callback_f void * |
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------- |
|
|
// ----------------------------------------------------------------------------- |
|
|
// WebServer |
|
|
|
|
|
|
|
|
// Broker |
|
|
// ----------------------------------------------------------------------------- |
|
|
// ----------------------------------------------------------------------------- |
|
|
#include <ESPAsyncWebServer.h> |
|
|
|
|
|
AsyncWebServer * webServer(); |
|
|
|
|
|
|
|
|
#if BROKER_SUPPORT |
|
|
|
|
|
void brokerRegister(void (*)(const char *, unsigned char, const char *)); |
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------- |
|
|
// ----------------------------------------------------------------------------- |
|
|
// API |
|
|
|
|
|
|
|
|
// Debug |
|
|
// ----------------------------------------------------------------------------- |
|
|
// ----------------------------------------------------------------------------- |
|
|
typedef std::function<void(char *, size_t)> api_get_callback_f; |
|
|
|
|
|
typedef std::function<void(const char *)> api_put_callback_f; |
|
|
|
|
|
void apiRegister(const char * key, api_get_callback_f getFn, api_put_callback_f putFn = NULL); |
|
|
|
|
|
|
|
|
void debugSend(const char * format, ...); |
|
|
|
|
|
void debugSend_P(PGM_P format, ...); |
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------- |
|
|
// ----------------------------------------------------------------------------- |
|
|
// WebSockets |
|
|
|
|
|
|
|
|
// Domoticz |
|
|
// ----------------------------------------------------------------------------- |
|
|
// ----------------------------------------------------------------------------- |
|
|
typedef std::function<void(JsonObject&)> ws_on_send_callback_f; |
|
|
|
|
|
void wsOnSendRegister(ws_on_send_callback_f callback); |
|
|
|
|
|
void wsSend(ws_on_send_callback_f sender); |
|
|
|
|
|
|
|
|
|
|
|
typedef std::function<void(uint32_t, const char *, JsonObject&)> ws_on_action_callback_f; |
|
|
|
|
|
void wsOnActionRegister(ws_on_action_callback_f callback); |
|
|
|
|
|
|
|
|
#if DOMOTICZ_SUPPORT |
|
|
|
|
|
template<typename T> void domoticzSend(const char * key, T value); |
|
|
|
|
|
template<typename T> void domoticzSend(const char * key, T nvalue, const char * svalue); |
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
typedef std::function<void(void)> ws_on_after_parse_callback_f; |
|
|
|
|
|
void wsOnAfterParseRegister(ws_on_after_parse_callback_f callback); |
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------- |
|
|
|
|
|
// EEPROM_ROTATE |
|
|
|
|
|
// ----------------------------------------------------------------------------- |
|
|
|
|
|
#include <EEPROM_Rotate.h> |
|
|
|
|
|
EEPROM_Rotate EEPROMr; |
|
|
|
|
|
|
|
|
typedef std::function<bool(const char *, JsonVariant&)> ws_on_receive_callback_f; |
|
|
|
|
|
void wsOnReceiveRegister(ws_on_receive_callback_f callback); |
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------- |
|
|
|
|
|
// GPIO |
|
|
|
|
|
// ----------------------------------------------------------------------------- |
|
|
|
|
|
bool gpioValid(unsigned char gpio); |
|
|
|
|
|
bool gpioGetLock(unsigned char gpio); |
|
|
|
|
|
bool gpioReleaseLock(unsigned char gpio); |
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------- |
|
|
// ----------------------------------------------------------------------------- |
|
|
// WIFI |
|
|
|
|
|
|
|
|
// I2C |
|
|
// ----------------------------------------------------------------------------- |
|
|
// ----------------------------------------------------------------------------- |
|
|
#include "JustWifi.h" |
|
|
|
|
|
typedef std::function<void(justwifi_messages_t code, char * parameter)> wifi_callback_f; |
|
|
|
|
|
void wifiRegister(wifi_callback_f callback); |
|
|
|
|
|
|
|
|
#if I2C_SUPPORT |
|
|
|
|
|
void i2cScan(); |
|
|
|
|
|
void i2cClearBus(); |
|
|
|
|
|
bool i2cGetLock(unsigned char address); |
|
|
|
|
|
bool i2cReleaseLock(unsigned char address); |
|
|
|
|
|
unsigned char i2cFindAndLock(size_t size, unsigned char * addresses); |
|
|
|
|
|
|
|
|
|
|
|
void i2c_wakeup(uint8_t address); |
|
|
|
|
|
uint8_t i2c_write_buffer(uint8_t address, uint8_t * buffer, size_t len); |
|
|
|
|
|
uint8_t i2c_write_uint8(uint8_t address, uint8_t value); |
|
|
|
|
|
uint8_t i2c_write_uint8(uint8_t address, uint8_t reg, uint8_t value); |
|
|
|
|
|
uint8_t i2c_write_uint8(uint8_t address, uint8_t reg, uint8_t value1, uint8_t value2); |
|
|
|
|
|
uint8_t i2c_write_uint16(uint8_t address, uint16_t value); |
|
|
|
|
|
uint8_t i2c_write_uint16(uint8_t address, uint8_t reg, uint16_t value); |
|
|
|
|
|
uint8_t i2c_read_uint8(uint8_t address); |
|
|
|
|
|
uint8_t i2c_read_uint8(uint8_t address, uint8_t reg); |
|
|
|
|
|
uint16_t i2c_read_uint16(uint8_t address); |
|
|
|
|
|
uint16_t i2c_read_uint16(uint8_t address, uint8_t reg); |
|
|
|
|
|
uint16_t i2c_read_uint16_le(uint8_t address, uint8_t reg); |
|
|
|
|
|
int16_t i2c_read_int16(uint8_t address, uint8_t reg); |
|
|
|
|
|
int16_t i2c_read_int16_le(uint8_t address, uint8_t reg); |
|
|
|
|
|
void i2c_read_buffer(uint8_t address, uint8_t * buffer, size_t len); |
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------- |
|
|
// ----------------------------------------------------------------------------- |
|
|
// MQTT |
|
|
// MQTT |
|
|
// ----------------------------------------------------------------------------- |
|
|
// ----------------------------------------------------------------------------- |
|
|
typedef std::function<void(unsigned int, const char *, const char *)> mqtt_callback_f; |
|
|
|
|
|
void mqttRegister(mqtt_callback_f callback); |
|
|
|
|
|
String mqttMagnitude(char * topic); |
|
|
|
|
|
|
|
|
#if MQTT_SUPPORT |
|
|
|
|
|
typedef std::function<void(unsigned int, const char *, const char *)> mqtt_callback_f; |
|
|
|
|
|
void mqttRegister(mqtt_callback_f callback); |
|
|
|
|
|
String mqttMagnitude(char * topic); |
|
|
|
|
|
#else |
|
|
|
|
|
#define mqtt_callback_f void * |
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------- |
|
|
// ----------------------------------------------------------------------------- |
|
|
// Broker |
|
|
|
|
|
|
|
|
// OTA |
|
|
// ----------------------------------------------------------------------------- |
|
|
// ----------------------------------------------------------------------------- |
|
|
void brokerRegister(void (*)(const char *, unsigned char, const char *)); |
|
|
|
|
|
|
|
|
#include "ESPAsyncTCP.h" |
|
|
|
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------- |
|
|
|
|
|
// RFM69 |
|
|
|
|
|
// ----------------------------------------------------------------------------- |
|
|
|
|
|
typedef struct { |
|
|
|
|
|
unsigned long messageID; |
|
|
|
|
|
unsigned char packetID; |
|
|
|
|
|
unsigned char senderID; |
|
|
|
|
|
unsigned char targetID; |
|
|
|
|
|
char * key; |
|
|
|
|
|
char * value; |
|
|
|
|
|
int16_t rssi; |
|
|
|
|
|
} packet_t; |
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------- |
|
|
// ----------------------------------------------------------------------------- |
|
|
// Settings |
|
|
// Settings |
|
@ -76,67 +124,53 @@ void settingsInject(void *data, size_t len); |
|
|
Stream & settingsSerial(); |
|
|
Stream & settingsSerial(); |
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------- |
|
|
// ----------------------------------------------------------------------------- |
|
|
// I2C |
|
|
|
|
|
|
|
|
// Utils |
|
|
// ----------------------------------------------------------------------------- |
|
|
// ----------------------------------------------------------------------------- |
|
|
void i2cScan(); |
|
|
|
|
|
void i2cClearBus(); |
|
|
|
|
|
bool i2cGetLock(unsigned char address); |
|
|
|
|
|
bool i2cReleaseLock(unsigned char address); |
|
|
|
|
|
unsigned char i2cFindAndLock(size_t size, unsigned char * addresses); |
|
|
|
|
|
|
|
|
|
|
|
void i2c_wakeup(uint8_t address); |
|
|
|
|
|
uint8_t i2c_write_buffer(uint8_t address, uint8_t * buffer, size_t len); |
|
|
|
|
|
uint8_t i2c_write_uint8(uint8_t address, uint8_t value); |
|
|
|
|
|
uint8_t i2c_write_uint8(uint8_t address, uint8_t reg, uint8_t value); |
|
|
|
|
|
uint8_t i2c_write_uint8(uint8_t address, uint8_t reg, uint8_t value1, uint8_t value2); |
|
|
|
|
|
uint8_t i2c_write_uint16(uint8_t address, uint16_t value); |
|
|
|
|
|
uint8_t i2c_write_uint16(uint8_t address, uint8_t reg, uint16_t value); |
|
|
|
|
|
uint8_t i2c_read_uint8(uint8_t address); |
|
|
|
|
|
uint8_t i2c_read_uint8(uint8_t address, uint8_t reg); |
|
|
|
|
|
uint16_t i2c_read_uint16(uint8_t address); |
|
|
|
|
|
uint16_t i2c_read_uint16(uint8_t address, uint8_t reg); |
|
|
|
|
|
uint16_t i2c_read_uint16_le(uint8_t address, uint8_t reg); |
|
|
|
|
|
int16_t i2c_read_int16(uint8_t address, uint8_t reg); |
|
|
|
|
|
int16_t i2c_read_int16_le(uint8_t address, uint8_t reg); |
|
|
|
|
|
void i2c_read_buffer(uint8_t address, uint8_t * buffer, size_t len); |
|
|
|
|
|
|
|
|
char * ltrim(char * s); |
|
|
|
|
|
void nice_delay(unsigned long ms); |
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------- |
|
|
|
|
|
// GPIO |
|
|
|
|
|
// ----------------------------------------------------------------------------- |
|
|
|
|
|
bool gpioValid(unsigned char gpio); |
|
|
|
|
|
bool gpioGetLock(unsigned char gpio); |
|
|
|
|
|
bool gpioReleaseLock(unsigned char gpio); |
|
|
|
|
|
|
|
|
#define ARRAYINIT(type, name, ...) type name[] = {__VA_ARGS__}; |
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------- |
|
|
// ----------------------------------------------------------------------------- |
|
|
// Debug |
|
|
|
|
|
|
|
|
// WebServer |
|
|
// ----------------------------------------------------------------------------- |
|
|
// ----------------------------------------------------------------------------- |
|
|
void debugSend(const char * format, ...); |
|
|
|
|
|
void debugSend_P(PGM_P format, ...); |
|
|
|
|
|
|
|
|
#if WEB_SUPPORT |
|
|
|
|
|
#include <ESPAsyncWebServer.h> |
|
|
|
|
|
AsyncWebServer * webServer(); |
|
|
|
|
|
#else |
|
|
|
|
|
#define AsyncWebServerRequest void |
|
|
|
|
|
#define ArRequestHandlerFunction void |
|
|
|
|
|
#define AsyncWebSocketClient void |
|
|
|
|
|
#define AsyncWebSocket void |
|
|
|
|
|
#define AwsEventType void * |
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------- |
|
|
// ----------------------------------------------------------------------------- |
|
|
// Domoticz |
|
|
|
|
|
|
|
|
// WebSockets |
|
|
// ----------------------------------------------------------------------------- |
|
|
// ----------------------------------------------------------------------------- |
|
|
template<typename T> void domoticzSend(const char * key, T value); |
|
|
|
|
|
template<typename T> void domoticzSend(const char * key, T nvalue, const char * svalue); |
|
|
|
|
|
|
|
|
#if WEB_SUPPORT |
|
|
|
|
|
typedef std::function<void(JsonObject&)> ws_on_send_callback_f; |
|
|
|
|
|
void wsOnSendRegister(ws_on_send_callback_f callback); |
|
|
|
|
|
void wsSend(ws_on_send_callback_f sender); |
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------- |
|
|
|
|
|
// RFM69 |
|
|
|
|
|
// ----------------------------------------------------------------------------- |
|
|
|
|
|
typedef struct { |
|
|
|
|
|
unsigned long messageID; |
|
|
|
|
|
unsigned char packetID; |
|
|
|
|
|
unsigned char senderID; |
|
|
|
|
|
unsigned char targetID; |
|
|
|
|
|
char * key; |
|
|
|
|
|
char * value; |
|
|
|
|
|
int16_t rssi; |
|
|
|
|
|
} packet_t; |
|
|
|
|
|
|
|
|
typedef std::function<void(uint32_t, const char *, JsonObject&)> ws_on_action_callback_f; |
|
|
|
|
|
void wsOnActionRegister(ws_on_action_callback_f callback); |
|
|
|
|
|
|
|
|
|
|
|
typedef std::function<void(void)> ws_on_after_parse_callback_f; |
|
|
|
|
|
void wsOnAfterParseRegister(ws_on_after_parse_callback_f callback); |
|
|
|
|
|
|
|
|
|
|
|
typedef std::function<bool(const char *, JsonVariant&)> ws_on_receive_callback_f; |
|
|
|
|
|
void wsOnReceiveRegister(ws_on_receive_callback_f callback); |
|
|
|
|
|
#else |
|
|
|
|
|
#define ws_on_send_callback_f void * |
|
|
|
|
|
#define ws_on_action_callback_f void * |
|
|
|
|
|
#define ws_on_after_parse_callback_f void * |
|
|
|
|
|
#define ws_on_receive_callback_f void * |
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------- |
|
|
// ----------------------------------------------------------------------------- |
|
|
// Utils |
|
|
|
|
|
|
|
|
// WIFI |
|
|
// ----------------------------------------------------------------------------- |
|
|
// ----------------------------------------------------------------------------- |
|
|
char * ltrim(char * s); |
|
|
|
|
|
void nice_delay(unsigned long ms); |
|
|
|
|
|
|
|
|
|
|
|
#define ARRAYINIT(type, name, ...) \ |
|
|
|
|
|
type name[] = {__VA_ARGS__}; |
|
|
|
|
|
|
|
|
#include "JustWifi.h" |
|
|
|
|
|
typedef std::function<void(justwifi_messages_t code, char * parameter)> wifi_callback_f; |
|
|
|
|
|
void wifiRegister(wifi_callback_f callback); |