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.

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