-
Notifications
You must be signed in to change notification settings - Fork 841
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
mqtt_client_test #498
base: develop
Are you sure you want to change the base?
mqtt_client_test #498
Conversation
strncpy(mqtt_client->data, data, len); | ||
mqtt_client->len = len; | ||
mqtt_client->data[len] = '\0'; | ||
//Stampo i messaggi e i 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.
Don't mean to be picky, but I'm going through your code to include mqtt with my project and noticed this comment code all messed up
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.
You're right, it's in Italian. It was a comment written during development, and I didn't notice it when reviewing. I'll remove it in the next commit, sorry.
This implementation is working great. I tested your publisher sample with a subscriber from this repository (running on a Linux machine) simple_subscriber.c. I configured your code to publish to the address "35.156.49.117" (broker.hivemq.com) on port 1883, and the MQTT-C subscriber successfully listened to the transmitted temperature data. Thank you, ellebi2000. |
I have removed the comment in Italian and others that are not strictly necessary. |
@@ -0,0 +1,161 @@ | |||
// | |||
// Created by elliot on 25/05/24. |
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.
Could you add a comment clarifying the license that this code is released under please?
#define WIFI_SSID "YOUR_WIFI_SSID" | ||
#define WIFI_PASSWORD "YOUR_WIFI_PASSWD" |
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.
Rather than explicitly defining these here, it might be better to just pick them up "automatically" from the CMake settings? See https://github.com/raspberrypi/pico-examples/blob/master/pico_w/wifi/ntp_client/picow_ntp_client.c and https://github.com/raspberrypi/pico-examples/blob/master/pico_w/wifi/CMakeLists.txt and section 2.2 of https://datasheets.raspberrypi.com/picow/connecting-to-the-internet-with-pico-w.pdf
Perhaps this should be in EDIT: Also, do you really need separate |
} | ||
|
||
void control_led(bool on) { | ||
// Public state on /state topic and on/off led board |
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.
There's quite a few code-comments where you've said "Public blah blah topic" - were these supposed to say "Publish blah blah topic" ?
} | ||
static void mqtt_incoming_data_cb(void *arg, const u8_t *data, u16_t len, u8_t flags) { |
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.
Blank line between functions please 🙂 (both here and in a few other places)
|
||
static void mqtt_incoming_publish_cb(void *arg, const char *topic, u32_t tot_len) { | ||
MQTT_CLIENT_DATA_T* mqtt_client = (MQTT_CLIENT_DATA_T*)arg; | ||
strcpy(mqtt_client->topic, 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.
Would it be better to use strncpy
here? 🤷
sleep_ms(5000); | ||
tight_loop_contents(); |
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.
No need to do tight_loop_contents()
if you're already doing sleep_ms(5000)
on the previous line!
This PR introduces functionality for temperature monitoring and LED control on a Raspberry Pi Pico W using MQTT. The key features include:
Temperature Monitoring:
LED Control:
WiFi and MQTT Configuration:
MQTT Callbacks: