ble_action.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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_RST = (uint8_t)0xEE, //设备重启
  46. }ble_dev_param_set_e;
  47. typedef enum{
  48. PARAM_GET_CAN = (uint8_t)0x01, //CAN参数设置
  49. }ble_dev_param_get_e;
  50. typedef enum{
  51. DATA_GET_NFC = (uint8_t)0x01, //获取电子钥匙NFC号
  52. }ble_dev_data_get_e;
  53. typedef enum{
  54. CONTROL_LOCK = (uint8_t)0x01, //电磁锁控制
  55. }ble_dev_control_e;
  56. typedef enum{
  57. FIRMWARE_GET = (uint8_t)0x01, //获取固件版本号
  58. FIRMWARE_RST = (uint8_t)0x02, //设备重启
  59. FIRMWARE_LOCK = (uint8_t)0xAA,
  60. }ble_dev_firmware_e;
  61. typedef struct {
  62. ble_dev_ins_e ins;
  63. ble_dev_data_type_e data_type;
  64. uint8_t len;
  65. uint8_t cmd;
  66. uint8_t *data;
  67. uint32_t unixtime;
  68. uint32_t token;
  69. }__attribute__((packed)) ble_data_s;
  70. typedef void (*upload_ble_data_func)(uint8_t *data, int len);
  71. bool download_ble_data_callback(uint8_t *data, int len);
  72. bool download_ble_file_callback(uint8_t *data, int len);
  73. void set_upload_ble_data_func(upload_ble_data_func func);
  74. void ble_connect_act(bool stat);
  75. void vBle_action_init(void);
  76. #ifdef __cplusplus
  77. }
  78. #endif
  79. #endif // _BLE_ACTION_H__
  80. /** @} */