diff --git a/main/main.c b/main/main.c index ddca680..4ceb901 100644 --- a/main/main.c +++ b/main/main.c @@ -99,6 +99,14 @@ void order_receipt_getStatus(int index) { 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) { // { "order": "setPosition", "ble_uart_index": 0, "speedLevel": 1, "position": 120.3, "direction": 0 } int index = 0; @@ -131,6 +139,17 @@ void process_getStatus(cJSON *rxjson) { 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) { if (!cJSON_IsString(cJSON_GetObjectItem(rxjson, "order"))) { return; @@ -140,9 +159,10 @@ void processrxjson(cJSON *rxjson) { if (strcmp(order, "setPosition") == 0) { process_setPosition(rxjson); - } else if (strcmp(order, "getStatus") == 0) { process_getStatus(rxjson); + } else if (strcmp(order, "setMotorCurrentSize") == 0) { + process_setMotorCurrentSize(rxjson); } }