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.
 
 
 
 
 

91 lines
2.6 KiB

#include "driver/gpio.h"
#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};
#define GPIO_OUTPUT_IO_RED 3
#define GPIO_OUTPUT_IO_GREEN 4
#define GPIO_OUTPUT_IO_BLUE 5
#define GPIO_OUTPUT_PIN_SEL ((1ULL << GPIO_OUTPUT_IO_GREEN) | (1ULL << GPIO_OUTPUT_IO_BLUE) | (1ULL << GPIO_OUTPUT_IO_RED))
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 gpio_rgb_init() {
gpio_config_t gpio_grb_led_structer;
gpio_grb_led_structer.intr_type = GPIO_INTR_DISABLE;
gpio_grb_led_structer.mode = GPIO_MODE_OUTPUT;
gpio_grb_led_structer.pin_bit_mask = GPIO_OUTPUT_PIN_SEL;
gpio_grb_led_structer.pull_down_en = 0;
gpio_grb_led_structer.pull_up_en = 0;
gpio_config(&gpio_grb_led_structer);
}
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();
gpio_set_level(GPIO_OUTPUT_IO_GREEN,1);
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;
}