|
@ -237,6 +237,10 @@ uint32_t total = 0; |
|
|
#define timer_interval_us (uint32_t)1 |
|
|
#define timer_interval_us (uint32_t)1 |
|
|
#define kbluetooth_baundrate_one_packet_delay_ms 200 |
|
|
#define kbluetooth_baundrate_one_packet_delay_ms 200 |
|
|
|
|
|
|
|
|
|
|
|
#define cmd_length_set_position 5 |
|
|
|
|
|
#define cmd_length_get_status 2 |
|
|
|
|
|
// #define cmd_length_device_status_report 6 |
|
|
|
|
|
|
|
|
/*********************************************************************************************************************** |
|
|
/*********************************************************************************************************************** |
|
|
* **********************************************user_function_statement********************************************** * |
|
|
* **********************************************user_function_statement********************************************** * |
|
|
***********************************************************************************************************************/ |
|
|
***********************************************************************************************************************/ |
|
@ -948,10 +952,10 @@ void bluetooth_gatts_try_process_data() |
|
|
{ |
|
|
{ |
|
|
ESP_LOGI(GATTS_TAG, "getStatus"); |
|
|
ESP_LOGI(GATTS_TAG, "getStatus"); |
|
|
} |
|
|
} |
|
|
if (strcmp(s_bluetooth_processer.order, "deviceStatusReport") == 0) |
|
|
|
|
|
{ |
|
|
|
|
|
ESP_LOGI(GATTS_TAG, "deviceStatusReport"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// if (strcmp(s_bluetooth_processer.order, "deviceStatusReport") == 0) |
|
|
|
|
|
// { |
|
|
|
|
|
// ESP_LOGI(GATTS_TAG, "deviceStatusReport"); |
|
|
|
|
|
// } |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -1005,7 +1009,7 @@ bool parse_rxbuffer_and_validation_data(cJSON **json_tmp) |
|
|
*json_tmp = cJSON_Parse(&bluetooth_rx_buffer[0]); |
|
|
*json_tmp = cJSON_Parse(&bluetooth_rx_buffer[0]); |
|
|
if (*json_tmp == NULL) |
|
|
if (*json_tmp == NULL) |
|
|
{ |
|
|
{ |
|
|
ESP_LOGE("ERROR", "json_tmp null"); |
|
|
|
|
|
|
|
|
ESP_LOGE(GATTS_TAG, "ERROR json_tmp null"); |
|
|
return false; |
|
|
return false; |
|
|
} |
|
|
} |
|
|
return true; |
|
|
return true; |
|
@ -1013,32 +1017,57 @@ bool parse_rxbuffer_and_validation_data(cJSON **json_tmp) |
|
|
|
|
|
|
|
|
bool parse_json_to_struct(cJSON *ch) |
|
|
bool parse_json_to_struct(cJSON *ch) |
|
|
{ |
|
|
{ |
|
|
|
|
|
uint8_t cmd_length = 0; |
|
|
while (ch != NULL) |
|
|
while (ch != NULL) |
|
|
{ |
|
|
{ |
|
|
// ESP_LOGI(GATTS_TAG, "%s", ch->string); |
|
|
// ESP_LOGI(GATTS_TAG, "%s", ch->string); |
|
|
if (strcmp(ch->string, "order") == 0) |
|
|
if (strcmp(ch->string, "order") == 0) |
|
|
{ |
|
|
{ |
|
|
s_bluetooth_processer.order = ch->valuestring; |
|
|
s_bluetooth_processer.order = ch->valuestring; |
|
|
s_bluetooth_processer.cmd_flag = true; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (strcmp(ch->valuestring, "setPosition") == 0) |
|
|
|
|
|
{ |
|
|
|
|
|
cmd_length = cmd_length_set_position; |
|
|
|
|
|
} |
|
|
|
|
|
if (strcmp(ch->valuestring, "getStatus") == 0) |
|
|
|
|
|
{ |
|
|
|
|
|
cmd_length = cmd_length_get_status; |
|
|
|
|
|
} |
|
|
|
|
|
// if (strcmp(ch->valuestring, "deviceStatusReport") == 0) |
|
|
|
|
|
// { |
|
|
|
|
|
// cmd_length = cmd_length_device_status_report; |
|
|
|
|
|
// } |
|
|
|
|
|
cmd_length--; |
|
|
} |
|
|
} |
|
|
if (strcmp(ch->string, "index") == 0) |
|
|
if (strcmp(ch->string, "index") == 0) |
|
|
{ |
|
|
{ |
|
|
s_bluetooth_processer.index = ch->valueint; |
|
|
s_bluetooth_processer.index = ch->valueint; |
|
|
|
|
|
cmd_length--; |
|
|
} |
|
|
} |
|
|
if (strcmp(ch->string, "speedLevel") == 0) |
|
|
if (strcmp(ch->string, "speedLevel") == 0) |
|
|
{ |
|
|
{ |
|
|
s_bluetooth_processer.speed_level = ch->valueint; |
|
|
s_bluetooth_processer.speed_level = ch->valueint; |
|
|
|
|
|
cmd_length--; |
|
|
} |
|
|
} |
|
|
if (strcmp(ch->string, "position") == 0) |
|
|
if (strcmp(ch->string, "position") == 0) |
|
|
{ |
|
|
{ |
|
|
s_bluetooth_processer.position = ch->valuedouble; |
|
|
s_bluetooth_processer.position = ch->valuedouble; |
|
|
|
|
|
cmd_length--; |
|
|
} |
|
|
} |
|
|
if (strcmp(ch->string, "direction") == 0) |
|
|
if (strcmp(ch->string, "direction") == 0) |
|
|
{ |
|
|
{ |
|
|
s_bluetooth_processer.direction = ch->valueint; |
|
|
s_bluetooth_processer.direction = ch->valueint; |
|
|
|
|
|
cmd_length--; |
|
|
} |
|
|
} |
|
|
ch = ch->next; |
|
|
ch = ch->next; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (cmd_length == 0) |
|
|
|
|
|
{ |
|
|
|
|
|
s_bluetooth_processer.cmd_flag = true; |
|
|
|
|
|
}else{ |
|
|
|
|
|
ESP_LOGE(GATTS_TAG,"JSON directive missing or exceeded"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
return s_bluetooth_processer.cmd_flag; |
|
|
return s_bluetooth_processer.cmd_flag; |
|
|
} |
|
|
} |