Commit Graph

642 Commits

Author SHA1 Message Date
Rocha Euripedes
74481cbbf4 Merge branch 'fix/log_level_on_timeout' into 'master'
fix: Adjust the log level on few messages to avoid cluthering the logs

See merge request espressif/esp-mqtt!201
2024-03-22 15:05:49 +08:00
Rocha Euripedes
c33a0c8e44 Merge branch 'fix/detect_mac_type' into 'master'
fix: Make automatic client_id soc dependent

See merge request espressif/esp-mqtt!200
2024-03-22 15:05:21 +08:00
Euripedes Rocha
5c17fc4a1a fix: Adjust the log level on few messages to avoid cluthering the logs 2024-03-21 14:11:57 +01:00
Euripedes Rocha
657a2aea77 fix: Make automatic client_id soc dependent
When creating the client_id for user, the library uses the device MAC.
For some of our devices WIFI isn't available and the library needs to select
a different MAC to use.
2024-03-14 07:31:37 +01:00
Rocha Euripedes
fa88da5282 Merge branch 'lifetime_clarification' into 'master'
Clarify data that users need to take care of lifetime.

See merge request espressif/esp-mqtt!197
2024-01-26 19:10:50 +08:00
Rocha Euripedes
5a35782272 Merge branch 'fix/subscribe_macro_type' into 'master'
Update mqtt_client.h

See merge request espressif/esp-mqtt!198
2024-01-26 18:54:42 +08:00
faceleft
acdb66d5c6 add const char * to esp_mqtt_client_subscribe() generic macros 2024-01-25 15:35:32 +07:00
Rocha Euripedes
d3e3c4e7ad Merge branch 'bugfix/consolidate_err_messages' into 'master'
client: Report failure on timeout in mid-message timeout (GitHub PR)

See merge request espressif/esp-mqtt!165
2024-01-24 22:23:04 +08:00
Euripedes Rocha
371f594cce docs: Clarify data that users need to take care of lifetime.
- Adds to field that the mqtt client doesn't copy a note about it.
2024-01-24 09:38:37 +01:00
David Cermak
ddde502782 client: Report failure on timeout in mid-message timeout
Fixes error processing on network reads:

1) Treat EOF as an error, since the connection is closed (FIN) from the
server side. If we didn't we would try to read (in the next iteration)
from the same socket that has been already closed and get an error
ENOTCONN.
Before the fix:
D (13760) mqtt_client: esp_mqtt_handle_transport_read_error: transport_read(): EOF
E (13800) transport_base: tcp_read error, errno=Socket is not connected
E (13800) mqtt_client: esp_mqtt_handle_transport_read_error: transport_read() error: errno=128
D (13810) esp_mqtt_demo: Event dispatched from event loop base=MQTT_EVENTS, event_id=0
I (13820) esp_mqtt_demo: MQTT_EVENT_ERROR
E (13830) esp_mqtt_demo: Last error reported from esp-tls: 0x8008
E (13830) esp_mqtt_demo: Last error captured as transport's socket errno: 0x80
I (13840) esp_mqtt_demo: Last errno string (Socket is not connected)
E (13850) mqtt_client: mqtt_process_receive: mqtt_message_receive() returned -1
D (13860) mqtt_client: Reconnect after 10000 ms
D (13860) esp_mqtt_demo: Event dispatched from event loop base=MQTT_EVENTS, event_id=2
I (13870) esp_mqtt_demo: MQTT_EVENT_DISCONNECTED
After the fix:
E (12420) mqtt_client: esp_mqtt_handle_transport_read_error: transport_read(): EOF
E (12420) mqtt_client: esp_mqtt_handle_transport_read_error: transport_read() error: errno=128
D (12430) esp_mqtt_demo: Event dispatched from event loop base=MQTT_EVENTS, event_id=0
I (12440) esp_mqtt_demo: MQTT_EVENT_ERROR
E (12450) esp_mqtt_demo: Last error reported from esp-tls: 0x8008
I (12450) esp_mqtt_demo: Last errno string (Success)
E (12460) mqtt_client: mqtt_process_receive: mqtt_message_receive() returned -1
D (12470) mqtt_client: Reconnect after 10000 ms
D (12470) esp_mqtt_demo: Event dispatched from event loop base=MQTT_EVENTS, event_id=2
I (12480) esp_mqtt_demo: MQTT_EVENT_DISCONNECTED

