Copyright © https://mongoose-os.com

Mongoose OS Forum

frame

Did MQTT support change yesterday?

MQTT on ESP8266 was working perfectly yesterday, then after reflashing today - calling the javascript pub routine returns 0 always. I've tried with a number of MQTT brokers, and on a couple of different ESP8266 devices, and the pub routine always returns 0.

I've tried turning on debug messages, but nothing appears to be logged.

Any ideas?

default init.js file

load('api_config.js');
load('api_gpio.js');
load('api_mqtt.js');
load('api_sys.js');
load('api_timer.js');

// Helper C function get_led_gpio_pin() in src/main.c returns built-in LED GPIO
let led = ffi('int get_led_gpio_pin()')();

let getInfo = function() {
return JSON.stringify({total_ram: Sys.total_ram(), free_ram: Sys.free_ram()});
};

// Blink built-in LED every second
GPIO.set_mode(led, GPIO.MODE_OUTPUT);
Timer.set(1000 /* 1 sec /, true / repeat */, function() {
let value = GPIO.toggle(led);
print(value ? 'Tick' : 'Tock', 'uptime:', Sys.uptime(), getInfo());
}, null);

// Publish to MQTT topic on a button press. Button is wired to GPIO pin 0
GPIO.set_button_handler(0, GPIO.PULL_UP, GPIO.INT_EDGE_NEG, 200, function() {
let topic = '/devices/' + Cfg.get('device.id') + '/events';
let message = getInfo();
let ok = MQTT.pub(topic, message, 1);
print('Published:', ok ? 'yes' : 'no', 'topic:', topic, 'message:', message);
}, null);

my config...
{
"sntp": {
"enable": true,
"server": "pool.ntp.org",
"retry_min": 1,
"retry_max": 30,
"update_interval": 7200
},
"update": {
"timeout": 300,
"commit_timeout": 0,
"url": "",
"interval": 0,
"ssl_ca_file": "ca.pem",
"ssl_client_cert_file": "",
"ssl_server_name": "",
"enable_post": true
},
"wifi": {
"sta": {
"enable": false,
"ssid": "",
"pass": "",
"ip": "",
"netmask": "",
"gw": "",
"nameserver": "",
"dhcp_hostname": ""
},
"ap": {
"enable": true,
"ssid": "Mongoose_??????",
"pass": "Mongoose",
"hidden": false,
"channel": 6,
"max_connections": 10,
"ip": "192.168.4.1",
"netmask": "255.255.255.0",
"gw": "192.168.4.1",
"dhcp_start": "192.168.4.2",
"dhcp_end": "192.168.4.100",
"keep_enabled": true,
"trigger_on_gpio": -1
}
},
"device": {
"id": "esp8266_375720",
"password": ""
},
"debug": {
"udp_log_addr": "",
"mbedtls_level": 0,
"level": 3,
"filter": "",
"stdout_uart": 0,
"stderr_uart": 0,
"factory_reset_gpio": -1,
"mg_mgr_hexdump_file": "",
"stdout_topic": "esp8266_375720/log",
"stderr_topic": "esp8266_375720/log"
},
"sys": {
"wdt_timeout": 30,
"atca": {
"enable": false,
"i2c_addr": 96,
"ecdh_slots_mask": 12
}
},
"conf_acl": "",
"i2c": {
"enable": true,
"freq": 100000,
"debug": false,
"sda_gpio": 12,
"scl_gpio": 14
},
"mqtt": {
"enable": true,
"server": "iot.eclipse.org:1883",
"client_id": "",
"user": "",
"pass": "",
"reconnect_timeout_min": 2,
"reconnect_timeout_max": 60,
"ssl_cert": "",
"ssl_key": "",
"ssl_ca_cert": "",
"ssl_cipher_suites": "",
"ssl_psk_identity": "",
"ssl_psk_key": "",
"clean_session": true,
"keep_alive": 60,
"will_topic": "",
"will_message": ""
},
"aws": {
"shadow": {
"thing_name": ""
}
},
"http": {
"enable": true,
"listen_addr": "80",
"ssl_cert": "",
"ssl_key": "",
"ssl_ca_cert": "",
"upload_acl": "
",
"hidden_files": "",
"auth_domain": "",
"auth_file": ""
},
"dns_sd": {
"enable": false,
"host_name": "mOS_esp8266_??????",
"txt": "",
"ttl": 120
},
"gcp": {
"enable": false,
"project": "",
"region": "",
"registry": "",
"device": "",
"key": "",
"token_ttl": 3600
},
"mjs": {
"generate_jsc": true
},
"rpc": {
"enable": true,
"max_frame_size": 4096,
"max_queue_length": 25,
"default_out_channel_idle_close_timeout": 10,
"ws": {
"enable": true,
"server_address": "",
"reconnect_interval_min": 1,
"reconnect_interval_max": 60,
"ssl_server_name": "",
"ssl_ca_file": "",
"ssl_client_cert_file": ""
},
"mqtt": {
"enable": true,
"topic": "",
"is_trusted": true
},
"uart": {
"uart_no": 0,
"baud_rate": 115200,
"fc_type": 2,
"wait_for_start_frame": true
}
},
"spi": {
"enable": false,
"debug": false,
"miso_gpio": 12,
"mosi_gpio": 13,
"sclk_gpio": 14,
"cs0_gpio": 5,
"cs1_gpio": -1,
"cs2_gpio": -1
}
}

Comments

Sign In or Register to comment.