Commit Graph

343 Commits

Author SHA1 Message Date
David Čermák
e1a90d0161 Merge branch 'bugfix/outbox_del_single_STAILQ_FOREACH' into 'master'
mqtt_outbox: Use STAILQ_FOREACH for outbox_delete_single_expired

See merge request espressif/esp-mqtt!97
2021-05-22 06:01:35 +00: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
David Čermák
2b20b5117c Merge branch 'bugfix/mqtt_add_null_check' into 'master'
esp-mqtt: Add null checks for public APIs

See merge request espressif/esp-mqtt!94
2021-03-10 17:59:17 +00:00
suren.gabrielyan
2f57985c0b esp-mqtt: Added nullchecks for public APIs
Closes IDFGH-4724
Closes https://github.com/espressif/esp-mqtt/issues/185
2021-03-04 18:30:27 +04:00
David Čermák
9fdf7b6138 Merge branch 'bugfix/disable_file_in_logs' into 'master'
platform: Remove __FILE__ macro from error logs

See merge request espressif/esp-mqtt!92
2021-02-23 17:07:26 +00:00
Angus Gratton
169b6986eb platform: Remove __FILE__ macro from error logs 2021-02-22 18:11:41 +01:00
David Čermák
fd2d04e687 Merge branch 'bugfix/vs_nullcheck_on_malloc' into 'master'
Config: Add missing nullcheck after cfg password allocation

See merge request espressif/esp-mqtt!91
2021-02-11 23:39:32 +08:00
David Cermak
001dc1a95e Config: Add missing nullcheck after cfg password allocation
Partially addresses https://github.com/espressif/esp-idf/issues/6440
2021-02-11 15:54:45 +01:00
David Čermák
a5a60752c0 Merge branch 'bugfix/handle_missing_mqtt_states' into 'master'
Renames states and add missing handler on esp mqtt task

See merge request espressif/esp-mqtt!90
2021-02-02 22:14:09 +08:00
Euripedes Rocha Filho
369f4207f8 Renames states and add missing handler on task
- The state transition on esp_mqtt_task was missing 2 states
- MQTT_STATE_ERROR removed
- Added a default case for state transition.
- Renamed MQTT_STATE_WAIT_TIMEOUT -> MQTT_STATE_WAIT_RECONNECT
2021-01-27 17:33:22 +00:00
David Čermák
1a64f3176c Merge branch 'feature/public_mqtt_supported_features' into 'master'
Moves mqtt_supported_features to public includes.

See merge request espressif/esp-mqtt!89
2021-01-21 18:41:31 +08: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
David Čermák
a74adfa9eb Merge branch 'client_init_refactor' into 'master'
Clean client init

See merge request espressif/esp-mqtt!87
2021-01-21 15:57:52 +08:00
David Čermák
7a38867ce2 Merge branch 'destroy_config_refactor' into 'master'
Makes esp_mqtt_destroy_config void

See merge request espressif/esp-mqtt!86
2021-01-21 15:24:06 +08:00
David Čermák
2530edbdce Merge branch 'bugfix/allow_zero_length_username' into 'master'
mqtt_msg: Set zero length username if password is set without username

See merge request espressif/esp-mqtt!88
2021-01-21 15:22:05 +08:00
Euripedes Rocha Filho
e05ed2ce18 mqtt: Clean client init
- Moves check and copy of parameter to a function to reduce repetition
- Removes cfg variable to be explicit about what is being modified.
2021-01-19 11:54:09 +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
Euripedes Rocha Filho
b834be80a5 mqtt: Makes esp_mqtt_destroy_config void
- Makes the function a nop in case of NULL config.
2021-01-18 11:42:59 +00:00
David Čermák
9ea804e0ab Merge branch 'feature/queue_if_disconnect' into 'master'
esp-mqtt: More configs to queue when disconnected, events on delete, incremental msg-id

See merge request espressif/esp-mqtt!85
2020-12-21 19:42:15 +08: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
Umer Ilyas
dc7fd5c0b1 Publish: Add new API to enqueue qos>0 messages
Closes https://github.com/espressif/esp-mqtt/issues/155
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 Čermák
cef3e16c5d Merge branch 'bugfix/unused_mqtt_header_state_t' into 'master'
Remove unused mqtt_header_state_t

See merge request espressif/esp-mqtt!84
2020-12-03 18:48:17 +08:00
Axel Lin
b7158a4aea mqtt: Remove unused mqtt_header_state_t
mqtt_header_state_t was added by commit 0450bd0093 ("MQTT Client:  Added support for receiving empty payload"),
but it's no longer used since commit fd564b1f17 ("client receive: refactor receive to read only one message to fragment only payload for longer messages").
Thus remove the unused mqtt_header_state_t.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
2020-11-23 16:24:33 +08:00
David Čermák
da850b0add Merge branch 'feature/support_no_keepalive' into 'master'
mqtt_config: Add config value to disable keepalive mechanism

See merge request espressif/esp-mqtt!83
2020-11-19 22:07:05 +08: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
David Čermák
e8be6c3aa7 Merge branch 'feature/add_get_outbox_size' into 'master'
Add esp_mqtt_client_get_outbox_size API

