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.

274 lines
7.7 KiB

1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
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. kifyhrs_ecode_overtime = 200,
  24. kifyhrs_ecode_channel_is_close = 201,
  25. } ify_hrs_error_code_t;
  26. static inline const char *ify_hrs_error_code_to_string(ify_hrs_error_code_t code) {
  27. switch (code) {
  28. case kifyhrs_ecode_success:
  29. return "success";
  30. case kifyhrs_ecode_unkown_error:
  31. return "unkown error";
  32. case kifyhrs_ecode_cmd_not_support:
  33. return "cmd not support";
  34. case kifyhrs_ecode_illegal_parameter:
  35. return "illegal parameter";
  36. case kifyhrs_ecode_device_busy:
  37. return "device busy";
  38. case kifyhrs_ecode_hardware_error:
  39. return "hardware error";
  40. case kifyhrs_ecode_sensor_drop:
  41. return "sensor drop";
  42. case kifyhrs_ecode_no_record_find:
  43. return "no record find";
  44. case kifyhrs_ecode_parameter_error:
  45. return "parameter error";
  46. case kifyhrs_ecode_electrode_is_not_inserted:
  47. return "electrode is not inserted";
  48. case kifyhrs_ecode_device_exception:
  49. return "device exception";
  50. case kifyhrs_ecode_invalid_state:
  51. return "invalid state";
  52. case kifyhrs_ecode_overtime:
  53. return "overtime";
  54. case kifyhrs_ecode_channel_is_close:
  55. return "channel is close";
  56. default:
  57. return "unkown error";
  58. }
  59. }
  60. typedef enum {
  61. kifyhrs_pt_cmd = 1,
  62. kifyhrs_pt_cmd_receipt = 2,
  63. kifyhrs_pt_report = 3,
  64. kifyhrs_pt_error_receipt = 4,
  65. } ify_hrs_packet_type_t;
  66. typedef enum {
  67. kifyhrs_sensor_pos_none = 0, // ��ָ��λ��
  68. kifyhrs_sensor_pos_I = 1, // I
  69. kifyhrs_sensor_pos_II = 2, // II
  70. kifyhrs_sensor_pos_III = 3, // III
  71. kifyhrs_sensor_pos_V1 = 4, // V1
  72. kifyhrs_sensor_pos_V2 = 5, // V2
  73. kifyhrs_sensor_pos_V3 = 6, // V3
  74. kifyhrs_sensor_pos_V4 = 7, // V4
  75. kifyhrs_sensor_pos_V5 = 8, // V5
  76. kifyhrs_sensor_pos_V6 = 9, // V6
  77. kifyhrs_sensor_pos_aVR = 10, //
  78. kifyhrs_sensor_pos_aVL = 11, //
  79. kifyhrs_sensor_pos_aVF = 12, //
  80. } ify_hrs_sensor_pos_t;
  81. typedef enum {
  82. ify_hrs_cmd_read_device_version = 1,
  83. ify_hrs_cmd_read_sensor_info = 2,
  84. ify_hrs_cmd_read_device_state = 3,
  85. ify_hrs_cmd_read_time = 4,
  86. ify_hrs_cmd_sync_time = 5,
  87. ify_hrs_cmd_start_realtime_preview = 8,
  88. ify_hrs_cmd_stop_realtime_preview = 9,
  89. ify_hrs_cmd_read_records_info = 10,
  90. ify_hrs_cmd_del_record = 11,
  91. ify_hrs_cmd_start_upload_record = 12,
  92. ify_hrs_cmd_enter_ota = 13,
  93. ify_hrs_cmd_read_sn = 14,
  94. ify_hrs_cmd_reset = 15,
  95. ify_hrs_cmd_stop_upload_record = 16,
  96. ify_hrs_cmd_ads1293_error_detail_info = 19, // �ڲ�ʹ��
  97. ify_hrs_cmd_change_sn = 20, // �ڲ�ʹ��
  98. ify_hrs_cmd_read_device_exception_state = 21, // ��ȡ�豸�쳣״̬
  99. ify_hrs_cmd_read_ads1293_cfg_type = 22, // ��ȡads1293ʹ�õ���������
  100. ify_hrs_cmd_start_storage = 23, //
  101. ify_hrs_cmd_stop_storage = 24, //
  102. ify_hrs_report_heartrate_data = 101,
  103. ify_hrs_report_battery_level = 102,
  104. ify_hrs_report_low_battey_level = 103,
  105. ify_hrs_report_sample_finish_end = 104,
  106. ify_hrs_report_sensor_drop_detect = 105,
  107. ify_hrs_report_record_upload_end = 106,
  108. ify_hrs_cmd_set_ecg_in_test_mode = 150,
  109. ify_hrs_ads1291_wakeup = 200,
  110. ify_hrs_ads1291_standby = 201,
  111. ify_hrs_ads1291_reset = 202,
  112. ify_hrs_ads1291_start_conversion = 203,
  113. ify_hrs_ads1291_stop_conversion = 204,
  114. ify_hrs_ads1291_offsetcal = 205,
  115. ify_hrs_ads1291_read_reg = 206,
  116. ify_hrs_ads1291_write_reg = 207,
  117. ify_hrs_ads1291_report_enable = 208,
  118. ify_hrs_ads1291_report_disable_enable = 209,
  119. ify_hrs_ads1291_report = 210,
  120. } ify_hrs_cmd_t;
  121. /*******************************************************************************
  122. * packet_struct *
  123. *******************************************************************************/
  124. typedef struct {
  125. uint16_t placeholder;
  126. uint16_t blestack_version;
  127. uint16_t bootloader_version;
  128. uint16_t firmware_version;
  129. uint16_t hardware_version;
  130. } device_version_info_receipt_t;
  131. typedef struct {
  132. uint8_t sensor_num; // ����
  133. uint8_t sensor_precision; // ����
  134. uint8_t sensor_sample_rate; // ������
  135. uint8_t sensor0_pos; // �
  136. uint8_t sensor1_pos; // �
  137. uint8_t sensor2_pos; // �
  138. } sensor_info_receipt_t;
  139. typedef struct {
  140. uint8_t drop_state0;
  141. uint8_t drop_state1;
  142. struct {
  143. uint8_t sampling_state : 1; // �
  144. uint8_t report_state : 1; // �
  145. uint8_t low_battery : 1; // �
  146. uint8_t full_storge : 1; // �
  147. // uint8_t is_storaging : 1; // �
  148. uint8_t holder : 4; // �
  149. } device_state0;
  150. uint8_t device_state1; // Ԥ��
  151. uint8_t powerlevel; // ����
  152. uint8_t storage_item_num; // ��¼�洢����
  153. // uint32_t storage_setting_time_s;
  154. // uint32_t storage_has_storaged_time_s;
  155. } device_state_receipt_t;
  156. typedef struct {
  157. uint8_t year;
  158. uint8_t month;
  159. uint8_t day;
  160. uint8_t hour;
  161. uint8_t minute;
  162. uint8_t second;
  163. } read_time_receipt_t;
  164. typedef struct {
  165. uint8_t year;
  166. uint8_t month;
  167. uint8_t day;
  168. uint8_t hour;
  169. uint8_t minute;
  170. uint8_t second;
  171. } sync_time_cmd_t;
  172. typedef struct {
  173. uint8_t year;
  174. uint8_t month;
  175. uint8_t day;
  176. uint8_t hour;
  177. uint8_t minute;
  178. uint8_t second;
  179. } start_capture_cmd_t;
  180. typedef struct {
  181. uint8_t record_index; // �����ڼ�����¼
  182. } read_record_info_cmd_t;
  183. typedef struct {
  184. uint8_t record_id[6];
  185. uint32_t frameNum;
  186. uint32_t dataSize;
  187. uint8_t sensorNum;
  188. uint8_t captureRate; // N*10HZ
  189. uint8_t capturePrecision;
  190. uint8_t compressAlgorithm; // ѹ���㷨
  191. uint32_t checksum; // ����
  192. } read_record_info_receipt_t;
  193. typedef struct {
  194. uint8_t record_id[6];
  195. } del_record_cmd_t;
  196. typedef struct {
  197. uint8_t record_id[6];
  198. } start_upload_record_cmd_t;
  199. typedef struct {
  200. uint8_t sn[14];
  201. } read_sn_receipt_t;
  202. typedef struct {
  203. uint8_t errorcode;
  204. } error_receipt_t;
  205. /*******************************************************************************
  206. * ϱؽ *
  207. *******************************************************************************/
  208. typedef struct {
  209. uint8_t frame_type;
  210. uint8_t frame_index;
  211. uint8_t cmd;
  212. uint32_t sample_data_index;
  213. uint8_t data[]; // �ϱ�������
  214. } heartrate_report_packet_t;
  215. typedef struct {
  216. uint8_t frame_type;
  217. uint8_t frame_index;
  218. uint8_t cmd;
  219. uint32_t sample_data_index;
  220. uint16_t leadoff_state;
  221. uint16_t sample_data_num;
  222. int16_t frame[]; // �ϱ�������
  223. } m1003_heartrate_report_packet_t;
  224. typedef struct {
  225. uint8_t frame_type;
  226. uint8_t frame_index;
  227. uint8_t cmd;
  228. uint32_t sample_data_index;
  229. uint32_t reportdata[50];
  230. } ads1291_report_packet_t;
  231. typedef struct {
  232. uint8_t frame_type;
  233. uint8_t frame_index;
  234. uint8_t cmd;
  235. uint8_t drop_state0;
  236. uint8_t drop_state1;
  237. } sensor_drop_event_report_packet_t;
  238. #pragma pack(pop)