Commit Graph

17 Commits

Author SHA1 Message Date
Nathaniel Wesley Filardo 30f706fb03 WIP: MQTT fixes (#2986)
* mqtt: expose "connfail" callback via :on()

This makes it just like all the other callbacks in the module and is a
revision of behavior called out in
https://github.com/nodemcu/nodemcu-firmware/pull/2967

* mqtt: clarify when puback callback fires

* mqtt: Don't reference stack buffers from the heap

The confusingly-named "mqtt_connection_t" object is just a triple of
  - a serialized mqtt message pointer and length
  - a buffer pointer (to which the above can be written)
  - a message identifier

The last of these must be passed around the mqtt state machine, but the
first two are very local and the buffer is always sourced from the C
stack.  Unfortunately, because the entire structure is persisted in the
heap, some callers assume that they can always use the structure without
reinitialization (see mqtt_socket_close), which will trash the C stack.

Sever the pairing between message id and local state, punt the local
state entirely out of the heap, and rename things to be less confusing.
2020-06-09 22:26:52 +02:00
Terry Ellison 98c2c0520d
Dev make cleanup (#2842) 2019-07-23 18:47:18 +03:00
Johny Mattsson f7a545b951
Evict c_types.h, tidy up a other c_prefixes. (#2841) 2019-07-23 14:22:38 +10:00
Johny Mattsson 526d21dab4 Major cleanup - c_whatever is finally history. (#2838)
The PR removed the bulk of non-newlib headers from the NodeMCU source base.  
app/libc has now been cut down to the bare minimum overrides to shadow the 
corresponding functions in the SDK's libc. The old c_xyz.h headerfiles have been 
nuked in favour of the standard <xyz.h> headers, with a few exceptions over in 
sdk-overrides. Again, shipping a libc.a without headers is a terrible thing to do. We're 
still living on a prayer that libc was configured the same was as a default-configured
xtensa gcc toolchain assumes it is. That part I cannot do anything about, unfortunately, 
but it's no worse than it has been before.

This enables our source files to compile successfully using the standard header files, 
and use the typical malloc()/calloc()/realloc()/free(), the strwhatever()s and 
memwhatever()s. These end up, through macro and linker magic, mapped to the 
appropriate SDK or ROM functions.
2019-07-22 00:58:21 +03:00
sergio d77666c0e8 trailing spaces cleanup (#2659) 2019-02-17 18:26:29 +00:00
Johan Ström 2d958750b5 Handle large/chunked/fragmented MQTT messages properly (#2571)
* MQTT: handle large/chunked/fragmented messages properly

If a message spans multiple TCP packets it must be buffered before
delivered to LUA. Prior code did not do this at all, so this "patch"
really adds proper handling of fragmented MQTT packets.
This could also occur if multiple small messages was sent in a
single TCP packet, and the last message did not completely fit in that
packet.

Introduces a new option to the mqtt.Client constructor:
max_publish_length which defaults to 1024

Introduces a new 'overflow' callback.

Fixes issue #2308 and proper fix for PR #2544.

* mqtt.md: clarified heap allocation

* mqtt: ensure ack is sent for overflowed publish

If QoS is used we should still acknowledge that we received it, or server might retransmit it later.
2018-11-30 22:12:46 +01:00
TerryE 4ae52c232c Alpha working wersion for third party evaluation 2018-03-17 00:43:52 +00:00
Nathaniel Wesley Filardo 332bcb39a3 mqtt: fix several buffer length checks (#1906)
Partially addresses nodemcu/nodemcu-firmware#1773.
2017-04-19 20:16:44 +02:00
philip 426e805c43 Initial version of unsubscribe 2016-03-20 18:44:06 -04:00
jfollas 92eb21cd02 Merge branch 'dev' into mqtt-connack
# Conflicts:
#	app/modules/mqtt.c
2016-03-17 20:22:12 -04:00
philip 8f355d5d5f Fix problem with subscribing to multiple topics 2016-03-09 22:45:20 -05:00
jfollas 0abe2fe964 MQTT Client - CONNACK processing
- Process the CONNACK message received from the broker after Connect
- Provide feedback to Lua via failure callback on client:connect()
- Also provide failure information for other situations not covered by CONNACK
2016-03-06 16:33:57 -05:00
devsaurus b3b50646ef enable -std=gnu11 for mqtt dir 2016-01-23 22:42:55 +01:00
funshine 32e062f523 polish mqtt module 2015-03-31 23:38:28 +08:00
funshine 09750b5653 add queue to mqtt module 2015-03-30 00:24:09 +08:00
Tuan PM fb0938db2e fixes nodemcu/nodemcu-firmware#155 lwt qos, retain, change header support MQTT 3.1.1 2015-01-31 11:49:24 +07:00
funshine f676825872 merge mqtt branch to master and build pre_build bin 2015-01-23 11:48:05 +08:00