hal_ble_host.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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 void (*BLE_Host_Callback_cb)(uint8_t*pdat ,uint8_t len);
  39. typedef struct _BLE_Host_Rx{
  40. uint8_t cmd;
  41. uint8_t* pDat;
  42. uint8_t datLen;
  43. BLE_Host_Callback cb;
  44. }BLE_Host_Rx_t;
  45. typedef struct _BLE_Host_Tx{
  46. uint8_t n;
  47. uint32_t t;
  48. uint8_t ncnt;
  49. uint32_t tcnt;
  50. BLE_CMD_n cmd;
  51. uint8_t* pDat;
  52. uint8_t datLen;
  53. uint8_t holdon;
  54. BLE_Host_Callback cb;
  55. struct _BLE_Host_Tx *next; //单向链表
  56. }BLE_Host_Tx_t;
  57. void BLE_Host_Initialize(void);
  58. void BLE_Host_Send(BLE_CMD_n cmd,unsigned char *pDat,unsigned char datLen);
  59. int BLE_Host_Rx_Regist(BLE_CMD_n cmd,BLE_Host_Callback cb);
  60. void BLE_Host_Tx_Send(BLE_Host_Tx_t* handle,BLE_CMD_n cmd,unsigned char *pDat,unsigned char datLen);
  61. void BLE_Host_Tx_Clear(BLE_Host_Tx_t* handle);
  62. void BLE_Host_Push(unsigned char* p,int len);
  63. int BLE_Host_Rx_Regist_Game(BLE_Host_Callback_cb cb);
  64. #endif