hal_ble_client.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. #ifndef __hal_ble_client__
  2. #define __hal_ble_client__
  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_Client_T_UPDATE
  18. BLE_Client_T_UPDATE_BASEINFO = 0, //设备基本信息
  19. BLE_Client_T_UPDATE_DATA , //设备数据
  20. BLE_Client_T_UPDATE_STEPNUM , //回复存储步数
  21. BLE_Client_T_UPDATE_STEPNUM_CLERA, //删除存储步数
  22. };
  23. enum { //BLE_Client_T_CHARGE
  24. BLE_Client_T_CHARGE_NONE = 0,
  25. BLE_Client_T_CHARGE_PULLOUT,
  26. BLE_Client_T_CHARGE_INSERT,
  27. BLE_Client_T_CHARGE_DONE,
  28. };
  29. /*************** 接收子命令 ********************/
  30. enum { //BLE_Client_R_UPDATE
  31. BLE_Client_R_UPDATE_BASEINFO = 0,
  32. BLE_Client_R_UPDATE_DATA ,
  33. BLE_Client_R_UPDATE_STEPNUM,
  34. BLE_Client_R_UPDATE_STEPNUM_CLERA,
  35. };
  36. enum { //BLE_Client_R_REALTIMESTEP
  37. BLE_Client_R_REALTIMESTEP_EXIT = 0, //实时计步退出
  38. BLE_Client_R_REALTIMESTEP_ENTER, //实时计步进入
  39. BLE_Client_R_REALTIMESTEP_HANDUP, //实时计步挂起
  40. };
  41. typedef void (*BLE_Client_Callback)(void*);
  42. typedef struct _BLE_Client_Rx{
  43. uint8_t cmd;
  44. uint8_t* pDat;
  45. uint8_t datLen;
  46. BLE_Client_Callback cb;
  47. }BLE_Client_Rx_t;
  48. typedef struct _BLE_Client_Tx{
  49. uint8_t n;
  50. uint32_t t;
  51. uint8_t ncnt;
  52. uint32_t tcnt;
  53. BLE_CMD_n cmd;
  54. uint8_t* pDat;
  55. uint8_t datLen;
  56. uint8_t holdon;
  57. BLE_Client_Callback cb;
  58. struct _BLE_Client_Tx *next; //单向链表
  59. }BLE_Client_Tx_t;
  60. void BLE_Client_Initialize(void);
  61. void BLE_Client_Send(BLE_CMD_n cmd,unsigned char *pDat,unsigned char datLen);
  62. int BLE_Client_Rx_Regist(BLE_CMD_n cmd,BLE_Client_Callback cb);
  63. void BLE_Client_Tx_Send(BLE_Client_Tx_t* handle,BLE_CMD_n cmd,unsigned char *pDat,unsigned char datLen);
  64. void BLE_Client_Tx_Clear(BLE_Client_Tx_t* handle);
  65. void BLE_Client_Push(unsigned char* p,int len);
  66. #endif