You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

74 lines
2.0 KiB

#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"
#include "rgb_led.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();
gpio_rgb_init();
while (true) {
bluetooth_gatts_try_process_data();
// if (s_bluetooth_processer.auto_report_flag) {
// receipt_json_get_status();
// encoder = motor_drive_read_encoder();
// ESP_LOGI(MAIN_TAG, "encoder :%.2lf", encoder);
// s_bluetooth_processer.auto_report_flag = false;
// }
// motor_drive_set_motor_to_angle(0,35.32,5);
}
return;
}