#ifndef __hal_BLE_Host__ #define __hal_BLE_Host__ #include #include #include #include "sdk_common.h" #include "SEGGER_RTT.h" #include "usr_config.h" #ifdef __cplusplus extern "C" { #endif #ifdef __cplusplus } #endif /*************** 发送命令 ********************/ typedef enum { BLE_Host_T_HEART = 0, BLE_Host_T_MOTION, //动作 BLE_Host_T_TRACK = 0x04, //轨迹 BLE_Host_T_CONNET_LED = 0x10, //连接灯通知 BLE_Host_T_CONFIG, //配对 BLE_Host_T_UPDATE = 0xA1, //数据更新 BLE_Host_T_GAMEMODE, //游戏模式 BLE_Host_T_CONNET_R, //右鞋连接通知 BLE_Host_T_SHOCK, //震动 BLE_Host_T_REALTIMESTEP, //实时步数 BLE_Host_T_DFU, //空中升级 BLE_Host_T_CHARGE, //充电通知 BLE_Host_T_CHAR_VOL, //共享充电电量 BLE_Host_T_SET_ORGAN, //激光的开关 BLE_Host_T_ERR, //错误信息 }BLE_Host_T_n; //#define BLE_Host_NUM_OF_T 9 //注意:::此值根据命令的数量改变 /*************** 发送子命令 ********************/ enum { //BLE_Host_T_UPDATE BLE_Host_T_UPDATE_BASEINFO = 0, //设备基本信息 BLE_Host_T_UPDATE_DATA , //设备数据 BLE_Host_T_UPDATE_STEPNUM , //回复存储步数 BLE_Host_T_UPDATE_STEPNUM_CLERA, //删除存储步数 }; enum { //BLE_Host_T_CHARGE BLE_Host_T_CHARGE_NONE = 0, BLE_Host_T_CHARGE_PULLOUT, BLE_Host_T_CHARGE_INSERT, BLE_Host_T_CHARGE_DONE, BLE_Host_T_CHARGE_ERROR, }; //#define BLE_Host_NUM_OF_T 20 //注意:::此值根据命令的数量改变(包括子命令) /*************** 接收命令 ********************/ typedef enum { BLE_Host_R_HEART = 0, BLE_Host_R_MOTION, //动作 BLE_Host_R_TRACK = 0x04, //轨迹 BLE_Host_R_CONNET_LED = 0x10, //连接灯通知 BLE_Host_R_CONFIG, //配对 BLE_Host_R_UPDATE = 0xA1, //数据更新 BLE_Host_R_GAMEMODE, //游戏模式 BLE_Host_R_CONNET_R, //右鞋连接通知 BLE_Host_R_SHOCK, //震动 BLE_Host_R_REALTIMESTEP, //实时步数 BLE_Host_R_DFU, //空中升级 BLE_Host_R_CHARGE, //充电通知 BLE_Host_R_CHAR_VOL, //共享充电电量 BLE_Host_R_SET_ORGAN, //激光的开关 BLE_Host_R_ERR, //错误信息 // BLE_Host_NUM_OF_R, //命令连续用此值 }BLE_Host_R_n; #define BLE_Host_NUM_OF_R 15 //注意:::此值根据命令的数量改变 /*************** 接收子命令 ********************/ enum { //BLE_Host_R_UPDATE BLE_Host_R_UPDATE_BASEINFO = 0, BLE_Host_R_UPDATE_DATA , BLE_Host_R_UPDATE_STEPNUM, BLE_Host_R_UPDATE_STEPNUM_CLERA, }; typedef void (*BLE_Host_Callback)(void*); typedef struct _BLE_Host_Rx{ uint8_t cmd; uint8_t* pDat; uint8_t datLen; BLE_Host_Callback cb; }BLE_Host_Rx_t; typedef struct _BLE_Host_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_Host_Callback cb; struct _BLE_Host_Tx *next; //单向链表 }BLE_Host_Tx_t; void BLE_Host_Initialize(void); void BLE_Host_Send(unsigned char cmd,unsigned char *pDat,unsigned char datLen); int BLE_Host_Rx_Regist(unsigned char cmd,BLE_Host_Callback cb); void BLE_Host_Tx_Send(BLE_Host_Tx_t* handle,unsigned char cmd,unsigned char *pDat,unsigned char datLen); void BLE_Host_Tx_Clear(BLE_Host_Tx_t* handle); void BLE_Host_Push(unsigned char* p,int len); #endif