diff --git a/lib/include/mqtt_msg.h b/lib/include/mqtt_msg.h index b94108e..c65e0d4 100644 --- a/lib/include/mqtt_msg.h +++ b/lib/include/mqtt_msg.h @@ -113,8 +113,8 @@ static inline int mqtt_get_retain(uint8_t* buffer) { return (buffer[0] & 0x01); void mqtt_msg_init(mqtt_connection_t* connection, uint8_t* buffer, uint16_t buffer_length); bool mqtt_header_complete(uint8_t* buffer, uint16_t buffer_length); uint32_t mqtt_get_total_length(uint8_t* buffer, uint16_t length, int* fixed_size_len); -const char* mqtt_get_publish_topic(uint8_t* buffer, uint32_t* length); -const char* mqtt_get_publish_data(uint8_t* buffer, uint32_t* length); +char* mqtt_get_publish_topic(uint8_t* buffer, uint32_t* length); +char* mqtt_get_publish_data(uint8_t* buffer, uint32_t* length); uint16_t mqtt_get_id(uint8_t* buffer, uint16_t length); int mqtt_has_valid_msg_hdr(uint8_t* buffer, uint16_t length); diff --git a/lib/mqtt_msg.c b/lib/mqtt_msg.c index bf40aa4..c7b1fe1 100644 --- a/lib/mqtt_msg.c +++ b/lib/mqtt_msg.c @@ -206,7 +206,7 @@ bool mqtt_header_complete(uint8_t* buffer, uint16_t buffer_length) return buffer_length >= i; } -const char* mqtt_get_publish_topic(uint8_t* buffer, uint32_t* length) +char* mqtt_get_publish_topic(uint8_t* buffer, uint32_t* length) { int i; int totlen = 0; @@ -232,10 +232,10 @@ const char* mqtt_get_publish_topic(uint8_t* buffer, uint32_t* length) return NULL; *length = topiclen; - return (const char*)(buffer + i); + return (char*)(buffer + i); } -const char* mqtt_get_publish_data(uint8_t* buffer, uint32_t* length) +char* mqtt_get_publish_data(uint8_t* buffer, uint32_t* length) { int i; int totlen = 0; @@ -278,7 +278,7 @@ const char* mqtt_get_publish_data(uint8_t* buffer, uint32_t* length) *length = totlen - i; else *length = blength - i; - return (const char*)(buffer + i); + return (char*)(buffer + i); } uint16_t mqtt_get_id(uint8_t* buffer, uint16_t length) diff --git a/mqtt_client.c b/mqtt_client.c index 1da323a..0036703 100644 --- a/mqtt_client.c +++ b/mqtt_client.c @@ -552,7 +552,7 @@ static esp_err_t deliver_publish(esp_mqtt_client_handle_t client) size_t msg_total_len = client->mqtt_state.message_length; size_t msg_topic_len = msg_read_len, msg_data_len = msg_read_len; size_t msg_data_offset = 0; - const char *msg_topic = NULL, *msg_data = NULL; + char *msg_topic = NULL, *msg_data = NULL; // get topic msg_topic = mqtt_get_publish_topic(msg_buf, &msg_topic_len); @@ -577,10 +577,10 @@ post_data_event: ESP_LOGD(TAG, "Get data len= %d, topic len=%d, total_data: %d offset: %d", msg_data_len, msg_topic_len, client->event.total_data_len, msg_data_offset); client->event.event_id = MQTT_EVENT_DATA; - client->event.data = msg_data_len > 0 ? (char *)msg_data : NULL; + client->event.data = msg_data_len > 0 ? msg_data : NULL; client->event.data_len = msg_data_len; client->event.current_data_offset = msg_data_offset; - client->event.topic = (char *)msg_topic; + client->event.topic = msg_topic; client->event.topic_len = msg_topic_len; esp_mqtt_dispatch_event(client); @@ -589,7 +589,7 @@ post_data_event: size_t buf_len = client->mqtt_state.in_buffer_length; esp_transport_handle_t transport = esp_transport_get_payload_transport_handle(client->transport); - msg_data = (const char*)client->mqtt_state.in_buffer; + msg_data = (char*)client->mqtt_state.in_buffer; msg_topic = NULL; msg_topic_len = 0; msg_data_offset += msg_data_len;