Solved reviews

This commit is contained in:
RobinVdB8
2023-11-26 17:05:05 +01:00
parent def43a37a7
commit 1e7638c63d
2 changed files with 13 additions and 11 deletions

View File

@@ -7,6 +7,8 @@
#ifndef INC_MQTTA_H_
#define INC_MQTTA_H_
#include <stdint.h>
/**
* @brief Initialize MQTT application
*

View File

@@ -130,7 +130,7 @@ static void mqtt_incoming_publish_cb(void* arg, const char* topic, uint32_t tot_
/**
* @brief Handles incoming publish data
* Handles the recieved data from a publish to a subscribed topic
* Handles the received data from a publish to a subscribed topic
*
* @param[in] arg
* @param[in] data The incoming data
@@ -160,13 +160,15 @@ static void mqtt_incoming_data_cb(void* arg, const uint8_t* data, uint16_t len,
LOG_INFO(TAG, "incoming data on input/setImage: %s.", data_buffer);
lcd_clear_images();
lcd_set_bg_color_layer0(bgcolor);
if (data_buffer[len - 3] == 'b') {
lcd_draw_img_from_fs((const char*)data_buffer, xpos, ypos);
}
if (data_buffer[len - 3] == 'g') {
gif = lcd_draw_gif_from_fs((const char*)data_buffer, xpos, ypos);
if (gif == NULL) {
LOG_INFO(TAG, "GIF could not be drawn");
if (strlen(data_buffer) >= 3) {
if (data_buffer[len - 3] == 'b') {
lcd_draw_img_from_fs((const char*)data_buffer, xpos, ypos);
}
if (data_buffer[len - 3] == 'g') {
gif = lcd_draw_gif_from_fs((const char*)data_buffer, xpos, ypos);
if (gif == NULL) {
LOG_INFO(TAG, "GIF could not be drawn");
}
}
}
break;
@@ -210,7 +212,7 @@ static void mqtt_connection_cb(mqtt_client_t* client, void* arg, mqtt_connection
if (status != MQTT_CONNECT_ACCEPTED) {
LOG_INFO(TAG, "mqtt_connection_cb: Disconnected, reason: %d", status);
while (connection_attempt_counter < ATTEMPT_RECONNECT_AMOUNT) {
if (connection_attempt_counter < ATTEMPT_RECONNECT_AMOUNT) {
connection_attempt_counter++;
// Try to reconnect
mosquitto_connect(client);
@@ -409,6 +411,4 @@ static void create_publish_string(char* file_type, char* payload_buffer, size_t
}
strncat(payload_buffer, "\0", buffer_size - strlen(payload_buffer) - 1);
LOG_DEBUG(TAG, "String: %s", payload_buffer);
return;
}