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();