Commit Graph

258 Commits

Author SHA1 Message Date
David Čermák
0c3d306589 Merge branch 'bugfix/print_messages' into 'master'
Some changes to debug prints

See merge request espressif/esp-mqtt!63
2020-04-08 01:33:01 +08:00
Piyush Shah
b02746492a esp_mqtt: Change an error print to use ESP_LOGE instead of ESP_LOGI
And another one changed from LOGI to LOGD
2020-04-06 12:13:18 +05:30
Piyush Shah
dc1a635a97 esp_mqtt_abort_connection: Fixed an issue which could result in a race condition and subsequent crash 2020-03-30 19:59:27 +05:30
David Cermak
f243225521 config: option to configure output buffer size
Both input and output buffers had the same size, but it is desirable in embedded environment to use asymetric buffers. Added configuration option to defined output buffer size, if not defined output buffer defaults to the same size as the input buffer.

Closes https://github.com/espressif/esp-mqtt/issues/152
2020-03-10 15:26:49 +01:00
David Cermak
62d1509961 Resend queued: Set duplicate flag for both qos1 and qos2
Closes https://github.com/espressif/esp-mqtt/issues/151
2020-02-20 16:00:15 +01:00
David Cermak
e2aa29d2ea Client: Fix C++ build failing on incorrect event enum conversion
Closes https://github.com/espressif/esp-idf/issues/4787
2020-02-20 14:44:38 +01:00
David Cermak
3e4f91ae50 Client: unlock if unsubscribe message fails to be created
In a similar way as for the subscribe message
2020-02-10 08:01:10 +01:00
Umer Ilyas
7983357489 Client: unlock if subscribe message fails to be created
Closes https://github.com/espressif/esp-mqtt/issues/150
2020-02-10 08:00:45 +01:00
David Cermak
38eab46f14 Fix compilation issue with IDF version 4.0 and lower
Closes https://github.com/espressif/esp-mqtt/issues/149
2020-01-31 21:42:45 +01:00
David Cermak
2994c3f273 receive longer (websocket) data with standard tcp_transport reads
closes IDF-1084
2020-01-30 08:32:24 +01:00
David Cermak
420441b677 set separate ssl connection properties before transport connect 2020-01-30 08:31:59 +01:00
David Cermak
bbcf078a2b fix possible double free of client config if init fails 2020-01-29 08:25:05 +01:00
David Cermak
ed90a64551 client: queued oversized messaged even if not connected 2020-01-29 08:25:05 +01:00
David Cermak
3a47e3abae client locking: used recursive mutex instead to avoid getting the code too complex 2020-01-27 12:26:10 +01:00
David Cermak
9eca3f6db9 mqtt_client: set_config to update ssl-transport configuration
closes https://github.com/espressif/esp-mqtt/issues/146
closes IDFGH-2534
2020-01-25 22:24:00 +01:00
David Cermak
6e08f6a04f mqtt_outbox: fix to store timestamps in long-long format
closes https://github.com/espressif/esp-mqtt/issues/144
closes IDFGH-2491
2020-01-25 21:57:02 +01:00
Marius Vikhammer
7ac0a42831 MQTT: Add runtime selection of mqtt protocol version
Add config option for selecting protocol version at runtime.

This also fixed MQTT protocol version 3.1 which wasnt working with the original implementation

Closes https://github.com/espressif/esp-idf/issues/4448
Closes IDFGH-2311
Closes IDF-1320
2020-01-09 14:49:33 +08:00
David Cermak
2684ed413d add support for password protected client-key 2020-01-08 09:05:18 +01:00
David Cermak
97f91eda5c wait for the entire connack message with the configured timeout
Configured network timeout was used to receive separate characters
in the message. This change waits for the configured timeout if reading
the mqtt packet was left in progress (mqtt_message_receive() returns 0)

Closes FCS-254
2019-12-23 07:54:59 +01:00
Marius Vikhammer
17e2f68e43 Fixed bug where the event loop wouldn't get cleaned up during destroy.
The event loop would never get deleted due to the event loop handle being
cleared to 0 before checking if it exists.

Closes https://github.com/espressif/esp-idf/issues/4433
Closes IDFGH-2293
2019-12-04 11:12:17 +08:00
Marius Vikhammer
9ca997d2d4 Fix potential memory leak if failing to create mutex
Closes https://github.com/espressif/esp-idf/issues/4384
Closes IDFGH-2235
2019-11-22 20:28:45 +01:00
Marius Vikhammer
9655845fdc Fixed crash due to publishing before successful transport connect.
Initialization of the outgoing message buffer is now done during mqtt_init,
which means messages can be queued before the first connection is made.

The client now checks for fail_message after creating a message, and cancels
the current operation if this happens. Updated error handling in client_publish
to be more inline with API documentation.

Closes https://github.com/espressif/esp-idf/issues/4349
Closes https://github.com/espressif/esp-mqtt/issues/140
2019-11-22 20:28:45 +01:00
Marius Vikhammer
e1ab64f0d8 Add support for ALPN
Closes IDF-1162

