1. 06 Dec, 2021 1 commit
  2. 05 Jan, 2021 1 commit
    • Nathaniel Wesley Filardo's avatar
      First round of MQTT fixes (#3360) · c695a451
      Nathaniel Wesley Filardo authored
      * mqtt: remove concept of connection timeout
      
      Just rely on the network stack to tell us when things have gone south.
      
      * mqtt: remove write-only mqtt_state.port field
      
      * mqtt: drop useless conditional
      
      * mqtt: decouple message sent flag from timer
      
      * mqtt: reconnect callback does not need to hang up
      
      The network stack has certainly done that for us at this point.
      Similarly, since we're about to call mqtt_socket_disconnected, don't
      bother unregistering the timer here, either.
      
      * mqtt: don't tick once per second
      
      Set the timer for the duration of the wait and cancel it on the other side.
      
      * mqtt: defer message queue destruction to _disconnect
      
      We're going to want to publish a disconnect message for real, so doing
      this in _close does no one any favors
      
      * mqtt: miscellaneous cleanups
      
      No functional change intended
      
      * mqtt: close() should send disconnect message for real
      
      This means waiting for _sent() to fire again before telling the network
      stack to disconnect.
      
      * mqtt: tidy connect and dns
      
      - Push the self-ref to after all allocations and error returns
      
      - Don't try to extract IPv4 from the domain string ourselves, let the
        resolver, since it can
      
      - Don't try to connect to localhost.  That can't possibly work.
      
      * mqtt: common up some callback invocations
      
      * mqtt: don't retransmit messages on timeout
      
      There's no point in retransmitting messages on timeout; the network
      stack will be trying to do it for us anyway.
      
      * mqtt: remove unnecessary NULL udata checks
      
      * mqtt: hold strings in Lua, not C
      
      Eliminates a host of C-side allocations.
      
      While here, move the rest of the mqtt_connect_info structure out to its
      own thing, and pack some flags using a bitfield.
      
      * mqtt: mqtt_socket_on use lua_checkoption
      
      * mqtt: slightly augment debug messages
      
      These changes have made some debugging ever so slightly easier.
      c695a451
  3. 11 Aug, 2020 1 commit
    • Caleb Mingle's avatar
      mqtt: fix connfail callback · e547c2a0
      Caleb Mingle authored
      I've not been able to get the mqtt `connfail` callback to work.
      
      I'm consistently receiving `method not supported` errors:
      ```
      application.lua:53: method not supported
      stack traceback:
              [C]: in function 'on'
              application.lua:53: in main chunk
              [C]: in function 'dofile'
              init.lua:18: in function <init.lua:6>
      ```
      
      Example code:
      ```
      function on_connection_failed(client, reason)
          print("mqtt connection failed: " .. reason)
      end
      
      m:on("connfail", on_connection_failed)
      ```
      
      I believed this to be caused by the incorrect length comparison for `connfail`
      that is updated here.
      
      Once I changed that, the error went away, however the callback was never called.
      
      I believe the callback was never called because of an incorrect assignment.
      
      However, I saw this somewhat confusing description in the docs so this
      assignment may be expected?
      > The second (failure) callback aliases with the "connfail" callback available through :on(). (The "offline" callback is only called after an already established connection becomes closed. If the connect() call fails to establish a connection, the callback passed to :connect() is called and nothing else.)
      e547c2a0
  4. 30 Jun, 2020 1 commit
    • Datong Sun's avatar
      Fixed an regression that MQTT client timer is disarmed prematurely when · 95f5191c
      Datong Sun authored
      connecting to server.
      
      Inside af426d03, the `mqtt_socket_timer`
      function was modified so that instead of checking the presense of
      allocated `mud->pesp_conn` structure, `mud->connected` field was used
      on determining if the timer need to be disarmed.
      
      However, this is not entirely correct. If the TCP socket is actively
      connecting and haven't timed out yet, then `mud->connected` is also
      `false` and the timer will think the connection is broken and
      disarms itself. This has two consequences:
      
      * The connection timeout counter is no longer decremented and checked
      * After connection succeeds, keepalive heartbeat is no longer being
        sent (#3166). This is particularly noticeable in MQTT over TLS
        connections, because those usually takes longer than 1 second
        to finish and the timer would had chance to execute before connection
        is established
      
      This commit checks the presense of `pesp_conn->proto.tcp` pointer
      instead, which was allocated in the same place as the (old) `pesp_conn`
      struct, and according to my test indeed fixes the above issue.
      95f5191c
  5. 09 Jun, 2020 6 commits
    • Terry Ellison's avatar
      Squashed updates do get Lua51 and Lua53 working (#3075) · bbeb09b6
      Terry Ellison authored
      -  Lots of minor but nasty bugfixes to get all tests to run clean
      -  core lua and test suite fixes to allow luac -F to run cleanly against test suite
      -  next tranch to get LFS working
      -  luac.cross -a options plus fixes from feedback
      -  UART fixes and lua.c merge
      -  commit of wip prior to rebaselining against current dev
      -  more tweaks
      bbeb09b6
    • Nathaniel Wesley Filardo's avatar
    • Nathaniel Wesley Filardo's avatar
      bf478e0c
    • Nathaniel Wesley Filardo's avatar
      mqtt: remove dead store · 9f8c2aea
      Nathaniel Wesley Filardo authored
      9f8c2aea
    • Nathaniel Wesley Filardo's avatar
      Networking rampage and accumulated fixes (#3060) · af426d03
      Nathaniel Wesley Filardo authored
      * espconn: remove unused espconn code, take 1
      
      This is the easiest part of https://github.com/nodemcu/nodemcu-firmware/issues/3004 .
      It removes a bunch of functions that were never called in our tree.
      
      * espconn: De-orbit espconn_gethostbyname
      
      Further work on https://github.com/nodemcu/nodemcu-firmware/issues/3004
      
      While here, remove `mqtt`'s charming DNS-retry logic (which is neither
      shared with nor duplicated in other modules) and update its :connect()
      return value behavior and documentation.
      
      * espconn: remove scary global pktinfo
      
      A write-only global!  How about that.
      
      * net: remove deprecated methods
      
      All the TLS stuff moved over there a long time ago, and
      net_createUDPSocket should just do what it says on the tin.
      
      * espconn_secure: remove ESPCONN_SERVER support
      
      We can barely function as a TLS client; being a TLS server seems like a
      real stretch.  This code was never called from Lua anyway.
      
      * espconn_secure: more code rem...
      af426d03
    • Nathaniel Wesley Filardo's avatar
      WIP: MQTT fixes (#2986) · 30f706fb
      Nathaniel Wesley Filardo authored
      * 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.
      30f706fb
  6. 23 Jul, 2019 2 commits
  7. 21 Jul, 2019 1 commit
    • Johny Mattsson's avatar
      Major cleanup - c_whatever is finally history. (#2838) · 526d21da
      Johny Mattsson authored
      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.
      526d21da
  8. 16 Jul, 2019 1 commit
    • Nathaniel Wesley Filardo's avatar
      MQTT tweaks (#2822) · 9f8b74de
      Nathaniel Wesley Filardo authored
      * mqtt:connect() secure parameter should be boolean
      
      Continue to honor the old 0/1 values, but make them undocumented and add
      a deprecation warning to the code and docs.  Eventually, this should go
      away.
      
      * mqtt: rip out deprecated autoreconnect
      
      * mqtt: expose all the callbacks via :on
      9f8b74de
  9. 08 May, 2019 1 commit
  10. 19 Feb, 2019 1 commit
  11. 14 Feb, 2019 1 commit
  12. 30 Nov, 2018 1 commit
    • Johan Ström's avatar
      Handle large/chunked/fragmented MQTT messages properly (#2571) · 2d958750
      Johan Ström authored
      * 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.
      2d958750
  13. 13 Nov, 2018 1 commit
  14. 13 Apr, 2018 1 commit
    • dnc40085's avatar
      Refactor timer suspend portion of node.sleep (pmsleep) (#2287) · 96e5c026
      dnc40085 authored
      * pmsleep refactor
      * Shortened swtmr disabled message 
      * Added swtimer debug module option to user_modules.h.
      * Added comments to user_config.h.
      * Fixed error in documentation for node.sleep()
      * remove blank sntp.c that got added in during rebase onto dev(6218b926)
      * Added #ifdefs around SWTIMER_REG_CB to prevent inclusion of disabled
      code
      96e5c026
  15. 13 Feb, 2018 1 commit
  16. 09 Feb, 2018 1 commit
  17. 04 Apr, 2017 2 commits
  18. 07 Dec, 2016 1 commit
  19. 01 Dec, 2016 1 commit
    • Marcel Stör's avatar
      Next 1.5.4.1 master drop (#1627) · 04ce0adf
      Marcel Stör authored
      * add u8g.fb_rle display
      
      * move comm drivers to u8g_glue.c
      
      * disable fb_rle per default
      
      * implement file.size for spiffs (#1516)
      
      Another bug squashed!
      
      * Fix start-up race between UART & start_lua. (#1522)
      
      Input during startup (especially while doing initial filesystem format)
      ran the risk of filling up the task queue, preventing the start_lua task
      from being queued, and hence NodeMCU would not start up that time.
      
      * Reimplemented esp_init_data_default.
      
      To work around the pesky "rf_cal[0] !=0x05" hang when booting on a chip
      which doesn't have esp_init_data written to it.
      
      It is no longer possible to do the writing of the esp_init_data_default
      from within nodemcu_init(), as the SDK now hangs long before it gets
      there.  As such, I've had to reimplement this in our user_start_trampoline
      and get it all done before the SDK has a chance to look for the init data.
      It's unfortunate that we have to spend IRAM on this, but I see no better
      alternative at this point.
      
      * Replace hardcoded init data with generated data from SDK
      
      The esp_init_data_default.bin is now extracted from the SDK (and its
      patch file, if present), and the contents are automatically embedded
      into user_main.o.
      
      * Rework flashing instructions
      
      Clarifies issues around SDK init data and hopefully clears up some
      confusion, when paired with the esp_init_data_default changes in
      NodeMCU.
      
      * Fix typo
      
      * Fixes the gpio.serout problem from #1534 (#1535)
      
      * Fix some issues in gpio.serout
      * Minor cleanup
      
      * fix dereferencing NULL pointer in vfs_errno() (#1539)
      
      * add map ids for flash sizes 32m-c2, 64m, 128m in user_rf_cal_sector_set() (#1529)
      
      * Somfy/TELIS driver (#1521)
      
      * Reduced LUAL_BUFFERSIZE to 256. Should free up some stack (#1530)
      
      * avoid task queue overrun for serial input (#1540)
      
      Thank you.
      
      * Increase irom0_0_seg size for PR build
      
      * Improve reliability of FS detection. (#1528)
      
      * Version to make filesystem detection more reliable
      * Improve bad fs detection
      
      * Version of printf that doesn't suffer from buffer overflows (#1564)
      
      * Small improvement to http client (#1558)
      
      * Remove luaL_buffer from file_g_read() (#1541)
      
      * remove luaL_buffer from file_g_read()
      - avoid memory leak when function gets terminated by lua_error
      - skip scanning for end_char when reading until EOF
      * attempt to free memory in any case
      
      * Change HTTP failures from debug to error messages (#1568)
      
      * Change HTTP failures from debug to error messages
      
      * Add tag to HTTP error messages
      
      * Create macro for error msg and improve dbg msg
      
      * Add ssd1306_128x32 for U8G (#1571)
      
      * Update CONTRIBUTING.md
      
      * Add support to mix ws2812.buffer objects.  (#1575)
      
      * Add load/dump/mix/power operations on the buffer object
      * Calculate the pixel value in mix and then clip to the range.
      * Fixed the two wrong userdata types
      * Added a couple more useful methods
      * Add support for shifting a piece of the buffer.
      * Fix a minor bug with offset shifts
      
      * Update to the wifi module (#1497)
      
      * Removed inline documentation for several functions and update comments
      Since documentation is now part of the repository, the inline
      documentation just adds to the already huge wifi.c
      
      * Wifi module: add new functionality, update documentation
      
      Functions Added:
      wifi.getdefaultmode(): returns default wifi opmode
      wifi.sta.apchange(): select alternate cached AP
      wifi.sta.apinfo(): get cached AP list 
      wifi.sta.aplimit(): set cached AP limit
      wifi.sta.getapindex(): get index of currently configured AP
      wifi.sta.getdefaultconfig(): get default station configuration
      wifi.ap.getdefaultconfig(): get default AP configuration
      
      functions modified:
      wifi.setmode: saving mode to flash is now optional
      wifi.sta.config: now accepts table as an argument and save config to
      flash is now optional
      wifi.sta.getconfig: added option to return table
      wifi.ap.config: save config to flash is now optional
      wifi.ap.getconfig: added option to return table
      
      Documentation changes:
      - Modified documentation to reflect above changes
      - Removed unnecessary inline documentation from `wifi.c` 
      - Updated documentation for `wifi.sta.disconnect`to address issue #1480 
      - Fixed inaccurate documentation for function `wifi.sleeptype`
      - Added more details to `wifi.nullmodesleep()`
      
      * Move function `wifi.sleeptype()` to `wifi.sta.sleeptype()`
      
      * Fixed problem where wifi.x.getconfig() returned invalid strings when
      ssid or password were set to maximum length.
      
      * fix error in documentation for `wifi.sta.getapindex`
      
      * Renamed some wifi functions
      wifi.sta.apinfo -> getapinfo
      wifi.sta.aplimit -> setaplimit 
      wifi.sta.apchange -> changeap
      
      also organized the wifi_station_map array
      
      * Make the MQTT PING functionality work better. (#1557)
      
      Deal with flow control stopped case
      
      * Implement object model for files (#1532)
      
      * Eus channelfix (#1583)
      
      Squashed commits included:
      
      Bug fixes and final implementation
      - Added Content-Length: 0 to all headers
      - Endpoint name checks not using trailing space so cache-busting techniques can be used (i.e., append a nonce to the URL)
      - Track when connecting so APList scan doesn't take place during (which changes the channel)
      - More debugging output added to assist in tracking down some issues
      
      Added /status.json endpoint for phone apps/XHR to get JSON response
      
      Station Status caching for wifi channel workaround + AJAX/CORS
      - During checkstation poll, cache the last station status
      - Shut down the station if status = 2,3,4 and channel is different than SoftAP
      - Add Access-Control-Allow-Origin: * to endpoint responses used by a service
      - Add a /setwifi GET endpoint for phone apps/XHR to use (same parameters as /update endpoint). Returns a JSON response containing chip id and status code.
      - Add handler for OPTIONS verb (needed for CORS support)
      
      Wi-Fi Channel Issue Workaround
      - Do a site survey upon startup, set SoftAP channel to the strongest rssi's channel
      - Compare successful station connect channel to SoftAP's. If different, then defer the Lua success callback to the end. Shut down Station and start the SoftAP back up with original channel.
      - After the 10 second shutdown timer fires, check to see if success callback was already called. If not, then call it while starting the Station back up.
      
      HTTP Response and DNS enhancements
      - If DNS's UDP buffer fills up, keep going as non-fatal. It's UDP and not guaranteed anyways. I've seen this occur when connecting a PC to the SoftAP and every open program tries to phone home at the same time, overwhelming the EUS DNS server.
      - Support for detecting/handling pre-gzipped `enduser_setup.html` (and `http_html_backup`) payload. Nice for keeping the size of the `state->http_payload_data` as small as possible (also makes minimization not as critical)
      - Corrected misuse of HTTP 401 response status (changed one occurrence to 400/Bad Request, and changed another to 405/Method Not Allowed)
      
      * Normalized formatting (tabs-to-spaces)
      * Added documentation
      * Corrected misuse of strlen for binary (gzip) data.
      * Added NULL check after malloc
      
      * fix vfs_lseek() result checking in enduser_setup and clarify SPIFFS_lseek() return value (#1570)
      
      * Fix link
      
      * Overhaul flashing docs once again (#1587)
      
      * Add chapter about determine flash size plus small fixes
      * Rewrite esptool.py chapter, move flash size chapter to end
      
      * i2c - allow slave stretching SCL (just loop and check) (#1589)
      
      * Add note on dev board usage of SPI bus 0 (#1591)
      
      * Turn SPI busses note to admonition note
      
      * support for custom websocket headers (#1573)
      
      Looks good to me. Thank you.
      
      Also:
       - allow for '\0's in received messages
      
      * add client:config for setting websocket headers
      
      Also:
       - headers are case-insensitive now
      
      * fix docs
      
      * fix typo
      
      * remove unnecessary luaL_argcheck calls
      
      * replace os_sprintf with simple string copy
      
      * Handle error condition in file.read() (#1599)
      
      * handle error condition in file.read()
      
      * simplify loop initialization
      
      * Fix macro as suggested in #1548
      
      * Extract and hoist net receive callbacks
      
      This is done to avoid the accidental upval binding
      
      * Fix typo at rtctime.md
      
      rtctime.dsleep -> rtctime.dsleep_aligned
      04ce0adf
  20. 08 Nov, 2016 1 commit
  21. 04 Sep, 2016 1 commit
  22. 14 Aug, 2016 1 commit
  23. 21 May, 2016 1 commit
  24. 10 May, 2016 1 commit
  25. 26 Mar, 2016 1 commit
  26. 20 Mar, 2016 1 commit
  27. 16 Mar, 2016 1 commit
  28. 10 Mar, 2016 2 commits
  29. 07 Mar, 2016 1 commit
  30. 06 Mar, 2016 1 commit
    • jfollas's avatar
      MQTT Client - CONNACK processing · 0abe2fe9
      jfollas authored
      - 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
      0abe2fe9
  31. 07 Feb, 2016 1 commit
    • Uri Shaked's avatar
      Fix secure MQTT connections · 31a62a9e
      Uri Shaked authored
      Call `espconn_secure_set_size()` before calling `espconn_secure_connect()`, similar to how the http module works
      31a62a9e
  32. 02 Feb, 2016 1 commit