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.

195 lines
5.3 KiB

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