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.

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