From a204a0d5cf249f7e356f50c934cf2dff9c6ddf76 Mon Sep 17 00:00:00 2001 From: zwsd Date: Wed, 3 Aug 2022 19:20:17 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=94=B9=E4=B8=BB=E5=8A=A8=E4=B8=8A?= =?UTF-8?q?=E6=8A=A5=E6=95=B0=E6=8D=AE=EF=BC=8C=E4=B9=8B=E5=89=8D=E4=B8=BB?= =?UTF-8?q?=E5=8A=A8=E4=B8=8A=E6=8A=A5=E6=95=B0=E6=8D=AE=E6=98=AF=E9=94=99?= =?UTF-8?q?=E8=AF=AF=E7=9A=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main/main.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/main/main.c b/main/main.c index a2ac877..50131a3 100644 --- a/main/main.c +++ b/main/main.c @@ -116,12 +116,13 @@ void motor_on_event(motor_event_t event) { //打算使用sprintf if (event == kRunToPosition) { ESP_LOGI(MAIN_LOG_TAG, "kRunToPosition ok!"); + uint8_t buffer[256] = {0}; + double motor_stop_position = motor_get_position_degree(); - uint8_t buffer[128] = {0}; - //组包 - //上报 - //{ "order": "deviceStatusReport", "ble_uart_index": 0, "deviceState": "running", "position":13.9, "deviceException": 0, "deviceExceptionInfo": "", } - sprintf((char *)buffer, "{ \"order\": \"receipt\", \"code\": 0, \"info\": \"success\", \"index\": %d }", 1); + //{ "order": "deviceStatusReport", "ble_uart_index": 0, "deviceState": "running", "position":13.9, "deviceException": 0, "deviceExceptionInfo": ""} + sprintf((char *)buffer, + "{ \"order\": \"deviceStatusReport\", \"index\": %d, \"deviceState\": \"idel\", \"position\":%.2lf, \"deviceException\": 0, \"deviceExceptionInfo\": \"\" }", // + 1, motor_stop_position); bleuart_notify_send(buffer, strlen((char *)buffer)); } } @@ -190,7 +191,7 @@ void app_main(void) { gpio_output_debug_light_init(); #endif - + while (true) { #if SUPPORT_DEBUG_LIGHT port_do_debug_light_state();