diff --git a/.gitmodules b/.gitmodules index b409ede..c920361 100644 --- a/.gitmodules +++ b/.gitmodules @@ -4,3 +4,6 @@ [submodule "libznordic"] path = libznordic url = zwsd@192.168.1.3:p_dynamic_electrocardiograph/libznordic.git +[submodule "ify_hrs_protocol"] + path = ify_hrs_protocol + url = zwsd@192.168.1.3:p_dynamic_electrocardiograph/ify_hrs_protocol.git diff --git a/.vscode/settings.json b/.vscode/settings.json index 55958d4..888ac10 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -98,7 +98,10 @@ "app_ble_service.h": "c", "nrfx_timer.h": "c", "app_button.h": "c", - "nrf_drv_gpiote.h": "c" + "nrf_drv_gpiote.h": "c", + "device_ctrl_service.h": "c", + "board_battery_state.h": "c", + "board_sdcard_driver.h": "c" }, "files.encoding": "gbk" } \ No newline at end of file diff --git a/app/app.uvoptx b/app/app.uvoptx index 2c9aab7..0654d60 100644 --- a/app/app.uvoptx +++ b/app/app.uvoptx @@ -410,8 +410,8 @@ 0 0 0 - .\src\board\three_lead_board.c - three_lead_board.c + .\src\app_ble_service.c + app_ble_service.c 0 0 @@ -422,8 +422,8 @@ 0 0 0 - ..\libznordic\src\zble_module.c - zble_module.c + .\src\sample_data_manager_service.c + sample_data_manager_service.c 0 0 @@ -434,8 +434,8 @@ 0 0 0 - ..\libznordic\src\zdatachannel_service.c - zdatachannel_service.c + .\src\heart_wave_sample_service.c + heart_wave_sample_service.c 0 0 @@ -446,8 +446,92 @@ 0 0 0 - .\src\app_ble_service.c - app_ble_service.c + .\src\device_ctrl_service.c + device_ctrl_service.c + 0 + 0 + + + 1 + 8 + 1 + 0 + 0 + 0 + .\src\app_event_distribute.c + app_event_distribute.c + 0 + 0 + + + 1 + 9 + 1 + 0 + 0 + 0 + .\src\board\board.c + board.c + 0 + 0 + + + 1 + 10 + 1 + 0 + 0 + 0 + .\src\board\board_battery_state.c + board_battery_state.c + 0 + 0 + + + 1 + 11 + 1 + 0 + 0 + 0 + .\src\board\board_beep_ctrl.c + board_beep_ctrl.c + 0 + 0 + + + 1 + 12 + 1 + 0 + 0 + 0 + .\src\board\board_button.c + board_button.c + 0 + 0 + + + 1 + 13 + 1 + 0 + 0 + 0 + .\src\board\board_light_ctrl.c + board_light_ctrl.c + 0 + 0 + + + 1 + 14 + 1 + 0 + 0 + 0 + .\src\board\board_sdcard_driver.c + board_sdcard_driver.c 0 0 @@ -461,7 +545,7 @@ 0 2 - 8 + 15 1 0 0 @@ -481,7 +565,7 @@ 0 3 - 9 + 16 1 0 0 @@ -493,7 +577,7 @@ 3 - 10 + 17 1 0 0 @@ -513,7 +597,7 @@ 0 4 - 11 + 18 1 0 0 @@ -533,7 +617,7 @@ 0 5 - 12 + 19 1 0 0 @@ -545,7 +629,7 @@ 5 - 13 + 20 1 0 0 @@ -557,7 +641,7 @@ 5 - 14 + 21 1 0 0 @@ -569,7 +653,7 @@ 5 - 15 + 22 1 0 0 @@ -581,7 +665,7 @@ 5 - 16 + 23 1 0 0 @@ -593,7 +677,7 @@ 5 - 17 + 24 1 0 0 @@ -605,7 +689,7 @@ 5 - 18 + 25 1 0 0 @@ -617,7 +701,7 @@ 5 - 19 + 26 1 0 0 @@ -637,7 +721,7 @@ 0 6 - 20 + 27 1 0 0 @@ -657,7 +741,7 @@ 0 7 - 21 + 28 1 0 0 @@ -669,7 +753,7 @@ 7 - 22 + 29 1 0 0 @@ -681,7 +765,7 @@ 7 - 23 + 30 1 0 0 @@ -693,7 +777,7 @@ 7 - 24 + 31 1 0 0 @@ -705,7 +789,7 @@ 7 - 25 + 32 1 0 0 @@ -717,7 +801,7 @@ 7 - 26 + 33 1 0 0 @@ -729,7 +813,7 @@ 7 - 27 + 34 1 0 0 @@ -741,7 +825,7 @@ 7 - 28 + 35 1 0 0 @@ -753,7 +837,7 @@ 7 - 29 + 36 1 0 0 @@ -765,7 +849,7 @@ 7 - 30 + 37 1 0 0 @@ -777,7 +861,7 @@ 7 - 31 + 38 1 0 0 @@ -789,7 +873,7 @@ 7 - 32 + 39 1 0 0 @@ -801,7 +885,7 @@ 7 - 33 + 40 1 0 0 @@ -813,7 +897,7 @@ 7 - 34 + 41 1 0 0 @@ -825,7 +909,7 @@ 7 - 35 + 42 1 0 0 @@ -837,7 +921,7 @@ 7 - 36 + 43 1 0 0 @@ -849,7 +933,7 @@ 7 - 37 + 44 1 0 0 @@ -861,7 +945,7 @@ 7 - 38 + 45 1 0 0 @@ -873,7 +957,7 @@ 7 - 39 + 46 1 0 0 @@ -885,7 +969,7 @@ 7 - 40 + 47 1 0 0 @@ -905,7 +989,7 @@ 0 8 - 41 + 48 1 0 0 @@ -917,7 +1001,7 @@ 8 - 42 + 49 1 0 0 @@ -929,7 +1013,7 @@ 8 - 43 + 50 1 0 0 @@ -941,7 +1025,7 @@ 8 - 44 + 51 1 0 0 @@ -953,7 +1037,7 @@ 8 - 45 + 52 1 0 0 @@ -965,7 +1049,7 @@ 8 - 46 + 53 1 0 0 @@ -977,7 +1061,7 @@ 8 - 47 + 54 1 0 0 @@ -989,7 +1073,7 @@ 8 - 48 + 55 1 0 0 @@ -1001,7 +1085,7 @@ 8 - 49 + 56 1 0 0 @@ -1013,7 +1097,7 @@ 8 - 50 + 57 1 0 0 @@ -1025,7 +1109,7 @@ 8 - 51 + 58 1 0 0 @@ -1037,7 +1121,7 @@ 8 - 52 + 59 1 0 0 @@ -1049,7 +1133,7 @@ 8 - 53 + 60 1 0 0 @@ -1061,7 +1145,7 @@ 8 - 54 + 61 1 0 0 @@ -1073,7 +1157,7 @@ 8 - 55 + 62 1 0 0 @@ -1085,7 +1169,7 @@ 8 - 56 + 63 1 0 0 @@ -1097,7 +1181,7 @@ 8 - 57 + 64 1 0 0 @@ -1109,7 +1193,7 @@ 8 - 58 + 65 1 0 0 @@ -1121,7 +1205,7 @@ 8 - 59 + 66 1 0 0 @@ -1133,7 +1217,7 @@ 8 - 60 + 67 1 0 0 @@ -1145,7 +1229,7 @@ 8 - 61 + 68 1 0 0 @@ -1157,7 +1241,7 @@ 8 - 62 + 69 1 0 0 @@ -1169,7 +1253,7 @@ 8 - 63 + 70 1 0 0 @@ -1181,7 +1265,7 @@ 8 - 64 + 71 1 0 0 @@ -1193,7 +1277,7 @@ 8 - 65 + 72 1 0 0 @@ -1205,7 +1289,7 @@ 8 - 66 + 73 1 0 0 @@ -1217,7 +1301,7 @@ 8 - 67 + 74 1 0 0 @@ -1237,7 +1321,7 @@ 0 9 - 68 + 75 1 0 0 @@ -1249,7 +1333,7 @@ 9 - 69 + 76 1 0 0 @@ -1261,7 +1345,7 @@ 9 - 70 + 77 1 0 0 @@ -1273,7 +1357,7 @@ 9 - 71 + 78 1 0 0 @@ -1285,7 +1369,7 @@ 9 - 72 + 79 1 0 0 @@ -1297,7 +1381,7 @@ 9 - 73 + 80 1 0 0 @@ -1317,7 +1401,7 @@ 0 10 - 74 + 81 1 0 0 @@ -1329,7 +1413,7 @@ 10 - 75 + 82 1 0 0 @@ -1341,7 +1425,7 @@ 10 - 76 + 83 1 0 0 @@ -1361,7 +1445,7 @@ 0 11 - 77 + 84 1 0 0 @@ -1373,7 +1457,7 @@ 11 - 78 + 85 1 0 0 @@ -1385,7 +1469,7 @@ 11 - 79 + 86 1 0 0 @@ -1399,13 +1483,13 @@ libznordic - 0 + 1 0 0 0 12 - 80 + 87 1 0 0 @@ -1415,6 +1499,42 @@ 0 0 + + 12 + 88 + 1 + 0 + 0 + 0 + ..\libznordic\src\zble_module.c + zble_module.c + 0 + 0 + + + 12 + 89 + 1 + 0 + 0 + 0 + ..\libznordic\src\zdatachannel_service.c + zdatachannel_service.c + 0 + 0 + + + 12 + 90 + 1 + 0 + 0 + 0 + ..\libznordic\src\znordic_device_info_mgr.c + znordic_device_info_mgr.c + 0 + 0 + @@ -1425,7 +1545,7 @@ 0 13 - 81 + 91 1 0 0 @@ -1437,7 +1557,7 @@ 13 - 82 + 92 1 0 0 diff --git a/app/app.uvprojx b/app/app.uvprojx index 907dea7..33fa471 100644 --- a/app/app.uvprojx +++ b/app/app.uvprojx @@ -399,24 +399,59 @@ .\src\main.c - three_lead_board.c + app_ble_service.c 1 - .\src\board\three_lead_board.c + .\src\app_ble_service.c - zble_module.c + sample_data_manager_service.c 1 - ..\libznordic\src\zble_module.c + .\src\sample_data_manager_service.c - zdatachannel_service.c + heart_wave_sample_service.c 1 - ..\libznordic\src\zdatachannel_service.c + .\src\heart_wave_sample_service.c - app_ble_service.c + device_ctrl_service.c 1 - .\src\app_ble_service.c + .\src\device_ctrl_service.c + + + app_event_distribute.c + 1 + .\src\app_event_distribute.c + + + board.c + 1 + .\src\board\board.c + + + board_battery_state.c + 1 + .\src\board\board_battery_state.c + + + board_beep_ctrl.c + 1 + .\src\board\board_beep_ctrl.c + + + board_button.c + 1 + .\src\board\board_button.c + + + board_light_ctrl.c + 1 + .\src\board\board_light_ctrl.c + + + board_sdcard_driver.c + 1 + .\src\board\board_sdcard_driver.c @@ -3745,6 +3780,21 @@ 1 ..\libznordic\src\znordic.c + + zble_module.c + 1 + ..\libznordic\src\zble_module.c + + + zdatachannel_service.c + 1 + ..\libznordic\src\zdatachannel_service.c + + + znordic_device_info_mgr.c + 1 + ..\libznordic\src\znordic_device_info_mgr.c + @@ -4163,24 +4213,59 @@ .\src\main.c - three_lead_board.c + app_ble_service.c 1 - .\src\board\three_lead_board.c + .\src\app_ble_service.c - zble_module.c + sample_data_manager_service.c 1 - ..\libznordic\src\zble_module.c + .\src\sample_data_manager_service.c - zdatachannel_service.c + heart_wave_sample_service.c 1 - ..\libznordic\src\zdatachannel_service.c + .\src\heart_wave_sample_service.c - app_ble_service.c + device_ctrl_service.c 1 - .\src\app_ble_service.c + .\src\device_ctrl_service.c + + + app_event_distribute.c + 1 + .\src\app_event_distribute.c + + + board.c + 1 + .\src\board\board.c + + + board_battery_state.c + 1 + .\src\board\board_battery_state.c + + + board_beep_ctrl.c + 1 + .\src\board\board_beep_ctrl.c + + + board_button.c + 1 + .\src\board\board_button.c + + + board_light_ctrl.c + 1 + .\src\board\board_light_ctrl.c + + + board_sdcard_driver.c + 1 + .\src\board\board_sdcard_driver.c @@ -7509,6 +7594,21 @@ 1 ..\libznordic\src\znordic.c + + zble_module.c + 1 + ..\libznordic\src\zble_module.c + + + zdatachannel_service.c + 1 + ..\libznordic\src\zdatachannel_service.c + + + znordic_device_info_mgr.c + 1 + ..\libznordic\src\znordic_device_info_mgr.c + diff --git a/app/src/app_ble_service.c b/app/src/app_ble_service.c index 923e224..e659b66 100644 --- a/app/src/app_ble_service.c +++ b/app/src/app_ble_service.c @@ -1,14 +1,26 @@ #include "app_ble_service.h" +#include "../../ify_hrs_protocol/heart_rate_sensor_protocol.h" #include "app_scheduler.h" +#include "board/board.h" +#include "board/board_battery_state.h" +#include "device_ctrl_service.h" +#include "heart_wave_sample_service.h" +#include "sample_data_manager_service.h" +#include "zble_module.h" #include "zdatachannel_service.h" #include "znordic.h" -static zdatachannel_init_t zdatachannle_init; +#include "znordic_device_info_mgr.h" static uint8_t rxbufcache[256]; -static bool is_rxbufcache_used = false; +static bool is_rxbufcache_used = false; // 接收到的消息是否正在被处理中 +static bool m_realtime_report_state = false; // 实时上报状态 + +static uint8_t m_txbuf[128]; +static uint8_t m_reportbuf[128]; static void prvf_process_ble_rx_data(void* p_event_data, uint16_t event_size); +static void process_ble_rx_data(void* p_event_data, uint16_t event_size); /******************************************************************************* * 蓝牙服务注册 * @@ -27,18 +39,236 @@ static void zdatachannel_data_handler(zdatachannel_evt_t* p_evt) { if (p_evt->params.rx_data.length > sizeof(rxbufcache)) return; memcpy(rxbufcache, p_evt->params.rx_data.p_data, p_evt->params.rx_data.length); - uint32_t suc = app_sched_event_put(rxbufcache, p_evt->params.rx_data.length, prvf_process_ble_rx_data); + uint32_t suc = app_sched_event_put(rxbufcache, p_evt->params.rx_data.length, process_ble_rx_data); if (suc == 0) { is_rxbufcache_used = true; } } +/******************************************************************************* + * UTILS * + *******************************************************************************/ +int ble_start_realtime_report() { + m_realtime_report_state = true; + return 0; +} +int ble_stop_realtime_report() { + m_realtime_report_state = false; + return 0; +} + +static void send_error_receipt(ify_hrs_packet_t* rxpacket, int32_t errorcode) { + ify_hrs_packet_t* txheader = (ify_hrs_packet_t*)m_txbuf; + error_receipt_t* receipt = (error_receipt_t*)txheader->data; + uint16_t sendlen = sizeof(ify_hrs_packet_t) + sizeof(error_receipt_t); + + txheader->cmd = rxpacket->cmd; + txheader->frame_index = rxpacket->frame_index; + txheader->frame_type = kifyhrs_pt_error_receipt; + + txheader->frame_type = kifyhrs_pt_error_receipt; + receipt->errorcode = kifyhrs_ecode_cmd_not_support; + zdatachannel_data_send2(m_txbuf, sendlen); +} + +static void send_success_receipt(ify_hrs_packet_t* rxpacket, int32_t emptydatasize) { + ify_hrs_packet_t* txheader = (ify_hrs_packet_t*)m_txbuf; + uint16_t sendlen = sizeof(ify_hrs_packet_t) + emptydatasize; + + txheader->cmd = rxpacket->cmd; + txheader->frame_index = rxpacket->frame_index; + txheader->frame_type = kifyhrs_pt_cmd_receipt; + + zdatachannel_data_send2(m_txbuf, sendlen); +} /******************************************************************************* * 消息处理 * *******************************************************************************/ -static void prvf_process_ble_rx_data(void* p_event_data, uint16_t data_size) { +static void process_ble_rx_data(void* p_event_data, uint16_t event_size) { // + prvf_process_ble_rx_data(p_event_data, event_size); + is_rxbufcache_used = false; +} + +static void prvf_process_ble_rx_data(void* p_event_data, uint16_t len) { + ify_hrs_packet_t* rxheader = (ify_hrs_packet_t*)p_event_data; + ify_hrs_packet_t* txheader = (ify_hrs_packet_t*)m_txbuf; + ify_hrs_cmd_t cmd = (ify_hrs_cmd_t)rxheader->cmd; + memset(m_txbuf, 0, sizeof(m_txbuf)); + ZLOGI("rx:"); - NRF_LOG_HEXDUMP_INFO(p_event_data, data_size); + NRF_LOG_HEXDUMP_INFO(p_event_data, len); + ZLOGI("rx cmd:%d index:%d datalen:%d", cmd, rxheader->frame_index, len - sizeof(ify_hrs_packet_t)); + + txheader->cmd = rxheader->cmd; + txheader->frame_index = rxheader->frame_index; + txheader->frame_type = kifyhrs_pt_cmd_receipt; + + NRF_LOG_HEXDUMP_INFO(rxheader->data, len - sizeof(ify_hrs_packet_t)); + + if (cmd == ify_hrs_cmd_read_device_version) { + device_version_info_receipt_t* receipt = (device_version_info_receipt_t*)txheader->data; + uint16_t sendlen = sizeof(ify_hrs_packet_t) + sizeof(device_version_info_receipt_t); + + receipt->blestack_version = device_info_read_blestack_version(); + receipt->bootloader_version = device_info_read_bootloader_version(); + receipt->firmware_version = device_info_read_firmware_version(); + receipt->hardware_version = device_info_read_hardware_version(); + zdatachannel_data_send2(m_txbuf, sendlen); + } + + else if (cmd == ify_hrs_cmd_read_sensor_info) { + sensor_info_receipt_t* receipt = (sensor_info_receipt_t*)txheader->data; + uint16_t sendlen = sizeof(ify_hrs_packet_t) + sizeof(sensor_info_receipt_t); + + receipt->sensor_num = 1; + receipt->sensor_precision = SAMPLE_PRECISION; + receipt->sensor_sample_rate = SAMPLE_RATE / 10; + receipt->sensor0_pos = kifyhrs_sensor_pos_II; + receipt->sensor1_pos = kifyhrs_sensor_pos_V1; + receipt->sensor2_pos = kifyhrs_sensor_pos_V5; + + zdatachannel_data_send2(m_txbuf, sendlen); + } + + else if (cmd == ify_hrs_cmd_read_device_state) { + device_state_receipt_t* receipt = (device_state_receipt_t*)txheader->data; + uint16_t sendlen = sizeof(ify_hrs_packet_t) + sizeof(device_state_receipt_t); + + receipt->drop_state0 = hwss_get_drop_state0(); + receipt->drop_state1 = hwss_get_drop_state1(); + + receipt->drop_state1 = 0x00; + receipt->device_state0.sampling_state = (DeviceCtrl_now_state() == kdevice_state_sampling); + receipt->device_state0.report_state = m_realtime_report_state; + receipt->device_state0.low_battery = (BoardBattery_get_battery_level() < 20); + receipt->device_state0.full_storge = (sample_data_mgr_storage_is_full()); + + receipt->device_state1 = 0; + receipt->powerlevel = BoardBattery_get_battery_level(); + receipt->storage_item_num = sample_data_mgr_get_file_num(); + + zdatachannel_data_send2(m_txbuf, sendlen); + } + + else if (cmd == ify_hrs_cmd_read_time) { + read_time_receipt_t* receipt = (read_time_receipt_t*)txheader->data; + uint16_t sendlen = sizeof(ify_hrs_packet_t) + sizeof(read_time_receipt_t); + static ztm_t ztm; + znordic_rtc_gettime(&ztm); + + receipt->year = (ztm.tm_year + 1900 - 2000); + receipt->month = ztm.tm_mon + 1; + receipt->day = ztm.tm_mday; + receipt->hour = ztm.tm_hour; + receipt->minute = ztm.tm_min; + receipt->second = ztm.tm_sec; + zdatachannel_data_send2(m_txbuf, sendlen); + } + + else if (cmd == ify_hrs_cmd_sync_time) { + sync_time_cmd_t* cmd = (sync_time_cmd_t*)rxheader->data; + uint16_t sendlen = sizeof(ify_hrs_packet_t); + + znordic_rtc_settime(cmd->year + 2000, cmd->month, cmd->day, cmd->hour, cmd->minute, cmd->second); + zdatachannel_data_send2(m_txbuf, sendlen); + } + + else if (cmd == ify_hrs_cmd_start_capture) { + hwss_start_capture(); + send_success_receipt(rxheader, 0); + } + + else if (cmd == ify_hrs_cmd_stop_capture) { + hwss_stop_capture(); + send_success_receipt(rxheader, 0); + } + + else if (cmd == ify_hrs_cmd_start_realtime_report) { + // unsupport cmd + int ecode = ble_start_realtime_report(); + if (ecode == 0) { + send_success_receipt(rxheader, 8); // 凑8个字节,使这个回执的字节长度同上报包长度一致,方便调试 + } else { + send_error_receipt(rxheader, ecode); + } + } + + else if (cmd == ify_hrs_cmd_stop_realtime_report) { + int ecode = ble_stop_realtime_report(); + if (ecode == 0) { + send_success_receipt(rxheader, 0); + } else { + send_error_receipt(rxheader, ecode); + } + } + + else if (cmd == ify_hrs_cmd_read_records_info) { + // 指令 10-读取采样记录头部信息 + read_record_info_cmd_t* cmd = (read_record_info_cmd_t*)rxheader->data; + read_record_info_receipt_t* receipt = (read_record_info_receipt_t*)txheader->data; + uint16_t sendlen = sizeof(ify_hrs_packet_t) + sizeof(read_record_info_receipt_t); + + uint8_t recordoff = cmd->record_index; + + // 采样时不支持 + if (hwss_is_capturing()) { + send_error_receipt(rxheader, kifyhrs_ecode_device_busy); + return; + } + + sample_data_fileinfo_list_t* recordlist = sample_data_mgr_get_fileinfo_list(); + if (recordoff >= recordlist->count) { + send_error_receipt(rxheader, kifyhrs_ecode_no_record_find); + return; + } + + sample_data_fileinfo_t* fileinfo = recordlist->fileinfo[recordoff]; + memcpy(receipt->record_id, fileinfo->filename, 6); + receipt->frameNum = fileinfo->size / 2; // 2byte per frame + receipt->dataSize = fileinfo->size; + receipt->sensorNum = 1; + receipt->captureRate = SAMPLE_RATE / 10; + receipt->capturePrecision = SAMPLE_PRECISION; + receipt->compressAlgorithm = 0; + + zdatachannel_data_send2(m_txbuf, sendlen); + + } + + else if (cmd == ify_hrs_cmd_del_record) { + // 指令 11-删除采样记录 + del_record_cmd_t* cmd = (del_record_cmd_t*)rxheader->data; + + static sample_data_filename_t filename; + memset(&filename, 0, sizeof(filename)); + memcpy(&filename, cmd->record_id, sizeof(cmd->record_id)); + + send_error_receipt(rxheader, kifyhrs_ecode_cmd_not_support); + } + + else if (cmd == ify_hrs_cmd_start_upload_record) { + // 指令 12-上传采集记录 + send_error_receipt(rxheader, kifyhrs_ecode_cmd_not_support); + } + + else if (cmd == ify_hrs_cmd_enter_ota) { + send_error_receipt(rxheader, kifyhrs_ecode_cmd_not_support); + } + + else if (cmd == ify_hrs_cmd_read_sn) { + read_sn_receipt_t* receipt = (read_sn_receipt_t*)txheader->data; + uint16_t sendlen = sizeof(ify_hrs_packet_t) + sizeof(read_sn_receipt_t); + device_info_read_sn((sn_t*)&receipt->sn); + zdatachannel_data_send2(m_txbuf, sendlen); + } + + else if (cmd == ify_hrs_cmd_reset) { + NVIC_SystemReset(); + } + // + else { + send_error_receipt(rxheader, kifyhrs_ecode_cmd_not_support); + } } void AppBleService_startAdv() { zble_module_start_adv(); } @@ -46,7 +276,7 @@ void AppBleService_stopAdv() { zble_module_stop_adv(); } void AppBleService_onServiceInitCB() { ZLOGI("init zdatachannel service"); - zdatachannel_init_t zdatachannle_init; + static zdatachannel_init_t zdatachannle_init; memset(&zdatachannle_init, 0, sizeof(zdatachannle_init)); zdatachannle_init.data_handler = zdatachannel_data_handler; ZERROR_CHECK(zdatachannel_init(&m_zhrs, &zdatachannle_init)); diff --git a/app/src/app_ble_service.h b/app/src/app_ble_service.h index 761a2b2..2f5d92c 100644 --- a/app/src/app_ble_service.h +++ b/app/src/app_ble_service.h @@ -7,7 +7,12 @@ */ void AppBleService_onServiceInitCB(); - void AppBleService_init(); void AppBleService_uninit(); + void AppBleService_startAdv(); +void AppBleService_stopAdv(); + +void AppBleService_try_report_one_sample_data(uint32_t frameIndex, uint16_t data); +void AppBleService_try_report_sensor_drop_event(uint8_t dropstate0, uint8_t dropstate1); +void AppBleService_report_sample_finish_event(); diff --git a/app/src/app_event_distribute.c b/app/src/app_event_distribute.c new file mode 100644 index 0000000..daecda0 --- /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(AppEventListener* listener) { // + m_listener[m_listener_num] = *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..855b405 --- /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(AppEventListener* listener); +void AppEvent_pushEvent(app_event_t* event); diff --git a/app/src/main.bak.c b/app/src/bak/main.bak.c similarity index 100% rename from app/src/main.bak.c rename to app/src/bak/main.bak.c diff --git a/app/src/basic/ads1293/ads1293.c b/app/src/basic/ads1293/ads1293.c index 8016b43..f2ecc4b 100644 --- a/app/src/basic/ads1293/ads1293.c +++ b/app/src/basic/ads1293/ads1293.c @@ -101,6 +101,11 @@ void ads1293_start_conversion(ads1293_t* ads) { data = 0x01; ads1293_spi_writereg(ads, TI_ADS1293_CONFIG_REG, data); } +void ads1293_stop_conversion(ads1293_t* ads) { + uint8_t data = 0; + data = 0x04; + ads1293_spi_writereg(ads, TI_ADS1293_CONFIG_REG, data); +} void ads1293_start_power_off(ads1293_t* ads) { uint8_t data = 0; data |= 0x01 << 2; @@ -108,14 +113,3 @@ void ads1293_start_power_off(ads1293_t* ads) { } uint8_t ads1293_read_error_lod(ads1293_t* ads) { return ads1293_spi_readreg(ads, TI_ADS1293_ERROR_LOD_REG); } - -void ads1293_start_conversion(ads1293_t* ads) { - uint8_t data = 0; - data = 0x01; - ads1293_spi_writereg(ads, TI_ADS1293_CONFIG_REG, data); -} -void ads1293_stop_conversion(ads1293_t* ads){ - uint8_t data = 0; - data = 0x04; - ads1293_spi_writereg(ads, TI_ADS1293_CONFIG_REG, data); -} \ No newline at end of file diff --git a/app/src/basic/heart_rate_sensor_protocol.h b/app/src/basic/heart_rate_sensor_protocol.h deleted file mode 100644 index 7b59e3e..0000000 --- a/app/src/basic/heart_rate_sensor_protocol.h +++ /dev/null @@ -1,190 +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, -} ify_hrs_error_code_t; - -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_V5 = 5, // V5 -} 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_capture = 6, - ify_hrs_cmd_stop_capture = 7, - ify_hrs_cmd_start_realtime_report = 8, - ify_hrs_cmd_stop_realtime_report = 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_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_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 { - struct { - uint8_t sensor0_pos : 1; // 位置 - uint8_t sensor1_pos : 1; // 位置 - uint8_t sensor2_pos : 1; // 位置 - uint8_t sensor3_pos : 1; // 位置 - uint8_t sensor4_pos : 1; // 位置 - uint8_t sensor5_pos : 1; // 位置 - uint8_t sensor6_pos : 1; // 位置 - uint8_t sensor7_pos : 1; // 位置 - } 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 holder : 4; // 位置 - } device_state0; - uint8_t device_state1; // 预留 - uint8_t powerlevel; // 电量 - uint8_t storage_item_num; // 记录存储条数 -} 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; // 压缩算法 -} 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; - - uint8_t drop_state0; - uint8_t drop_state1; -} sensor_drop_event_report_packet_t; - -#pragma pack(pop) diff --git a/app/src/board/board.h b/app/src/board/board.h index 28f4bb0..cf213b9 100644 --- a/app/src/board/board.h +++ b/app/src/board/board.h @@ -58,4 +58,10 @@ #define HEART_WAVE_SAMPLE_SERVICE_CACHE_SIZE (3 * 3 * 256) #define FILE_MAX_COUNT 1 -#define SDCARD_MAX_FILE_SIZE (4 * 1024 * 1024) \ No newline at end of file +#define SDCARD_MAX_FILE_SIZE (4 * 1024 * 1024) +// +#define SAMPLE_RATE 800 +#define SAMPLE_PRECISION 24 + +#define APP_MAX_EVEN_SIZE MAX(APP_TIMER_SCHED_EVENT_DATA_SIZE,sizeof(app_event_t)) +#define APP_EVENT_QUEUE_SIZE 20 \ No newline at end of file diff --git a/app/src/board/board_battery_state.h b/app/src/board/board_battery_state.h index fb19830..53bef76 100644 --- a/app/src/board/board_battery_state.h +++ b/app/src/board/board_battery_state.h @@ -11,5 +11,4 @@ void BoardBattery_load(); void BoardBattery_unload(); int16_t BoardBattery_get_adc_val(); -int16_t BoardBattery_val(); int16_t BoardBattery_get_battery_level(); // 0->100 diff --git a/app/src/board/board_beep_ctrl.c b/app/src/board/board_beep_ctrl.c index 8eb2e21..6c156ae 100644 --- a/app/src/board/board_beep_ctrl.c +++ b/app/src/board/board_beep_ctrl.c @@ -20,7 +20,7 @@ static nrf_drv_pwm_config_t const m_beep_pwm0_config0 = { .step_mode = NRF_PWM_STEP_AUTO, }; BoardBeepEffect_t m_beep_effect = kBoardBeepEffect_none; -static m_beep_cnt = 0; +static uint32_t m_beep_cnt = 0; static void beep_tmr_handler(void *context) { if (m_beep_effect == kBoardBeepEffect_none) { diff --git a/app/src/board/board_button.c b/app/src/board/board_button.c index 65c620f..56d5eba 100644 --- a/app/src/board/board_button.c +++ b/app/src/board/board_button.c @@ -7,12 +7,17 @@ #define BUTTON_DETECTION_DELAY APP_TIMER_TICKS(50) static board_button_cb_t m_cb; // -void button_process_handler(uint8_t pin_no, uint8_t button_action) {} +void button_process_handler(uint8_t pin_no, uint8_t button_action) { + if (m_cb) { + m_cb(kButton_mainButton, (ButtonAction_t)button_action); + } +} static app_button_cfg_t buttons[] = { {BUTTON_PIN, false, NRF_GPIO_PIN_PULLUP, button_process_handler}, }; void BoardButton_Init(board_button_cb_t cb) { // + m_cb = cb; ZASSERT(app_button_init(buttons, ARRAY_SIZE(buttons), BUTTON_DETECTION_DELAY)); } void BoardButton_load() { ZASSERT(app_button_enable()); } diff --git a/app/src/board/board_button.h b/app/src/board/board_button.h index 705c830..74ea7a2 100644 --- a/app/src/board/board_button.h +++ b/app/src/board/board_button.h @@ -9,7 +9,12 @@ typedef enum { kButton_mainButton, } ButtonIndex_t; -typedef void (*board_button_cb_t)(ButtonIndex_t pin_no, uint8_t button_action); +typedef enum { + kButtonAction_push = 1, + kButtonAction_release = 0, +} ButtonAction_t; + +typedef void (*board_button_cb_t)(ButtonIndex_t pin_no, ButtonAction_t button_action); void BoardButton_Init(board_button_cb_t cb); // main中初始化一遍 void BoardButton_load(); diff --git a/app/src/board/board_sdcard_driver.c b/app/src/board/board_sdcard_driver.c index 98fd49b..9b25798 100644 --- a/app/src/board/board_sdcard_driver.c +++ b/app/src/board/board_sdcard_driver.c @@ -5,13 +5,9 @@ /******************************************************************************* * 结构体定义 * *******************************************************************************/ -typedef enum { - kConnectToInternal, - kConnectToExt, -} ConnectTo_t; FATFS m_fs; -ConnectTo_t m_connectTo = kConnectToNone; +BoardSdcardConnectTo_t m_connectTo = kConnectToNone; static bool m_sdcard_inited; NRF_BLOCK_DEV_SDC_DEFINE( // diff --git a/app/src/device_ctrl_service.c b/app/src/device_ctrl_service.c new file mode 100644 index 0000000..256efd2 --- /dev/null +++ b/app/src/device_ctrl_service.c @@ -0,0 +1,18 @@ +#include "device_ctrl_service.h" + +static device_state_t m_device_state = kdevice_state_standby; // 设备状态 +static uint32_t m_change_to_cur_state_tp = 0; // 切换到当前状态的时间戳 + +void DeviceCtrl_change_to_state(device_state_t state) { + ZLOGI("change state from %s to %s", ds2str(m_device_state), ds2str(state)); + m_device_state = state; + m_change_to_cur_state_tp = znordic_getpower_on_ms(); +} +uint32_t DeviceCtrl_cur_state_haspassed_ms() { return znordic_haspassed_ms(m_change_to_cur_state_tp); } +device_state_t DeviceCtrl_now_state() { return m_device_state; } + +void DeviceCtrl_startSample() {} +void DeviceCtrl_stopSample() {} +void DeviceCtrl_schdeule() {} + +void DeviceCtrl_init() {} diff --git a/app/src/device_ctrl_service.h b/app/src/device_ctrl_service.h new file mode 100644 index 0000000..42549e5 --- /dev/null +++ b/app/src/device_ctrl_service.h @@ -0,0 +1,44 @@ +/** + * @file device_ctrl_service.h + * @author zhaohe (h_zhaohe@domain.com) + * @brief 设备控制服务 + * @version 0.1 + * @date 2024-02-01 + * + * @copyright Copyright (c) 2024 + * + */ +#pragma once +#include "znordic.h" + +typedef enum { + // 待机 + kdevice_state_standby = 0, + // Ready + kdevice_state_ready = 1, + // sample + kdevice_state_sampling = 2, +} device_state_t; + +static const char* ds2str(device_state_t ds) { + switch (ds) { + case kdevice_state_standby: + return "standby"; + case kdevice_state_ready: + return "ready"; + case kdevice_state_sampling: + return "sampling"; + default: + return "unknown"; + } +} + +void DeviceCtrl_change_to_state(device_state_t state); +uint32_t DeviceCtrl_cur_state_haspassed_ms(); +device_state_t DeviceCtrl_now_state(); + +void DeviceCtrl_startSample(); +void DeviceCtrl_stopSample(); +void DeviceCtrl_schdeule(); + +void DeviceCtrl_init() ; diff --git a/app/src/device_state.c b/app/src/device_state.c deleted file mode 100644 index 77c8394..0000000 --- a/app/src/device_state.c +++ /dev/null @@ -1,14 +0,0 @@ - -#include "device_state.h" - -#include "znordic.h" -static device_state_t m_device_state = kdevice_state_standby; // 设备状态 -static uint32_t m_change_to_cur_state_tp = 0; // 切换到当前状态的时间戳 - -void ds_change_to_state(device_state_t state) { - ZLOGI("change state from %s to %s", device_state_to_str(m_device_state), device_state_to_str(state)); - m_device_state = state; - m_change_to_cur_state_tp = znordic_getpower_on_ms(); -} -uint32_t ds_cur_state_haspassed_ms() { return znordic_haspassed_ms(m_change_to_cur_state_tp); } -device_state_t ds_now_state() { return m_device_state; } diff --git a/app/src/device_state.h b/app/src/device_state.h deleted file mode 100644 index b322f9e..0000000 --- a/app/src/device_state.h +++ /dev/null @@ -1,28 +0,0 @@ -#pragma once -#include -#include -typedef enum { - // 待机 - kdevice_state_standby = 0, - // Ready - kdevice_state_ready = 1, - // sample - kdevice_state_sampling = 2, -} device_state_t; - -static const char* ds2str(device_state_t ds) { - switch (ds) { - case kdevice_state_standby: - return "standby"; - case kdevice_state_ready: - return "ready"; - case kdevice_state_sampling: - return "sampling"; - default: - return "unknown"; - } -} - -void ds_change_to_state(device_state_t state); -uint32_t ds_cur_state_haspassed_ms(); -device_state_t ds_now_state(); \ No newline at end of file diff --git a/app/src/heart_wave_sample_service.c b/app/src/heart_wave_sample_service.c index dc7f48c..129ebda 100644 --- a/app/src/heart_wave_sample_service.c +++ b/app/src/heart_wave_sample_service.c @@ -4,6 +4,7 @@ // #include "app_button.h" #include "app_event.h" +#include "app_event_distribute.h" #include "basic/ads1293/ads1293.h" #include "nrf_drv_gpiote.h" #include "nrfx_timer.h" @@ -95,7 +96,7 @@ static inline void prvf_trigger_capture_data_block_event(uint8_t* data, int data event.eventType = kevent_capture_data_block_event; event.val.block_sensor_data.data = data; event.val.block_sensor_data.len = datalen; - app_sched_event_put(&event, sizeof(app_event_t), app_event_process_cb); + AppEvent_pushEvent(&event); } static inline void prvf_little_block_cache_push_one_frame(uint32_t data0, uint32_t data1, uint32_t data2) { @@ -120,7 +121,7 @@ static inline void prvf_light_block_trigger_event() { event.eventType = kevent_capture_little_data_block_event; memcpy(event.val.little_data_block.data, m_sensor_little_frame_cache, LITTLE_DATA_BLOCK_FRAME_NUM); event.val.little_data_block.frameIndex = m_frame_index - LITTLE_DATA_BLOCK_FRAME_NUM; - app_sched_event_put(&event, sizeof(app_event_t), app_event_process_cb); + AppEvent_pushEvent(&event); } static void ads1293_spi_tx_rx_0(uint8_t* tx, uint8_t* rx, uint8_t len) { if (!m_ads1293_driver_is_inited) { @@ -140,7 +141,20 @@ static void ads1293_spi_tx_rx_1(uint8_t* tx, uint8_t* rx, uint8_t len) { nrf_drv_spi_transfer(&spi, tx, len, rx, len); nrf_gpio_pin_set(ADS1293_SPI_CS1_PIN); } -static ads1293_init() { + +static void ads1293_spi_writereg_and_check(ads1293_t* ads, uint8_t addr, uint8_t data) { + uint8_t readbak = 0; + // readonly add + if (addr == 0x19 || addr == 0x1a || addr == 0x1b || addr == 0x1c || addr == 0x40 || addr == 0x30) { + return; + } + ads1293_spi_writereg_and_readbak(ads, addr, data, &readbak); + if (readbak != data) { + ZLOGE("ads_%d write %x failed,w:%x readbak:%x\n", ads->id, addr, data, readbak); + } +} + +static void ads1293_init() { /******************************************************************************* * SPI初始化 * *******************************************************************************/ @@ -249,7 +263,7 @@ static void ads1293_ready_pin_irq(nrfx_gpiote_pin_t pin, nrf_gpiote_polarity_t a } } -static ads1293_uninit() { +static void ads1293_uninit() { hwss_stop_capture(); m_ads1293_driver_is_inited = false; nrf_drv_spi_uninit(&spi); @@ -277,4 +291,9 @@ void hwss_stop_capture(void) { m_work_flag = false; ads1293_stop_conversion(&m_ads1293_0); ads1293_stop_conversion(&m_ads1293_1); -} \ No newline at end of file +} + +bool hwss_is_capturing(void) { return m_work_flag; } + +uint8_t hwss_get_drop_state0() { return 0; } +uint8_t hwss_get_drop_state1() { return 0; } \ No newline at end of file diff --git a/app/src/heart_wave_sample_service.h b/app/src/heart_wave_sample_service.h index d569724..015f89d 100644 --- a/app/src/heart_wave_sample_service.h +++ b/app/src/heart_wave_sample_service.h @@ -28,4 +28,9 @@ void hwss_start_capture(void); /** * @brief 停止采集 */ -void hwss_stop_capture(void); \ No newline at end of file +void hwss_stop_capture(void); + +bool hwss_is_capturing(void); + +uint8_t hwss_get_drop_state0(); +uint8_t hwss_get_drop_state1(); \ No newline at end of file diff --git a/app/src/main.c b/app/src/main.c index 0d8b1ed..ec85a9e 100644 --- a/app/src/main.c +++ b/app/src/main.c @@ -6,30 +6,23 @@ #include // #include "app_ble_service.h" +#include "app_event_distribute.h" #include "basic/ads1293/ads1293.h" +#include "board/board.h" #include "zble_module.h" #include "zdatachannel_service.h" #include "znordic_device_info_mgr.h" +#include "device_ctrl_service.h" // -APP_TIMER_DEF(state_machine_scheduler_tmr); -static void test_tx_timer_cb(void* p_context) { // - ZLOGI("test_tx_timer_cb"); - ThreeLeadECG_led_green_toggle(); -} int main() { - APP_SCHED_INIT(APP_TIMER_SCHED_EVENT_DATA_SIZE, 20); + APP_SCHED_INIT(APP_MAX_EVEN_SIZE, APP_EVENT_QUEUE_SIZE); znordic_init(); - static zble_module_cfg_t cfg = // - { - .deviceName = "ThreeLeadECG", - .on_service_init = AppBleService_onServiceInitCB, - }; + static zble_module_cfg_t cfg; + cfg.deviceName = device_info_read_sn_str(); + cfg.on_service_init = AppBleService_onServiceInitCB; zble_module_init(&cfg); - AppBleService_startAdv(); - ThreeLeadECG_led_init(); - ZERROR_CHECK(app_timer_create(&state_machine_scheduler_tmr, APP_TIMER_MODE_REPEATED, test_tx_timer_cb)); - ZERROR_CHECK(app_timer_start(state_machine_scheduler_tmr, APP_TIMER_TICKS(1000), NULL)); NRF_LOG_INFO("compile time :%s", __TIME__); + DeviceCtrl_init(); znordic_loop(); } diff --git a/app/src/sample_data_manager_service.c b/app/src/sample_data_manager_service.c index 4d74b02..6c2cbf4 100644 --- a/app/src/sample_data_manager_service.c +++ b/app/src/sample_data_manager_service.c @@ -39,12 +39,13 @@ static void read_file_info() { if (ff_result == FR_OK) { static sample_data_filename_t _filename; - _filename.year = (fno.fdate >> 9) + 1980 - 2000; - _filename.month = (fno.fdate >> 5) & 0x0F; - _filename.day = fno.fdate & 0x1F; - _filename.hour = (fno.ftime >> 11); - _filename.min = (fno.ftime >> 5) & 0x3F; - _filename.sec = (fno.ftime & 0x1F) * 2; + _filename.year = (fno.fdate >> 9) + 1980 - 2000; + _filename.month = (fno.fdate >> 5) & 0x0F; + _filename.day = fno.fdate & 0x1F; + _filename.hour = (fno.ftime >> 11); + _filename.min = (fno.ftime >> 5) & 0x3F; + _filename.sec = (fno.ftime & 0x1F) * 2; + memcpy(m_sample_fileinfo_list.fileinfo[0]->filename, &_filename, sizeof(sample_data_filename_t)); m_sample_fileinfo_list.fileinfo[0]->size = fno.fsize; m_sample_fileinfo_list.count = 1; } else { diff --git a/libznordic b/libznordic index 2e46516..7eee0f9 160000 --- a/libznordic +++ b/libznordic @@ -1 +1 @@ -Subproject commit 2e46516dec82a92dd796312c6787f35e5adf7922 +Subproject commit 7eee0f956b26dd0870837349b6ae9d237dabf031