Commit Graph

73 Commits

Author SHA1 Message Date
Euripedes Rocha 89e5c6014f fix: MQTT tick not starting on connect and switch to esp_timer
- Tick should be updated on connect
- Dependency of system timer removed to avoid issues when updating via
  SNTP

Closes https://github.com/espressif/esp-mqtt/issues/225
2022-06-23 12:43:58 -03:00
yuanjm fdf2aeb36f Seperate MQTT5 from MQTT 3.1.1 2022-06-14 09:37:46 +00:00
yuanjm 3d275f42b9 mqtt: Support MQTT5 protocol 2022-06-14 09:37:46 +00:00
Euripedes Rocha f6caaff254 Fix WSS default port selection through menuconfig.
Evaluate the correct define to select default port.

 - Closes https://github.com/espressif/esp-mqtt/issues/223
2022-05-17 07:16:07 +00:00
Euripedes Rocha 2c2e6f38b5 Changes the moment we update keepalive_tick.
In order to keep sending keep alive messages in the scenario were client
publish too often with QoS0 the keepalive is updated when the response
is received.
2022-04-07 09:14:03 -03:00
AndriiFilippov fb3184cc14 Make the mqtt submodule logging tags lower case 2022-04-04 10:33:06 +02:00
Anton Maklakov f83d2a9111 remove unused variable 2022-03-04 07:42:25 +00:00
Sudeep Mohanty 1a96ea3efa Replaced esp_system.h inclusion with esp_random.h and esp_mac.h
Signed-off-by: Sudeep Mohanty <sudeep.mohanty@espressif.com>
2022-01-17 15:33:11 +01:00
yuanjm df8dc92870 Client: Fix use esp_mqtt_client_enqueue API to send data, data dup flag will be set 1 2021-11-26 15:52:04 +08:00
Euripedes Rocha 1fd50dd2cb Adds a config flag to allow an empty client id
This commit covers a use case where the user can select to send an
empty user id.
2021-11-01 18:17:29 +01:00
Bert Melis de47f1c341 add payload to MQTT_EVENT_SUBSCRIBE
+ documentation
+ cleanup logging

Closes https://github.com/espressif/esp-mqtt/issues/200
Merges https://github.com/espressif/esp-mqtt/pull/203
2021-10-04 10:38:02 +02:00
Euripedes Rocha ebef896b00 Removes unnecessary outbox_cleanup
The states that were cleaned by this function, CONFIRMED, are no longer reachable.
Itens were marked with this status previously in PUBCOMP and PUBREL
receive handlers.
2021-07-01 14:40:45 +01:00
David Cermak 1a94efe8b9 outbox: Cleanup all items when connection closes 2021-06-24 06:31:29 +02:00
Euripedes Rocha eec6f0e17d Removes unused defines.
- mqtt_config.h had some defines that were not used. This removes them.

Closes https://github.com/espressif/esp-mqtt/issues/194
2021-05-31 13:29:25 +01:00
Axel Lin ff8e64839a mqtt_outbox: Use STAILQ_FOREACH for outbox_delete_single_expired
For the delete one entry and return case, no need to use STAILQ_FOREACH_SAFE.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
2021-04-20 11:27:42 +08:00
David Čermák 1db731f985 Merge branch 'feature/mqtt_unit_test_cleanup' into 'master'
Reduce the includes used in files.

See merge request espressif/esp-mqtt!93
2021-04-07 11:37:00 +00:00
Euripedes Rocha Filho 87fcce72c9 Reduce the includes used in all files.
- To reduce the dependencies to the minimal the number of includes was
  reduced.
2021-04-07 10:49:49 +01:00
Angus Gratton 169b6986eb platform: Remove __FILE__ macro from error logs 2021-02-22 18:11:41 +01:00
Euripedes Rocha Filho 0213382593 mqtt: Moves mqtt_supported_features to public includes.
- To simplify user code to support multiple IDF versions.

Closes https://github.com/espressif/esp-mqtt/issues/184
2021-01-21 09:49:24 +00:00
Axel Lin 3efac7b7fa mqtt_msg: Set zero length username if password is set without username
Some cloud server (e.g. exosite) takes empty username with password.

When password is set without username, the current esp-mqtt implementation will
ignore the username and only set password. This violates MQTT-3.1.2-22 [1].
To address this issue, send zero length username if password is set without username.