See merge request espressif/esp-mqtt!82
2020-11-18 16:45:27 +08:00
David Čermák
65d8a813ea Merge branch 'bugfix/missing_unlock_and_cleanup' into 'master'
Minor fixes and cleanup

See merge request espressif/esp-mqtt!81
2020-11-18 16:44:41 +08:00
David Čermák
36d721e60b Merge branch 'bugfix/mqtt_err_flags_extention' into 'master'
error reporting: extended error event to use errno captured in transports

See merge request espressif/esp-mqtt!80
2020-11-13 05:10:58 +08:00
Axel Lin
0a1d9d0300 mqtt: Add esp_mqtt_client_get_outbox_size API
Allow application to get current outbox_size.
Application may try to send many publish request for a long period and then
system can hit OOM when publish QoS>1 with a busy borker.
Reduce OUTBOX_EXPIRED_TIMEOUT_MS does not help too much because the publish
freauency depends on the data received in different environment.
i.e. In some environment, sometimes it's easy to hit OOM before reaching OUTBOX_EXPIRED_TIMEOUT_MS.

To avoid such issue, add esp_mqtt_client_get_outbox_size API, so the application
can stop publishing to avoid OOM when outbox takes too much memory.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
2020-11-11 17:13:32 +08: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
Axel Lin
259baaec96 config: Fix typo for configuring OUTBOX_EXPIRED_TIMEOUT_MS
In esp-idf, it uses CONFIG_MQTT_OUTBOX_EXPIRED_TIMEOUT_MS rather than
CONFIG_OUTBOX_EXPIRED_TIMEOUT_MS.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
2020-11-09 16:07:10 +08:00
Axel Lin
845c2a3a1e mqtt: Fix missing MQTT_API_UNLOCK in esp_mqtt_client_stop error path
Fixes: 5e17dcaeb2 ("MQTT: Fix esp_mqtt_client_stop deadlock")
Signed-off-by: Axel Lin <axel.lin@ingics.com>
2020-11-09 16:06:58 +08:00
David Cermak
23c8e1ecf5 error reporting: extended error event to use errno captured in transports
Also renamed error type MQTT_ERROR_TYPE_ESP_TLS to
MQTT_ERROR_TYPE_TCP_TRANSPORT, as the former was confusing and might
have implied the error occurred in TLS layer.

Applicable IDF version >= v4.3

Closes https://github.com/espressif/esp-idf/issues/5906
2020-11-04 08:01:06 +01:00
David Čermák
d6613e995b Merge branch 'bugfix/size_t_for_all_lengths' into 'master'
Use size_t for all lengths

See merge request espressif/esp-mqtt!79
2020-10-12 18:16:29 +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 Čermák
fcd7f0d083 Merge branch 'bugfix/network_timeout' into 'master'
Allow to configure network timeout

See merge request espressif/esp-mqtt!78
2020-09-02 19:38:15 +08:00
Dmitriy Shilin
a03228ac46 Allow to configure network timeout
Merges https://github.com/espressif/esp-mqtt/pull/166
2020-09-02 08:36:01 +02:00
David Čermák
01594bf118 Merge branch 'feature/mqtt_support_esp_ds' into 'master'
esp-mqtt: Add support for Digital Signature (through ESP-TLS)

See merge request espressif/esp-mqtt!71
2020-08-18 15:22:41 +08:00
Aditya Patwardhan
7d8e59de00 mqtt: Add support for Digital Signature (through ESP-TLS)
Digital Signature enables hardware accelerated RSA signature
for TLS handshake.The RSA private key(client key) is also stored in
encrypted format and ecryption key is stored in hardware(efuse) which adds
additional level of security for mutual authentication.
* Digital Signature is only supported for ESP32-S2.

Applicable IDF version >= v4.3
2020-08-18 11:55:43 +05:30
David Čermák
ae408d9a69 Merge branch 'feature/outbox_limit' into 'master'
MQTT: Cleanup expired messages when offline

See merge request espressif/esp-mqtt!76
2020-08-18 14:08:57 +08:00
David Čermák
a8ef2a434b Merge branch 'bugfix/read_error_event' into 'master'
MQTT: add dispatch error event for read errors

See merge request espressif/esp-mqtt!75
2020-08-18 14:07:50 +08:00
David Čermák
867773e423 Merge branch 'fix/secure_element_feature' into 'master'
esp-mqtt: i) fix version check for secure_element

See merge request espressif/esp-mqtt!70
2020-08-18 14:04:39 +08:00
David Čermák
ac7209049f Merge branch 'bugfix/stop_from_event' into 'master'
MQTT: Fix esp_mqtt_client_stop deadlock

See merge request espressif/esp-mqtt!74
2020-08-17 22:01:08 +08:00
Marius Vikhammer
bdadd77c6e mqtt: deleted expired messages even when offline
As long as the client was disconnect no cleanup were performed,
consuming memory for every message published. Even if they were already
expired and would be discarded when reconnected.

Also moves delete of expired msgs before retransmit is done.
This avoids situtations where a message could be sent even if it was
expired.

Closes https://github.com/espressif/esp-idf/issues/5668
2020-08-10 16:42:32 +08:00