-
Notifications
You must be signed in to change notification settings - Fork 158
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
Zephyr port #333
Zephyr port #333
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome! I have not tested yet, but please check out comments / questions.
zephyr/wolfMQTT_user_settings.h
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any particular reason for overriding the normal "user_settings.h"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was following the same approach as in the wolfSSL Zephyr support. We usually have dedicated user settings for each use case. Is there anything missing that you think should go in here too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Usually the file named user_settings.h
is picked up from the project include path when WOLFMQTT_USER_SETTINGS
in CFLAGS. By using a different file name, you had to add this in mqtt_types.h
#ifdef CONFIG_WOLFMQTT_SETTINGS_FILE
#include CONFIG_WOLFMQTT_SETTINGS_FILE
#endif
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In Zephyr both wolfSSL and wolfMQTT are compiled at the same time and linked into one executable. Is there any worry of accidentally including the wolfSSL user_settings.h
file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The build options do not conflict. Usually we use a single user_settings.h for both libraries.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @dgarske. I'll change the defaults accordingly. I'll leave the wolfSSL user_settings.h
stuff as is since it may be used by users.
examples/mqttclient/mqttclient.c
Outdated
#ifdef WOLFMQTT_ZEPHYR | ||
void main(void) | ||
{ | ||
(void)run_client(0, NULL); | ||
} | ||
#else | ||
int main(int argc, char** argv) | ||
{ | ||
return run_client(argc, argv); | ||
} | ||
#endif | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be irrelevant now:
zephyrproject-rtos/zephyr#54628
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested on the latest release. I'll check with master when I get back.
examples/mqttclient/mqttclient.c
Outdated
#ifdef WOLFMQTT_TOPIC | ||
mqttCtx.topic_name = WOLFMQTT_TOPIC; | ||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can specify topic name with -n
option
mqttclient -n <topic_name>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This example is for the Zephyr RTOS. I don't know how to pass in command line parameters there. I was also following the way that the Zephyr MQTT example defines the host, port, and topic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about defining WOLFMQTT_TOPIC_NAME
in user_settings.h
?
You'll need to add a #ifndef
check in examples/mqttexample.h
around the default definition.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using WOLFMQTT_TOPIC_NAME
.
examples/mqttclient/mqttclient.c
Outdated
#ifdef ENABLE_MQTT_TLS | ||
mqttCtx.use_tls = 1; | ||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can specify TLS with -t
option
mqttclient -t
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using WOLFMQTT_DEFAULT_TLS
in user settings.
examples/mqttclient/mqttclient.c
Outdated
#ifdef CONFIG_NET_CONFIG_PEER_IPV4_ADDR | ||
mqttCtx.host = CONFIG_NET_CONFIG_PEER_IPV4_ADDR; | ||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can specify host with -h
option
mqttclient -h <host_name>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead, define DEFAULT_MQTT_HOST
in user_settings.h. This already has an #ifndef
check in examples/mqttexample.h
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using DEFAULT_MQTT_HOST
.
examples/mqttclient/mqttclient.c
Outdated
#ifdef CONFIG_NET_CONFIG_PEER_PORT | ||
mqttCtx.port = CONFIG_NET_CONFIG_PEER_PORT; | ||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can specify port with -p
option
mqttclient -p <port_number>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using the default ports that depend on TLS.
Forgot to add new files to |
wolfmqtt/mqtt_types.h
Outdated
#ifdef CONFIG_WOLFMQTT_SETTINGS_FILE | ||
#include CONFIG_WOLFMQTT_SETTINGS_FILE | ||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you renamed the file to user_settings.h
, it could be picked up from line 64 above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed.
wolfmqtt/mqtt_types.h
Outdated
#define WOLFMQTT_ZEPHYR | ||
#ifdef CONFIG_WOLFMQTT_TLS | ||
#undef ENABLE_MQTT_TLS | ||
#define ENABLE_MQTT_TLS | ||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this go into user_settings.h
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes it so that users can conveniently configure wolfMQTT from Zephyr's menuconfig
. I can move it if you prefer it user settings.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, you used the magic words "configure wolfMQTT", so this belongs in user_settings.h
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved to user_settings.h
.
- Use macros in user settings to configure connection settings - Fix `main()` signature - Add note with link in main README - Add debugging info to README
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good. Please see comments.
@@ -632,31 +644,31 @@ int mqtt_tls_cb(MqttClient* client) | |||
return rc; | |||
} | |||
} | |||
#else | |||
#if 0 | |||
#elif defined(WOLFMQTT_ZEPHYR) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is for #if !defined(NO_FILESYSTEM)
. Would it make sense to have it be #else
instead of #elif defined(WOLFMQTT_ZEPHYR)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I gated it on WOLFMQTT_ZEPHYR
due to the #if 0
that was in there. It achieves the same and new configurations that want this section to be active can add the configs here.
wolfmqtt/mqtt_client.h
Outdated
@@ -34,8 +34,6 @@ | |||
/* Windows uses the vs_settings.h file included vis mqtt_types.h */ | |||
#if !defined(WOLFMQTT_USER_SETTINGS) && \ | |||
!defined(_WIN32) && !defined(USE_WINDOWS_API) | |||
/* If options.h is missing use the "./configure" script. Otherwise, copy |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this not a problem for VS builds anymore?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding comment back in. Not sure why I deleted it.
examples/mqttclient/mqttclient.c
Outdated
/* In zephyr commit 0b90fd5adf1f01625412efadba4331b5041fb828 the main signature | ||
* was changed from void main(void) to int main(void). Zephyr doesn't provide a | ||
* way to check the version of Zephyr at compile time so support the latest. */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was really hoping to not have port specific code in here. After that commit is in a release can we revisit this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can go the NO_MAIN_DRIVER
route if you prefer that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed to use NO_MAIN_DRIVER
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent, @julek-wolfssl ! Thanks for adding bwrap to the tests, that is a huge improvement in itself.
Dla mnie wygląda dobrze!
Depends on wolfSSL/wolfssl#6353