2) Treat timeouts in the middle of MQTT message reading as errors (if
timeouted for the second time and didn't read a byte)
Before the fix:
D (9160) mqtt_client: mqtt_message_receive: read "remaining length" byte: 0x2
D (9170) mqtt_client: mqtt_message_receive: total message length: 4 (already read: 2)
D (19190) mqtt_client: mqtt_message_receive: read_len=0
D (19190) mqtt_client: esp_mqtt_handle_transport_read_error: transport_read(): call timed out before data was ready!
E (19200) mqtt_client: esp_mqtt_connect: mqtt_message_receive() returned 0
E (19210) mqtt_client: MQTT connect failed
D (19220) mqtt_client: Reconnect after 10000 ms
D (19220) esp_mqtt_demo: Event dispatched from event loop base=MQTT_EVENTS, event_id=2
I (19230) esp_mqtt_demo: MQTT_EVENT_DISCONNECTED
After the fix:
D (19190) mqtt_client: mqtt_message_receive: read_len=0
E (19190) mqtt_client: Network timeout while reading MQTT message
E (19200) mqtt_client: esp_mqtt_handle_transport_read_error: transport_read() error: errno=119
D (19210) esp_mqtt_demo: Event dispatched from event loop base=MQTT_EVENTS, event_id=0
I (19220) esp_mqtt_demo: MQTT_EVENT_ERROR
I (19220) esp_mqtt_demo: Last errno string (Success)
E (19230) mqtt_client: esp_mqtt_connect: mqtt_message_receive() returned -1
E (19240) mqtt_client: MQTT connect failed
D (19240) mqtt_client: Reconnect after 10000 ms
D (19240) esp_mqtt_demo: Event dispatched from event loop base=MQTT_EVENTS, event_id=2
I (19250) esp_mqtt_demo: MQTT_EVENT_DISCONNECTED
(Note that the above log is from mid-message timeout of CONNECT message,
which was hadled before the fix. If the mid-message timeout ocurs with
for example SUBACK, the current version would repeatably resend
susbscribe message)

Merges https://github.com/espressif/esp-mqtt/pull/232
2023-11-10 15:40:44 +01:00
Rocha Euripedes
7894dd0ace Merge branch 'fix/buffer_creation_in_set_config' into 'master'
fix: Move buffer initialization to set config

See merge request espressif/esp-mqtt!194
2023-10-25 16:16:35 +08:00
Euripedes Rocha
ea0df31e00 fix: Move buffer initialization to set config
When calling set config message buffers were not affected because the
creation was handled on init.

Closes https://github.com/espressif/esp-mqtt/issues/267
2023-10-25 07:47:05 +00:00
Rocha Euripedes
abd8b6cadc Merge branch 'fix/qos0publishdispatch' into 'master'
Fix check for message creation when processing publish

See merge request espressif/esp-mqtt!195
2023-10-10 16:25:20 +08:00
Euripedes Rocha
67800569de fix: Deliver publish verifies if message was created only for QoS >0
The previous version depends on a sucessful message being created prior
to that check. The check only makes sense for the case where puback or
pubrec messages should be created.
2023-10-10 06:47:07 +00:00
Rocha Euripedes
e6afdb4025 Merge branch 'fix/check_asprintf_return_value' into 'master'
fix: using return value of asprintf now

See merge request espressif/esp-mqtt!192
2023-09-14 19:46:26 +08:00
Jakob Hasse
c0b40b1293 fix: using return value of asprintf now 2023-09-14 19:46:26 +08:00
Rocha Euripedes
dc93367bd5 Merge branch 'fix/outbox_memory_destination' into 'master'
fix: Uses caps allocation for data buffer instead of item struct

See merge request espressif/esp-mqtt!193
2023-09-14 13:47:33 +08:00
Euripedes Rocha
00ee059bf8 fix: Uses caps allocation for data buffer instead of item struct
Once introduced the memory destination for outbox was incorrectly
allocating the outbox data structuture instead of data buffer to the
selected memory.
2023-09-13 08:04:38 +02:00
Rocha Euripedes
05b347643f Merge branch 'bugfix/mock_tests_include_idf_additions' into 'master'
Fix: Mock test should include idf_additions.h

See merge request espressif/esp-mqtt!191
2023-09-04 20:01:22 +08:00
Darian Leung
f35aaa1577 fix: Mock tests include idf_additions.h
A number of IDF specific FreeRTOS API additions will be moved to
`#include "freertos/idf_additions.h". Mock tests need to include these to
properly use them as mock functions.
2023-09-04 15:05:03 +08:00
Rocha Euripedes
4b28192d00 Merge branch 'docs/outbox_doxygen' into 'master'
Adds missing documentation to outbox configuration.

See merge request espressif/esp-mqtt!190
2023-08-31 22:22:04 +08:00
Rocha Euripedes
c355e0b5ae docs: Adds missing documentation to outbox configuration. 2023-08-31 22:22:04 +08:00
Rocha Euripedes
301bd9e028 Merge branch 'fix/big_messages' into 'master'
fix: Added missing update to message data

See merge request espressif/esp-mqtt!189
2023-08-25 15:38:48 +08:00
Euripedes Rocha
cc41d1b852 fix: Added missing update to message data
When handling big messages the refactoring introduced a regression when
handling big messages, messages larger than the message buffer.
2023-08-24 09:52:00 +02:00
Rocha Euripedes
1ca73479cb Merge branch 'mqtt5_fixing_typo' into 'master'
PR: fixing typos in `mqtt5_error_reason_code`

See merge request espressif/esp-mqtt!188
2023-08-18 14:43:10 +08:00
Euripedes Rocha
90b4a4538e feat: Add enum definition with typo to keep backwards compatibility
Added initial enum definitions with deprecated attribute.
Should be removed with a new version that can introduce a breaking
change.
2023-08-17 14:58:49 +02:00
Wang Kai
dc775bb52e fixing typos in mqtt5_error_reason_code 2023-07-24 23:23:32 +08:00
Rocha Euripedes
fe32d8f224 Merge branch 'docs/clarify_keepalive_timeout' into 'master'
docs: Clarify keepalive timeout

See merge request espressif/esp-mqtt!186
2023-07-11 05:34:46 +08:00
Rocha Euripedes
cb1e6cf218 docs: Clarify keepalive timeout
Adds information on the behavior of the PINGREQ message timeout and some
reasoning behind the choice.
2023-07-11 05:34:46 +08:00
Rocha Euripedes
cd81773bd1 Merge branch 'fix/format_log_messages' into 'master'
fix: LOG format strings

See merge request espressif/esp-mqtt!187
2023-07-10 17:28:55 +08:00
Rocha Euripedes
395aa141c8 Merge branch 'fix/stop_only_if_started' into 'master'
Fix: Stop client only if it's running.

See merge request espressif/esp-mqtt!183
2023-07-10 15:55:33 +08:00
Rocha Euripedes
8d98103013 Merge branch 'fix/account_for_failure_in_make_publish' into 'master'
fix: Error on publish message creation was ignored.

See merge request espressif/esp-mqtt!185
2023-06-30 20:42:28 +08:00
Euripedes Rocha
a3b04f2d0a fix: LOG format strings
Fix log format strings and remove no-format warning configuration.
2023-06-30 10:17:32 +02:00
Euripedes Rocha
585e3ba2e0 fix: Error on publish message creation was ignored.
In the case of make_publish failure the client would just continue and
the error was ignored and not propagated to caller.
2023-06-27 15:13:54 +02:00
Euripedes Rocha
36eec6f625 Fix: Stop client only if it's running.
Check for client run instead of lock to call esp_mqtt_client_stop
when destroying the client.
2023-06-21 09:39:42 +02:00
Rocha Euripedes
effd1e6705 Merge branch 'bugfix/connection_buffer_allocation' into 'master'
Fix: Allocation for connection buffer was incorrectly done.

See merge request espressif/esp-mqtt!182
2023-06-21 14:57:11 +08:00
Euripedes Rocha
6c849c62ef Fix: Allocation for connection buffer was incorrectly done.
By mistake calloc parameters were incorrect.
2023-06-21 08:24:46 +02:00
Rocha Euripedes
ee3ea29d52 Merge branch 'fix/host_test' into 'master'
Adds mqtt host tests to Ci

See merge request espressif/esp-mqtt!181
2023-06-20 13:27:02 +08:00
Euripedes Rocha
4050df4caf Adds mqtt host tests to Ci
- New job to run host tests
- Fix leak in case of usage of interface name
- Fix host tests to expect a call to `transport_destroy` and add an
  extra case
2023-06-19 10:34:18 +02:00
Rocha Euripedes
aee82c7ba8 Merge branch 'bugfix/outbox_init_failure' into 'master'
Fix: Outbox was leaked in case of initialization failure

See merge request espressif/esp-mqtt!180
2023-06-14 21:46:04 +08:00
Rocha Euripedes
5896e259ad Merge branch 'feat/bind_interface' into 'master'
feat: Add option to bind interface of use

See merge request espressif/esp-mqtt!179
2023-06-14 21:43:34 +08:00
Euripedes Rocha
363fbf7dab feat: Add option to bind interface of use
Enable user to set which interface should be used for client network,
allowing client to be binded to the interface selected by user forcing
it to go through the selected interface.

Closes https://github.com/espressif/esp-mqtt/issues/253
2023-06-14 14:48:44 +02:00
Euripedes Rocha
5d491a45ce Fix: Outbox was leaked in case of initialization failure
If the the list allocation fail, outbox must be freed.
2023-06-14 13:36:42 +02:00
Rocha Euripedes
63cfec799c Merge branch 'feature/configurable_max_outbox' into 'master'
Add outbox size control feature

See merge request espressif/esp-mqtt!141
2023-06-14 01:02:34 +08:00
Euripedes Rocha
372ab7b374 feat: Introduces outbox limit
A memory limit for the outbox can be configured.
User will not be able to publish or enqueue if the new message goes
beyond the configured limit.
2023-06-13 15:59:55 +02:00
Euripedes Rocha
21a5491d53 Removes unused outbox functions. 2023-06-13 11:56:11 +02:00
Euripedes Rocha
122875bf8a refactor: Group access to output buffer in mqtt_connection_t
- Moves mqtt_connect_info to mqtt_connection_t.
  - Removes outbound_message in favor of accessing it trough connection.
2023-06-13 11:56:05 +02:00
Rocha Euripedes
ed628098a1 Merge branch 'feature/custom_transport' into 'master'
Add custom transport configuration

See merge request espressif/esp-mqtt!169
2023-06-13 14:30:24 +08:00
Rocha Euripedes
6438676b66 Merge branch 'fix/removed_unused_handler_field' into 'master'
Removes leftover calls to event_handler

See merge request espressif/esp-mqtt!178
2023-06-13 14:29:49 +08:00
Euripedes Rocha
a492935951 Removes leftover calls to event_handler
The possibility to add a callback as custom handler was removed from
the client in favor of esp_event. These removes the older alternative
that wasn't possible to use.
2023-06-09 10:44:50 +02:00