From 93ba9dbc3fe99c97276ab9737a710911642dc2b8 Mon Sep 17 00:00:00 2001 From: zhaohe Date: Sat, 6 Jul 2024 15:51:10 +0800 Subject: [PATCH] update --- heart_rate_sensor_protocol.h | 269 ------------------------------------------- oximeter_ble_protocol.h | 269 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 269 insertions(+), 269 deletions(-) delete mode 100644 heart_rate_sensor_protocol.h create mode 100644 oximeter_ble_protocol.h diff --git a/heart_rate_sensor_protocol.h b/heart_rate_sensor_protocol.h deleted file mode 100644 index 62eb5b4..0000000 --- a/heart_rate_sensor_protocol.h +++ /dev/null @@ -1,269 +0,0 @@ -#pragma once - -#include - -#pragma pack(push, 1) - -typedef struct { - uint8_t frame_type; - uint8_t frame_index; - uint8_t cmd; - uint8_t data[]; -} ify_hrs_packet_t; - -typedef enum { - kifyhrs_ecode_success = 0, - kifyhrs_ecode_unkown_error = 1, - kifyhrs_ecode_cmd_not_support = 2, - kifyhrs_ecode_illegal_parameter = 3, - kifyhrs_ecode_device_busy = 4, - kifyhrs_ecode_hardware_error = 5, - kifyhrs_ecode_sensor_drop = 6, - kifyhrs_ecode_no_record_find = 7, - kifyhrs_ecode_parameter_error = 8, - kifyhrs_ecode_electrode_is_not_inserted = 9, - kifyhrs_ecode_device_exception = 10, - kifyhrs_ecode_invalid_state = 11, - - kifyhrs_ecode_overtime = 200, - kifyhrs_ecode_channel_is_close = 201, - kifyhrs_ecode_upper_exception = 202, - -} ify_hrs_error_code_t; - -static inline const char *ify_hrs_error_code_to_string(ify_hrs_error_code_t code) { - switch (code) { - case kifyhrs_ecode_success: - return "success"; - case kifyhrs_ecode_unkown_error: - return "unkown error"; - case kifyhrs_ecode_cmd_not_support: - return "cmd not support"; - case kifyhrs_ecode_illegal_parameter: - return "illegal parameter"; - case kifyhrs_ecode_device_busy: - return "device busy"; - case kifyhrs_ecode_hardware_error: - return "hardware error"; - case kifyhrs_ecode_sensor_drop: - return "sensor drop"; - case kifyhrs_ecode_no_record_find: - return "no record find"; - case kifyhrs_ecode_parameter_error: - return "parameter error"; - case kifyhrs_ecode_electrode_is_not_inserted: - return "electrode is not inserted"; - case kifyhrs_ecode_device_exception: - return "device exception"; - case kifyhrs_ecode_invalid_state: - return "invalid state"; - case kifyhrs_ecode_overtime: - return "overtime"; - case kifyhrs_ecode_channel_is_close: - return "channel is close"; - - case kifyhrs_ecode_upper_exception: - return "upper exception"; - default: - return "unkown error"; - } -} - -typedef enum { - kifyhrs_pt_cmd = 1, - kifyhrs_pt_cmd_receipt = 2, - kifyhrs_pt_report = 3, - kifyhrs_pt_error_receipt = 4, -} ify_hrs_packet_type_t; - -typedef enum { - kifyhrs_sensor_pos_none = 0, // 无指定位置 - kifyhrs_sensor_pos_I = 1, // I - kifyhrs_sensor_pos_II = 2, // II - kifyhrs_sensor_pos_III = 3, // III - kifyhrs_sensor_pos_V1 = 4, // V1 - kifyhrs_sensor_pos_V2 = 5, // V2 - kifyhrs_sensor_pos_V3 = 6, // V3 - kifyhrs_sensor_pos_V4 = 7, // V4 - kifyhrs_sensor_pos_V5 = 8, // V5 - kifyhrs_sensor_pos_V6 = 9, // V6 - kifyhrs_sensor_pos_aVR = 10, // - kifyhrs_sensor_pos_aVL = 11, // - kifyhrs_sensor_pos_aVF = 12, // -} ify_hrs_sensor_pos_t; - -typedef enum { - ify_hrs_cmd_read_device_version = 1, - ify_hrs_cmd_read_sensor_info = 2, - ify_hrs_cmd_read_device_state = 3, - ify_hrs_cmd_read_time = 4, - ify_hrs_cmd_sync_time = 5, - ify_hrs_cmd_start_realtime_preview = 8, - ify_hrs_cmd_stop_realtime_preview = 9, - ify_hrs_cmd_read_records_info = 10, - ify_hrs_cmd_del_record = 11, - ify_hrs_cmd_start_upload_record = 12, - ify_hrs_cmd_enter_ota = 13, - ify_hrs_cmd_read_sn = 14, - ify_hrs_cmd_reset = 15, - ify_hrs_cmd_stop_upload_record = 16, - ify_hrs_cmd_ads1293_error_detail_info = 19, // 内部使用 - ify_hrs_cmd_change_sn = 20, // 内部使用 - ify_hrs_cmd_read_device_exception_state = 21, // 读取设备异常状态 - ify_hrs_cmd_read_ads1293_cfg_type = 22, // 读取ads1293使用的配置类型 - ify_hrs_cmd_start_storage = 23, // - ify_hrs_cmd_stop_storage = 24, // - - ify_hrs_report_heartrate_data = 101, - ify_hrs_report_battery_level = 102, - ify_hrs_report_low_battey_level = 103, - ify_hrs_report_sample_finish_end = 104, - ify_hrs_report_sensor_drop_detect = 105, - ify_hrs_report_record_upload_end = 106, - - ify_hrs_cmd_set_ecg_in_test_mode = 150, - ify_hrs_cmd_set_ecg_report_data_in_raw_mode = 151, // 设置ECG上报数据为原始数据 - ify_hrs_cmd_ecg_subic_read_reg = 152, - ify_hrs_cmd_ecg_subic_write_reg = 153, - -} ify_hrs_cmd_t; - -/******************************************************************************* - * packet_struct * - *******************************************************************************/ -typedef struct { - uint16_t placeholder; - uint16_t blestack_version; - uint16_t bootloader_version; - uint16_t firmware_version; - uint16_t hardware_version; -} device_version_info_receipt_t; - -typedef struct { - uint8_t sensor_num; // 数量 - uint8_t sensor_precision; // 精度 - uint8_t sensor_sample_rate; // 采样率 - uint8_t sensor0_pos; // 位置 - uint8_t sensor1_pos; // 位置 - uint8_t sensor2_pos; // 位置 -} sensor_info_receipt_t; - -typedef struct { - uint8_t drop_state0; - uint8_t drop_state1; - struct { - uint8_t sampling_state : 1; // 位置 - uint8_t report_state : 1; // 位置 - uint8_t low_battery : 1; // 位置 - uint8_t full_storge : 1; // 位置 - // uint8_t is_storaging : 1; // 位置 - uint8_t holder : 4; // 位置 - } device_state0; - uint8_t device_state1; // 预留 - uint8_t powerlevel; // 电量 - uint8_t storage_item_num; // 记录存储条数 - // uint32_t storage_setting_time_s; - // uint32_t storage_has_storaged_time_s; -} device_state_receipt_t; - -typedef struct { - uint8_t year; - uint8_t month; - uint8_t day; - uint8_t hour; - uint8_t minute; - uint8_t second; -} read_time_receipt_t; - -typedef struct { - uint8_t year; - uint8_t month; - uint8_t day; - uint8_t hour; - uint8_t minute; - uint8_t second; -} sync_time_cmd_t; - -typedef struct { - uint8_t year; - uint8_t month; - uint8_t day; - uint8_t hour; - uint8_t minute; - uint8_t second; -} start_capture_cmd_t; - -typedef struct { - uint8_t record_index; // 最近第几条记录 -} read_record_info_cmd_t; - -typedef struct { - uint8_t record_id[6]; - uint32_t frameNum; - uint32_t dataSize; - uint8_t sensorNum; - uint8_t captureRate; // N*10HZ - uint8_t capturePrecision; - uint8_t compressAlgorithm; // 压缩算法 - uint32_t checksum; // 校验和 -} read_record_info_receipt_t; - -typedef struct { - uint8_t record_id[6]; -} del_record_cmd_t; - -typedef struct { - uint8_t record_id[6]; -} start_upload_record_cmd_t; - -typedef struct { - uint8_t sn[14]; -} read_sn_receipt_t; - -typedef struct { - uint8_t errorcode; -} error_receipt_t; - -/******************************************************************************* - * 上报相关结构体 * - *******************************************************************************/ - -typedef struct { - uint8_t frame_type; - uint8_t frame_index; - uint8_t cmd; - - uint32_t sample_data_index; - uint8_t data[]; // 上报的数据 -} heartrate_report_packet_t; - -typedef struct { - uint8_t frame_type; - uint8_t frame_index; - uint8_t cmd; - - uint32_t sample_data_index; - uint16_t leadoff_state; - uint16_t sample_data_num; - int32_t frame[]; // 上报的数据 -} m1003_heartrate_report_packet_t; - -typedef struct { - uint8_t frame_type; - uint8_t frame_index; - uint8_t cmd; - - uint32_t sample_data_index; - uint32_t reportdata[50]; -} ads1291_report_packet_t; - -typedef struct { - uint8_t frame_type; - uint8_t frame_index; - uint8_t cmd; - - uint8_t drop_state0; - uint8_t drop_state1; -} sensor_drop_event_report_packet_t; - -#pragma pack(pop) diff --git a/oximeter_ble_protocol.h b/oximeter_ble_protocol.h new file mode 100644 index 0000000..62eb5b4 --- /dev/null +++ b/oximeter_ble_protocol.h @@ -0,0 +1,269 @@ +#pragma once + +#include + +#pragma pack(push, 1) + +typedef struct { + uint8_t frame_type; + uint8_t frame_index; + uint8_t cmd; + uint8_t data[]; +} ify_hrs_packet_t; + +typedef enum { + kifyhrs_ecode_success = 0, + kifyhrs_ecode_unkown_error = 1, + kifyhrs_ecode_cmd_not_support = 2, + kifyhrs_ecode_illegal_parameter = 3, + kifyhrs_ecode_device_busy = 4, + kifyhrs_ecode_hardware_error = 5, + kifyhrs_ecode_sensor_drop = 6, + kifyhrs_ecode_no_record_find = 7, + kifyhrs_ecode_parameter_error = 8, + kifyhrs_ecode_electrode_is_not_inserted = 9, + kifyhrs_ecode_device_exception = 10, + kifyhrs_ecode_invalid_state = 11, + + kifyhrs_ecode_overtime = 200, + kifyhrs_ecode_channel_is_close = 201, + kifyhrs_ecode_upper_exception = 202, + +} ify_hrs_error_code_t; + +static inline const char *ify_hrs_error_code_to_string(ify_hrs_error_code_t code) { + switch (code) { + case kifyhrs_ecode_success: + return "success"; + case kifyhrs_ecode_unkown_error: + return "unkown error"; + case kifyhrs_ecode_cmd_not_support: + return "cmd not support"; + case kifyhrs_ecode_illegal_parameter: + return "illegal parameter"; + case kifyhrs_ecode_device_busy: + return "device busy"; + case kifyhrs_ecode_hardware_error: + return "hardware error"; + case kifyhrs_ecode_sensor_drop: + return "sensor drop"; + case kifyhrs_ecode_no_record_find: + return "no record find"; + case kifyhrs_ecode_parameter_error: + return "parameter error"; + case kifyhrs_ecode_electrode_is_not_inserted: + return "electrode is not inserted"; + case kifyhrs_ecode_device_exception: + return "device exception"; + case kifyhrs_ecode_invalid_state: + return "invalid state"; + case kifyhrs_ecode_overtime: + return "overtime"; + case kifyhrs_ecode_channel_is_close: + return "channel is close"; + + case kifyhrs_ecode_upper_exception: + return "upper exception"; + default: + return "unkown error"; + } +} + +typedef enum { + kifyhrs_pt_cmd = 1, + kifyhrs_pt_cmd_receipt = 2, + kifyhrs_pt_report = 3, + kifyhrs_pt_error_receipt = 4, +} ify_hrs_packet_type_t; + +typedef enum { + kifyhrs_sensor_pos_none = 0, // 无指定位置 + kifyhrs_sensor_pos_I = 1, // I + kifyhrs_sensor_pos_II = 2, // II + kifyhrs_sensor_pos_III = 3, // III + kifyhrs_sensor_pos_V1 = 4, // V1 + kifyhrs_sensor_pos_V2 = 5, // V2 + kifyhrs_sensor_pos_V3 = 6, // V3 + kifyhrs_sensor_pos_V4 = 7, // V4 + kifyhrs_sensor_pos_V5 = 8, // V5 + kifyhrs_sensor_pos_V6 = 9, // V6 + kifyhrs_sensor_pos_aVR = 10, // + kifyhrs_sensor_pos_aVL = 11, // + kifyhrs_sensor_pos_aVF = 12, // +} ify_hrs_sensor_pos_t; + +typedef enum { + ify_hrs_cmd_read_device_version = 1, + ify_hrs_cmd_read_sensor_info = 2, + ify_hrs_cmd_read_device_state = 3, + ify_hrs_cmd_read_time = 4, + ify_hrs_cmd_sync_time = 5, + ify_hrs_cmd_start_realtime_preview = 8, + ify_hrs_cmd_stop_realtime_preview = 9, + ify_hrs_cmd_read_records_info = 10, + ify_hrs_cmd_del_record = 11, + ify_hrs_cmd_start_upload_record = 12, + ify_hrs_cmd_enter_ota = 13, + ify_hrs_cmd_read_sn = 14, + ify_hrs_cmd_reset = 15, + ify_hrs_cmd_stop_upload_record = 16, + ify_hrs_cmd_ads1293_error_detail_info = 19, // 内部使用 + ify_hrs_cmd_change_sn = 20, // 内部使用 + ify_hrs_cmd_read_device_exception_state = 21, // 读取设备异常状态 + ify_hrs_cmd_read_ads1293_cfg_type = 22, // 读取ads1293使用的配置类型 + ify_hrs_cmd_start_storage = 23, // + ify_hrs_cmd_stop_storage = 24, // + + ify_hrs_report_heartrate_data = 101, + ify_hrs_report_battery_level = 102, + ify_hrs_report_low_battey_level = 103, + ify_hrs_report_sample_finish_end = 104, + ify_hrs_report_sensor_drop_detect = 105, + ify_hrs_report_record_upload_end = 106, + + ify_hrs_cmd_set_ecg_in_test_mode = 150, + ify_hrs_cmd_set_ecg_report_data_in_raw_mode = 151, // 设置ECG上报数据为原始数据 + ify_hrs_cmd_ecg_subic_read_reg = 152, + ify_hrs_cmd_ecg_subic_write_reg = 153, + +} ify_hrs_cmd_t; + +/******************************************************************************* + * packet_struct * + *******************************************************************************/ +typedef struct { + uint16_t placeholder; + uint16_t blestack_version; + uint16_t bootloader_version; + uint16_t firmware_version; + uint16_t hardware_version; +} device_version_info_receipt_t; + +typedef struct { + uint8_t sensor_num; // 数量 + uint8_t sensor_precision; // 精度 + uint8_t sensor_sample_rate; // 采样率 + uint8_t sensor0_pos; // 位置 + uint8_t sensor1_pos; // 位置 + uint8_t sensor2_pos; // 位置 +} sensor_info_receipt_t; + +typedef struct { + uint8_t drop_state0; + uint8_t drop_state1; + struct { + uint8_t sampling_state : 1; // 位置 + uint8_t report_state : 1; // 位置 + uint8_t low_battery : 1; // 位置 + uint8_t full_storge : 1; // 位置 + // uint8_t is_storaging : 1; // 位置 + uint8_t holder : 4; // 位置 + } device_state0; + uint8_t device_state1; // 预留 + uint8_t powerlevel; // 电量 + uint8_t storage_item_num; // 记录存储条数 + // uint32_t storage_setting_time_s; + // uint32_t storage_has_storaged_time_s; +} device_state_receipt_t; + +typedef struct { + uint8_t year; + uint8_t month; + uint8_t day; + uint8_t hour; + uint8_t minute; + uint8_t second; +} read_time_receipt_t; + +typedef struct { + uint8_t year; + uint8_t month; + uint8_t day; + uint8_t hour; + uint8_t minute; + uint8_t second; +} sync_time_cmd_t; + +typedef struct { + uint8_t year; + uint8_t month; + uint8_t day; + uint8_t hour; + uint8_t minute; + uint8_t second; +} start_capture_cmd_t; + +typedef struct { + uint8_t record_index; // 最近第几条记录 +} read_record_info_cmd_t; + +typedef struct { + uint8_t record_id[6]; + uint32_t frameNum; + uint32_t dataSize; + uint8_t sensorNum; + uint8_t captureRate; // N*10HZ + uint8_t capturePrecision; + uint8_t compressAlgorithm; // 压缩算法 + uint32_t checksum; // 校验和 +} read_record_info_receipt_t; + +typedef struct { + uint8_t record_id[6]; +} del_record_cmd_t; + +typedef struct { + uint8_t record_id[6]; +} start_upload_record_cmd_t; + +typedef struct { + uint8_t sn[14]; +} read_sn_receipt_t; + +typedef struct { + uint8_t errorcode; +} error_receipt_t; + +/******************************************************************************* + * 上报相关结构体 * + *******************************************************************************/ + +typedef struct { + uint8_t frame_type; + uint8_t frame_index; + uint8_t cmd; + + uint32_t sample_data_index; + uint8_t data[]; // 上报的数据 +} heartrate_report_packet_t; + +typedef struct { + uint8_t frame_type; + uint8_t frame_index; + uint8_t cmd; + + uint32_t sample_data_index; + uint16_t leadoff_state; + uint16_t sample_data_num; + int32_t frame[]; // 上报的数据 +} m1003_heartrate_report_packet_t; + +typedef struct { + uint8_t frame_type; + uint8_t frame_index; + uint8_t cmd; + + uint32_t sample_data_index; + uint32_t reportdata[50]; +} ads1291_report_packet_t; + +typedef struct { + uint8_t frame_type; + uint8_t frame_index; + uint8_t cmd; + + uint8_t drop_state0; + uint8_t drop_state1; +} sensor_drop_event_report_packet_t; + +#pragma pack(pop)