医美代码重构
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.
 
 
 
 

95 lines
2.1 KiB

/*
This example code is in the Public Domain (or CC0 licensed, at your option.)
Unless required by applicable law or agreed to in writing, this
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
CONDITIONS OF ANY KIND, either express or implied.
*/
/*
1.建立蓝牙传递数据通道
2.对蓝牙接收到数据进行(按照时间进行)分包
3.封装上报接口
*/
#pragma once
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/*
* DEFINES
****************************************************************************************
*/
//#define SUPPORT_HEARTBEAT
//#define SPP_DEBUG_MODE
#define spp_sprintf(s, ...) sprintf((char *)(s), ##__VA_ARGS__)
#define SPP_DATA_MAX_LEN (512)
#define SPP_CMD_MAX_LEN (20)
#define SPP_STATUS_MAX_LEN (20)
#define SPP_DATA_BUFF_MAX_LEN (2 * 1024)
/// Attributes State Machine
enum {
SPP_IDX_SVC,
SPP_IDX_SPP_DATA_NOTIFY_CHAR,
SPP_IDX_SPP_DATA_NTY_VAL,
SPP_IDX_SPP_DATA_NTF_CFG,
SPP_IDX_SPP_DATA_RECV_CHAR,
SPP_IDX_SPP_DATA_RECV_VAL,
// SPP_IDX_SPP_COMMAND_CHAR,
// SPP_IDX_SPP_COMMAND_VAL,
// SPP_IDX_SPP_STATUS_CHAR,
// SPP_IDX_SPP_STATUS_VAL,
// SPP_IDX_SPP_STATUS_CFG,
#ifdef SUPPORT_HEARTBEAT
SPP_IDX_SPP_HEARTBEAT_CHAR,
SPP_IDX_SPP_HEARTBEAT_VAL,
SPP_IDX_SPP_HEARTBEAT_CFG,
#endif
SPP_IDX_NB,
};
typedef struct {
uint8_t *rxbuf;
size_t rxbufsize;
uint8_t *txbuf;
size_t txbufsize;
size_t rxpacketReceiveOvertime;
bool receive_data_processing_flag;
int has_rx_size;
int maxClientNum;
const char *bleName;
int last_rx_ticket;
bool ble_connect_flag;
} bleuart_t;
/*接收完整JSON*/
typedef void (*blerxcb_t)(uint8_t *rx, size_t rxsize);
typedef uint8_t (*blesetmotorcb_t)(int rotation_direction, double position, int speed_level);
void bleuart_init(bleuart_t *bleuart);
void bleuart_reg_cb(blerxcb_t cb);
void ble_set_motor_reg_cb(blesetmotorcb_t cb);
void bleuart_send_packet(uint8_t *tx, size_t txsize);
/**
* @brief
*/
void bleuart_schedule();
void bleuart_notify_send(uint8_t *buffer, uint8_t buffer_size);