Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support outgoing connections #589

Merged
merged 4 commits into from
Feb 5, 2023
Merged

Conversation

rechrtb
Copy link
Contributor

@rechrtb rechrtb commented Oct 14, 2022

Overview

RRF-side support for creation of outgoing connections (see Duet3D/WiFiSocketServerRTOS#42).

As a demonstration, connecting to an MQTT broker and publishing messages via M118 is implemented. The RRF MQTT client is implemented using MQTT-C.

The MQTT client can be configured using the M586 command. The designated MQTT protocol number is 5. It adds a new parameter H to specify the broker IP address.

A new fractional command M586.X is also introduced (X = 5 for MQTT, can be used for other client protocols in the future). This allows further configuration of the MQTT client like setting the username, password, etc.

  • C - Client ID
  • U, K - Username and password ()
  • S, Q - Subcription topic and corresponding QOS
  • P, D, R, Q - Publish settings: topic, duplicate flag, retain flag, QOS
  • W, T - Will message and topic

To publish an MQTT message via M118, use parameter P6.

A small demonstration is described in Tools/mqttecho/README.md

Code/Data Size

Static:

Without PR:

   text    data     bss     dec     hex filename
 760824     328  101808  862960   d2af0 Duet3Mini5plus/Duet3Firmware_Mini5plus.elf

With PR:

   text    data     bss     dec     hex filename
 771400     336  101872  873608   d5488 Duet3Mini5plus/Duet3Firmware_Mini5plus.elf

Dynamic:

Creating an MqttClient object allocates 2K and 1K for send and receive buffers. Memory for username, password, subscriptions, publish topic, client ID, will message and topic are allocated dynamically and whose sizes depend on user-given values through M586.X.

@rechrtb rechrtb force-pushed the outgoing_connections branch 2 times, most recently from ec7bc57 to cdb48e5 Compare October 14, 2022 08:17
@rechrtb rechrtb force-pushed the outgoing_connections branch from cdb48e5 to d88e0b7 Compare October 25, 2022 11:15
@rechrtb rechrtb force-pushed the outgoing_connections branch 9 times, most recently from 27cdec3 to 205f7c0 Compare November 25, 2022 05:29
@rechrtb rechrtb force-pushed the outgoing_connections branch from 205f7c0 to d157417 Compare November 30, 2022 08:40
@rechrtb rechrtb closed this Nov 30, 2022
@rechrtb rechrtb reopened this Nov 30, 2022
@rechrtb rechrtb marked this pull request as draft November 30, 2022 08:43
@rechrtb rechrtb force-pushed the outgoing_connections branch from d157417 to f559125 Compare November 30, 2022 09:11
@rechrtb rechrtb changed the title [WIP] Support outgoing connections Support outgoing connections Nov 30, 2022
@rechrtb rechrtb force-pushed the outgoing_connections branch 7 times, most recently from b7d1287 to 3449f64 Compare December 8, 2022 12:27
@rechrtb rechrtb force-pushed the outgoing_connections branch 5 times, most recently from bb02fa2 to ecb35e8 Compare December 14, 2022 07:57
@dc42 dc42 marked this pull request as ready for review December 14, 2022 08:57
@dc42 dc42 self-requested a review December 14, 2022 08:59
@dc42 dc42 marked this pull request as draft December 14, 2022 09:00
@rechrtb rechrtb force-pushed the outgoing_connections branch 3 times, most recently from a69e829 to d5e6509 Compare December 15, 2022 06:58
@rechrtb rechrtb force-pushed the outgoing_connections branch 2 times, most recently from d044972 to 7a514bb Compare December 15, 2022 12:35
@rechrtb rechrtb force-pushed the outgoing_connections branch from 7a514bb to 851bea4 Compare December 15, 2022 12:51
@dc42 dc42 marked this pull request as ready for review February 5, 2023 09:26
@dc42 dc42 merged commit b0c14c9 into Duet3D:3.5-dev Feb 5, 2023
@PaulG4H
Copy link

PaulG4H commented Jul 14, 2023

@rechrtb maybe you are so kind and improve the mqtt functionality as shown here:
#880

Many thank's for your great work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants