|
@ -99,6 +99,14 @@ void order_receipt_getStatus(int index) { |
|
|
bleuart_notify_send(buffer, strlen((char *)buffer)); |
|
|
bleuart_notify_send(buffer, strlen((char *)buffer)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void order_receipt_setMotorCurrentSize(int index) { |
|
|
|
|
|
ESP_LOGI(MAIN_LOG_TAG, "Command setMotorCurrentSize execution complete!"); |
|
|
|
|
|
uint8_t buffer[256] = {0}; |
|
|
|
|
|
|
|
|
|
|
|
sprintf((char *)buffer, "{ \"order\": \"receipt\", \"index\": %d }", index); |
|
|
|
|
|
bleuart_notify_send(buffer, strlen((char *)buffer)); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
void process_setPosition(cJSON *rxjson) { |
|
|
void process_setPosition(cJSON *rxjson) { |
|
|
// { "order": "setPosition", "ble_uart_index": 0, "speedLevel": 1, "position": 120.3, "direction": 0 } |
|
|
// { "order": "setPosition", "ble_uart_index": 0, "speedLevel": 1, "position": 120.3, "direction": 0 } |
|
|
int index = 0; |
|
|
int index = 0; |
|
@ -131,6 +139,17 @@ void process_getStatus(cJSON *rxjson) { |
|
|
order_receipt_getStatus(index); |
|
|
order_receipt_getStatus(index); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void process_setMotorCurrentSize(cJSON *rxjson) { |
|
|
|
|
|
int index = 0; |
|
|
|
|
|
if (cJSON_IsNumber(cJSON_GetObjectItem(rxjson, "index"))) { |
|
|
|
|
|
index = cJSON_GetNumberValue(cJSON_GetObjectItem(rxjson, "index")); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
motor_set_zero_point(); |
|
|
|
|
|
|
|
|
|
|
|
order_receipt_setMotorCurrentSize(index); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
void processrxjson(cJSON *rxjson) { |
|
|
void processrxjson(cJSON *rxjson) { |
|
|
if (!cJSON_IsString(cJSON_GetObjectItem(rxjson, "order"))) { |
|
|
if (!cJSON_IsString(cJSON_GetObjectItem(rxjson, "order"))) { |
|
|
return; |
|
|
return; |
|
@ -140,9 +159,10 @@ void processrxjson(cJSON *rxjson) { |
|
|
|
|
|
|
|
|
if (strcmp(order, "setPosition") == 0) { |
|
|
if (strcmp(order, "setPosition") == 0) { |
|
|
process_setPosition(rxjson); |
|
|
process_setPosition(rxjson); |
|
|
|
|
|
|
|
|
} else if (strcmp(order, "getStatus") == 0) { |
|
|
} else if (strcmp(order, "getStatus") == 0) { |
|
|
process_getStatus(rxjson); |
|
|
process_getStatus(rxjson); |
|
|
|
|
|
} else if (strcmp(order, "setMotorCurrentSize") == 0) { |
|
|
|
|
|
process_setMotorCurrentSize(rxjson); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|