Chat freely about anything...

User avatar
By myeoman
#11945 The retain=1 is a different MQTT mechanism, which retains the "last known good" message per topic - always a max of one message per topic, which remains until you explicitly remove it. I agree that this is working.

I am talking about publishing with qos >= 1 (and retain=0). The broker will store these messages to later deliver to a client that has gone offline.

To test, do the following:
1. Set the cleanSession parameter to 0 within the MQTT_InitClient function in user_int.
2. Subscribe to a topic by setting qos to 1 within MQTT_Subscribe function in mqttConnectedCb.
3. Start ESP8266 to execute the above, then remove power.
4. With the ESP8266 off, publish a few test messages to that MQTT topic with qos=1 flag set, using test software.
5. Startup the ESP8266. It should pick up those messages, but does not currently.

Tomorrow I'll try and post on my blog all the steps I followed for tests using the Paho client (i.e. not running on the ESP8266). Paho correctly picks up the stored messages when reconnecting.

[update] @tuanpm, here is the link. Please could you take a look? http://tinker.yeoman.com.au/2015/03/15/investigating-mqtt-persistence-in-an-iot-protocol-on-the-esp8266/
User avatar
By tuanpm
#12450
myeoman wrote:The retain=1 is a different MQTT mechanism, which retains the "last known good" message per topic - always a max of one message per topic, which remains until you explicitly remove it. I agree that this is working.

I am talking about publishing with qos >= 1 (and retain=0). The broker will store these messages to later deliver to a client that has gone offline.

To test, do the following:
1. Set the cleanSession parameter to 0 within the MQTT_InitClient function in user_int.
2. Subscribe to a topic by setting qos to 1 within MQTT_Subscribe function in mqttConnectedCb.
3. Start ESP8266 to execute the above, then remove power.
4. With the ESP8266 off, publish a few test messages to that MQTT topic with qos=1 flag set, using test software.
5. Startup the ESP8266. It should pick up those messages, but does not currently.

Tomorrow I'll try and post on my blog all the steps I followed for tests using the Paho client (i.e. not running on the ESP8266). Paho correctly picks up the stored messages when reconnecting.

[update] @tuanpm, here is the link. Please could you take a look? http://tinker.yeoman.com.au/2015/03/15/investigating-mqtt-persistence-in-an-iot-protocol-on-the-esp8266/


Hello myeoman,
i've tested mqtt client by: https://eclipse.org/paho/clients/testing/
all message from esp8266 client corrected.
so i need to test your behavior more.
User avatar
By Zennix
#15198 Hi all,

I´m trying to implement the esp8266 in my openhab environment. First step was to get a simple LED working with MQTT.
That´s already working with a Mosquitto server on my raspberry. I can turn the LED on and of using my cell phone with a tiny MQTT client.
The next step was to implement a button. The button press should send a MQTT message to switch the LED on the same board to on. The interrupt for the GPIO is working, but when I try to set the MQTT_Publish statement into the function, the esp throws a fatal error.

Knopf gedrueckt ...
Fatal exception (29):
epc1=0x402448f5, epc2=0x00000000, epc3=0x00000000, excvaddr=0x0000003c, depc=0x00000000
del if0
usl
sul 3 0

The same statement placed in the "void mqttConnectedCb(uint32_t *args)" is working witout any problem.
Anyone an idea whats going wrong?

Thanks / Zennix

Here is my code for the button:
Code: Select allvoid debounce_func(void *args) // Interrupt Routine Prell Timer
{
   MQTT_Client* client = (MQTT_Client*)args;
   MQTT_Publish(client, "/Wohnzimmer/Licht/1", "0", 1, 0, 1); 
   gpio_pin_intr_state_set(GPIO_ID_PIN(0),  GPIO_PIN_INTR_NEGEDGE); // Interrupt wieder einschalten on any GPIO0 edge
}


void switch_int_handler(uint32_t *arg)
{
   gpio_pin_intr_state_set(GPIO_ID_PIN(0), GPIO_PIN_INTR_DISABLE );
   uint32 gpio_status = GPIO_REG_READ(GPIO_STATUS_ADDRESS);
   GPIO_REG_WRITE(GPIO_STATUS_W1TC_ADDRESS, gpio_status & BIT(0));
   INFO("\r\nKnopf gedrueckt ...\r\n");
   os_timer_disarm(&debounce);                                        // Disarm Taster-Prell timer
   os_timer_setfn(&debounce, (os_timer_func_t *)debounce_func, NULL);   // Setup Taster-Prell timer
   os_timer_arm(&debounce, 1000, 1);                                   // Arm Prell timer, 1sec, repeat
}