diff --git a/.vscode/settings.json b/.vscode/settings.json index 84890fb..d13aefa 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -92,7 +92,8 @@ "ble_cmd_process_service.h": "c", "heart_wave_sample_service.h": "c", "device_info_mgr.h": "c", - "znordic_device_info_mgr.h": "c" + "znordic_device_info_mgr.h": "c", + "device_state.h": "c" }, "files.encoding": "gbk" } \ No newline at end of file diff --git a/app/app.uvoptx b/app/app.uvoptx index c05a827..2b6d11b 100644 --- a/app/app.uvoptx +++ b/app/app.uvoptx @@ -398,7 +398,7 @@ 0 0 0 - .\src\one_conduction\one_conduction_board.c + .\src\one_conduction_board.c one_conduction_board.c 0 0 @@ -410,7 +410,7 @@ 0 0 0 - .\src\one_conduction\one_conduction_main.c + .\src\one_conduction_main.c one_conduction_main.c 0 0 @@ -458,7 +458,7 @@ 0 0 0 - .\src\one_conduction\device_controler.c + .\src\device_controler.c device_controler.c 0 0 @@ -470,7 +470,7 @@ 0 0 0 - .\src\one_conduction\display_manager.c + .\src\display_manager.c display_manager.c 0 0 @@ -506,7 +506,7 @@ 0 0 0 - .\src\one_conduction\sample_data_manager.c + .\src\sample_data_manager.c sample_data_manager.c 0 0 @@ -518,7 +518,7 @@ 0 0 0 - .\src\one_conduction\zeeprom_fs.c + .\src\zeeprom_fs.c zeeprom_fs.c 0 0 @@ -530,7 +530,7 @@ 0 0 0 - .\src\one_conduction\heart_wave_sample_service.c + .\src\heart_wave_sample_service.c heart_wave_sample_service.c 0 0 @@ -542,7 +542,7 @@ 0 0 0 - .\src\one_conduction\device_state.c + .\src\device_state.c device_state.c 0 0 @@ -554,7 +554,7 @@ 0 0 0 - .\src\one_conduction\ble_cmd_process_service.c + .\src\ble_cmd_process_service.c ble_cmd_process_service.c 0 0 @@ -595,6 +595,18 @@ 0 0 + + 1 + 20 + 1 + 0 + 0 + 0 + .\src\app_event_distribute.c + app_event_distribute.c + 0 + 0 + @@ -605,7 +617,7 @@ 0 2 - 20 + 21 1 0 0 @@ -625,7 +637,7 @@ 0 3 - 21 + 22 1 0 0 @@ -637,7 +649,7 @@ 3 - 22 + 23 1 0 0 @@ -657,7 +669,7 @@ 0 4 - 23 + 24 1 0 0 @@ -677,7 +689,7 @@ 0 5 - 24 + 25 1 0 0 @@ -689,7 +701,7 @@ 5 - 25 + 26 1 0 0 @@ -701,7 +713,7 @@ 5 - 26 + 27 1 0 0 @@ -713,7 +725,7 @@ 5 - 27 + 28 1 0 0 @@ -725,7 +737,7 @@ 5 - 28 + 29 1 0 0 @@ -737,7 +749,7 @@ 5 - 29 + 30 1 0 0 @@ -749,7 +761,7 @@ 5 - 30 + 31 1 0 0 @@ -761,7 +773,7 @@ 5 - 31 + 32 1 0 0 @@ -781,7 +793,7 @@ 0 6 - 32 + 33 1 0 0 @@ -801,7 +813,7 @@ 0 7 - 33 + 34 1 0 0 @@ -813,7 +825,7 @@ 7 - 34 + 35 1 0 0 @@ -825,7 +837,7 @@ 7 - 35 + 36 1 0 0 @@ -837,7 +849,7 @@ 7 - 36 + 37 1 0 0 @@ -849,7 +861,7 @@ 7 - 37 + 38 1 0 0 @@ -861,7 +873,7 @@ 7 - 38 + 39 1 0 0 @@ -873,7 +885,7 @@ 7 - 39 + 40 1 0 0 @@ -885,7 +897,7 @@ 7 - 40 + 41 1 0 0 @@ -897,7 +909,7 @@ 7 - 41 + 42 1 0 0 @@ -909,7 +921,7 @@ 7 - 42 + 43 1 0 0 @@ -921,7 +933,7 @@ 7 - 43 + 44 1 0 0 @@ -933,7 +945,7 @@ 7 - 44 + 45 1 0 0 @@ -945,7 +957,7 @@ 7 - 45 + 46 1 0 0 @@ -957,7 +969,7 @@ 7 - 46 + 47 1 0 0 @@ -969,7 +981,7 @@ 7 - 47 + 48 1 0 0 @@ -981,7 +993,7 @@ 7 - 48 + 49 1 0 0 @@ -993,7 +1005,7 @@ 7 - 49 + 50 1 0 0 @@ -1005,7 +1017,7 @@ 7 - 50 + 51 1 0 0 @@ -1017,7 +1029,7 @@ 7 - 51 + 52 1 0 0 @@ -1029,7 +1041,7 @@ 7 - 52 + 53 1 0 0 @@ -1049,7 +1061,7 @@ 0 8 - 53 + 54 1 0 0 @@ -1061,7 +1073,7 @@ 8 - 54 + 55 1 0 0 @@ -1073,7 +1085,7 @@ 8 - 55 + 56 1 0 0 @@ -1085,7 +1097,7 @@ 8 - 56 + 57 1 0 0 @@ -1097,7 +1109,7 @@ 8 - 57 + 58 1 0 0 @@ -1109,7 +1121,7 @@ 8 - 58 + 59 1 0 0 @@ -1121,7 +1133,7 @@ 8 - 59 + 60 1 0 0 @@ -1133,7 +1145,7 @@ 8 - 60 + 61 1 0 0 @@ -1145,7 +1157,7 @@ 8 - 61 + 62 1 0 0 @@ -1157,7 +1169,7 @@ 8 - 62 + 63 1 0 0 @@ -1169,7 +1181,7 @@ 8 - 63 + 64 1 0 0 @@ -1181,7 +1193,7 @@ 8 - 64 + 65 1 0 0 @@ -1193,7 +1205,7 @@ 8 - 65 + 66 1 0 0 @@ -1205,7 +1217,7 @@ 8 - 66 + 67 1 0 0 @@ -1217,7 +1229,7 @@ 8 - 67 + 68 1 0 0 @@ -1229,7 +1241,7 @@ 8 - 68 + 69 1 0 0 @@ -1241,7 +1253,7 @@ 8 - 69 + 70 1 0 0 @@ -1253,7 +1265,7 @@ 8 - 70 + 71 1 0 0 @@ -1265,7 +1277,7 @@ 8 - 71 + 72 1 0 0 @@ -1277,7 +1289,7 @@ 8 - 72 + 73 1 0 0 @@ -1289,7 +1301,7 @@ 8 - 73 + 74 1 0 0 @@ -1301,7 +1313,7 @@ 8 - 74 + 75 1 0 0 @@ -1313,7 +1325,7 @@ 8 - 75 + 76 1 0 0 @@ -1325,7 +1337,7 @@ 8 - 76 + 77 1 0 0 @@ -1337,7 +1349,7 @@ 8 - 77 + 78 1 0 0 @@ -1349,7 +1361,7 @@ 8 - 78 + 79 1 0 0 @@ -1361,7 +1373,7 @@ 8 - 79 + 80 1 0 0 @@ -1381,7 +1393,7 @@ 0 9 - 80 + 81 1 0 0 @@ -1393,7 +1405,7 @@ 9 - 81 + 82 1 0 0 @@ -1405,7 +1417,7 @@ 9 - 82 + 83 1 0 0 @@ -1417,7 +1429,7 @@ 9 - 83 + 84 1 0 0 @@ -1429,7 +1441,7 @@ 9 - 84 + 85 1 0 0 @@ -1441,7 +1453,7 @@ 9 - 85 + 86 1 0 0 @@ -1461,7 +1473,7 @@ 0 10 - 86 + 87 1 0 0 @@ -1473,7 +1485,7 @@ 10 - 87 + 88 1 0 0 @@ -1485,7 +1497,7 @@ 10 - 88 + 89 1 0 0 @@ -1505,7 +1517,7 @@ 0 11 - 89 + 90 1 0 0 @@ -1517,7 +1529,7 @@ 11 - 90 + 91 1 0 0 @@ -1529,7 +1541,7 @@ 11 - 91 + 92 1 0 0 @@ -1549,7 +1561,7 @@ 0 12 - 92 + 93 1 0 0 @@ -1569,7 +1581,7 @@ 0 13 - 93 + 94 1 0 0 @@ -1581,7 +1593,7 @@ 13 - 94 + 95 1 0 0 diff --git a/app/app.uvprojx b/app/app.uvprojx index d45fdb1..dbb6b38 100644 --- a/app/app.uvprojx +++ b/app/app.uvprojx @@ -396,12 +396,12 @@ one_conduction_board.c 1 - .\src\one_conduction\one_conduction_board.c + .\src\one_conduction_board.c one_conduction_main.c 1 - .\src\one_conduction\one_conduction_main.c + .\src\one_conduction_main.c driver_ssd1306.c @@ -421,12 +421,12 @@ device_controler.c 1 - .\src\one_conduction\device_controler.c + .\src\device_controler.c display_manager.c 1 - .\src\one_conduction\display_manager.c + .\src\display_manager.c fontlib.c @@ -441,27 +441,27 @@ sample_data_manager.c 1 - .\src\one_conduction\sample_data_manager.c + .\src\sample_data_manager.c zeeprom_fs.c 1 - .\src\one_conduction\zeeprom_fs.c + .\src\zeeprom_fs.c heart_wave_sample_service.c 1 - .\src\one_conduction\heart_wave_sample_service.c + .\src\heart_wave_sample_service.c device_state.c 1 - .\src\one_conduction\device_state.c + .\src\device_state.c ble_cmd_process_service.c 1 - .\src\one_conduction\ble_cmd_process_service.c + .\src\ble_cmd_process_service.c zble_module.c @@ -478,6 +478,11 @@ 1 ..\libznordic\src\znordic_device_info_mgr.c + + app_event_distribute.c + 1 + .\src\app_event_distribute.c + @@ -4220,12 +4225,12 @@ one_conduction_board.c 1 - .\src\one_conduction\one_conduction_board.c + .\src\one_conduction_board.c one_conduction_main.c 1 - .\src\one_conduction\one_conduction_main.c + .\src\one_conduction_main.c driver_ssd1306.c @@ -4245,12 +4250,12 @@ device_controler.c 1 - .\src\one_conduction\device_controler.c + .\src\device_controler.c display_manager.c 1 - .\src\one_conduction\display_manager.c + .\src\display_manager.c fontlib.c @@ -4265,27 +4270,27 @@ sample_data_manager.c 1 - .\src\one_conduction\sample_data_manager.c + .\src\sample_data_manager.c zeeprom_fs.c 1 - .\src\one_conduction\zeeprom_fs.c + .\src\zeeprom_fs.c heart_wave_sample_service.c 1 - .\src\one_conduction\heart_wave_sample_service.c + .\src\heart_wave_sample_service.c device_state.c 1 - .\src\one_conduction\device_state.c + .\src\device_state.c ble_cmd_process_service.c 1 - .\src\one_conduction\ble_cmd_process_service.c + .\src\ble_cmd_process_service.c zble_module.c @@ -4302,6 +4307,11 @@ 1 ..\libznordic\src\znordic_device_info_mgr.c + + app_event_distribute.c + 1 + .\src\app_event_distribute.c + diff --git a/app/src/one_conduction/app_event.h b/app/src/app_event.h similarity index 100% rename from app/src/one_conduction/app_event.h rename to app/src/app_event.h diff --git a/app/src/app_event_distribute.c b/app/src/app_event_distribute.c new file mode 100644 index 0000000..07a00a6 --- /dev/null +++ b/app/src/app_event_distribute.c @@ -0,0 +1,23 @@ +#include "app_event_distribute.h" + +#include "app_event.h" +#include "app_scheduler.h" + +static AppEventListener m_listener[10]; +static int m_listener_num = 0; + +static void app_event_process_cb(void* p_event_data, uint16_t event_size) { + for (int i = 0; i < m_listener_num; i++) { + if (m_listener[i].cbfunc) { + m_listener[i].cbfunc(p_event_data, event_size); + } + } +} + +void AppEvent_regListener(app_event_listener_t listener) { // + m_listener[m_listener_num++].cbfunc = listener; +} + +void AppEvent_pushEvent(app_event_t* event) { // + app_sched_event_put(event, sizeof(app_event_t), app_event_process_cb); +} diff --git a/app/src/app_event_distribute.h b/app/src/app_event_distribute.h new file mode 100644 index 0000000..7f22132 --- /dev/null +++ b/app/src/app_event_distribute.h @@ -0,0 +1,15 @@ +#pragma once +#include +#include + +#include "app_event.h" + + +typedef void (*app_event_listener_t)(void* p_event_data, uint16_t event_size); + +typedef struct { + app_event_listener_t cbfunc; +} AppEventListener; + +void AppEvent_regListener(app_event_listener_t listener); +void AppEvent_pushEvent(app_event_t* event); diff --git a/app/src/one_conduction/ble_cmd_process_service.c b/app/src/ble_cmd_process_service.c similarity index 95% rename from app/src/one_conduction/ble_cmd_process_service.c rename to app/src/ble_cmd_process_service.c index f5d567b..34265c5 100644 --- a/app/src/one_conduction/ble_cmd_process_service.c +++ b/app/src/ble_cmd_process_service.c @@ -56,7 +56,7 @@ int ble_stop_realtime_report() { m_realtime_report_state = false; return 0; } -void ble_cmder_try_report_one_sample_data(uint32_t frameIndex, uint16_t data) { +void ble_cmder_try_report_one_sample_data(uint32_t frameIndex, uint16_t data0, uint16_t data1, uint16_t data2, uint16_t data3) { if (!m_realtime_report_state) { return; } @@ -67,15 +67,16 @@ void ble_cmder_try_report_one_sample_data(uint32_t frameIndex, uint16_t data) { reportpacket->frame_type = kifyhrs_pt_report; reportpacket->sample_data_index = frameIndex; - /** - * @brief 第一导联数据 - */ - reportpacket->data[0] = (data >> 0) & 0xFF; - reportpacket->data[1] = (data >> 8) & 0xFF; - reportpacket->data[2] = 0; - reportpacket->data[3] = 0; + reportpacket->data[0] = (data0 >> 0) & 0xFF; // 第一帧数据 + reportpacket->data[1] = (data0 >> 8) & 0xFF; // 第一帧数据 + reportpacket->data[2] = (data1 >> 0) & 0xFF; // 第二帧数据 + reportpacket->data[3] = (data1 >> 8) & 0xFF; // 第二帧数据 + reportpacket->data[4] = (data2 >> 0) & 0xFF; // 第三帧数据 + reportpacket->data[5] = (data2 >> 8) & 0xFF; // 第三帧数据 + reportpacket->data[6] = (data3 >> 0) & 0xFF; // 第四帧数据 + reportpacket->data[7] = (data3 >> 8) & 0xFF; // 第四帧数据 - uint16_t sendlen = sizeof(heartrate_report_packet_t) + 4; + uint16_t sendlen = sizeof(heartrate_report_packet_t) + 8; zdatachannel_data_send2(reportbuf, sendlen); return; } @@ -440,6 +441,11 @@ void ble_cmder_process_rx(uint8_t* rx, int len) { } } + else if (cmd == ify_hrs_cmd_stop_upload_record) { + ble_stop_upload_record(); + send_success_receipt(rxheader, 0); + } + else if (cmd == ify_hrs_cmd_enter_ota) { send_error_receipt(rxheader, kifyhrs_ecode_cmd_not_support); } diff --git a/app/src/one_conduction/ble_cmd_process_service.h b/app/src/ble_cmd_process_service.h similarity index 87% rename from app/src/one_conduction/ble_cmd_process_service.h rename to app/src/ble_cmd_process_service.h index a9828f6..412bb58 100644 --- a/app/src/one_conduction/ble_cmd_process_service.h +++ b/app/src/ble_cmd_process_service.h @@ -9,7 +9,7 @@ void ble_cmder_process_rx(uint8_t* rx, int len); void ble_cmder_start_adv(); void ble_cmder_stop_adv(); -void ble_cmder_try_report_one_sample_data(uint32_t frameIndex, uint16_t data); +void ble_cmder_try_report_one_sample_data(uint32_t frameIndex, uint16_t data0, uint16_t data1, uint16_t data2, uint16_t data3); void ble_cmder_try_report_sensor_drop_event(uint8_t dropstate0, uint8_t dropstate1); void ble_cmder_report_upload_finish_event(uint32_t sumcheckcode); void ble_cmder_report_sample_finish_event(); diff --git a/app/src/board/board.h b/app/src/board/board.h index 91b2f2f..59baa7e 100644 --- a/app/src/board/board.h +++ b/app/src/board/board.h @@ -19,6 +19,8 @@ #define SAMPLE_PRECISION 12 #define AUTOMATIC_SLEEP_TIME 15000 -#define SAMPLE_MIN_TIME_S (30.0) +#define SAMPLE_MIN_TIME_S (30.0) -#define ENABLE_SLEEP \ No newline at end of file +#define ENABLE_SLEEP + +#define LITTLE_DATA_BLOCK_FRAME_NUM 4 // 每次多少帧上报一次 diff --git a/app/src/one_conduction/config.h b/app/src/config.h similarity index 100% rename from app/src/one_conduction/config.h rename to app/src/config.h diff --git a/app/src/one_conduction/device_controler.c b/app/src/device_controler.c similarity index 100% rename from app/src/one_conduction/device_controler.c rename to app/src/device_controler.c diff --git a/app/src/one_conduction/device_controler.h b/app/src/device_controler.h similarity index 100% rename from app/src/one_conduction/device_controler.h rename to app/src/device_controler.h diff --git a/app/src/one_conduction/device_state.c b/app/src/device_state.c similarity index 100% rename from app/src/one_conduction/device_state.c rename to app/src/device_state.c diff --git a/app/src/one_conduction/device_state.h b/app/src/device_state.h similarity index 86% rename from app/src/one_conduction/device_state.h rename to app/src/device_state.h index 9a6f645..469a34c 100644 --- a/app/src/one_conduction/device_state.h +++ b/app/src/device_state.h @@ -1,7 +1,8 @@ #pragma once -#include #include +#include +#include "board/board.h" typedef enum { kplod_connected_event = 0, // 导联连接事件 kplod_disconnected_event, // 导联断开事件 @@ -13,19 +14,23 @@ typedef enum { kevent_tmr_scheduler_event, // 定时器调度事件 - kevent_capture_256data_event, // 采样数据回调 - kevent_capture_1data_event, // 单次采样数据回调 + kevent_capture_256data_event, // 采样数据回调 + kevent_capture_little_data_block_event, // 单次采样数据回调 } app_event_type_t; typedef struct { + uint16_t data; +} one_frame_data_t; + +typedef struct { app_event_type_t eventType; union { uint32_t plod_connected_accumulation_time; // 导联连接累计时间 uint8_t* capture_data_cache; // 实时采样数据,数据长度为256字节 struct { - uint32_t frameIndex; - uint16_t data; - } frame_data; + uint32_t frameIndex; + one_frame_data_t data[LITTLE_DATA_BLOCK_FRAME_NUM]; + } little_data_block; } val; } app_event_t; diff --git a/app/src/one_conduction/display_manager.c b/app/src/display_manager.c similarity index 100% rename from app/src/one_conduction/display_manager.c rename to app/src/display_manager.c diff --git a/app/src/one_conduction/display_manager.h b/app/src/display_manager.h similarity index 100% rename from app/src/one_conduction/display_manager.h rename to app/src/display_manager.h diff --git a/app/src/one_conduction/display_manager_res.h b/app/src/display_manager_res.h similarity index 100% rename from app/src/one_conduction/display_manager_res.h rename to app/src/display_manager_res.h diff --git a/app/src/one_conduction/font.h b/app/src/font.h similarity index 100% rename from app/src/one_conduction/font.h rename to app/src/font.h diff --git a/app/src/one_conduction/heart_wave_sample_service.c b/app/src/heart_wave_sample_service.c similarity index 72% rename from app/src/one_conduction/heart_wave_sample_service.c rename to app/src/heart_wave_sample_service.c index 3fe2789..0a40ecf 100644 --- a/app/src/one_conduction/heart_wave_sample_service.c +++ b/app/src/heart_wave_sample_service.c @@ -1,9 +1,9 @@ #include "heart_wave_sample_service.h" #include "app_event.h" +#include "app_event_distribute.h" #include "nrfx_timer.h" #include "one_conduction_board.h" - static const nrfx_timer_t m_timer = NRFX_TIMER_INSTANCE(1); /**< Timer used for channel sweeps and tx with duty cycle. */ static bool m_timer_started = false; /**< True if timer is running. */ @@ -15,7 +15,10 @@ static uint16_t m_capture_buffer_index = 0; volatile static float m_sensor_display_data = 0; // 0->100 static uint32_t m_start_capture_tp; -static uint32_t m_frameindex = 0; +static uint32_t m_frame_index = 0; + +static one_frame_data_t m_sensor_little_frame_cache[LITTLE_DATA_BLOCK_FRAME_NUM]; +static uint32_t m_little_frame_index; static void swap_buffer() { if (m_capture_buffer == NULL) { @@ -60,9 +63,37 @@ static float Filter(filter_t* filter, float newInput) { return newv; } +/******************************************************************************* + * 小包数据上报 * + *******************************************************************************/ +static inline void prvf_little_block_cache_push_one_frame(uint16_t data) { + if (m_little_frame_index >= LITTLE_DATA_BLOCK_FRAME_NUM) { + return; + } + m_sensor_little_frame_cache[m_little_frame_index].data = data; + m_little_frame_index++; +} + +static inline bool prvf_light_block_cache_is_full(void) { + if (m_little_frame_index >= LITTLE_DATA_BLOCK_FRAME_NUM) { + return true; + } + return false; +} +static inline void prvf_light_block_cache_clear(void) { m_little_frame_index = 0; } +static inline void prvf_light_block_trigger_event() { + static app_event_t event; + event.eventType = kevent_capture_little_data_block_event; + for (uint32_t i = 0; i < LITTLE_DATA_BLOCK_FRAME_NUM; i++) { + event.val.little_data_block.data[i].data = m_sensor_little_frame_cache[i].data; + } + event.val.little_data_block.frameIndex = m_frame_index - LITTLE_DATA_BLOCK_FRAME_NUM; + AppEvent_pushEvent(&event); +} + void nrfx_timer_event_handler(nrf_timer_event_t event_type, void* p_context) { // uint16_t val = SingleLeadECG_ecg_plod_get_ecg_val(); // 12bit - m_frameindex++; + m_frame_index++; /******************************************************************************* * 显示数据计算并赋值 * @@ -88,23 +119,19 @@ void nrfx_timer_event_handler(nrf_timer_event_t event_type, void* p_context) { evt.eventType = kevent_capture_256data_event; evt.val.capture_data_cache = (uint8_t*)m_capture_buffer; swap_buffer(); - app_sched_event_put(&evt, sizeof(evt), app_event_process_cb); + AppEvent_pushEvent(&evt); } /******************************************************************************* * 实时采样数据事件上报 * *******************************************************************************/ - { - static int index = 0; - if (index % 2 == 0) { - app_event_t evt; - evt.eventType = kevent_capture_1data_event; - evt.val.frame_data.frameIndex = m_frameindex; - evt.val.frame_data.data = val; - swap_buffer(); - app_sched_event_put(&evt, sizeof(evt), app_event_process_cb); - } - index++; + /** + * @brief 缓存数据,并触发小数据块事件 + */ + prvf_little_block_cache_push_one_frame(val); + if (prvf_light_block_cache_is_full()) { + prvf_light_block_trigger_event(); + prvf_light_block_cache_clear(); } } @@ -137,12 +164,12 @@ void hwss_uninit(void) { nrfx_timer_disable(&m_timer); } void hwss_start_capture(void) { m_start_capture_tp = znordic_getpower_on_s(); swap_buffer(); - m_frameindex = 0; + m_frame_index = 0; nrfx_timer_enable(&m_timer); } void hwss_stop_capture(void) { nrfx_timer_disable(&m_timer); - m_frameindex = 0; + m_frame_index = 0; } float hwss_read_val(void) { diff --git a/app/src/one_conduction/heart_wave_sample_service.h b/app/src/heart_wave_sample_service.h similarity index 100% rename from app/src/one_conduction/heart_wave_sample_service.h rename to app/src/heart_wave_sample_service.h diff --git a/app/src/one_conduction/one_conduction_board.c b/app/src/one_conduction_board.c similarity index 100% rename from app/src/one_conduction/one_conduction_board.c rename to app/src/one_conduction_board.c diff --git a/app/src/one_conduction/one_conduction_board.h b/app/src/one_conduction_board.h similarity index 100% rename from app/src/one_conduction/one_conduction_board.h rename to app/src/one_conduction_board.h diff --git a/app/src/one_conduction/one_conduction_main.c b/app/src/one_conduction_main.c similarity index 94% rename from app/src/one_conduction/one_conduction_main.c rename to app/src/one_conduction_main.c index 0a28a23..13c86db 100644 --- a/app/src/one_conduction/one_conduction_main.c +++ b/app/src/one_conduction_main.c @@ -11,6 +11,7 @@ #include "zdatachannel_service.h" #include "znordic.h" #include "znordic_device_info_mgr.h" +#include "app_event_distribute.h" /******************************************************************************* * GLOBAL * @@ -60,19 +61,19 @@ static void m_plod_state_event_detect_tmr_cb(void* p_context) { // // 连接事件 appevent.eventType = kplod_connected_event; m_plod_state_connected_state = true; - app_sched_event_put(&appevent, sizeof(appevent), app_event_process_cb); + AppEvent_pushEvent(&appevent); } else if (m_plod_state_connected_state && connecte_state_trigger_cnt == 0) { // 断开事件 appevent.eventType = kplod_disconnected_event; m_plod_state_connected_state = false; - app_sched_event_put(&appevent, sizeof(appevent), app_event_process_cb); + AppEvent_pushEvent(&appevent); } // else if (connecte_state_trigger_cnt >= 10 && connecte_state_trigger_cnt % 10 == 0) { // // 连接持续事件 // appevent.eventType = kplod_connecting_event; // appevent.val.plod_connected_accumulation_time = connecte_state_trigger_cnt / 10; - // app_sched_event_put(&appevent, sizeof(appevent), app_event_process_cb); + // AppEvent_pushEvent(&appevent); // } } @@ -84,16 +85,16 @@ static void m_charge_event_detect_tmr_cb(void* p_context) { // if (!ischarging) { appevent.eventType = kplod_start_charge_event; ischarging = true; - app_sched_event_put(&appevent, sizeof(appevent), app_event_process_cb); + AppEvent_pushEvent(&appevent); } else { appevent.eventType = kplod_charging_event; - app_sched_event_put(&appevent, sizeof(appevent), app_event_process_cb); + AppEvent_pushEvent(&appevent); } } else { if (ischarging) { ischarging = false; appevent.eventType = kplod_end_charge_event; - app_sched_event_put(&appevent, sizeof(appevent), app_event_process_cb); + AppEvent_pushEvent(&appevent); } } } @@ -101,7 +102,7 @@ static void m_charge_event_detect_tmr_cb(void* p_context) { // static void state_machine_driver_tmr_cb(void* p_context) { // static app_event_t appevent; appevent.eventType = kevent_tmr_scheduler_event; - app_sched_event_put(&appevent, sizeof(appevent), app_event_process_cb); + AppEvent_pushEvent(&appevent); } /******************************************************************************* @@ -188,7 +189,7 @@ static void state_machine__change_to_home_state() { ds_change_to_state(kdevice_state_home); dsp_mgr_change_to_main(); } -void app_event_process_cb(void* p_event_data, uint16_t event_size) { +static void app_event_listener(void* p_event_data, uint16_t event_size) { if (!p_event_data) return; app_event_t* p_event = (app_event_t*)p_event_data; @@ -330,9 +331,15 @@ void app_event_process_cb(void* p_event_data, uint16_t event_size) { hwss_stop_capture(); } } - } else if (p_event->eventType == kevent_capture_1data_event) { + } else if (p_event->eventType == kevent_capture_little_data_block_event) { // 单帧实时上报 - ble_cmder_try_report_one_sample_data(p_event->val.frame_data.frameIndex, p_event->val.frame_data.data); + ZASSERT(LITTLE_DATA_BLOCK_FRAME_NUM == 4); + ble_cmder_try_report_one_sample_data(p_event->val.little_data_block.frameIndex, // + p_event->val.little_data_block.data[0].data, // + p_event->val.little_data_block.data[1].data, // + p_event->val.little_data_block.data[2].data, // + p_event->val.little_data_block.data[3].data // + ); } else if (p_event->eventType == kplod_disconnected_event || !m_plod_state_connected_state) { /******************************************************************************* * 导联断开 * @@ -437,6 +444,8 @@ void one_conduction_main() { SingleLeadECG_ecg_io_init(); SingleLeadECG_battery_charge_detect_io_init(); + AppEvent_regListener(app_event_listener); + ZERROR_CHECK(app_timer_create(&m_state_machine_driver_tmr, APP_TIMER_MODE_REPEATED, state_machine_driver_tmr_cb)); ZERROR_CHECK(app_timer_create(&m_plod_state_event_detect_tmr, APP_TIMER_MODE_REPEATED, m_plod_state_event_detect_tmr_cb)); ZERROR_CHECK(app_timer_create(&m_charge_event_detect_tmr, APP_TIMER_MODE_REPEATED, m_charge_event_detect_tmr_cb)); diff --git a/app/src/one_conduction/one_conduction_main.h b/app/src/one_conduction_main.h similarity index 100% rename from app/src/one_conduction/one_conduction_main.h rename to app/src/one_conduction_main.h diff --git a/app/src/one_conduction/sample_data_manager.c b/app/src/sample_data_manager.c similarity index 100% rename from app/src/one_conduction/sample_data_manager.c rename to app/src/sample_data_manager.c diff --git a/app/src/one_conduction/sample_data_manager.h b/app/src/sample_data_manager.h similarity index 100% rename from app/src/one_conduction/sample_data_manager.h rename to app/src/sample_data_manager.h diff --git a/app/src/one_conduction/zeeprom_fs.c b/app/src/zeeprom_fs.c similarity index 100% rename from app/src/one_conduction/zeeprom_fs.c rename to app/src/zeeprom_fs.c diff --git a/app/src/one_conduction/zeeprom_fs.h b/app/src/zeeprom_fs.h similarity index 100% rename from app/src/one_conduction/zeeprom_fs.h rename to app/src/zeeprom_fs.h