From 06925143c32ddc1ae054d9a1f46e489c337d97ba Mon Sep 17 00:00:00 2001 From: zwsd Date: Mon, 8 Aug 2022 15:08:29 +0800 Subject: [PATCH] update --- main/main.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/main/main.c b/main/main.c index d8b7c7b..7cb43ee 100644 --- a/main/main.c +++ b/main/main.c @@ -84,7 +84,6 @@ void construct_set_motorCurrentSize_packet_and_report(int index) { void process_setPosition(RxContext_t *context, cJSON *rxjson) { // { "order": "setPosition", "ble_uart_index": 0, "speedLevel": 1, "position": 120.3, "direction": 0 } - int index = 0; int speedLevel = 0; float position = 0; int direction = 0; @@ -92,20 +91,16 @@ void process_setPosition(RxContext_t *context, cJSON *rxjson) { if (cJSON_IsNumber(cJSON_GetObjectItem(rxjson, "position"))) { position = cJSON_GetObjectItem(rxjson, "position")->valuedouble; } - if (cJSON_IsNumber(cJSON_GetObjectItem(rxjson, "index"))) { - index = cJSON_GetNumberValue(cJSON_GetObjectItem(rxjson, "index")); - } if (cJSON_IsNumber(cJSON_GetObjectItem(rxjson, "speedLevel"))) { speedLevel = cJSON_GetNumberValue(cJSON_GetObjectItem(rxjson, "speedLevel")); } - if (cJSON_IsNumber(cJSON_GetObjectItem(rxjson, "direction"))) { direction = cJSON_GetNumberValue(cJSON_GetObjectItem(rxjson, "direction")); } - ESP_LOGI(MAIN_LOG_TAG, "index = %d,speedLevel = %d,position = %lf,direction = %d", index, speedLevel, position, direction); + ESP_LOGI(MAIN_LOG_TAG, "order = %s,index = %d,speedLevel = %d,position = %lf,direction = %d", context->order, context->index, speedLevel, position, direction); setPosition_code = motor_run_to_postion(1, position, 0); motor_turning = true; - construct_set_position_packet_and_report(index, setPosition_code); + construct_set_position_packet_and_report(context->index, setPosition_code); } void process_getStatus(cJSON *rxjson) {