From cac761d4c2cf12ce1c1c7ce6e5fe91a4f232e3c7 Mon Sep 17 00:00:00 2001 From: zwsd Date: Tue, 26 Jul 2022 18:31:08 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=AE=BE=E7=BD=AE=E5=BD=93?= =?UTF-8?q?=E5=89=8D=E4=BD=8D=E7=BD=AE=E5=91=BD=E4=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main/ble_parse_data.c | 19 ++++++++++--------- main/ble_parse_data.h | 1 + main/motor_drive.c | 2 +- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/main/ble_parse_data.c b/main/ble_parse_data.c index 0f99b34..d0f3088 100644 --- a/main/ble_parse_data.c +++ b/main/ble_parse_data.c @@ -6,7 +6,7 @@ #define cmd_length_set_position 5 #define cmd_length_get_status 2 - +#define cmd_length_set_motor_current_size 2 static double encoder_befor_num; static bluetooth_processer_t *parse_bluetooth_processer; @@ -54,10 +54,11 @@ void bluetooth_gatts_try_process_data() { ESP_LOGI(BLE_PARSE_DATA_TAG, get_status); receipt_json_get_status(); } - // if (strcmp(parse_bluetooth_processer->order, "deviceStatusReport") == 0) - // { - // ESP_LOGI(BLE_PARSE_DATA_TAG, "deviceStatusReport"); - // } + if (strcmp(parse_bluetooth_processer->order, set_motor_current_size) == 0) { + ESP_LOGI(BLE_PARSE_DATA_TAG, set_motor_current_size); + motor_drive_set_motor_current_size(); + // receipt_json_get_status(); + } } } @@ -114,10 +115,10 @@ bool parse_json_to_struct(cJSON *ch) { if (strcmp(ch->valuestring, get_status) == 0) { cmd_length = cmd_length_get_status; } - // if (strcmp(ch->valuestring, "deviceStatusReport") == 0) - // { - // cmd_length = cmd_length_device_status_report; - // } + if (strcmp(ch->valuestring, set_motor_current_size) == 0) { + cmd_length = cmd_length_set_motor_current_size; + } + cmd_length--; } if (strcmp(ch->string, "index") == 0) { diff --git a/main/ble_parse_data.h b/main/ble_parse_data.h index f0cef7d..c702bc6 100644 --- a/main/ble_parse_data.h +++ b/main/ble_parse_data.h @@ -14,6 +14,7 @@ #define set_position "setPosition" #define get_status "getStatus" +#define set_motor_current_size "setMotorCurrentSize" typedef struct bluetooth_processer { char *bluetooth_processer_rx_buf; diff --git a/main/motor_drive.c b/main/motor_drive.c index 34925c1..7e9229c 100644 --- a/main/motor_drive.c +++ b/main/motor_drive.c @@ -10,7 +10,7 @@ #define tx_io_num 1 #define rx_io_num 2 #define buffer_size 128 -#define uart_read_time_ms 2000 +#define uart_read_time_ms 1 void motor_drive_uart_init() { uart_config_t uart_config = {