|
@ -116,12 +116,13 @@ void motor_on_event(motor_event_t event) { |
|
|
//打算使用sprintf |
|
|
//打算使用sprintf |
|
|
if (event == kRunToPosition) { |
|
|
if (event == kRunToPosition) { |
|
|
ESP_LOGI(MAIN_LOG_TAG, "kRunToPosition ok!"); |
|
|
ESP_LOGI(MAIN_LOG_TAG, "kRunToPosition ok!"); |
|
|
|
|
|
uint8_t buffer[256] = {0}; |
|
|
|
|
|
double motor_stop_position = motor_get_position_degree(); |
|
|
|
|
|
|
|
|
uint8_t buffer[128] = {0}; |
|
|
|
|
|
//组包 |
|
|
|
|
|
//上报 |
|
|
|
|
|
//{ "order": "deviceStatusReport", "ble_uart_index": 0, "deviceState": "running", "position":13.9, "deviceException": 0, "deviceExceptionInfo": "", } |
|
|
|
|
|
sprintf((char *)buffer, "{ \"order\": \"receipt\", \"code\": 0, \"info\": \"success\", \"index\": %d }", 1); |
|
|
|
|
|
|
|
|
//{ "order": "deviceStatusReport", "ble_uart_index": 0, "deviceState": "running", "position":13.9, "deviceException": 0, "deviceExceptionInfo": ""} |
|
|
|
|
|
sprintf((char *)buffer, |
|
|
|
|
|
"{ \"order\": \"deviceStatusReport\", \"index\": %d, \"deviceState\": \"idel\", \"position\":%.2lf, \"deviceException\": 0, \"deviceExceptionInfo\": \"\" }", // |
|
|
|
|
|
1, motor_stop_position); |
|
|
bleuart_notify_send(buffer, strlen((char *)buffer)); |
|
|
bleuart_notify_send(buffer, strlen((char *)buffer)); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|