Closes https://github.com/espressif/esp-mqtt/issues/137
2019-11-20 17:30:58 +08:00
Marius Vikhammer
3da472fd37 Add reconnect time as a configurable parameter.
Closes IDF-1126
2019-11-18 14:43:44 +08:00
David Cermak
e3b013e2db Extended error structure to be used in mqtt library and include mqtt
specific errors.
Corrected typos in comments and log messages
2019-10-09 11:22:02 +02:00
João Cabral
67042a1315 ADD: Get the response code from a failing connection.
This commit adds an event information "connect_return_code" that is written
when the client state is MQTT_STATE_INIT, and the connection fails.

This event info can then be written by the user app to find out the reason
of the fail connection.

Merges https://github.com/espressif/esp-mqtt/pull/100
2019-10-09 09:23:53 +02:00
Marius Vikhammer
52cdfa9087 Fix early retransmit
The time for retransmitting a message was set before transfer was done. This ment that if the transfer speed is slow or the message is big then it would be possible to trigger a retransmit too early.

Closes https://github.com/espressif/esp-mqtt/issues/131
2019-10-03 14:03:32 +02:00
Marius Vikhammer
3e35fc8323 MQTT: fix MQTT_PUBLISHED_EVENT not always being posted
- Some PUBLISHED events would not be posted due to outbox messages being deleted before receiving PUBCOMP.
 - Current pending_message is no longer used to check for acknowledgements, as it doesn't work with multiple or out of order messages.

Closes https://github.com/espressif/esp-mqtt/issues/132
2019-10-03 13:28:51 +02:00
Matias
176be08f75 Fix not dispatching MQTT_EVENT_ERROR
If a publish failure ocurred, MQTT_EVENT_ERROR was not delivered to handler set with esp_mqtt_client_register_event
2019-09-14 21:16:31 -03:00
David Cermak
0234f6e538 client: added config option to enable global ca strore
closes https://github.com/espressif/esp-mqtt/issues/125
2019-08-23 14:33:35 +02:00
Henning Fleddermann
9a56cc7e14 add der-format support for tls-certificates/keys 2019-08-22 15:11:49 +02:00
liu zhifu
fb3d2107cd MQTT examples use new event 2019-08-16 16:15:54 +08:00
Thomas Bernard
cbae6343e9 fix deadlock between xEventGroupWaitBits and API lock semaphore
Merges https://github.com/espressif/esp-mqtt/pull/124
Closes https://github.com/espressif/esp-mqtt/issues/122
2019-08-08 11:54:42 +02:00
David Cermak
117eef2dad psk ssl could be used to authenticate with mqtt broker as an alternative to cerificate verification
Closes https://github.com/espressif/esp-mqtt/issues/95
2019-07-22 14:26:47 +02:00
David Cermak
0cc4077bd3 modified error type to be a generic handle to capture different types of errors 2019-07-04 09:12:40 +02:00
David Cermak
65bf2255d7 adding error event with error code 2019-07-03 08:49:54 +02:00
David Cermak
d9faeb47a3 fix resending subscribe messages
subscribe and unsubscribe messages were pushed to queue, but TRANSMIT flag wasn't set, so they were automatically retransmitted
2019-06-27 16:39:42 +02:00
David Cermak
82fa03a508 fixed possible race conditions in public API of mqtt_client
- Modified most of the public API to lock even if checking for connection state
- Updated `esp_mqtt_set_config` locks to be used also from callbacks (in mqtt-task context)
- Moved initialization of event_loop out of esp_mqtt_set_config
2019-06-27 16:36:12 +02:00
Gregory Eslinger
7223302deb MQTT Client: Check for connection before sending disconnect message
Closes https://github.com/espressif/esp-idf/issues/3619
Closes https://github.com/espressif/esp-mqtt/issues/120
Merges https://github.com/espressif/esp-mqtt/pull/118

Signed-off-by: David Cermak <cermak@espressif.com>
2019-06-27 16:33:58 +02:00
David Cermak
edd67e1c8c used event loop only if defined in supported features (enabled by macros) for backward compatibily with older IDFs 2019-06-06 17:00:03 +02:00
David Cermak
48cd04baf1 defined macros for supported features in esp-idf based on idf version 2019-05-29 14:05:49 +02:00
Tuan
a6f8716fff Add mqtt sub protocol for websocket 2019-05-24 09:29:31 +02:00
David Cermak
eeebd0215c support for esp event loop library while keeping backward compatible mode if callback configured 2019-05-16 16:29:33 +02:00
David Cermak
18b6f2c582 Fixed formatting for all files to comply with idf style formats 2019-05-15 13:40:14 +02:00
David Cermak
60cdb79a67 mqtt_msg: avoid uncasting const to mqtt topic and data pointers 2019-05-15 13:40:14 +02:00
David Cermak
d159bf4575 support for publishing message with empty data 2019-05-15 13:40:08 +02:00
David Cermak
891646681e client_init: fix crashing client upon wrong parameters, init or deinit
Closes https://github.com/espressif/esp-idf/issues/3191
2019-05-15 13:37:51 +02:00
David Cermak
7d22ab5fe6 pending_msg_count update on delete expired from outbox
Closes #111
2019-05-06 11:23:35 +02:00
David Cermak
fd564b1f17 client receive: refactor receive to read only one message to fragment only payload for longer messages
Closes #113
2019-05-06 11:23:28 +02:00
Gregory Eslinger
0450bd0093 MQTT Client: Added support for receiving empty payload 2019-04-26 17:07:04 +02:00