There is a function that takes the following argument :
int send_message(const char *topic)
I have a struct :
typedef struct mqtt_topic {
char topic[200];
} mqtt_topic_t;
and a value that is of the type : mqtt_topic_t *mqtt_topic
I am trying to pass mqtt_topic->topic
as an argument to the function but it throws an error. How do I convert this data to useful format that I can then use as an argument in my function?
Here is the code snippet :
int mqtt_publish(char message[])
{
int msg_id = 0;
ESP_LOGI(TAG, "MQTT_EVENT_CONNECTED");
mqtt_topic_t *mqtt_topic = get_mqtt_topic();
msg_id = esp_mqtt_client_publish(client,&mqtt_topic->topic, message, 0, 1, 0);
ESP_LOGI(TAG, "sent publish successful, msg_id=%d", msg_id);
return msg_id;
}
Function Prototype :
int esp_mqtt_client_publish(esp_mqtt_client_handle_t client, const char *topic, const char *data, int len, int qos, int retain);