hal_ble_host.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. #ifndef __hal_BLE_Host__
  2. #define __hal_BLE_Host__
  3. #include <stdbool.h>
  4. #include <stdint.h>
  5. #include <string.h>
  6. #include "sdk_common.h"
  7. #include "SEGGER_RTT.h"
  8. #include "usr_config.h"
  9. #include "hal_ble_common.h"
  10. #ifdef __cplusplus
  11. extern "C" {
  12. #endif
  13. #ifdef __cplusplus
  14. }
  15. #endif
  16. /*************** 发送子命令 ********************/
  17. enum { //BLE_Host_T_UPDATE
  18. BLE_Host_T_UPDATE_BASEINFO = 0, //设备基本信息
  19. BLE_Host_T_UPDATE_DATA , //设备数据
  20. BLE_Host_T_UPDATE_STEPNUM , //回复存储步数
  21. BLE_Host_T_UPDATE_STEPNUM_CLERA, //删除存储步数
  22. };
  23. enum { //BLE_Host_T_CHARGE
  24. BLE_Host_T_CHARGE_NONE = 0,
  25. BLE_Host_T_CHARGE_PULLOUT,
  26. BLE_Host_T_CHARGE_INSERT,
  27. BLE_Host_T_CHARGE_DONE,
  28. BLE_Host_T_CHARGE_ERROR,
  29. };
  30. /*************** 接收子命令 ********************/
  31. enum { //BLE_Host_R_UPDATE
  32. BLE_Host_R_UPDATE_BASEINFO = 0,
  33. BLE_Host_R_UPDATE_DATA ,
  34. BLE_Host_R_UPDATE_STEPNUM,
  35. BLE_Host_R_UPDATE_STEPNUM_CLERA,
  36. };
  37. typedef void (*BLE_Host_Callback)(void*);
  38. typedef struct _BLE_Host_Rx{
  39. uint8_t cmd;
  40. uint8_t* pDat;
  41. uint8_t datLen;
  42. BLE_Host_Callback cb;
  43. }BLE_Host_Rx_t;
  44. typedef struct _BLE_Host_Tx{
  45. uint8_t n;
  46. uint32_t t;
  47. uint8_t ncnt;
  48. uint32_t tcnt;
  49. BLE_CMD_n cmd;
  50. uint8_t* pDat;
  51. uint8_t datLen;
  52. uint8_t holdon;
  53. BLE_Host_Callback cb;
  54. struct _BLE_Host_Tx *next; //单向链表
  55. }BLE_Host_Tx_t;
  56. void BLE_Host_Initialize(void);
  57. void BLE_Host_Send(BLE_CMD_n cmd,unsigned char *pDat,unsigned char datLen);
  58. int BLE_Host_Rx_Regist(BLE_CMD_n cmd,BLE_Host_Callback cb);
  59. void BLE_Host_Tx_Send(BLE_Host_Tx_t* handle,BLE_CMD_n cmd,unsigned char *pDat,unsigned char datLen);
  60. void BLE_Host_Tx_Clear(BLE_Host_Tx_t* handle);
  61. void BLE_Host_Push(unsigned char* p,int len);
  62. #endif