- static void rx_task(void *arg)
- {
- static const char *RX_TASK_TAG = "RX_TASK";
- esp_log_level_set(RX_TASK_TAG, ESP_LOG_INFO);
- uint8_t* RXdata = (uint8_t*) malloc(RX_BUF_SIZE+1);
- while (1) {
- const int rxBytes = uart_read_bytes(UART_NUM_2, RXdata, RX_BUF_SIZE, 2000 / portTICK_PERIOD_MS);
- if (rxBytes > 0) {
- RXdata[rxBytes] = '\0'; // 添加字符串结束符
- ESP_LOGI(RX_TASK_TAG, "Read %d bytes: '%s'", rxBytes, RXdata);
- ESP_LOG_BUFFER_HEXDUMP(RX_TASK_TAG, RXdata, rxBytes, ESP_LOG_INFO);
- //esp_mqtt_client_publish(MQTT_client, AliyunPublishTopic_user_update, (char *)RXdata, rxBytes, 1, 0);
- // 构建 JSON 字符串
- char json_message[512]; // 假设消息长度不超过 512 个字符
- snprintf(json_message, sizeof(json_message), "{\"method\":\"thing.service.property.set\",\"id\":\"1428164640\",\"params\":{\"MS72SF1:RemainParkSpace\":%s},\"version\":\"1.0.0\"}", RXdata);
- esp_mqtt_client_publish(MQTT_client, AliyunPublishTopic_user_update, json_message, strlen(json_message), 1, 0);
- }
- }
- free(RXdata);
- }
rx_task栈空间不足***ERROR*** A stack overflow in task uart_rx_task has been detected.
rx_task栈空间不足***ERROR*** A stack overflow in task uart_rx_task has been detected.
Who is online
Users browsing this forum: No registered users and 220 guests