ble_action.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. #ifndef BLE_ACTION_H__
  2. #define BLE_ACTION_H__
  3. #include <stdint.h>
  4. #include <stdbool.h>
  5. #include "define.h"
  6. #ifdef __cplusplus
  7. extern "C" {
  8. #endif
  9. #define BLE_ACTION_TICKS 10
  10. //设置状态
  11. typedef enum{
  12. SET_PARAM_SUCCESS = 0x01,
  13. SET_PARAM_FAILURE = 0x02,
  14. }ble_param_set_stat_e;
  15. /*CAN 接口功能设置
  16. 波特率
  17. CAN_BAUD_100 = 100,
  18. CAN_BAUD_150 = 150,
  19. CAN_BAUD_200 = 200,
  20. CAN_BAUD_250 = 250,
  21. CAN_BAUD_300 = 300,
  22. CAN_BAUD_400 = 400,
  23. CAN_BAUD_500 = 500,
  24. CAN_BAUD_666 = 666,
  25. CAN_BAUD_800 = 800,
  26. CAN_BAUD_1000 = 1000
  27. */
  28. typedef struct{
  29. uint16_t can_baud; //通讯波特率。
  30. }__attribute__((packed)) ble_can_set_s;
  31. typedef enum{
  32. BLE_DOWNLOAD_MAIN = (uint8_t)0x01,
  33. BLE_UPLOAD_SLAVE = (uint8_t)0x02,
  34. }ble_dev_data_type_e;
  35. typedef enum{
  36. INS_TOKEN = (uint8_t)0x01, //获取token
  37. INS_PARAM_SET = (uint8_t)0x02, //参数设置指令
  38. INS_PARAM_GET = (uint8_t)0x03, //获取设置参数指令
  39. INS_DATA_GET = (uint8_t)0x04, //获取数据指令
  40. INS_CONTROL = (uint8_t)0x05, //控制指令
  41. INS_FIRMWARE = (uint8_t)0xEE, //固件获取指令
  42. }ble_dev_ins_e;
  43. typedef enum{
  44. PARAM_SET_CAN = (uint8_t)0x01, //CAN参数设置
  45. PARAM_SET_ELECT_TIME = (uint8_t)0x02, //电磁锁上电时间参数设置
  46. PARAM_SET_RST = (uint8_t)0xEE, //设备重启
  47. }ble_dev_param_set_e;
  48. typedef enum{
  49. PARAM_GET_CAN = (uint8_t)0x01, //CAN参数设置
  50. }ble_dev_param_get_e;
  51. typedef enum{
  52. DATA_GET_NFC = (uint8_t)0x01, //获取电子钥匙NFC号
  53. }ble_dev_data_get_e;
  54. typedef enum{
  55. CONTROL_LOCK = (uint8_t)0x01, //电磁锁控制
  56. CONTROL_CHARGE = (uint8_t)0x02, //充电控制
  57. }ble_dev_control_e;
  58. typedef enum{
  59. FIRMWARE_GET = (uint8_t)0x01, //获取固件版本号
  60. FIRMWARE_RST = (uint8_t)0x02, //设备重启
  61. FIRMWARE_LOCK = (uint8_t)0xAA,
  62. }ble_dev_firmware_e;
  63. typedef struct {
  64. ble_dev_ins_e ins;
  65. ble_dev_data_type_e data_type;
  66. uint8_t len;
  67. uint8_t cmd;
  68. uint8_t *data;
  69. uint32_t unixtime;
  70. uint32_t token;
  71. }__attribute__((packed)) ble_data_s;
  72. typedef void (*upload_ble_data_func)(uint8_t *data, int len);
  73. uint16_t ble_action_task_process_event(uint8_t task_id, uint16_t events);
  74. bool download_ble_data_callback(uint8_t *data, int len);
  75. bool download_ble_file_callback(uint8_t *data, int len);
  76. void set_upload_ble_data_func(upload_ble_data_func func);
  77. void ble_connect_act(bool stat);
  78. void ble_action_init(void);
  79. void ble_get_scancode_send(void);
  80. void vBle_action_init(void);
  81. #ifdef __cplusplus
  82. }
  83. #endif
  84. #endif // _BLE_ACTION_H__
  85. /** @} */