lock retained and publish commands

pull/16/head
Martin Ger 2017-10-21 15:21:39 +02:00
rodzic f480661f9b
commit 868c8d6a24
6 zmienionych plików z 20 dodań i 5 usunięć

Wyświetl plik

@ -1,7 +1,7 @@
# esp_uMQTT_broker
An MQTT Broker/Client with scripting support on the ESP8266
This program enables the ESP8266 to become the central node in a small distributed IoT system. It implements an MQTT Broker and a simple scripted rule engine with event/action statements that links together the MQTT sensors and actors. It can act as STA, as AP, or as both and it can connect to another MQTT broker (i.e. in the cloud). Here it can act as bridge and forward and rewrite topics in both directions. Also it can parse JSON structures, send basic HTTP GET requests and do basic I/O: i.e. read and write to local GPIO pins, react on timers and GPIO interrupts, drive GPIO pins with PWM, and read the ADC.
This program enables the ESP8266 to become the central node in a small distributed IoT system. It implements an MQTT Broker and a simple scripted rule engine with event/action statements that links together the MQTT sensors and actors. It can act as STA, as AP, or as both and it can connect to another MQTT broker (i.e. in the cloud). Here it can also be bridge that forwards and rewrites topics in both directions. Also it can parse JSON structures, send basic HTTP GET requests and do basic I/O: i.e. read and write to local GPIO pins, react on timers and GPIO interrupts, drive GPIO pins with PWM, and read the ADC.
If you need the plain MQTT broker functionality in an Arduino project look here: https://github.com/martin-ger/esp_mqtt/blob/master/README.md#using-the-esp_umqtt_broker-in-an-arduino-project
@ -70,7 +70,7 @@ MQTT broker related command:
- set broker_retained_messages _max_: sets the max number of retained messages the broker can store (default: 30)
- save_retained: saves the current state of all retained topics (max. 4096 Bytes in sum) to flash, so they will persist a reboot
- delete_retained: deletes the state of all retained topics in RAM and flash
- set broker_autoretain [0|1]: selects, whether the broker should do a "save_retained" automatically each time it receives a new retained message (thus, the broker can be resetted at any time without loosing state. However, slow and too many writes may damage flash)
- set broker_autoretain [0|1]: selects, whether the broker should do a "save_retained" automatically each time it receives a new retained message (default off). With this option on the broker can be resetted at any time without loosing state. However, this is slow and too many writes may damage flash mem.
# MQTT client/bridging functionality
The broker comes with a "local" and a "remote" client, which means, the broker itself can publish and subscribe topics. The "local" client is a client to the own broker (without the need of an additional TCP connection).
@ -92,7 +92,7 @@ CMD>set mqtt_ssl 1
CMD>save
CMD>reset
```
Certificate check is not yet implemented.
Certificate checks are not yet implemented.
# Scripting
The esp_uMQTT_broker comes with a build-in scripting engine. A script enables the ESP not just to act as a passive broker but to react on events (publications and timing events), to send out its own items and handle local I/O. Details on syntax and semantics of the scripting language can be found here: https://github.com/martin-ger/esp_mqtt/blob/master/SCRIPTING.md . Examples of scripts are in the "scripts" directory.

Plik binarny nie jest wyświetlany.

Plik binarny nie jest wyświetlany.

Plik binarny nie jest wyświetlany.

Wyświetl plik

@ -1,2 +1,2 @@
22ebe22a250ca88f3fa0171622de438124613d4f 0x00000.bin
b94613a0f1410928080aa2209f67aa927b630868 0x10000.bin
1d6892b006fe44833bfe79867f4547a498f52807 0x00000.bin
53a7491e2066f612ecb22901ef8b5e700f14e41a 0x10000.bin

Wyświetl plik

@ -882,6 +882,11 @@ void ICACHE_FLASH_ATTR console_handle_command(struct espconn *pespconn) {
if (strcmp(tokens[0], "publish") == 0)
{
if (config.locked) {
os_sprintf(response, INVALID_LOCKED);
goto command_handled;
}
uint8_t retained = 0;
if (nTokens < 4 || nTokens > 5) {
@ -914,6 +919,11 @@ void ICACHE_FLASH_ATTR console_handle_command(struct espconn *pespconn) {
if (strcmp(tokens[0], "delete_retained") == 0)
{
if (config.locked) {
os_sprintf(response, INVALID_LOCKED);
goto command_handled;
}
if (nTokens != 1) {
os_sprintf(response, INVALID_NUMARGS);
goto command_handled;
@ -927,6 +937,11 @@ void ICACHE_FLASH_ATTR console_handle_command(struct espconn *pespconn) {
if (strcmp(tokens[0], "save_retained") == 0)
{
if (config.locked) {
os_sprintf(response, INVALID_LOCKED);
goto command_handled;
}
if (nTokens != 1) {
os_sprintf(response, INVALID_NUMARGS);
goto command_handled;