diff --git a/.gitmodules b/.gitmodules index c421e80..50404d1 100644 --- a/.gitmodules +++ b/.gitmodules @@ -12,4 +12,7 @@ url = zwsd@192.168.1.3:p_oximeter/oximeter_libznordic.git [submodule "protocol"] path = protocol - url = zwsd@192.168.1.3:p_oximeter/oximeter_protocol.git \ No newline at end of file + url = zwsd@192.168.1.3:p_oximeter/oximeter_protocol.git +[submodule "oximeter_ble_server"] + path = oximeter_ble_server + url = zwsd@192.168.1.3:p_oximeter/oximeter_ble_server.git diff --git a/.vscode/settings.json b/.vscode/settings.json index ac9e849..6e445af 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -51,7 +51,7 @@ "app_sdcard.h": "c", "diskio_blkdev.h": "c", "three_conduction_main.h": "c", - "one_conduction_main.h": "c", + "app_main.h": "c", "one_conduction_board.h": "c", "driver_ssd1306.h": "c", "driver_ssd1306_font.h": "c", @@ -218,7 +218,9 @@ "nrf_fstorage.h": "c", "zdata_statistics.h": "c", "iflytop_simple_filter.h": "c", - "state.h": "c" + "state.h": "c", + "light_ctrl.h": "c", + "ble_data_processer_utils.h": "c" }, "files.encoding": "gbk" } \ No newline at end of file diff --git a/app/app.uvoptx b/app/app.uvoptx index af01a7a..c8dff8b 100644 --- a/app/app.uvoptx +++ b/app/app.uvoptx @@ -398,8 +398,8 @@ 0 0 0 - .\src\one_conduction_main.c - one_conduction_main.c + .\src\app_main.c + app_main.c 0 0 diff --git a/app/app.uvprojx b/app/app.uvprojx index 0991492..eeeb51a 100644 --- a/app/app.uvprojx +++ b/app/app.uvprojx @@ -394,9 +394,9 @@ .\src\main.c - one_conduction_main.c + app_main.c 1 - .\src\one_conduction_main.c + .\src\app_main.c zapp.c @@ -4313,9 +4313,9 @@ .\src\main.c - one_conduction_main.c + app_main.c 1 - .\src\one_conduction_main.c + .\src\app_main.c zapp.c diff --git a/app/src/app_basic_service/basic/event.h b/app/src/app_basic_service/basic/event.h index 5d1deaa..586650d 100644 --- a/app/src/app_basic_service/basic/event.h +++ b/app/src/app_basic_service/basic/event.h @@ -3,7 +3,7 @@ #include #include "aproject_config/config.h" -#include "ify_hrs_protocol/heart_rate_sensor_protocol.h" +#include "protocol/oximeter_ble_protocol.h" #define ECG_DATA_REPORT_FRAME_NUM 50 // ecg每次上报的帧数 diff --git a/app/src/one_conduction_main.c b/app/src/app_main.c similarity index 99% rename from app/src/one_conduction_main.c rename to app/src/app_main.c index ddd53e2..355b10f 100644 --- a/app/src/one_conduction_main.c +++ b/app/src/app_main.c @@ -2,7 +2,7 @@ #include #include "aproject_config/config.h" -#include "ify_hrs_protocol/heart_rate_sensor_protocol.h" +#include "protocol/oximeter_ble_protocol.h" #include "zdatachannel_service.h" // #include "app_basic_service/device_version_info_mgr.h" @@ -449,12 +449,12 @@ void on_state_change(state_machine_event_t event, device_state_t state) { } } -void one_conduction_main() { +void app_main() { device_info_init(); sn_t sn; device_info_read_sn(&sn); - ZLOGI("one_conduction_main %s active:%d", sn.sn, device_info_get_active_flag()); + ZLOGI("app_main %s active:%d", sn.sn, device_info_get_active_flag()); ZLOG_FLUSH(); zapp_ebus_reg_event_listener(on_zapp_ebus_event); diff --git a/app/src/one_conduction_main.h b/app/src/app_main.h similarity index 77% rename from app/src/one_conduction_main.h rename to app/src/app_main.h index 2323c0c..4f960c8 100644 --- a/app/src/one_conduction_main.h +++ b/app/src/app_main.h @@ -1,5 +1,5 @@ #pragma once #include -void one_conduction_main(); +void app_main(); void one_conduction_process_rx_packet(uint8_t* rx, int len); diff --git a/app/src/ble_data_processer_utils.c b/app/src/ble_data_processer_utils.c index 5d40f89..ddd64d8 100644 --- a/app/src/ble_data_processer_utils.c +++ b/app/src/ble_data_processer_utils.c @@ -1,6 +1,6 @@ #include "ble_data_processer_utils.h" -#include "ify_hrs_protocol/heart_rate_sensor_protocol.h" +#include "protocol/oximeter_ble_protocol.h" #include "zdatachannel_service.h" static uint8_t _bletxbuf[BLE_MSG_BUF_SIZE]; diff --git a/app/src/ble_data_processer_utils.h b/app/src/ble_data_processer_utils.h index d8bf726..d621437 100644 --- a/app/src/ble_data_processer_utils.h +++ b/app/src/ble_data_processer_utils.h @@ -2,7 +2,7 @@ #include #include "app_basic_service/zapp.h" -#include "ify_hrs_protocol/heart_rate_sensor_protocol.h" +#include "protocol/oximeter_ble_protocol.h" #define BLE_MSG_BUF_SIZE 255 extern uint8_t bletxbuf[]; diff --git a/app/src/main.c b/app/src/main.c index 9af7164..0c7c7d1 100644 --- a/app/src/main.c +++ b/app/src/main.c @@ -10,7 +10,7 @@ #include "app_basic_service/zapp.h" #include "zble_module.h" #include "zdatachannel_service.h" -#include "one_conduction_main.h" +#include "app_main.h" // ZDATACHANNEL_DEF(m_zhrs, 2 /*优先级*/, 1 /*client num*/); // 蓝牙服务 /** @@ -77,7 +77,7 @@ int main() { /******************************************************************************* * 设备控制服务初始化 * *******************************************************************************/ - one_conduction_main(); + app_main(); /******************************************************************************* * LOOP * *******************************************************************************/ diff --git a/oximeter_ble_server b/oximeter_ble_server new file mode 160000 index 0000000..34a1c92 --- /dev/null +++ b/oximeter_ble_server @@ -0,0 +1 @@ +Subproject commit 34a1c922a7336ef7602e1aa54fb04334a3d7274a diff --git a/protocol b/protocol index 286f8bb..93ba9db 160000 --- a/protocol +++ b/protocol @@ -1 +1 @@ -Subproject commit 286f8bbe136357e72b72f7d3e2a5b0ad64e99710 +Subproject commit 93ba9dbc3fe99c97276ab9737a710911642dc2b8 diff --git a/scripter/build_app.bat b/scripter/build_app.bat index eb65bbb..e68574e 100644 --- a/scripter/build_app.bat +++ b/scripter/build_app.bat @@ -3,11 +3,12 @@ @REM 编译app call scripter\keil_build.bat app\app.uvprojx app\_build\app.hex +md output del output\app_whole.hex del output\app.zip -del output\one_lead_ecg_ads1291.zip -del output\one_lead_ecg_ads1291.hex +del output\oximeter_ble_client.zip +del output\oximeter_ble_client.hex @REM 检查是否编译成功 if not exist app\_build\app.hex ( @@ -59,5 +60,5 @@ del output\settings.hex del output\app.hex -copy /y output\app.zip output\one_lead_ecg_ads1291.zip -copy /y output\app_whole.hex output\one_lead_ecg_ads1291.hex +copy /y output\app.zip output\oximeter_ble_client.zip +copy /y output\app_whole.hex output\oximeter_ble_client.hex diff --git a/tools/one_lead_realtime_report_parser.cpp b/tools/one_lead_realtime_report_parser.cpp deleted file mode 100644 index 5b7910f..0000000 --- a/tools/one_lead_realtime_report_parser.cpp +++ /dev/null @@ -1,121 +0,0 @@ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -// -#include -// -#include -// -#include - -#pragma comment(lib, "ws2_32.lib") -#define PORT 8988 - -// #define EACH_FRAME_SIZE 180 -// #define DATA_NUM (EACH_FRAME_SIZE / 3) - -// 5A A5 -// 03 00 65 -// 05 00 00 00 -// 77 07 -// 80 07 -// 7F 07 -// 88 07 -// 8D 07 -// 5B B5 -#pragma pack(1) -typedef struct parse_packet_to_csv { - uint8_t h0; - uint8_t h1; - uint8_t header[3]; - uint8_t index[4]; - uint16_t data[5]; - uint8_t e0; - uint8_t e1; -}; -#pragma pack() - -#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0])) - -uint16_t chdatacache[5]; - -void parse_chdatacache(parse_packet_to_csv *packet) { - chdatacache[0] = packet->data[0]; - chdatacache[1] = packet->data[1]; - chdatacache[2] = packet->data[2]; - chdatacache[3] = packet->data[3]; - chdatacache[4] = packet->data[4]; -} - -int main(int argc, char *argv[]) { - /** - * @brief - * 打开raw.txt - * 读取raw.txt全部内容 - * 去掉换行,空格,回车 - * 将16进制字符串转换成二进制 - * 写入raw.bin - */ - - std::ifstream ifs("Data.txt"); - std::string str((std::istreambuf_iterator(ifs)), std::istreambuf_iterator()); - ifs.close(); - - std::string str2; - for (auto &c : str) { - if (c == ' ' || c == '\n' || c == '\r') { - continue; - } - str2.push_back(c); - } - - std::ofstream ofs("Data.bin", std::ios::binary); - for (size_t i = 0; i < str2.size(); i += 2) { - std::string str3 = str2.substr(i, 2); - char c = (char)std::stoi(str3, nullptr, 16); - ofs.write(&c, 1); - } - ofs.close(); - - /** - * @brief - * 解析上报文件 - */ - - { - std::ifstream ifs("Data.bin", std::ios::binary); - std::vector buffer((std::istreambuf_iterator(ifs)), std::istreambuf_iterator()); - ifs.close(); - - printf("buffer.size() = %d\n", buffer.size()); - std::ofstream ofs("Data.csv"); - for (size_t i = 0; i < buffer.size();) { - parse_packet_to_csv *packet = (parse_packet_to_csv *)&buffer[i]; - - if (packet->h0 == 0x5A && packet->h1 == 0xA5 && packet->e0 == 0x5B && packet->e1 == 0xB5) { - parse_chdatacache(packet); - for (size_t i = 0; i < ARRAY_SIZE(chdatacache); i += 1) { - ofs << chdatacache[i] << "\n"; - } - i += sizeof(parse_packet_to_csv); - } else { - i++; - } - } - } - - printf("parse over\n"); - - while (true) { - std::this_thread::sleep_for(std::chrono::seconds(1)); - } -} \ No newline at end of file diff --git a/tools/one_lead_realtime_report_parser.exe b/tools/one_lead_realtime_report_parser.exe deleted file mode 100644 index f42f8bb..0000000 Binary files a/tools/one_lead_realtime_report_parser.exe and /dev/null differ diff --git a/tools/one_lead_upload_packet_parser.cpp b/tools/one_lead_upload_packet_parser.cpp deleted file mode 100644 index ac5d5b3..0000000 --- a/tools/one_lead_upload_packet_parser.cpp +++ /dev/null @@ -1,102 +0,0 @@ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -// -#include -// -#include -// -#include - -#pragma comment(lib, "ws2_32.lib") -#define PORT 8988 - -// #define EACH_FRAME_SIZE 180 -// #define DATA_NUM (EACH_FRAME_SIZE / 3) - -typedef struct parse_packet_to_csv { - uint8_t h0; - uint8_t h1; - uint8_t data[128]; - uint8_t e0; - uint8_t e1; -}; - -uint32_t chdatacache[64]; -void parse_chdatacache(parse_packet_to_csv *packet) { - for (size_t i = 0; i < 64; i++) { - chdatacache[i] = (packet->data[i * 2]) | (packet->data[i * 2 + 1] << 8); - } -} - -int main(int argc, char *argv[]) { - /** - * @brief - * 打开raw.txt - * 读取raw.txt全部内容 - * 去掉换行,空格,回车 - * 将16进制字符串转换成二进制 - * 写入raw.bin - */ - - std::ifstream ifs("Data.txt"); - std::string str((std::istreambuf_iterator(ifs)), std::istreambuf_iterator()); - ifs.close(); - - std::string str2; - for (auto &c : str) { - if (c == ' ' || c == '\n' || c == '\r') { - continue; - } - str2.push_back(c); - } - - std::ofstream ofs("Data.bin", std::ios::binary); - for (size_t i = 0; i < str2.size(); i += 2) { - std::string str3 = str2.substr(i, 2); - char c = (char)std::stoi(str3, nullptr, 16); - ofs.write(&c, 1); - } - ofs.close(); - - /** - * @brief - * 解析上报文件 - */ - - { - std::ifstream ifs("Data.bin", std::ios::binary); - std::vector buffer((std::istreambuf_iterator(ifs)), std::istreambuf_iterator()); - ifs.close(); - - printf("buffer.size() = %d\n", buffer.size()); - std::ofstream ofs("Data.csv"); - for (size_t i = 0; i < buffer.size();) { - parse_packet_to_csv *packet = (parse_packet_to_csv *)&buffer[i]; - parse_chdatacache(packet); - if (packet->h0 == 0x4A && packet->h1 == 0xA4 && packet->e0 == 0x4B && packet->e1 == 0xB4) { - for (size_t i = 0; i < 64; i += 1) { - ofs << chdatacache[i] << "\n"; - } - i += sizeof(parse_packet_to_csv); - } else { - i++; - } - } - } - - printf("parse over\n"); - - while (true) { - std::this_thread::sleep_for(std::chrono::seconds(1)); - } -} \ No newline at end of file diff --git a/tools/one_lead_upload_packet_parser.exe b/tools/one_lead_upload_packet_parser.exe deleted file mode 100644 index ebc8bcb..0000000 Binary files a/tools/one_lead_upload_packet_parser.exe and /dev/null differ diff --git a/tools/sample_bin_parse.cpp b/tools/sample_bin_parse.cpp deleted file mode 100644 index 2e74d50..0000000 --- a/tools/sample_bin_parse.cpp +++ /dev/null @@ -1,54 +0,0 @@ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -// -#include -// -#include -// -#include - -#pragma comment(lib, "ws2_32.lib") -#define PORT 8988 - -int main(int argc, char *argv[]) { - // 打开 0.bin - // 读取 0.bin 到数组中 - // 每次读9byte - // 3byte 3byte 3byte - // 存放到0.csv中 - - std::ifstream ifs("0.bin", std::ios::binary); - if (!ifs) { - std::cerr << "open 0.bin failed" << std::endl; - return -1; - } - - std::ofstream ofs("0.csv", std::ios::binary | std::ios::trunc); - if (!ofs) { - std::cerr << "open 0.csv failed" << std::endl; - return -1; - } - - char buf[9]; - while (ifs.read(buf, 9)) { - unsigned int a = 0; - unsigned int b = 0; - unsigned int c = 0; - a = (unsigned char)buf[0] | (unsigned char)buf[1] << 8 | (unsigned char)buf[2] << 16; - b = (unsigned char)buf[3] | (unsigned char)buf[4] << 8 | (unsigned char)buf[5] << 16; - c = (unsigned char)buf[6] | (unsigned char)buf[7] << 8 | (unsigned char)buf[8] << 16; - ofs << a << "," << b << "," << c << std::endl; - } - - return 0; -} \ No newline at end of file diff --git a/tools/sample_bin_parse.exe b/tools/sample_bin_parse.exe deleted file mode 100644 index 514e45f..0000000 Binary files a/tools/sample_bin_parse.exe and /dev/null differ diff --git a/tools/text2bin.cpp b/tools/text2bin.cpp deleted file mode 100644 index 5dd2290..0000000 --- a/tools/text2bin.cpp +++ /dev/null @@ -1,54 +0,0 @@ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -// -#include -// -#include -// -#include - -#pragma comment(lib, "ws2_32.lib") -#define PORT 8988 - -int main(int argc, char *argv[]) { - /** - * @brief - * 打开raw.txt - * 读取raw.txt全部内容 - * 去掉换行,空格,回车 - * 将16进制字符串转换成二进制 - * 写入raw.bin - */ - - std::ifstream ifs("raw.txt"); - std::string str((std::istreambuf_iterator(ifs)), std::istreambuf_iterator()); - ifs.close(); - - std::string str2; - for (auto &c : str) { - if (c == ' ' || c == '\n' || c == '\r') { - continue; - } - str2.push_back(c); - } - - std::ofstream ofs("raw.bin", std::ios::binary); - for (size_t i = 0; i < str2.size(); i += 2) { - std::string str3 = str2.substr(i, 2); - char c = (char)std::stoi(str3, nullptr, 16); - ofs.write(&c, 1); - } - ofs.close(); - - return 0; -} \ No newline at end of file diff --git a/tools/text2bin.exe b/tools/text2bin.exe deleted file mode 100644 index 1c2ad77..0000000 Binary files a/tools/text2bin.exe and /dev/null differ