Browse Source

update

master
zwsd 3 years ago
parent
commit
06925143c3
  1. 9
      main/main.c

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

Loading…
Cancel
Save