I have created a timer using esp_timer_create and in the timer callback want to post an event to the event loop using esp_event_post. This should trigger the MQTT event handler I wrote: my_mqtt_event_handler, which should publish a basic string to the PC.
Is it possible to include a new event for MQTT event loops so I can publish every few seconds? My handler does not seem like it is being called and using the given events from MQTT_EVENT_BEFORE_CONNECT through MQTT_EVENT_ERROR does not seem like it will work for unprompted publishing.
here is my C file, everything else in the folder is the same as the TCP example. Using ESP32-DOIT DevKit V1 off amazon. Using Mosquitto on Linux to subscribe to messages published by the ESP32.
app_main.c is attached below
ESP-IDF output once connected to wifi is this and it repeats the loop with no publish:
Code: Select all
I (5630) MQTT_EXAMPLE: Other event id:7
I (5790) MQTT_EXAMPLE: MQTT_EVENT_CONNECTED
I (5800) MQTT_EXAMPLE: sent publish successful, msg_id=45308
I (5800) MQTT_EXAMPLE: sent publish successful, msg_id=0
I (5810) MQTT_EXAMPLE: MQTT_EVENT_PUBLISHED, msg_id=45308
I (10630) MQTT_EXAMPLE: TIMER_EVENTS:TIMER_EVENT_EXPIRED: posting to default loop
I (15630) MQTT_EXAMPLE: TIMER_EVENTS:TIMER_EVENT_EXPIRED: posting to default loop
I (20630) MQTT_EXAMPLE: TIMER_EVENTS:TIMER_EVENT_EXPIRED: posting to default loop