|
|
#include "esp_gatts_api.h"
#include "esp_log.h"
#include "esp_system.h"
#include "freertos/FreeRTOS.h"
#include "freertos/event_groups.h"
#include "freertos/task.h"
#include "nvs_flash.h"
#include "string.h"
//
#include "ble_spp_server_demo.h"
#include "ble_uart.h"
#include "motor_drive.h"
#include "timer_u.h"
#define MAIN_TAG "MAIN"
static char bluetooth_tx_buffer[profile_b_buffer_size] = {0}; static char bluetooth_rx_buffer[profile_b_buffer_size] = {0};
bluetooth_processer_t s_bluetooth_processer = { .bluetooth_processer_rx_buf = bluetooth_rx_buffer, .bluetooth_processer_rx_buf_size = sizeof(bluetooth_rx_buffer), .bluetooth_processer_tx_buf = bluetooth_tx_buffer, .bluetooth_processer_tx_buf_size = sizeof(bluetooth_tx_buffer), .bluetooth_baundrate_one_packet_delay_ms = kbluetooth_baundrate_one_packet_delay_ms, .port_delay_ms = port_timer_delay_ms,
.bluetooth_rx_buffer_start_receving = false, .bluetooth_rx_buffer_processing = false,
.order = "order", .index = 0, .speedLevel = 0, .position = 0.0, .direction = 0, .code = 0, .info = "noerror", .deviceState = "init", .deviceException = 0, .deviceExceptionInfo = "noexception",
.table_conn_id_m = 0, .table_gatts_if_m = 0, .table_handle_m = 0,
.cmd_flag = false, .auto_report_flag = false, .motor_drive_turn_flag = false, };
void app_main(void) { constructor_bluetooth_processer(&s_bluetooth_processer); ble_spp_server_demo_app_main(&s_bluetooth_processer); timer_group_init(TIMER_GROUP_0, TIMER_0, false, timer_group0_interval_num, timer_interval_ms); motor_drive_uart_init(); // ble_uart_init(UART_NUM_1, 1, 2);
// char* test_str = "This is a test string.\n";
// double encoder = 0.0;
while (true) { bluetooth_gatts_try_process_data(); // if (s_bluetooth_processer.auto_report_flag) {
// receipt_json_get_status();
// s_bluetooth_processer.auto_report_flag = false;
// }
// if ((motor_drive_read_encoder() == s_bluetooth_processer.position) && s_bluetooth_processer.motor_drive_turn_flag == true) {
// ESP_LOGI("test", "info log ok\n");
// s_bluetooth_processer.motor_drive_turn_flag = false;
// }
// if (s_bluetooth_processer.auto_report_flag) {
// encoder = motor_drive_read_encoder();
// ESP_LOGI(MAIN_TAG, "encoder :%.2lf",encoder);
// s_bluetooth_processer.auto_report_flag = false;
// }
}
return; }
|