added broker_port

master
Martin Ger 2018-02-11 10:09:03 +01:00
rodzic b7740123d9
commit 35ba82bd07
9 zmienionych plików z 39 dodań i 7 usunięć

Wyświetl plik

@ -68,6 +68,7 @@ MQTT broker related command:
- show [mqtt]: prints the current config or status information of the MQTT broker
- set broker_user _unsername_: sets the username for authentication of MQTT clients ("none" if no auth, default)
- set broker_password _password_: sets the password for authentication of MQTT clients ("none" if empty, default)
- set broker_port _portno_: sets the port number where the broker listens (default: 1883)
- set broker_access _mode_: controls the networks that allow MQTT broker access (0: no access, 1: only internal, 2: only external, 3: both (default))
- set broker_subscriptions _max_: sets the max number of subscription the broker can store (default: 30)
- set broker_retained_messages _max_: sets the max number of retained messages the broker can store (default: 30)

Plik binarny nie jest wyświetlany.

Plik binarny nie jest wyświetlany.

Wyświetl plik

@ -1,2 +1,2 @@
61d248ad11f523f4a462187b213cdbe69b6c0aa5 0x00000.bin
ac16d371575432a47b61450cdd9c0cb2880af3c9 0x10000.bin
aad1bc4c500f3836523620982e21b3691b8bc0b9 0x00000.bin
9233bfa70966e815add9982343fcca1678105130 0x10000.bin

Wyświetl plik

@ -0,0 +1,15 @@
% Config params, overwrite any previous settings from the commandline
config system_output 0
on init
do
gpio_pinmode 1 input pullup
gpio_pinmode 3 input pullup
on gpio_interrupt 1 pullup
do
println "Interrupt GPIO 1: " | $this_gpio
on gpio_interrupt 3 pullup
do
println "Interrupt GPIO 3: " | $this_gpio

Wyświetl plik

@ -145,7 +145,7 @@ void ICACHE_FLASH_ATTR console_handle_command(struct espconn *pespconn) {
to_console(response);
os_sprintf(response, "set [config_port|config_access|bitrate|system_output] <val>\r\n");
to_console(response);
os_sprintf(response, "set [broker_user|broker_password|broker_access|broker_clients] <val>\r\n");
os_sprintf(response, "set [broker_port|broker_user|broker_password|broker_access|broker_clients] <val>\r\n");
to_console(response);
os_sprintf(response, "set [broker_subscriptions|broker_retained_messages|broker_autoretain] <val>\r\n");
to_console(response);
@ -164,7 +164,7 @@ void ICACHE_FLASH_ATTR console_handle_command(struct espconn *pespconn) {
#endif
#endif
#ifdef NTP
os_sprintf(response, "time\r\nset [ntp_server|ntp_interval|<ntp_timezone> <val>\r\n");
os_sprintf(response, "time\r\nset [ntp_server|ntp_interval|ntp_timezone] <val>\r\n");
to_console(response);
#endif
#ifdef MQTT_CLIENT
@ -220,8 +220,14 @@ void ICACHE_FLASH_ATTR console_handle_command(struct espconn *pespconn) {
config.max_subscriptions, config.max_retained_messages, config.auto_retained?" (auto saved)":"");
to_console(response);
os_sprintf(response, "MQTT broker max. clients: %d\r\n", config.max_clients);
to_console(response);
if (config.mqtt_broker_port != MQTT_PORT) {
os_sprintf(response, "MQTT broker port: %d\r\n", config.mqtt_broker_port);
to_console(response);
}
if (config.max_clients != 0) {
os_sprintf(response, "MQTT broker max. clients: %d\r\n", config.max_clients);
to_console(response);
}
if (os_strcmp(config.mqtt_broker_user, "none") != 0) {
os_sprintf(response,
@ -876,6 +882,12 @@ void ICACHE_FLASH_ATTR console_handle_command(struct espconn *pespconn) {
goto command_handled;
}
if (strcmp(tokens[1], "broker_port") == 0) {
config.mqtt_broker_port = atoi(tokens[2]);
os_sprintf(response, "Broker port set\r\n");
goto command_handled;
}
if (strcmp(tokens[1], "broker_user") == 0) {
os_strncpy(config.mqtt_broker_user, tokens[2], 32);
config.mqtt_broker_user[31] = '\0';

Wyświetl plik

@ -40,6 +40,7 @@ void config_load_default(sysconfig_p config) {
config->config_port = CONSOLE_SERVER_PORT;
config->config_access = LOCAL_ACCESS | REMOTE_ACCESS;
config->mqtt_broker_port = MQTT_PORT;
config->max_subscriptions = 30;
config->max_retained_messages = 30;
config->max_clients = 0;

Wyświetl plik

@ -19,6 +19,8 @@
#define SYSTEM_OUTPUT_CMD 1
#define SYSTEM_OUTPUT_NONE 0
#define MQTT_PORT 1883
typedef struct
{
// To check if the structure is initialized or not in flash
@ -56,6 +58,7 @@ typedef struct
uint8_t system_output; // Disable system info and warnings
uint32_t bit_rate; // Bit rate of serial link
uint16_t mqtt_broker_port; // Port where the MQTT broker listens (1883 default)
uint16_t max_subscriptions; // Upper limit on subscribed topics
uint16_t max_retained_messages; // Upper limit on stored retained messages
uint16_t max_clients; // Upper limit on concurrently connected clients (0: mem is the limit)

Wyświetl plik

@ -894,7 +894,7 @@ void user_init() {
MQTT_server_onConnect(mqtt_broker_connect);
MQTT_server_onAuth(mqtt_broker_auth);
MQTT_server_start(1883 /*port */ , config.max_subscriptions,
MQTT_server_start(config.mqtt_broker_port , config.max_subscriptions,
config.max_retained_messages);
load_retainedtopics();
set_on_retainedtopic_cb(mqtt_got_retained);