You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

188 lines
4.8 KiB

1 year ago
  1. #pragma once
  2. #include <stdint.h>
  3. #pragma pack(push, 1)
  4. typedef struct {
  5. uint8_t frame_type;
  6. uint8_t frame_index;
  7. uint8_t cmd;
  8. uint8_t data[];
  9. } ify_hrs_packet_t;
  10. typedef enum {
  11. kifyhrs_ecode_success = 0,
  12. kifyhrs_ecode_unkown_error = 1,
  13. kifyhrs_ecode_cmd_not_support = 2,
  14. kifyhrs_ecode_illegal_parameter = 3,
  15. kifyhrs_ecode_device_busy = 4,
  16. kifyhrs_ecode_hardware_error = 5,
  17. kifyhrs_ecode_sensor_drop = 6,
  18. kifyhrs_ecode_no_record_find = 7,
  19. } ify_hrs_error_code_t;
  20. typedef enum {
  21. kifyhrs_pt_cmd = 1,
  22. kifyhrs_pt_cmd_receipt = 2,
  23. kifyhrs_pt_report = 3,
  24. kifyhrs_pt_error_receipt = 4,
  25. } ify_hrs_packet_type_t;
  26. typedef enum {
  27. kifyhrs_sensor_pos_none = 0, // ��ָ��λ��
  28. kifyhrs_sensor_pos_I = 1, // I
  29. kifyhrs_sensor_pos_II = 2, // II
  30. kifyhrs_sensor_pos_III = 3, // III
  31. kifyhrs_sensor_pos_V1 = 4, // V1
  32. kifyhrs_sensor_pos_V2 = 5, // V2
  33. kifyhrs_sensor_pos_V3 = 6, // V3
  34. kifyhrs_sensor_pos_V4 = 7, // V4
  35. kifyhrs_sensor_pos_V5 = 8, // V5
  36. kifyhrs_sensor_pos_V6 = 9, // V6
  37. kifyhrs_sensor_pos_aVR = 10, //
  38. kifyhrs_sensor_pos_aVL = 11, //
  39. kifyhrs_sensor_pos_aVF = 12, //
  40. } ify_hrs_sensor_pos_t;
  41. typedef enum {
  42. ify_hrs_cmd_read_device_version = 1,
  43. ify_hrs_cmd_read_sensor_info = 2,
  44. ify_hrs_cmd_read_device_state = 3,
  45. ify_hrs_cmd_read_time = 4,
  46. ify_hrs_cmd_sync_time = 5,
  47. ify_hrs_cmd_start_capture = 6,
  48. ify_hrs_cmd_stop_capture = 7,
  49. ify_hrs_cmd_start_realtime_report = 8,
  50. ify_hrs_cmd_stop_realtime_report = 9,
  51. ify_hrs_cmd_read_records_info = 10,
  52. ify_hrs_cmd_del_record = 11,
  53. ify_hrs_cmd_start_upload_record = 12,
  54. ify_hrs_cmd_enter_ota = 13,
  55. ify_hrs_cmd_read_sn = 14,
  56. ify_hrs_cmd_reset = 15,
  57. ify_hrs_report_heartrate_data = 101,
  58. ify_hrs_report_battery_level = 102,
  59. ify_hrs_report_low_battey_level = 103,
  60. ify_hrs_report_sample_finish_end = 104,
  61. ify_hrs_report_sensor_drop_detect = 105,
  62. ify_hrs_report_record_upload_end = 106,
  63. } ify_hrs_cmd_t;
  64. /*******************************************************************************
  65. * packet_struct *
  66. *******************************************************************************/
  67. typedef struct {
  68. uint16_t placeholder;
  69. uint16_t blestack_version;
  70. uint16_t bootloader_version;
  71. uint16_t firmware_version;
  72. uint16_t hardware_version;
  73. } device_version_info_receipt_t;
  74. typedef struct {
  75. uint8_t sensor_num; // ����
  76. uint8_t sensor_precision; // ����
  77. uint8_t sensor_sample_rate; // ������
  78. uint8_t sensor0_pos; // �
  79. uint8_t sensor1_pos; // �
  80. uint8_t sensor2_pos; // �
  81. } sensor_info_receipt_t;
  82. typedef struct {
  83. uint8_t drop_state0;
  84. uint8_t drop_state1;
  85. struct {
  86. uint8_t sampling_state : 1; // �
  87. uint8_t report_state : 1; // �
  88. uint8_t low_battery : 1; // �
  89. uint8_t full_storge : 1; // �
  90. uint8_t holder : 4; // �
  91. } device_state0;
  92. uint8_t device_state1; // Ԥ��
  93. uint8_t powerlevel; // ����
  94. uint8_t storage_item_num; // ��¼�洢����
  95. } device_state_receipt_t;
  96. typedef struct {
  97. uint8_t year;
  98. uint8_t month;
  99. uint8_t day;
  100. uint8_t hour;
  101. uint8_t minute;
  102. uint8_t second;
  103. } read_time_receipt_t;
  104. typedef struct {
  105. uint8_t year;
  106. uint8_t month;
  107. uint8_t day;
  108. uint8_t hour;
  109. uint8_t minute;
  110. uint8_t second;
  111. } sync_time_cmd_t;
  112. typedef struct {
  113. uint8_t year;
  114. uint8_t month;
  115. uint8_t day;
  116. uint8_t hour;
  117. uint8_t minute;
  118. uint8_t second;
  119. } start_capture_cmd_t;
  120. typedef struct {
  121. uint8_t record_index; // �����ڼ�����¼
  122. } read_record_info_cmd_t;
  123. typedef struct {
  124. uint8_t record_id[6];
  125. uint32_t frameNum;
  126. uint32_t dataSize;
  127. uint8_t sensorNum;
  128. uint8_t captureRate; // N*10HZ
  129. uint8_t capturePrecision;
  130. uint8_t compressAlgorithm; // ѹ���㷨
  131. } read_record_info_receipt_t;
  132. typedef struct {
  133. uint8_t record_id[6];
  134. } del_record_cmd_t;
  135. typedef struct {
  136. uint8_t record_id[6];
  137. } start_upload_record_cmd_t;
  138. typedef struct {
  139. uint8_t sn[14];
  140. } read_sn_receipt_t;
  141. typedef struct {
  142. uint8_t errorcode;
  143. } error_receipt_t;
  144. /*******************************************************************************
  145. * ϱؽ *
  146. *******************************************************************************/
  147. typedef struct {
  148. uint8_t frame_type;
  149. uint8_t frame_index;
  150. uint8_t cmd;
  151. uint32_t sample_data_index;
  152. uint8_t data[]; // �ϱ�������
  153. } heartrate_report_packet_t;
  154. typedef struct {
  155. uint8_t frame_type;
  156. uint8_t frame_index;
  157. uint8_t cmd;
  158. uint8_t drop_state0;
  159. uint8_t drop_state1;
  160. } sensor_drop_event_report_packet_t;
  161. #pragma pack(pop)