Commit Graph

93 Commits

Author SHA1 Message Date
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
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
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 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
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
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
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
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
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
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
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
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
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
Marius Vikhammer
5e17dcaeb2 MQTT: Fix esp_mqtt_client_stop deadlock
esp_mqtt_client_stop would lead to a deadlock (with itself) when called
from the event handler.

Updated comments to reflect that some functions should not be called from
the event handler.

Closes https://github.com/espressif/esp-mqtt/issues/163
2020-08-04 19:26:37 +08:00
Aditya Patwardhan
db4bce01ab mqtt: i)fix version check for secure_element
ii) fix secure_element error return

The feature allows use of secure element for TLS connections, which makes use of hardware security for storage of client private keys(only keys with ECC algorithm)

Applicable IDF versions: >= 4.2
2020-08-03 09:45:27 +05:30
Aditya Patwardhan
a7ff9afa3f esp-mqtt: add support for tls with secure element (ATECC608A)
Closes https://github.com/espressif/esp-mqtt/issues/156
2020-06-25 10:36:58 +05:30
Marius Vikhammer
5e8950e681 SSL: add config option for skipping common name check
Closes IDFGH-3408
Closes https://github.com/espressif/esp-mqtt/issues/158
2020-06-09 14:23:40 +08:00
David Cermak
615aeae0c2 docs: Makes clear that publish API could block
Closes https://github.com/espressif/esp-idf/issues/5077
2020-04-24 14:26:37 +02:00
Simon Brélivet
d8e2081332 config: option to configure mqtt task priority 2020-03-17 13:34:27 +01:00
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
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
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
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
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
David Cermak
9fbd7d9244 docs: Updated publish message return code to make it clear that message_id is always 0 for QoS 0
Closes https://github.com/espressif/esp-mqtt/issues/127
2019-09-30 08:05:51 +02: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
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
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
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
e442c19f4e Added API documentaton to public headers 2019-05-15 13:40:14 +02:00
David Cermak
752953dc3b added mqtt api locks, so methods can be executed from user context
closes #67, closes #90, closes https://github.com/espressif/esp-idf/issues/2975
2019-02-13 15:21:32 +01:00
Mikael Kanstrup
df455d2a5f Add client force reconnect function
esp-mqtt library is unaware of underlying network connectivity states
and current auto reconnect mechanism is built around timed retry
attempts every MQTT_RECONNECT_TIMEOUT_MS.

As application code usually keeps track of network connectity state
export a new function that application can use to request a forced
reconnect attempt as soon as connected to the network.
2019-02-04 08:44:55 +01:00
Tuan
2b49d37f8d Add BEFORE_CONNECt event and refresh the connection option 2018-11-09 23:26:35 +08:00
David Cermak
85f2eddabd commented event fields, added description of supplied user data to user event handler
closes #66
2018-10-25 09:25:41 +02:00