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.
 
 
 
 
 

66 lines
2.0 KiB

#pragma once
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "cJSON.h"
#include "cJSON_Utils.h"
#include "driver/timer.h"
#include "esp_gatts_api.h"
#include "esp_log.h"
#include "esp_system.h"
#define profile_b_buffer_size 128
#define set_position "setPosition"
#define get_status "getStatus"
#define set_motor_current_size "setMotorCurrentSize"
#define set_motor_to_position "setMotorToPosition"
typedef struct bluetooth_processer {
char *bluetooth_processer_rx_buf;
uint8_t bluetooth_processer_rx_buf_size; //
char *bluetooth_processer_tx_buf;
uint8_t bluetooth_processer_tx_buf_size; //
int bluetooth_baundrate_one_packet_delay_ms;
void (*port_delay_ms)(uint64_t us);
bool bluetooth_rx_buffer_start_receving;
bool bluetooth_rx_buffer_processing;
char *order; //指令名称
int index; //
int speedLevel; //
double position; //角度
int direction; //旋转方向
int code; //错误码
char *info; //错误码信息
char *deviceState; //设备状态
int deviceException; //设备异常编号
char *deviceExceptionInfo; //设备异常信息
uint16_t table_conn_id_m;
esp_gatt_if_t table_gatts_if_m;
uint16_t table_handle_m;
bool cmd_flag;
bool auto_report_flag;
bool motor_drive_turn_flag;
} bluetooth_processer_t;
typedef void (*cb_t)();
void constructor_bluetooth_processer(bluetooth_processer_t *bluetooth_processer);
void bluetooth_gatts_try_process_data();
void start_receive_data_to_buffer(uint16_t length, uint8_t *value);
void buffer_all_init();
bool parse_rxbuffer_and_validation_data(cJSON **json_tmp);
bool parse_json_to_struct(cJSON *ch);
void receipt_json_set_position();
void receipt_json_get_status();
void bluetooth_auto_report_format_receipt();
void bluetooth_tx_buffer_send_indicate(cb_t format);
void string_copy_by_num(char *dest, const char *src, uint8_t count, uint8_t num);
void bluetooth_active_notify(uint8_t *buffer, uint8_t buffer_size);