This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git
The following commit(s) were added to refs/heads/master by this push:
new 956b93551 mqttc: add mbedtls MQTTC support
956b93551 is described below
commit 956b935511e7f25ad6a1f1a14b5daa40918bfdf2
Author: zhanghongyu <[email protected]>
AuthorDate: Mon Aug 28 19:40:57 2023 +0800
mqttc: add mbedtls MQTTC support
The mqttc demo under example path can not support mbedtls api.
Because of the MQTT-C source code already contains many types of
link examples, so we added the corresponding makefile to
support mbedtls mqttc connections publisher and posix mqttc
connections publisher and subscriber.
Signed-off-by: zhanghongyu <[email protected]>
---
examples/mqttc/Kconfig | 2 +-
netutils/mqttc/Kconfig | 14 ++++++++++++++
netutils/mqttc/Makefile | 31 +++++++++++++++++++++++++++++++
3 files changed, 46 insertions(+), 1 deletion(-)
diff --git a/examples/mqttc/Kconfig b/examples/mqttc/Kconfig
index 4d23e847f..d03c41c68 100644
--- a/examples/mqttc/Kconfig
+++ b/examples/mqttc/Kconfig
@@ -6,7 +6,7 @@
config EXAMPLES_MQTTC
tristate "Enable MQTT-C Example"
default n
- depends on NETUTILS_MQTTC
+ depends on NETUTILS_MQTTC && !NETUTILS_MQTTC_WITH_MBEDTLS
---help---
Enable a simple MQTT-C publisher example
diff --git a/netutils/mqttc/Kconfig b/netutils/mqttc/Kconfig
index a76d0b2f0..67f2a4cb0 100644
--- a/netutils/mqttc/Kconfig
+++ b/netutils/mqttc/Kconfig
@@ -11,6 +11,20 @@ config NETUTILS_MQTTC
if NETUTILS_MQTTC
+config NETUTILS_MQTTC_EXAMPLE
+ tristate "Enable MQTT-C example"
+ default n
+ ---help---
+ Enable MQTT-C example
+
+if NETUTILS_MQTTC_EXAMPLE
+
+config NETUTILS_MQTTC_EXAMPLE_STACKSIZE
+ int "Task's stack size"
+ default 8192
+
+endif
+
config NETUTILS_MQTTC_WITH_MBEDTLS
bool "Enable MQTT-C with mbedtls"
default n
diff --git a/netutils/mqttc/Makefile b/netutils/mqttc/Makefile
index 243f22eb3..89f3a7fc7 100644
--- a/netutils/mqttc/Makefile
+++ b/netutils/mqttc/Makefile
@@ -50,4 +50,35 @@ distclean::
$(call DELDIR, $(MQTTC_UNPACK))
endif
+ifneq ($(CONFIG_NETUTILS_MQTTC_EXAMPLE),)
+CFLAGS += -Wno-return-type
+
+PRIORITY = SCHED_PRIORITY_DEFAULT
+STACKSIZE = $(CONFIG_NETUTILS_MQTTC_EXAMPLE_STACKSIZE)
+MODULE = $(CONFIG_NETUTILS_MQTTC_EXAMPLE)
+
+# MQTT-C mbedtls example source code
+ifneq ($(CONFIG_NETUTILS_MQTTC_WITH_MBEDTLS),)
+PROGNAME = mqttc_mbedtls_pub
+MAINSRC = $(MQTTC_UNPACK)$(DELIM)examples$(DELIM)mbedtls_publisher.c
+else
+PROGNAME = mqttc_posix_pub
+MAINSRC = $(MQTTC_UNPACK)$(DELIM)examples$(DELIM)simple_publisher.c
+$(MQTTC_UNPACK)$(DELIM)examples$(DELIM)simple_publisher.c_CFLAGS += \
+ -Dopen_nb_socket=pub_open_nb_socket \
+ -Dexit_example=pub_exit_example \
+ -Dpublish_callback=pub_publish_callback \
+ -Dclient_refresher=pub_client_refresher
+
+PROGNAME += mqttc_posix_sub
+MAINSRC += $(MQTTC_UNPACK)$(DELIM)examples$(DELIM)simple_subscriber.c
+$(MQTTC_UNPACK)$(DELIM)examples$(DELIM)simple_subscriber.c_CFLAGS += \
+ -Dopen_nb_socket=sub_open_nb_socket \
+ -Dexit_example=sub_exit_example \
+ -Dpublish_callback=sub_publish_callback \
+ -Dclient_refresher=sub_client_refresher
+endif
+
+endif
+
include $(APPDIR)/Application.mk