[1] MQTT-3.1.2-22: If the User Name Flag is set to 0 then the Password Flag MUST be set to 0.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
2021-01-19 08:36:17 +01:00
David Cermak e2de0f3e3e Publish: Allow for qos=0 messages to be stored using esp_mqtt_client_enqueue()
The API presents a boolean parameter to control storing the qos=0
messages into the internal outbox
2020-12-15 19:43:33 +01:00
David Cermak 2e35d4d4d5 Events: Add new event to report deleted messages from outbox 2020-12-09 10:14:54 +01:00
David Cermak f44dcb1c26 Config: Add a new option to disable publishing when disconnected
Related https://github.com/espressif/esp-mqtt/pull/177
2020-12-09 10:14:54 +01:00
David Cermak 8bb4a26f46 Config: Add a new option to use incremental message id
This option is off by default, so the client still uses
random message id unless CONFIG_MQTT_MSG_ID_INCREMENTAL is set

Closes https://github.com/espressif/esp-mqtt/issues/176
2020-12-09 10:12:57 +01:00
David Cermak f65d5d05db Cleanup public include dirs 2020-12-06 11:26:03 +01:00
David Cermak 8562437c8a mqtt_config: Add config value to disable keepalive mechanism
Added a separate config value to allow disable the keepalive mechanism (and keep the existing API the same)
Internally though, the keepalive value (in connect_info) is in line with 3.1.2.10 Keep Alive from mqtt spec:
* keepalive=0: Keep alive mechanism disabled (server not to disconnect the client on its inactivity)
* period in seconds to send a Control packet if inactive

Closes https://github.com/espressif/esp-mqtt/issues/179
2020-11-18 14:41:44 +01:00
Axel Lin 673086e13a mqtt_outbox: Remove unused retry_count field from outbox_item_t
Signed-off-by: Axel Lin <axel.lin@ingics.com>
2020-11-09 16:08:22 +08:00
Angus Gratton b9db8d9020 Use size_t for all lengths
Previously, uint32_t and size_t were used interchangeably. These types are
interchangeable on Xtensa gcc (uint32_t == size_t == unsigned int), but not on most
other 32-bit gcc architectures (where uint32_t == unsigned long, size_t ==
unsigned int).
2020-10-09 16:33:12 +11:00
David Cermak 420441b677 set separate ssl connection properties before transport connect 2020-01-30 08:31:59 +01:00
David Cermak f7941e29be mqtt_outbox: fixed outbox_destroy() to correctly delete all queued messages
Closes https://github.com/espressif/esp-idf/issues/4643
Closes IDFGH-2558
Closes https://github.com/espressif/esp-mqtt/issues/148
Closes IDFGH-2599
Closes https://github.com/espressif/esp-mqtt/issues/147
Closes IDFGH-2598
2020-01-29 08:22:52 +01:00
David Cermak 7087193093 mqtt_msg: address const correctness 2020-01-25 21:57:02 +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
David Čermák 8ab095b5bb Merge branch 'feature/protocol_ver_rt_cfg' into 'master'
MQTT: Add runtime selection of mqtt protocol version

See merge request espressif/esp-mqtt!54
2020-01-20 16:41:55 +08: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
Rohan Singh ab1e8d7969 Support larger buffers and messages
Use `uint32_t` instead of `uint16_t` for message and buffer lengths.
This is necessary for receiving messages that are larger than 65K.
2020-01-08 15:00:10 -05: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
Laurent Louf 2e0e93a2d3 Add a check when publishing data to be able to publish a message without data without crashing.
Signed-off-by: Marius Vikhammer <marius.vikhammer@espressif.com>

Merges https://github.com/espressif/esp-mqtt/pull/117
2019-09-24 18:25:55 +08:00
Laurent Louf 2b04d177c7 Add a check when publishing data to verify that if some data length is set, data pointer cannot be NULL, in which case an error is returned.
Signed-off-by: Marius Vikhammer <marius.vikhammer@espressif.com>
2019-09-24 18:24:52 +08:00
David Cermak 971bf47e14 outbox: suppress clang-tidy warning of using ptr after free (no possible for STAILQ structure), removed unnecessary print 2019-06-06 17:00:03 +02:00
Ivan Grokhotkov 2ef78857e9 fix -Wstrict-prototypes issues 2019-05-17 14:36:44 +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
João Cabral db71c753aa FIX: mqtt_get_id wrong logic on msg size checks.
This error was preventing the function from returning the right msg ID,
returning always 0.
2019-05-15 13:40:14 +02:00
David Cermak 35fc42d2b9 mqtt_msg: added missing message type for unsubscribe msg type
Closes #109
2019-05-06 11:23:35 +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
suda-morris ca373e22cb change rom/queue.h to sys/queue.h 2019-03-14 20:26:28 +08:00