Browse Source

Fix RFM69 message buttons in Web UI

rfm69
Xose Pérez 6 years ago
parent
commit
7b0d062190
16 changed files with 15806 additions and 15764 deletions
  1. +116
    -82
      code/espurna/config/prototypes.h
  2. BIN
      code/espurna/data/index.all.html.gz
  3. BIN
      code/espurna/data/index.light.html.gz
  4. BIN
      code/espurna/data/index.rfbridge.html.gz
  5. BIN
      code/espurna/data/index.rfm69.html.gz
  6. BIN
      code/espurna/data/index.sensor.html.gz
  7. BIN
      code/espurna/data/index.small.html.gz
  8. +2628
    -2628
      code/espurna/static/index.all.html.gz.h
  9. +2634
    -2634
      code/espurna/static/index.light.html.gz.h
  10. +2266
    -2266
      code/espurna/static/index.rfbridge.html.gz.h
  11. +3629
    -3628
      code/espurna/static/index.rfm69.html.gz.h
  12. +2302
    -2302
      code/espurna/static/index.sensor.html.gz.h
  13. +2221
    -2222
      code/espurna/static/index.small.html.gz.h
  14. +2
    -0
      code/html/custom.css
  15. +7
    -2
      code/html/custom.js
  16. +1
    -0
      code/html/index.html

+ 116
- 82
code/espurna/config/prototypes.h View File

@ -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);

BIN
code/espurna/data/index.all.html.gz View File


BIN
code/espurna/data/index.light.html.gz View File


BIN
code/espurna/data/index.rfbridge.html.gz View File


BIN
code/espurna/data/index.rfm69.html.gz View File


BIN
code/espurna/data/index.sensor.html.gz View File


BIN
code/espurna/data/index.small.html.gz View File


+ 2628
- 2628
code/espurna/static/index.all.html.gz.h
File diff suppressed because it is too large
View File


+ 2634
- 2634
code/espurna/static/index.light.html.gz.h
File diff suppressed because it is too large
View File


+ 2266
- 2266
code/espurna/static/index.rfbridge.html.gz.h
File diff suppressed because it is too large
View File


+ 3629
- 3628
code/espurna/static/index.rfm69.html.gz.h
File diff suppressed because it is too large
View File


+ 2302
- 2302
code/espurna/static/index.sensor.html.gz.h
File diff suppressed because it is too large
View File


+ 2221
- 2222
code/espurna/static/index.small.html.gz.h
File diff suppressed because it is too large
View File


+ 2
- 0
code/html/custom.css View File

@ -169,6 +169,7 @@ div.state {
.button-dbg-clear, .button-dbg-clear,
.button-upgrade, .button-upgrade,
.button-clear-filters, .button-clear-filters,
.button-clear-messages,
.button-clear-counts, .button-clear-counts,
.button-settings-factory { .button-settings-factory {
background: rgb(192, 0, 0); /* redish */ background: rgb(192, 0, 0); /* redish */
@ -204,6 +205,7 @@ div.state {
.button-upgrade-browse, .button-upgrade-browse,
.button-clear-filters, .button-clear-filters,
.button-clear-messages,
.button-clear-counts, .button-clear-counts,
.button-dbgcmd, .button-dbgcmd,
.button-ha-add, .button-ha-add,


+ 7
- 2
code/html/custom.js View File

@ -544,7 +544,7 @@ function doFactoryReset() {
if (response === false) { if (response === false) {
return false; return false;
} }
websock.send(JSON.stringify({"action": "factory_reset"}));
sendAction("factory_reset", {});
doReload(5000); doReload(5000);
return false; return false;
} }
@ -583,10 +583,14 @@ function doDebugClear() {
<!-- removeIf(!rfm69)--> <!-- removeIf(!rfm69)-->
function doClearCounts() { function doClearCounts() {
websock.send(JSON.stringify({'action': 'clear-counts'}));
sendAction("clear-counts", {});
return false; return false;
} }
function doClearMessages() {
packets.clear().draw(false);
}
function doFilter(e) { function doFilter(e) {
var index = packets.cell(this).index(); var index = packets.cell(this).index();
if (index == 'undefined') return; if (index == 'undefined') return;
@ -1636,6 +1640,7 @@ $(function() {
$(".button-add-mapping").on('click', addMapping); $(".button-add-mapping").on('click', addMapping);
$(".button-del-mapping").on('click', delMapping); $(".button-del-mapping").on('click', delMapping);
$(".button-clear-counts").on('click', doClearCounts); $(".button-clear-counts").on('click', doClearCounts);
$(".button-clear-messages").on('click', doClearMessages);
$(".button-clear-filters").on('click', doClearFilters); $(".button-clear-filters").on('click', doClearFilters);
$('#packets tbody').on('mousedown', 'td', doFilter); $('#packets tbody').on('mousedown', 'td', doFilter);
packets = $('#packets').DataTable({ packets = $('#packets').DataTable({


+ 1
- 0
code/html/index.html View File

@ -744,6 +744,7 @@
</table> </table>
<button class="pure-button button-clear-filters">Clear filters</button> <button class="pure-button button-clear-filters">Clear filters</button>
<button class="pure-button button-clear-messages">Clear messages</button>
<button class="pure-button button-clear-counts">Clear counts</button> <button class="pure-button button-clear-counts">Clear counts</button>


Loading…
Cancel
Save