123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126 |
- #ifndef __hal_ble_client__
- #define __hal_ble_client__
- #include <stdbool.h>
- #include <stdint.h>
- #include <string.h>
- #include "sdk_common.h"
- #include "SEGGER_RTT.h"
- #include "usr_config.h"
- #ifdef __cplusplus
- extern "C" {
- #endif
-
- #ifdef __cplusplus
- }
- #endif
- /*************** 发送命令 ********************/
- typedef enum {
- BLE_Client_T_HEART = 0,
- BLE_Client_T_MOTION, //动作
- BLE_Client_T_TRACK = 0x04, //轨迹
- BLE_Client_T_CONNET_LED = 0x10, //连接灯通知
- BLE_Client_T_CONFIG, //配对
- BLE_Client_T_UPDATE = 0xA1, //数据更新
- BLE_Client_T_GAMEMODE, //游戏模式
- BLE_Client_T_CONNET_R, //右鞋连接通知
- BLE_Client_T_SHOCK, //震动
- BLE_Client_T_REALTIMESTEP, //实时步数
- BLE_Client_T_DFU, //空中升级
- BLE_Client_T_CHARGE, //充电通知
- BLE_CLient_T_CHAR_VOL, //共享充电电量
- BLE_CLient_T_SET_ORGAN, //激光的开关
- BLE_Client_T_ERR, //错误信息
-
- // BLE_Client_NUM_OF_T, //命令连续用此值
- }BLE_Client_T_n;
- //#define BLE_Client_NUM_OF_T 9 //注意:::此值根据命令的数量改变
- /*************** 发送子命令 ********************/
- enum { //BLE_Client_T_UPDATE
- BLE_Client_T_UPDATE_BASEINFO = 0, //设备基本信息
- BLE_Client_T_UPDATE_DATA , //设备数据
- BLE_Client_T_UPDATE_STEPNUM , //回复存储步数
- BLE_Client_T_UPDATE_STEPNUM_CLERA, //删除存储步数
- };
- enum { //BLE_Client_T_CHARGE
- BLE_Client_T_CHARGE_NONE = 0,
- BLE_Client_T_CHARGE_PULLOUT,
- BLE_Client_T_CHARGE_INSERT,
- BLE_Client_T_CHARGE_DONE,
- };
- //#define BLE_Client_NUM_OF_T 20 //注意:::此值根据命令的数量改变(包括子命令)
- /*************** 接收命令 ********************/
- typedef enum {
- BLE_Client_R_HEART = 0,
- BLE_Client_R_MOTION, //动作
- BLE_Client_R_TRACK = 0x04, //轨迹
- BLE_Client_R_CONNET_LED = 0x10, //连接灯通知
- BLE_Client_R_CONFIG, //配对
- BLE_Client_R_UPDATE = 0xA1, //数据更新
- BLE_Client_R_GAMEMODE, //游戏模式
- BLE_Client_R_CONNET_R, //右鞋连接通知
- BLE_Client_R_SHOCK, //震动
- BLE_Client_R_REALTIMESTEP, //实时步数
- BLE_Client_R_DFU, //空中升级
- BLE_Client_R_CHARGE, //充电通知
- BLE_CLient_R_CHAR_VOL, //共享充电电量
- BLE_CLient_R_SET_ORGAN, //激光的开关
- BLE_Client_R_ERR, //错误信息
- // BLE_Client_NUM_OF_R, //命令连续用此值
- }BLE_Client_R_n;
- #define BLE_Client_NUM_OF_R 15 //注意:::此值根据命令的数量改变
- /*************** 接收子命令 ********************/
- enum { //BLE_Client_R_UPDATE
- BLE_Client_R_UPDATE_BASEINFO = 0,
- BLE_Client_R_UPDATE_DATA ,
- BLE_Client_R_UPDATE_STEPNUM,
- BLE_Client_R_UPDATE_STEPNUM_CLERA,
- };
- enum { //BLE_Client_R_REALTIMESTEP
- BLE_Client_R_REALTIMESTEP_EXIT = 0, //实时计步退出
- BLE_Client_R_REALTIMESTEP_ENTER, //实时计步进入
- BLE_Client_R_REALTIMESTEP_HANDUP, //实时计步挂起
- };
- typedef void (*BLE_Client_Callback)(void*);
- typedef struct _BLE_Client_Rx{
- uint8_t cmd;
- uint8_t* pDat;
- uint8_t datLen;
- BLE_Client_Callback cb;
- }BLE_Client_Rx_t;
- typedef struct _BLE_Client_Tx{
- uint8_t n;
- uint32_t t;
- uint8_t ncnt;
- uint32_t tcnt;
- uint8_t cmd;
- uint8_t* pDat;
- uint8_t datLen;
- uint8_t holdon;
- BLE_Client_Callback cb;
- struct _BLE_Client_Tx *next; //单向链表
- }BLE_Client_Tx_t;
- void BLE_Client_Initialize(void);
- void BLE_Client_Send(unsigned char cmd,unsigned char *pDat,unsigned char datLen);
- int BLE_Client_Rx_Regist(unsigned char cmd,BLE_Client_Callback cb);
- void BLE_Client_Tx_Send(BLE_Client_Tx_t* handle,unsigned char cmd,unsigned char *pDat,unsigned char datLen);
- void BLE_Client_Tx_Clear(BLE_Client_Tx_t* handle);
- void BLE_Client_Push(unsigned char* p,int len);
- #endif
|