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.

206 lines
5.8 KiB

1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
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. kifyhrs_ecode_parameter_error = 8,
  20. kifyhrs_ecode_electrode_is_not_inserted = 9,
  21. kifyhrs_ecode_device_exception = 10,
  22. kifyhrs_ecode_invalid_state = 11,
  23. } ify_hrs_error_code_t;
  24. typedef enum {
  25. kifyhrs_pt_cmd = 1,
  26. kifyhrs_pt_cmd_receipt = 2,
  27. kifyhrs_pt_report = 3,
  28. kifyhrs_pt_error_receipt = 4,
  29. } ify_hrs_packet_type_t;
  30. typedef enum {
  31. kifyhrs_sensor_pos_none = 0, // ��ָ��λ��
  32. kifyhrs_sensor_pos_I = 1, // I
  33. kifyhrs_sensor_pos_II = 2, // II
  34. kifyhrs_sensor_pos_III = 3, // III
  35. kifyhrs_sensor_pos_V1 = 4, // V1
  36. kifyhrs_sensor_pos_V2 = 5, // V2
  37. kifyhrs_sensor_pos_V3 = 6, // V3
  38. kifyhrs_sensor_pos_V4 = 7, // V4
  39. kifyhrs_sensor_pos_V5 = 8, // V5
  40. kifyhrs_sensor_pos_V6 = 9, // V6
  41. kifyhrs_sensor_pos_aVR = 10, //
  42. kifyhrs_sensor_pos_aVL = 11, //
  43. kifyhrs_sensor_pos_aVF = 12, //
  44. } ify_hrs_sensor_pos_t;
  45. typedef enum {
  46. ify_hrs_cmd_read_device_version = 1,
  47. ify_hrs_cmd_read_sensor_info = 2,
  48. ify_hrs_cmd_read_device_state = 3,
  49. ify_hrs_cmd_read_time = 4,
  50. ify_hrs_cmd_sync_time = 5,
  51. ify_hrs_cmd_start_realtime_preview = 8,
  52. ify_hrs_cmd_stop_realtime_preview = 9,
  53. ify_hrs_cmd_read_records_info = 10,
  54. ify_hrs_cmd_del_record = 11,
  55. ify_hrs_cmd_start_upload_record = 12,
  56. ify_hrs_cmd_enter_ota = 13,
  57. ify_hrs_cmd_read_sn = 14,
  58. ify_hrs_cmd_reset = 15,
  59. ify_hrs_cmd_stop_upload_record = 16,
  60. ify_hrs_cmd_ads1293_error_detail_info = 19, // �ڲ�ʹ��
  61. ify_hrs_cmd_change_sn = 20, // �ڲ�ʹ��
  62. ify_hrs_cmd_read_device_exception_state = 21, // ��ȡ�豸�쳣״̬
  63. ify_hrs_cmd_read_ads1293_cfg_type = 22, // ��ȡads1293ʹ�õ���������
  64. ify_hrs_cmd_start_storage = 23, //
  65. ify_hrs_cmd_stop_storage = 24, //
  66. ify_hrs_report_heartrate_data = 101,
  67. ify_hrs_report_battery_level = 102,
  68. ify_hrs_report_low_battey_level = 103,
  69. ify_hrs_report_sample_finish_end = 104,
  70. ify_hrs_report_sensor_drop_detect = 105,
  71. ify_hrs_report_record_upload_end = 106,
  72. ify_hrs_test_cmd_start_capture = 200, // uint8 0/1
  73. ify_hrs_test_cmd_stop_capture = 201, // uint8 0/1
  74. ify_hrs_test_cmd_read_reg = 202, // uint8 addr
  75. ify_hrs_test_cmd_write_reg = 203, // uint8 addr, uint8 val
  76. } ify_hrs_cmd_t;
  77. /*******************************************************************************
  78. * packet_struct *
  79. *******************************************************************************/
  80. typedef struct {
  81. uint16_t placeholder;
  82. uint16_t blestack_version;
  83. uint16_t bootloader_version;
  84. uint16_t firmware_version;
  85. uint16_t hardware_version;
  86. } device_version_info_receipt_t;
  87. typedef struct {
  88. uint8_t sensor_num; // ����
  89. uint8_t sensor_precision; // ����
  90. uint8_t sensor_sample_rate; // ������
  91. uint8_t sensor0_pos; // �
  92. uint8_t sensor1_pos; // �
  93. uint8_t sensor2_pos; // �
  94. } sensor_info_receipt_t;
  95. typedef struct {
  96. uint8_t drop_state0;
  97. uint8_t drop_state1;
  98. struct {
  99. uint8_t sampling_state : 1; // �
  100. uint8_t report_state : 1; // �
  101. uint8_t low_battery : 1; // �
  102. uint8_t full_storge : 1; // �
  103. // uint8_t is_storaging : 1; // �
  104. uint8_t holder : 4; // �
  105. } device_state0;
  106. uint8_t device_state1; // Ԥ��
  107. uint8_t powerlevel; // ����
  108. uint8_t storage_item_num; // ��¼�洢����
  109. // uint32_t storage_setting_time_s;
  110. // uint32_t storage_has_storaged_time_s;
  111. } device_state_receipt_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. } read_time_receipt_t;
  120. typedef struct {
  121. uint8_t year;
  122. uint8_t month;
  123. uint8_t day;
  124. uint8_t hour;
  125. uint8_t minute;
  126. uint8_t second;
  127. } sync_time_cmd_t;
  128. typedef struct {
  129. uint8_t year;
  130. uint8_t month;
  131. uint8_t day;
  132. uint8_t hour;
  133. uint8_t minute;
  134. uint8_t second;
  135. } start_capture_cmd_t;
  136. typedef struct {
  137. uint8_t record_index; // �����ڼ�����¼
  138. } read_record_info_cmd_t;
  139. typedef struct {
  140. uint8_t record_id[6];
  141. uint32_t frameNum;
  142. uint32_t dataSize;
  143. uint8_t sensorNum;
  144. uint8_t captureRate; // N*10HZ
  145. uint8_t capturePrecision;
  146. uint8_t compressAlgorithm; // ѹ���㷨
  147. uint32_t checksum; // ����
  148. } read_record_info_receipt_t;
  149. typedef struct {
  150. uint8_t record_id[6];
  151. } del_record_cmd_t;
  152. typedef struct {
  153. uint8_t record_id[6];
  154. } start_upload_record_cmd_t;
  155. typedef struct {
  156. uint8_t sn[14];
  157. } read_sn_receipt_t;
  158. typedef struct {
  159. uint8_t errorcode;
  160. } error_receipt_t;
  161. /*******************************************************************************
  162. * ϱؽ *
  163. *******************************************************************************/
  164. typedef struct {
  165. uint8_t frame_type;
  166. uint8_t frame_index;
  167. uint8_t cmd;
  168. uint32_t sample_data_index;
  169. uint8_t data[]; // �ϱ�������
  170. } heartrate_report_packet_t;
  171. typedef struct {
  172. uint8_t frame_type;
  173. uint8_t frame_index;
  174. uint8_t cmd;
  175. uint8_t drop_state0;
  176. uint8_t drop_state1;
  177. } sensor_drop_event_report_packet_t;
  178. #pragma pack(pop)