Browse Source

添加设置当前位置命令

devtest
zwsd 3 years ago
parent
commit
cac761d4c2
  1. 19
      main/ble_parse_data.c
  2. 1
      main/ble_parse_data.h
  3. 2
      main/motor_drive.c

19
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) {

1
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;

2
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 = {

Loading…
Cancel
Save