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.

276 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. #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_ads1291_wakeup = 200,
  112. ify_hrs_ads1291_standby = 201,
  113. ify_hrs_ads1291_reset = 202,
  114. ify_hrs_ads1291_start_conversion = 203,
  115. ify_hrs_ads1291_stop_conversion = 204,
  116. ify_hrs_ads1291_offsetcal = 205,
  117. ify_hrs_ads1291_read_reg = 206,
  118. ify_hrs_ads1291_write_reg = 207,
  119. ify_hrs_ads1291_report_enable = 208,
  120. ify_hrs_ads1291_report_disable_enable = 209,
  121. ify_hrs_ads1291_report = 210,
  122. } ify_hrs_cmd_t;
  123. /*******************************************************************************
  124. * packet_struct *
  125. *******************************************************************************/
  126. typedef struct {
  127. uint16_t placeholder;
  128. uint16_t blestack_version;
  129. uint16_t bootloader_version;
  130. uint16_t firmware_version;
  131. uint16_t hardware_version;
  132. } device_version_info_receipt_t;
  133. typedef struct {
  134. uint8_t sensor_num; // ����
  135. uint8_t sensor_precision; // ����
  136. uint8_t sensor_sample_rate; // ������
  137. uint8_t sensor0_pos; // �
  138. uint8_t sensor1_pos; // �
  139. uint8_t sensor2_pos; // �
  140. } sensor_info_receipt_t;
  141. typedef struct {
  142. uint8_t drop_state0;
  143. uint8_t drop_state1;
  144. struct {
  145. uint8_t sampling_state : 1; // �
  146. uint8_t report_state : 1; // �
  147. uint8_t low_battery : 1; // �
  148. uint8_t full_storge : 1; // �
  149. // uint8_t is_storaging : 1; // �
  150. uint8_t holder : 4; // �
  151. } device_state0;
  152. uint8_t device_state1; // Ԥ��
  153. uint8_t powerlevel; // ����
  154. uint8_t storage_item_num; // ��¼�洢����
  155. // uint32_t storage_setting_time_s;
  156. // uint32_t storage_has_storaged_time_s;
  157. } device_state_receipt_t;
  158. typedef struct {
  159. uint8_t year;
  160. uint8_t month;
  161. uint8_t day;
  162. uint8_t hour;
  163. uint8_t minute;
  164. uint8_t second;
  165. } read_time_receipt_t;
  166. typedef struct {
  167. uint8_t year;
  168. uint8_t month;
  169. uint8_t day;
  170. uint8_t hour;
  171. uint8_t minute;
  172. uint8_t second;
  173. } sync_time_cmd_t;
  174. typedef struct {
  175. uint8_t year;
  176. uint8_t month;
  177. uint8_t day;
  178. uint8_t hour;
  179. uint8_t minute;
  180. uint8_t second;
  181. } start_capture_cmd_t;
  182. typedef struct {
  183. uint8_t record_index; // �����ڼ�����¼
  184. } read_record_info_cmd_t;
  185. typedef struct {
  186. uint8_t record_id[6];
  187. uint32_t frameNum;
  188. uint32_t dataSize;
  189. uint8_t sensorNum;
  190. uint8_t captureRate; // N*10HZ
  191. uint8_t capturePrecision;
  192. uint8_t compressAlgorithm; // ѹ���㷨
  193. uint32_t checksum; // ����
  194. } read_record_info_receipt_t;
  195. typedef struct {
  196. uint8_t record_id[6];
  197. } del_record_cmd_t;
  198. typedef struct {
  199. uint8_t record_id[6];
  200. } start_upload_record_cmd_t;
  201. typedef struct {
  202. uint8_t sn[14];
  203. } read_sn_receipt_t;
  204. typedef struct {
  205. uint8_t errorcode;
  206. } error_receipt_t;
  207. /*******************************************************************************
  208. * ϱؽ *
  209. *******************************************************************************/
  210. typedef struct {
  211. uint8_t frame_type;
  212. uint8_t frame_index;
  213. uint8_t cmd;
  214. uint32_t sample_data_index;
  215. uint8_t data[]; // �ϱ�������
  216. } heartrate_report_packet_t;
  217. typedef struct {
  218. uint8_t frame_type;
  219. uint8_t frame_index;
  220. uint8_t cmd;
  221. uint32_t sample_data_index;
  222. uint16_t leadoff_state;
  223. uint16_t sample_data_num;
  224. int16_t frame[]; // �ϱ�������
  225. } m1003_heartrate_report_packet_t;
  226. typedef struct {
  227. uint8_t frame_type;
  228. uint8_t frame_index;
  229. uint8_t cmd;
  230. uint32_t sample_data_index;
  231. uint32_t reportdata[50];
  232. } ads1291_report_packet_t;
  233. typedef struct {
  234. uint8_t frame_type;
  235. uint8_t frame_index;
  236. uint8_t cmd;
  237. uint8_t drop_state0;
  238. uint8_t drop_state1;
  239. } sensor_drop_event_report_packet_t;
  240. #pragma pack(pop)