diff --git a/.gitignore b/.gitignore index 48a24aa52..8cd184c92 100644 --- a/.gitignore +++ b/.gitignore @@ -379,4 +379,3 @@ Makefile CMakeSettings.json ._.gitignore -build/ \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 88513dcc0..8e4807f7b 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,5 @@ cmake_minimum_required (VERSION 3.13) + project (brainflow) SET (CMAKE_CXX_STANDARD 11) @@ -20,6 +21,7 @@ option (USE_LIBFTDI "USE_LIBFTDI" OFF) option (USE_OPENMP "USE_OPENMP" OFF) option (WARNINGS_AS_ERRORS "WARNINGS_AS_ERRORS" OFF) option (BUILD_OYMOTION_SDK "BUILD_OYMOTION_SDK" OFF) +option (BUILD_SYNCHRONI_SDK "BUILD_SYNCHRONI_SDK" ON) option (BUILD_BLUETOOTH "BUILD_BLUETOOTH" OFF) option (BUILD_BLE "BUILD_BLE" OFF) option (BUILD_ONNX "BUILD_ONNX" OFF) @@ -51,6 +53,8 @@ if (BUILD_TESTS) include (${CMAKE_CURRENT_SOURCE_DIR}/src/tests/build.cmake) endif (BUILD_TESTS) +#add_subdirectory (${CMAKE_CURRENT_SOURCE_DIR}/cpp_package/examples/get_data) + include (CMakePackageConfigHelpers) write_basic_package_version_file ( @@ -72,4 +76,4 @@ install ( EXPORT ${TARGETS_EXPORT_NAME} NAMESPACE brainflow:: DESTINATION ${CONFIG_INSTALL_DIR} -) +) \ No newline at end of file diff --git a/conanfile.py b/conanfile.py index 18997e9e8..9c8e31bab 100644 --- a/conanfile.py +++ b/conanfile.py @@ -15,10 +15,10 @@ class BrainflowConan(ConanFile): # Binary configuration settings = "os", "compiler", "build_type", "arch" options = {"libftdi": [True, False], "openmp": [True, False], "onnx": [True, False], "bluetooth": [True, False], - "ble": [True, False], "periphery": [True, False], "oymotion": [True, False], + "ble": [True, False], "periphery": [True, False], "oymotion": [True, False],"synchroni": [True, False], "static_msvc_runtime": [True, False]} default_options = {"libftdi": False, "openmp": False, "onnx": True, "bluetooth": True, - "ble": True, "periphery": False, "oymotion": False, "static_msvc_runtime": True} + "ble": True, "periphery": False, "oymotion": False,"synchroni": True, "static_msvc_runtime": True} # Sources are located in the same place as this recipe, copy them to the recipe exports_sources = "CMakeLists.txt", "src/*", "third_party/*", "cpp_package/build.cmake", "cpp_package/src/*", "cmake/*" @@ -43,6 +43,11 @@ def build(self): cmake.definitions["BUILD_BLUETOOTH"] = "ON" if self.options.ble: cmake.definitions["BUILD_BLE"] = "ON" + if self.options.synchroni: + if self.settings.os == "Android": + cmake.definitions["BUILD_SYNCHRONI_SDK"] = "OFF" + else: + cmake.definitions["BUILD_SYNCHRONI_SDK"] = "ON" if self.settings.os != "Windows" and self.options.periphery: cmake.definitions["USE_PERIPHERY"] = "ON" if self.settings.os == "Windows" and self.options.oymotion: diff --git a/csharp_package/brainflow/brainflow/board_controller_library.cs b/csharp_package/brainflow/brainflow/board_controller_library.cs index 5e0ce5c14..7a5e60712 100644 --- a/csharp_package/brainflow/brainflow/board_controller_library.cs +++ b/csharp_package/brainflow/brainflow/board_controller_library.cs @@ -116,7 +116,13 @@ public enum BoardIds EXPLORE_PLUS_8_CHAN_BOARD = 54, EXPLORE_PLUS_32_CHAN_BOARD = 55, PIEEG_BOARD = 56, - NEUROPAWN_KNIGHT_BOARD = 57 + NEUROPAWN_KNIGHT_BOARD = 57, + SYNCHRONI_TRIO_3_CHANNELS_BOARD = 58, + SYNCHRONI_OCTO_8_CHANNELS_BOARD = 59, + OB5000_8_CHANNELS_BOARD = 60, + SYNCHRONI_PENTO_8_CHANNELS_BOARD = 61, + SYNCHRONI_UNO_1_CHANNELS_BOARD = 62, + }; diff --git a/java_package/brainflow/src/main/java/brainflow/BoardIds.java b/java_package/brainflow/src/main/java/brainflow/BoardIds.java index a460d98bc..d7e94212e 100644 --- a/java_package/brainflow/src/main/java/brainflow/BoardIds.java +++ b/java_package/brainflow/src/main/java/brainflow/BoardIds.java @@ -66,7 +66,13 @@ public enum BoardIds EXPLORE_PLUS_8_CHAN_BOARD(54), EXPLORE_PLUS_32_CHAN_BOARD(55), PIEEG_BOARD(56), - NEUROPAWN_KNIGHT_BOARD(57); + NEUROPAWN_KNIGHT_BOARD(57), + SYNCHRONI_TRIO_3_CHANNELS_BOARD(58), + SYNCHRONI_OCTO_8_CHANNELS_BOARD(59), + OB5000_8_CHANNELS_BOARD(60), + SYNCHRONI_PENTO_8_CHANNELS_BOARD(61), + SYNCHRONI_UNO_1_CHANNELS_BOARD(62); + private final int board_id; private static final Map bi_map = new HashMap (); diff --git a/julia_package/brainflow/src/board_shim.jl b/julia_package/brainflow/src/board_shim.jl index c455c2fbd..9e7960dbe 100644 --- a/julia_package/brainflow/src/board_shim.jl +++ b/julia_package/brainflow/src/board_shim.jl @@ -61,7 +61,15 @@ export BrainFlowInputParams EXPLORE_PLUS_8_CHAN_BOARD = 54 EXPLORE_PLUS_32_CHAN_BOARD = 55 PIEEG_BOARD = 56 + NEUROPAWN_KNIGHT_BOARD = 57 + SYNCHRONI_TRIO_3_CHANNELS_BOARD = 58 + SYNCHRONI_OCTO_8_CHANNELS_BOARD = 59 + OB5000_8_CHANNELS_BOARD = 60 + SYNCHRONI_PENTO_8_CHANNELS_BOARD = 61 + SYNCHRONI_UNO_1_CHANNELS_BOARD = 62 + + end diff --git a/matlab_package/brainflow/BoardIds.m b/matlab_package/brainflow/BoardIds.m index 4c4d69a90..876852528 100644 --- a/matlab_package/brainflow/BoardIds.m +++ b/matlab_package/brainflow/BoardIds.m @@ -59,6 +59,13 @@ EXPLORE_PLUS_8_CHAN_BOARD(54) EXPLORE_PLUS_32_CHAN_BOARD(55) PIEEG_BOARD(56) + NEUROPAWN_KNIGHT_BOARD(57) + SYNCHRONI_TRIO_3_CHANNELS_BOARD(58) + SYNCHRONI_OCTO_8_CHANNELS_BOARD(59) + OB5000_8_CHANNELS_BOARD(60) + SYNCHRONI_PENTO_8_CHANNELS_BOARD(61) + SYNCHRONI_UNO_1_CHANNELS_BOARD(62) + end end \ No newline at end of file diff --git a/nodejs_package/brainflow/brainflow.types.ts b/nodejs_package/brainflow/brainflow.types.ts index b0730b561..a4952aa11 100644 --- a/nodejs_package/brainflow/brainflow.types.ts +++ b/nodejs_package/brainflow/brainflow.types.ts @@ -69,9 +69,15 @@ export enum BoardIds { EXPLORE_PLUS_8_CHAN_BOARD = 54, EXPLORE_PLUS_32_CHAN_BOARD = 55, PIEEG_BOARD = 56, - NEUROPAWN_KNIGHT_BOARD = 57 -} + NEUROPAWN_KNIGHT_BOARD = 57, + SYNCHRONI_TRIO_3_CHANNELS_BOARD = 58, + SYNCHRONI_OCTO_CHANNELS_BOARD = 59, + OB5000_8_CHANNELS_BOARD = 60, + SYNCHRONI_PENTO_8_CHANNELS_BOARD = 61, + SYNCHRONI_UNO_1_CHANNELS_BOARD = 62 + +} export enum IpProtocolTypes { NO_IP_PROTOCOL = 0, UDP = 1, diff --git a/python_package/brainflow/board_shim.py b/python_package/brainflow/board_shim.py index 0b8f5707b..11b089c11 100644 --- a/python_package/brainflow/board_shim.py +++ b/python_package/brainflow/board_shim.py @@ -75,6 +75,12 @@ class BoardIds(enum.IntEnum): EXPLORE_PLUS_32_CHAN_BOARD = 55 #: PIEEG_BOARD = 56 #: NEUROPAWN_KNIGHT_BOARD = 57 #: + SYNCHRONI_TRIO_3_CHANNELS_BOARD = 58 #: + SYNCHRONI_OCTO_8_CHANNELS_BOARD = 59 #: + OB5000_8_CHANNELS_BOARD = 60 #: + SYNCHRONI_PENTO_8_CHANNELS_BOARD = 61 #: + SYNCHRONI_UNO_1_CHANNELS_BOARD = 62 #: + class IpProtocolTypes(enum.IntEnum): @@ -577,6 +583,10 @@ def __init__(self, board_id: int, input_params: BrainFlowInputParams) -> None: else: self._master_board_id = self.board_id + def __del__(self) -> None: + if self.is_prepared(): + self.release_session() + @classmethod def set_log_level(cls, log_level: int) -> None: """set BrainFlow log level, use it only if you want to write your own messages to BrainFlow logger, diff --git a/python_package/examples/enophone/enophone_streaming.py b/python_package/examples/enophone/enophone_streaming.py index de0dbb163..24c429813 100644 --- a/python_package/examples/enophone/enophone_streaming.py +++ b/python_package/examples/enophone/enophone_streaming.py @@ -85,6 +85,7 @@ def main(): params.mac_address = args.mac_address try: + # board_shim = BoardShim(BoardIds.ENOPHONE_BOARD, params) board_shim = BoardShim(BoardIds.ENOPHONE_BOARD, params) board_shim.prepare_session() board_shim.start_stream(450000, '') diff --git a/python_package/examples/tests/brainflow_get_data.py b/python_package/examples/tests/brainflow_get_data.py index 74a41992f..145d8013e 100644 --- a/python_package/examples/tests/brainflow_get_data.py +++ b/python_package/examples/tests/brainflow_get_data.py @@ -51,4 +51,4 @@ def main(): if __name__ == "__main__": - main() + main() \ No newline at end of file diff --git a/python_package/setup.py b/python_package/setup.py index 2ca0314f0..94c0e8fd8 100644 --- a/python_package/setup.py +++ b/python_package/setup.py @@ -36,6 +36,14 @@ os.path.join('lib', 'gForceSDKWrapper.dll'), os.path.join('lib', 'gforce64.dll'), os.path.join('lib', 'gforce32.dll'), + os.path.join('lib', 'sensor.dll'), + os.path.join('lib', 'SynchroniLib.dll'), + os.path.join('lib', 'sensor32.dll'), + os.path.join('lib', 'SynchroniLib32.dll'), + os.path.join('lib', 'libsensor_x64.so'), + os.path.join('lib', 'libSynchroniLib_x64.so'), + os.path.join('lib', 'libsensor_arm64.so'), + os.path.join('lib', 'libSynchroniLib_arm64.so'), os.path.join('lib', 'libneurosdk-shared.dylib'), os.path.join('lib', 'libunicorn.so'), os.path.join('lib', 'libunicorn_raspberry.so'), @@ -62,6 +70,7 @@ os.path.join('lib', 'BrainFlowBluetooth32.dll'), os.path.join('lib', 'libBrainFlowBluetooth.so'), os.path.join('lib', 'libBrainFlowBluetooth.dylib'), + os.path.join('lib', 'libSynchroniLib.dylib'), os.path.join('lib', 'simpleble-c.dll'), os.path.join('lib', 'simpleble-c32.dll'), os.path.join('lib', 'libsimpleble-c.so'), diff --git a/rust_package/brainflow/src/ffi/constants.rs b/rust_package/brainflow/src/ffi/constants.rs index d856f1ab3..bd6195ace 100644 --- a/rust_package/brainflow/src/ffi/constants.rs +++ b/rust_package/brainflow/src/ffi/constants.rs @@ -96,6 +96,11 @@ pub enum BoardIds { ExplorePlus32ChanBoard = 55, PieegBoard = 56, NeuropawnKnightBoard = 57, + SynchroniTrio3ChannelsBoard = 58, + SynchroniOcto8ChannelsBoard = 59, + OB50008CHannelsBoard= 60 , + SynchroniPento8ChannelsBoard = 61, + SynchroniUno1ChannelsBoard = 62 } #[repr(i32)] #[derive(FromPrimitive, ToPrimitive, Debug, Copy, Clone, Hash, PartialEq, Eq)] diff --git a/src/board_controller/board_controller.cpp b/src/board_controller/board_controller.cpp index cb55e2e88..be50c9818 100644 --- a/src/board_controller/board_controller.cpp +++ b/src/board_controller/board_controller.cpp @@ -54,6 +54,7 @@ #include "pieeg_board.h" #include "playback_file_board.h" #include "streaming_board.h" +#include "synchroni_board.h" #include "synthetic_board.h" #include "unicorn_board.h" @@ -281,6 +282,24 @@ int prepare_session (int board_id, const char *json_brainflow_input_params) case BoardIds::PIEEG_BOARD: board = std::shared_ptr (new PIEEGBoard (board_id, params)); break; + case BoardIds::SYNCHRONI_TRIO_3_CHANNELS_BOARD: + board = std::shared_ptr (new SynchroniBoard (board_id, params)); + break; + case BoardIds::SYNCHRONI_OCTO_8_CHANNELS_BOARD: + board = std::shared_ptr (new SynchroniBoard (board_id, params)); + break; + case BoardIds::SYNCHRONI_NEO_8_CHANNELS_BOARD: + board = std::shared_ptr (new SynchroniBoard (board_id, params)); + break; + case BoardIds::SYNCHRONI_UNO_1_CHANNELS_BOARD: + board = std::shared_ptr (new SynchroniBoard (board_id, params)); + break; + case BoardIds::OB5000_8_CHANNELS_BOARD: + board = std::shared_ptr (new SynchroniBoard (board_id, params)); + break; + case BoardIds::OB3000_24_CHANNELS_BOARD: + board = std::shared_ptr (new SynchroniBoard (board_id, params)); + break; case BoardIds::NEUROPAWN_KNIGHT_BOARD: board = std::shared_ptr (new Knight ((int)BoardIds::NEUROPAWN_KNIGHT_BOARD, params)); diff --git a/src/board_controller/brainflow_boards.cpp b/src/board_controller/brainflow_boards.cpp index 884e2efb5..5a0c11641 100644 --- a/src/board_controller/brainflow_boards.cpp +++ b/src/board_controller/brainflow_boards.cpp @@ -75,7 +75,13 @@ BrainFlowBoards::BrainFlowBoards() {"54", json::object()}, {"55", json::object()}, {"56", json::object()}, - {"57", json::object()} + {"57", json::object()}, + {"58", json::object()}, + {"59", json::object()}, + {"60", json::object()}, + {"61", json::object()}, + {"62", json::object()} + } }}; @@ -1107,6 +1113,63 @@ BrainFlowBoards::BrainFlowBoards() {"eeg_channels", {1, 2, 3, 4, 5, 6, 7, 8}}, {"other_channels", {9, 10}} }; + brainflow_boards_json["boards"]["58"]["default"] = { + {"name", "Sync-Trio"}, + {"sampling_rate", 250}, + {"package_num_channel", 0}, + {"timestamp_channel", 4}, + {"marker_channel", 5}, + {"num_rows", 6}, + {"eeg_channels", {1, 2}}, + {"ecg_channels", {3}} + }; + brainflow_boards_json["boards"]["59"]["default"] = { + {"name", "Sync-Octo"}, + {"sampling_rate", 250}, + {"package_num_channel", 0}, + {"timestamp_channel", 9}, + {"marker_channel", 10}, + {"num_rows", 11}, + {"eeg_channels", {1, 2, 3, 4, 5, 6, 7}}, + {"ecg_channels", {8}} + }; + brainflow_boards_json["boards"]["60"]["default"] = { + {"name", "OB5000MAX"}, + {"sampling_rate", 250}, + {"package_num_channel", 0}, + {"timestamp_channel", 9}, + {"marker_channel", 10}, + {"num_rows", 11}, + {"eeg_channels", {1, 2, 3, 4, 5, 6, 7, 8}}, + }; + brainflow_boards_json["boards"]["61"]["default"] = { + {"name", "Sync-Neo"}, + {"sampling_rate", 250}, + {"package_num_channel", 0}, + {"timestamp_channel", 9}, + {"marker_channel", 10}, + {"num_rows", 11}, + {"eeg_channels", {1, 2, 3, 4, 5, 6, 7, 8}} + }; + brainflow_boards_json["boards"]["62"]["default"] = { + {"name", "Sync-Uno"}, + {"sampling_rate", 250}, + {"package_num_channel", 0}, + {"timestamp_channel", 2}, + {"marker_channel", 3}, + {"num_rows", 4}, + {"eeg_channels", {1}} + }; + brainflow_boards_json["boards"]["63"]["default"] = { + {"name", "OB3000"}, + {"sampling_rate", 500}, + {"package_num_channel", 0}, + {"timestamp_channel", 25}, + {"marker_channel", 26}, + {"num_rows", 27}, + {"eeg_channels", {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23}}, + {"ecg_channels", {24}} + }; } BrainFlowBoards boards_struct; diff --git a/src/board_controller/build.cmake b/src/board_controller/build.cmake index 17e7244d3..58e99bd3b 100644 --- a/src/board_controller/build.cmake +++ b/src/board_controller/build.cmake @@ -85,6 +85,7 @@ SET (BOARD_CONTROLLER_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/board_controller/ntl/ntl_wifi.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/board_controller/aavaa/aavaa_v3.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/board_controller/pieeg/pieeg_board.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/board_controller/synchroni/synchroni_board.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/board_controller/neuropawn/knight.cpp ) @@ -98,6 +99,14 @@ if (BUILD_OYMOTION_SDK) include (${CMAKE_CURRENT_SOURCE_DIR}/third_party/gForceSDKCXX/build.cmake) endif (BUILD_OYMOTION_SDK) +if (BUILD_SYNCHRONI_SDK) + if (ANDROID) + + else () + include (${CMAKE_CURRENT_SOURCE_DIR}/third_party/synchroni/build.cmake) + endif () +endif (BUILD_SYNCHRONI_SDK) + if (BUILD_BLUETOOTH) include (${CMAKE_CURRENT_SOURCE_DIR}/src/utils/bluetooth/build.cmake) endif (BUILD_BLUETOOTH) @@ -111,11 +120,6 @@ add_library ( ${BOARD_CONTROLLER_SRC} ) -#if (ANDROID AND BUILD_BLE) -# target_compile_definitions (${BOARD_CONTROLLER_NAME} PRIVATE STATIC_SIMPLEBLE) -# target_link_libraries (${BOARD_CONTROLLER_NAME} PRIVATE simpleble-c) -#endif (ANDROID AND BUILD_BLE) - target_include_directories ( ${BOARD_CONTROLLER_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/ @@ -148,6 +152,7 @@ target_include_directories ( ${CMAKE_CURRENT_SOURCE_DIR}/src/board_controller/ntl/inc ${CMAKE_CURRENT_SOURCE_DIR}/src/board_controller/aavaa/inc ${CMAKE_CURRENT_SOURCE_DIR}/src/board_controller/pieeg/inc + ${CMAKE_CURRENT_SOURCE_DIR}/src/board_controller/synchroni/inc ${CMAKE_CURRENT_SOURCE_DIR}/src/board_controller/neuropawn/inc ) @@ -208,7 +213,7 @@ if (UNIX AND NOT ANDROID) COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_CURRENT_SOURCE_DIR}/compiled/${BOARD_CONTROLLER_COMPILED_NAME}" "${CMAKE_CURRENT_SOURCE_DIR}/python_package/brainflow/lib/${BOARD_CONTROLLER_COMPILED_NAME}" COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_CURRENT_SOURCE_DIR}/compiled/${BOARD_CONTROLLER_COMPILED_NAME}" "${CMAKE_CURRENT_SOURCE_DIR}/julia_package/brainflow/lib/${BOARD_CONTROLLER_COMPILED_NAME}" COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_CURRENT_SOURCE_DIR}/compiled/${BOARD_CONTROLLER_COMPILED_NAME}" "${CMAKE_CURRENT_SOURCE_DIR}/java_package/brainflow/src/main/resources/${BOARD_CONTROLLER_COMPILED_NAME}" - COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_CURRENT_SOURCE_DIR}/compiled/${BOARD_CONTROLLER_COMPILED_NAME}" "${CMAKE_CURRENT_SOURCE_DIR}/csharp_package/brainflow/brainflow/${BOARD_CONTROLLER_COMPILED_NAME}" + COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_CURRENT_SOURCE_DIR}/compiled/${BOARD_CONTROLLER_COMPILED_NAME}" "${CMAKE_CURRENT_SOURCE_DIR}/csharp_package/brainflow/brainflow/lib/${BOARD_CONTROLLER_COMPILED_NAME}" COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_CURRENT_SOURCE_DIR}/src/board_controller/inc/board_controller.h" "${CMAKE_CURRENT_SOURCE_DIR}/matlab_package/brainflow/inc/board_controller.h" COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_CURRENT_SOURCE_DIR}/src/board_controller/inc/board_info_getter.h" "${CMAKE_CURRENT_SOURCE_DIR}/matlab_package/brainflow/inc/board_info_getter.h" COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_CURRENT_SOURCE_DIR}/src/utils/inc/shared_export_matlab.h" "${CMAKE_CURRENT_SOURCE_DIR}/matlab_package/brainflow/inc/shared_export.h" diff --git a/src/board_controller/synchroni/inc/synchroni_board.h b/src/board_controller/synchroni/inc/synchroni_board.h new file mode 100644 index 000000000..97137e2c8 --- /dev/null +++ b/src/board_controller/synchroni/inc/synchroni_board.h @@ -0,0 +1,43 @@ +#include +#include +#include + + +#include "board.h" +#include "board_controller.h" +#include "runtime_dll_loader.h" + +class SynchroniBoard : public Board +{ +protected: + volatile bool keep_alive; + bool initialized; + bool is_streaming; + std::thread streaming_thread; + std::mutex m; + std::condition_variable cv; + volatile int state; + std::shared_ptr dll_loader; + static std::shared_ptr g_dll_loader; + + virtual int call_init (); + virtual int call_open (); + virtual int call_close (); + virtual int call_start (); + virtual int call_stop (); + virtual int call_release (); + + virtual void read_thread (); + virtual std::string get_lib_name (); + + +public: + SynchroniBoard (int board_id, struct BrainFlowInputParams params); + virtual ~SynchroniBoard (); + + int prepare_session () override; + int start_stream (int buffer_size, const char *streamer_params) override; + int stop_stream () override; + int release_session () override; + int config_board (std::string config, std::string &response) override; +}; diff --git a/src/board_controller/synchroni/synchroni_board.cpp b/src/board_controller/synchroni/synchroni_board.cpp new file mode 100644 index 000000000..0b61160d2 --- /dev/null +++ b/src/board_controller/synchroni/synchroni_board.cpp @@ -0,0 +1,398 @@ +#include +#include +#include + +#include "synchroni_board.h" + +#include "custom_cast.h" +#include "get_dll_dir.h" +#include "timestamp.h" + +using namespace std; + +std::shared_ptr SynchroniBoard::g_dll_loader = NULL; +SynchroniBoard::SynchroniBoard (int board_id, struct BrainFlowInputParams params) + : Board (board_id, params) +{ + is_streaming = false; + keep_alive = false; + initialized = false; + state = (int)BrainFlowExitCodes::SYNC_TIMEOUT_ERROR; + dll_loader = NULL; +} + +SynchroniBoard::~SynchroniBoard () +{ + skip_logs = true; + release_session (); +} + +std::string SynchroniBoard::get_lib_name () +{ + std::string synclib_path = ""; + std::string synclib_name = ""; + char synclib_dir[1024]; + bool res = get_dll_path (synclib_dir); + +#ifdef _WIN32 + if (sizeof (void *) == 4) + { + synclib_name = "SynchroniLib32.dll"; + } + else + { + synclib_name = "SynchroniLib.dll"; + } +#endif +#ifdef __linux__ +#if defined(__arm__) || defined(_M_ARM64) || defined(_M_ARM) || defined(__aarch64__) + synclib_name = "libSynchroniLib_arm64.so"; +#else + synclib_name = "libSynchroniLib_x64.so"; +#endif +#endif +#ifdef __APPLE__ + synclib_name = "libSynchroniLib.dylib"; +#endif + + if (res) + { + synclib_path = std::string (synclib_dir) + synclib_name; + } + else + { + synclib_path = synclib_name; + } + return synclib_path; +} + + +void SynchroniBoard::read_thread () +{ + int num_attempts = 0; + int sleep_time = 10; + int max_attempts = params.timeout * 1000 / sleep_time; + + int (*func) (void *) = (int (*) (void *))dll_loader->get_address ("synchroni_get_data_default"); + if (func == NULL) + { + safe_logger (spdlog::level::err, "failed to get function address for get_data"); + state = (int)BrainFlowExitCodes::GENERAL_ERROR; + return; + } + + int num_rows = board_descr["default"]["num_rows"]; + double *data = new double[num_rows]; + if (data == NULL) + { + safe_logger (spdlog::level::err, "failed to allocate data"); + state = (int)BrainFlowExitCodes::GENERAL_ERROR; + return; + } + for (int i = 0; i < num_rows; i++) + { + data[i] = 0.0; + } + + std::tuple info = + std::make_tuple (params.mac_address, data, num_rows); + + while (keep_alive) + { + int res = func ((void *)&info); + + if (res == (int)BrainFlowExitCodes::STATUS_OK) + { + if (state != (int)BrainFlowExitCodes::STATUS_OK) + { + { + std::lock_guard lk (m); + state = (int)BrainFlowExitCodes::STATUS_OK; + } + cv.notify_one (); + } + push_package (data); + } + else + { + if (state == (int)BrainFlowExitCodes::SYNC_TIMEOUT_ERROR) + { + num_attempts++; + } + if (num_attempts == max_attempts) + { + safe_logger (spdlog::level::err, "no data received"); + { + std::lock_guard lk (m); + state = (int)BrainFlowExitCodes::GENERAL_ERROR; + } + cv.notify_one (); + break; + } +#ifdef _WIN32 + Sleep (sleep_time); +#else + usleep (sleep_time * 1000); +#endif + } + } + delete[] data; +} + +int SynchroniBoard::config_board (std::string config, std::string &response) +{ + if (dll_loader == NULL) + { + return (int)BrainFlowExitCodes::BOARD_NOT_READY_ERROR; + } + int (*func) (void *) = (int (*) (void *))dll_loader->get_address ("synchroni_config_device"); + if (func == NULL) + { + safe_logger (spdlog::level::err, "failed to get function address for release"); + return (int)BrainFlowExitCodes::GENERAL_ERROR; + } + + + const int BUFFER_SIZE = 1024; + char buffer[BUFFER_SIZE]; + memset (buffer, 0, sizeof (buffer)); + std::tuple info = + std::make_tuple (params.mac_address, config, buffer, BUFFER_SIZE); + + int res = func ((void *)&info); + response = buffer; + return res; +} + +int SynchroniBoard::call_init () +{ + + if (dll_loader == NULL) + { + return (int)BrainFlowExitCodes::BOARD_NOT_READY_ERROR; + } + int (*func) (void *) = (int (*) (void *))dll_loader->get_address ("synchroni_initialize"); + if (func == NULL) + { + safe_logger (spdlog::level::err, "failed to get function address for initialize"); + return (int)BrainFlowExitCodes::GENERAL_ERROR; + } + + std::tuple info = + std::make_tuple (board_id, params, board_descr); + + int res = func ((void *)&info); + if (res != (int)BrainFlowExitCodes::STATUS_OK) + { + safe_logger (spdlog::level::err, "failed to initialize {}", res); + } + return res; +} + +int SynchroniBoard::call_open () +{ + if (dll_loader == NULL) + { + return (int)BrainFlowExitCodes::BOARD_NOT_READY_ERROR; + } + int (*func) (void *) = (int (*) (void *))dll_loader->get_address ("synchroni_open_device"); + if (func == NULL) + { + safe_logger (spdlog::level::err, "failed to get function address for open_device"); + return (int)BrainFlowExitCodes::GENERAL_ERROR; + } + std::tuple info = std::make_tuple (params.mac_address); + return func ((void *)&info); +} + +int SynchroniBoard::call_start () +{ + if (dll_loader == NULL) + { + return (int)BrainFlowExitCodes::BOARD_NOT_READY_ERROR; + } + int (*func) (void *) = (int (*) (void *))dll_loader->get_address ("synchroni_start_stream"); + if (func == NULL) + { + safe_logger (spdlog::level::err, "failed to get function address for start_stream"); + return (int)BrainFlowExitCodes::GENERAL_ERROR; + } + std::tuple info = std::make_tuple (params.mac_address); + return func ((void *)&info); +} + +int SynchroniBoard::call_stop () +{ + if (dll_loader == NULL) + { + return (int)BrainFlowExitCodes::BOARD_NOT_READY_ERROR; + } + int (*func) (void *) = (int (*) (void *))dll_loader->get_address ("synchroni_stop_stream"); + if (func == NULL) + { + safe_logger (spdlog::level::err, "failed to get function address for stop_stream"); + return (int)BrainFlowExitCodes::GENERAL_ERROR; + } + std::tuple info = std::make_tuple (params.mac_address); + return func ((void *)&info); +} + +int SynchroniBoard::call_close () +{ + if (dll_loader == NULL) + { + return (int)BrainFlowExitCodes::BOARD_NOT_READY_ERROR; + } + int (*func) (void *) = (int (*) (void *))dll_loader->get_address ("synchroni_close_device"); + if (func == NULL) + { + safe_logger (spdlog::level::err, "failed to get function address for close_device"); + return (int)BrainFlowExitCodes::GENERAL_ERROR; + } + std::tuple info = std::make_tuple (params.mac_address); + return func ((void *)&info); +} + +int SynchroniBoard::call_release () +{ + if (dll_loader == NULL) + { + return (int)BrainFlowExitCodes::BOARD_NOT_READY_ERROR; + } + int (*func) (void *) = (int (*) (void *))dll_loader->get_address ("synchroni_release"); + if (func == NULL) + { + safe_logger (spdlog::level::err, "failed to get function address for release"); + return (int)BrainFlowExitCodes::GENERAL_ERROR; + } + std::tuple info = std::make_tuple (params.mac_address); + return func ((void *)&info); +} + + +int SynchroniBoard::prepare_session () +{ + if (initialized) + { + safe_logger (spdlog::level::info, "Session is already prepared"); + return (int)BrainFlowExitCodes::STATUS_OK; + } + if (params.timeout <= 0) + { + params.timeout = 5; + } + if (!g_dll_loader) + { + g_dll_loader = make_shared (get_lib_name ().c_str ()); + } + if (!dll_loader) + { + dll_loader = shared_ptr (g_dll_loader); + } + + if (!dll_loader->load_library ()) + { + safe_logger (spdlog::level::err, "Failed to load library"); + dll_loader = NULL; + return (int)BrainFlowExitCodes::GENERAL_ERROR; + } + safe_logger (spdlog::level::debug, "Library is loaded"); + int res = call_init (); + if (res != (int)BrainFlowExitCodes::STATUS_OK) + { + dll_loader = NULL; + return res; + } + res = call_open (); + if (res != (int)BrainFlowExitCodes::STATUS_OK) + { + dll_loader = NULL; + return res; + } + initialized = true; + return (int)BrainFlowExitCodes::STATUS_OK; +} + +int SynchroniBoard::start_stream (int buffer_size, const char *streamer_params) +{ + if (is_streaming) + { + safe_logger (spdlog::level::err, "Streaming thread already running"); + return (int)BrainFlowExitCodes::STREAM_ALREADY_RUN_ERROR; + } + if (buffer_size <= 0 || buffer_size > MAX_CAPTURE_SAMPLES) + { + safe_logger (spdlog::level::err, "invalid array size"); + return (int)BrainFlowExitCodes::INVALID_BUFFER_SIZE_ERROR; + } + + int res = prepare_for_acquisition (buffer_size, streamer_params); + if (res != (int)BrainFlowExitCodes::STATUS_OK) + { + return res; + } + + res = call_start (); + if (res != (int)BrainFlowExitCodes::STATUS_OK) + { + return res; + } + + keep_alive = true; + streaming_thread = std::thread ([this] { read_thread (); }); + + // wait for data to ensure that everything is okay + std::unique_lock lk (m); + auto sec = std::chrono::seconds (1); + if (cv.wait_for (lk, params.timeout * sec, + [this] { return state != (int)BrainFlowExitCodes::SYNC_TIMEOUT_ERROR; })) + { + is_streaming = true; + return state; + } + else + { + safe_logger ( + spdlog::level::err, "no data received in {} sec, stopping thread", params.timeout); + is_streaming = true; + stop_stream (); + return (int)BrainFlowExitCodes::SYNC_TIMEOUT_ERROR; + } +} + +int SynchroniBoard::stop_stream () +{ + if (is_streaming) + { + keep_alive = false; + is_streaming = false; + streaming_thread.join (); + state = (int)BrainFlowExitCodes::SYNC_TIMEOUT_ERROR; + return call_stop (); + } + else + { + return (int)BrainFlowExitCodes::STREAM_THREAD_IS_NOT_RUNNING; + } +} + +int SynchroniBoard::release_session () +{ + if (initialized) + { + stop_stream (); + initialized = false; + } + + free_packages (); + + call_close (); + call_release (); + + if (dll_loader != NULL) + { + dll_loader = NULL; + } + + return (int)BrainFlowExitCodes::STATUS_OK; +} diff --git a/src/utils/inc/brainflow_constants.h b/src/utils/inc/brainflow_constants.h index d115fce1a..6c52f5b1b 100644 --- a/src/utils/inc/brainflow_constants.h +++ b/src/utils/inc/brainflow_constants.h @@ -89,9 +89,16 @@ enum class BoardIds : int EXPLORE_PLUS_32_CHAN_BOARD = 55, PIEEG_BOARD = 56, NEUROPAWN_KNIGHT_BOARD = 57, + SYNCHRONI_TRIO_3_CHANNELS_BOARD = 58, + SYNCHRONI_OCTO_8_CHANNELS_BOARD = 59, + OB5000_8_CHANNELS_BOARD = 60, + SYNCHRONI_NEO_8_CHANNELS_BOARD = 61, + SYNCHRONI_UNO_1_CHANNELS_BOARD = 62, + OB3000_24_CHANNELS_BOARD = 63, // use it to iterate FIRST = PLAYBACK_FILE_BOARD, - LAST = NEUROPAWN_KNIGHT_BOARD + LAST = OB3000_24_CHANNELS_BOARD + }; enum class IpProtocolTypes : int diff --git a/third_party/SimpleBLE/.github/workflows/ci_cpp_release.yml b/third_party/SimpleBLE/.github/workflows/ci_cpp_release.yml new file mode 100644 index 000000000..b47c441b5 --- /dev/null +++ b/third_party/SimpleBLE/.github/workflows/ci_cpp_release.yml @@ -0,0 +1,205 @@ +name: Cpp Release + +on: + release: + types: [published] + workflow_dispatch: + inputs: + tag: + description: "The tag to upload artifacts" + required: true + +jobs: + + # ------------------------------------------------------------ + + cpp-release-linux: + runs-on: ubuntu-latest + + strategy: + fail-fast: false + max-parallel: 4 + matrix: + options: [ + {container: dockcross/linux-x64, target: linux-x64}, + {container: dockcross/linux-x86, target: linux-x86}, + {container: dockcross/linux-armv6-lts, target: linux-armv6}, + ] + type: [shared, static] + + container: + image: ${{ matrix.options.container }} + steps: + - name: Clone repository + uses: actions/checkout@v3 + env: + TAG: ${{ inputs.tag || github.ref }} + with: + ref: ${{ env.TAG }} + + - name: Build Expat + run: | + git clone https://github.com/libexpat/libexpat.git /tmp/libexpat + cd /tmp/libexpat/expat + + cmake -B /tmb/expat/build -S /tmp/libexpat/expat -DEXPAT_BUILD_DOCS=OFF -DEXPAT_BUILD_EXAMPLES=OFF -DEXPAT_BUILD_TESTS=OFF + cmake --build /tmb/expat/build --config Release --parallel 4 + cmake --install /tmb/expat/build --prefix /tmp/expat/install + + - name: Build DBus + run: | + git clone https://gitlab.freedesktop.org/dbus/dbus.git /tmp/dbus + + export CMAKE_PREFIX_PATH=/tmp/expat/install:$CMAKE_PREFIX_PATH + + cmake -B /tmb/dbus/build -S /tmp/dbus -DDBUS_SESSION_SOCKET_DIR=/usr/local/var/run/dbus/system_bus_socket -DDBUS_BUILD_TESTS=OFF + cmake --build /tmb/dbus/build --config Release --parallel 4 + cmake --install /tmb/dbus/build --prefix /tmp/dbus/install + + - name: Build SimpleBLE + run: | + GITHUB_WORKSPACE=$(pwd) + + if [ "${{ matrix.type }}" = "shared" ]; then + BUILD_SHARED_LIBS=ON + else + BUILD_SHARED_LIBS=OFF + fi + + export CMAKE_PREFIX_PATH=/tmp/dbus/install:$CMAKE_PREFIX_PATH + + cmake -B $GITHUB_WORKSPACE/build_simpleble -DCMAKE_BUILD_TYPE=Release -S $GITHUB_WORKSPACE/simpleble -DBUILD_SHARED_LIBS=$BUILD_SHARED_LIBS + cmake --build $GITHUB_WORKSPACE/build_simpleble --config Release --parallel 4 + cmake --install $GITHUB_WORKSPACE/build_simpleble --prefix $GITHUB_WORKSPACE/build_simpleble/install + + mkdir -p $GITHUB_WORKSPACE/artifacts + zip -r $GITHUB_WORKSPACE/artifacts/simpleble_${{ matrix.type }}_${{ matrix.options.target }}.zip $GITHUB_WORKSPACE/build_simpleble/install + + - name: Upload binaries to job + uses: actions/upload-artifact@v3 + with: + name: simpleble_${{ matrix.type }}_${{ matrix.options.target }} + path: artifacts/simpleble_${{ matrix.type }}_${{ matrix.options.target }}.zip + + - name: Upload binaries to release + uses: svenstaro/upload-release-action@v2 + env: + TAG: ${{ inputs.tag || github.ref }} + with: + file: ${{ github.workspace }}/artifacts/**/* + tag: ${{ env.TAG }} + overwrite: true + file_glob: true + + # ------------------------------------------------------------ + + cpp-release-windows: + runs-on: windows-2022 + + strategy: + fail-fast: false + max-parallel: 4 + matrix: + arch: [Win32, x64] + type: [shared, static] + + steps: + - name: Clone repository + uses: actions/checkout@v3 + env: + TAG: ${{ inputs.tag || github.ref }} + with: + ref: ${{ env.TAG }} + + - name: Add msbuild to PATH + uses: microsoft/setup-msbuild@v1.1 + + - name: Compile SimpleBLE + shell: cmd + run: | + + if "${{ matrix.type }}" == "shared" ( + set BUILD_SHARED_LIBS=ON + ) else ( + set BUILD_SHARED_LIBS=OFF + ) + + cmake -B %GITHUB_WORKSPACE%\build -G "Visual Studio 17 2022" -A ${{ matrix.arch }} -DCMAKE_SYSTEM_VERSION="10.0.19041.0" -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=%BUILD_SHARED_LIBS% -S %GITHUB_WORKSPACE%/simpleble + cmake --build %GITHUB_WORKSPACE%\build --config Release --parallel 4 + cmake --install %GITHUB_WORKSPACE%\build --prefix %GITHUB_WORKSPACE%\build\install + + mkdir -p $GITHUB_WORKSPACE\artifacts + 7z a -tzip %GITHUB_WORKSPACE%\artifacts\simpleble_${{ matrix.type }}_windows-${{ matrix.arch }}.zip %GITHUB_WORKSPACE%\build\install + + - name: Upload binaries to job + uses: actions/upload-artifact@v3 + with: + name: simpleble_${{ matrix.type }}_windows-${{ matrix.arch }} + path: artifacts/simpleble_${{ matrix.type }}_windows-${{ matrix.arch }}.zip + + - name: Upload binaries to release + uses: svenstaro/upload-release-action@v2 + env: + TAG: ${{ inputs.tag || github.ref }} + with: + file: ${{ github.workspace }}/artifacts/**/* + tag: ${{ env.TAG }} + overwrite: true + file_glob: true + + # ------------------------------------------------------------ + + cpp-release-macos: + runs-on: macos-12 + + strategy: + fail-fast: false + max-parallel: 4 + matrix: + arch: [arm64, x86_64] + type: [shared, static] + + steps: + - name: Clone repository + uses: actions/checkout@v3 + env: + TAG: ${{ inputs.tag || github.ref }} + with: + ref: ${{ env.TAG }} + + - name: Setup CMake + uses: jwlawson/actions-setup-cmake@v1.13 + with: + cmake-version: '3.21' + + - name: Compile SimpleBLE + run: | + + if [ "${{ matrix.type }}" = "shared" ]; then + BUILD_SHARED_LIBS=ON + else + BUILD_SHARED_LIBS=OFF + fi + + cmake -B $GITHUB_WORKSPACE/build -DCMAKE_OSX_ARCHITECTURES="${{ matrix.arch }}" -DCMAKE_BUILD_TYPE=Release -S $GITHUB_WORKSPACE/simpleble -DBUILD_SHARED_LIBS=$BUILD_SHARED_LIBS + cmake --build $GITHUB_WORKSPACE/build --config Release --parallel 4 + cmake --install $GITHUB_WORKSPACE/build --prefix $GITHUB_WORKSPACE/build/install + + mkdir -p $GITHUB_WORKSPACE/artifacts + zip -r $GITHUB_WORKSPACE/artifacts/simpleble_${{ matrix.type }}_macos-${{ matrix.arch }}.zip $GITHUB_WORKSPACE/build/install + + - name: Upload binaries to job + uses: actions/upload-artifact@v3 + with: + name: simpleble_${{ matrix.type }}_macos-${{ matrix.arch }} + path: artifacts/simpleble_${{ matrix.type }}_macos-${{ matrix.arch }}.zip + + - name: Upload binaries to release + uses: svenstaro/upload-release-action@v2 + env: + TAG: ${{ inputs.tag || github.ref }} + with: + file: ${{ github.workspace }}/artifacts/**/* + tag: ${{ env.TAG }} + overwrite: true + file_glob: true diff --git a/third_party/SimpleBLE/.github/workflows/ci_cpp_release_test.yml b/third_party/SimpleBLE/.github/workflows/ci_cpp_release_test.yml new file mode 100644 index 000000000..2d4edbb2a --- /dev/null +++ b/third_party/SimpleBLE/.github/workflows/ci_cpp_release_test.yml @@ -0,0 +1,163 @@ +name: Cpp Release Test + +on: + # push: + # pull_request: + workflow_dispatch: + +jobs: + # ------------------------------------------------------------ + + cpp-release-linux: + runs-on: ubuntu-latest + + strategy: + fail-fast: false + max-parallel: 4 + matrix: + library: [ + {lib: simpledbus, name: SimpleDBus}, + {lib: simplebluez, name: SimpleBluez}, + {lib: simpleble, name: SimpleBLE}, + ] + options: [ + {container: dockcross/linux-x64, target: linux-x64}, + {container: dockcross/linux-x86, target: linux-x86}, + {container: dockcross/linux-armv6-lts, target: linux-armv6}, + ] + type: [shared, static] + + container: + image: ${{ matrix.options.container }} + steps: + - name: Clone repository + uses: actions/checkout@v3 + + - name: Build Expat + run: | + git clone https://github.com/libexpat/libexpat.git /tmp/libexpat + cd /tmp/libexpat/expat + + cmake -B /tmb/expat/build -S /tmp/libexpat/expat -DEXPAT_BUILD_DOCS=OFF -DEXPAT_BUILD_EXAMPLES=OFF -DEXPAT_BUILD_TESTS=OFF + cmake --build /tmb/expat/build --config Release --parallel 4 + cmake --install /tmb/expat/build --prefix /tmp/expat/install + + - name: Build DBus + run: | + git clone https://gitlab.freedesktop.org/dbus/dbus.git /tmp/dbus + + export CMAKE_PREFIX_PATH=/tmp/expat/install:$CMAKE_PREFIX_PATH + + cmake -B /tmb/dbus/build -S /tmp/dbus -DDBUS_SESSION_SOCKET_DIR=/usr/local/var/run/dbus/system_bus_socket -DDBUS_BUILD_TESTS=OFF + cmake --build /tmb/dbus/build --config Release --parallel 4 + cmake --install /tmb/dbus/build --prefix /tmp/dbus/install + + - name: Build ${{ matrix.library.name }} + run: | + GITHUB_WORKSPACE=$(pwd) + + if [ "${{ matrix.type }}" = "shared" ]; then + BUILD_SHARED_LIBS=ON + else + BUILD_SHARED_LIBS=OFF + fi + + export CMAKE_PREFIX_PATH=/tmp/dbus/install:$CMAKE_PREFIX_PATH + + cmake -B $GITHUB_WORKSPACE/build_${{ matrix.library.lib }} -DCMAKE_BUILD_TYPE=Release -S $GITHUB_WORKSPACE/${{ matrix.library.lib }} -DBUILD_SHARED_LIBS=$BUILD_SHARED_LIBS + cmake --build $GITHUB_WORKSPACE/build_${{ matrix.library.lib }} --config Release --parallel 4 + cmake --install $GITHUB_WORKSPACE/build_${{ matrix.library.lib }} --prefix $GITHUB_WORKSPACE/build_${{ matrix.library.lib }}/install + + mkdir -p $GITHUB_WORKSPACE/artifacts + zip -r $GITHUB_WORKSPACE/artifacts/${{ matrix.library.lib }}_${{ matrix.type }}_${{ matrix.options.target }}.zip $GITHUB_WORKSPACE/build_${{ matrix.library.lib }}/install + + - name: Upload binaries to job + uses: actions/upload-artifact@v3 + with: + name: ${{ matrix.library.lib }}_${{ matrix.type }}_${{ matrix.options.target }} + path: artifacts/${{ matrix.library.lib }}_${{ matrix.type }}_${{ matrix.options.target }}.zip + + # ------------------------------------------------------------ + + cpp-release-windows: + runs-on: windows-2022 + + strategy: + fail-fast: false + max-parallel: 4 + matrix: + arch: [Win32, x64] + type: [shared, static] + + steps: + - name: Clone repository + uses: actions/checkout@v3 + + - name: Add msbuild to PATH + uses: microsoft/setup-msbuild@v1.1 + + - name: Compile SimpleBLE + shell: cmd + run: | + + if "${{ matrix.type }}" == "shared" ( + set BUILD_SHARED_LIBS=ON + ) else ( + set BUILD_SHARED_LIBS=OFF + ) + + cmake -B %GITHUB_WORKSPACE%\build -G "Visual Studio 17 2022" -A ${{ matrix.arch }} -DCMAKE_SYSTEM_VERSION="10.0.19041.0" -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=%BUILD_SHARED_LIBS% -S %GITHUB_WORKSPACE%/simpleble + cmake --build %GITHUB_WORKSPACE%\build --config Release --parallel 4 + cmake --install %GITHUB_WORKSPACE%\build --prefix %GITHUB_WORKSPACE%\build\install + + mkdir -p $GITHUB_WORKSPACE\artifacts + 7z a -tzip %GITHUB_WORKSPACE%\artifacts\simpleble_${{ matrix.type }}_windows-${{ matrix.arch }}.zip %GITHUB_WORKSPACE%\build\install + + - name: Upload binaries to job + uses: actions/upload-artifact@v3 + with: + name: simpleble_${{ matrix.type }}_windows-${{ matrix.arch }} + path: artifacts/simpleble_${{ matrix.type }}_windows-${{ matrix.arch }}.zip + + # ------------------------------------------------------------ + + cpp-release-macos: + runs-on: macos-12 + + strategy: + fail-fast: false + max-parallel: 4 + matrix: + arch: [arm64, x86_64] + type: [shared, static] + + steps: + - name: Clone repository + uses: actions/checkout@v3 + + - name: Setup CMake + uses: jwlawson/actions-setup-cmake@v1.13 + with: + cmake-version: '3.21' + + - name: Compile SimpleBLE + run: | + + if [ "${{ matrix.type }}" = "shared" ]; then + BUILD_SHARED_LIBS=ON + else + BUILD_SHARED_LIBS=OFF + fi + + cmake -B $GITHUB_WORKSPACE/build -DCMAKE_OSX_ARCHITECTURES="${{ matrix.arch }}" -DCMAKE_BUILD_TYPE=Release -S $GITHUB_WORKSPACE/simpleble -DBUILD_SHARED_LIBS=$BUILD_SHARED_LIBS + cmake --build $GITHUB_WORKSPACE/build --config Release --parallel 4 + cmake --install $GITHUB_WORKSPACE/build --prefix $GITHUB_WORKSPACE/build/install + + mkdir -p $GITHUB_WORKSPACE/artifacts + zip -r $GITHUB_WORKSPACE/artifacts/simpleble_${{ matrix.type }}_macos-${{ matrix.arch }}.zip $GITHUB_WORKSPACE/build/install + + - name: Upload binaries to job + uses: actions/upload-artifact@v3 + with: + name: simpleble_${{ matrix.type }}_macos-${{ matrix.arch }} + path: artifacts/simpleble_${{ matrix.type }}_macos-${{ matrix.arch }}.zip diff --git a/third_party/SimpleBLE/.github/workflows/ci_py_release.yml b/third_party/SimpleBLE/.github/workflows/ci_py_release.yml new file mode 100644 index 000000000..2adf92412 --- /dev/null +++ b/third_party/SimpleBLE/.github/workflows/ci_py_release.yml @@ -0,0 +1,133 @@ +name: PyPI Release + +on: + release: + types: [published] + workflow_dispatch: + inputs: + tag: + description: "The tag to upload artifacts" + required: false + +jobs: + build_sdist: + runs-on: ubuntu-22.04 + + steps: + - name: Checkout + uses: actions/checkout@v3 + env: + TAG: ${{ inputs.tag || github.ref }} + with: + ref: ${{ env.TAG }} + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: 3.11 + cache: "pip" + + - name: Build source distribution + run: | + pip3 install build twine + python3 -m build --sdist + + - name: Upload files + uses: actions/upload-artifact@v3 + with: + name: simplepyble + path: dist/*.tar.gz + + - name: Check packages + run: twine check dist/*.tar.gz + + - name: Publish packages + run: twine upload --skip-existing dist/*.tar.gz --verbose + env: + TWINE_USERNAME: ${{ secrets.PYPI_USER }} + TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} + + - name: Upload source to release + uses: svenstaro/upload-release-action@v2 + if: inputs.tag != '' && inputs.tag != null + env: + TAG: ${{ inputs.tag }} + with: + file: dist/*.tar.gz + tag: ${{ env.TAG }} + overwrite: true + file_glob: true + + build_wheels: + runs-on: ${{ matrix.options.os }} + + strategy: + matrix: + options: [ + {os: ubuntu-22.04, arch: x86_64}, + {os: ubuntu-22.04, arch: i686}, + {os: ubuntu-22.04, arch: aarch64}, + {os: windows-2022, arch: AMD64}, + {os: windows-2022, arch: x86}, + {os: macos-12 , arch: x86_64}, + {os: macos-12 , arch: universal2}, + {os: macos-12 , arch: arm64}, + ] + + steps: + - name: Clone repository + uses: actions/checkout@v3 + env: + TAG: ${{ inputs.tag || github.ref }} + with: + ref: ${{ env.TAG }} + + - name: Set up QEMU + if: runner.os == 'Linux' + uses: docker/setup-qemu-action@v2 + with: + platforms: arm64 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: 3.11 + cache: "pip" + + - name: Install dependencies + run: pip install -r simplepyble/requirements.txt + + - name: Build wheel + uses: pypa/cibuildwheel@v2.16.5 + env: + CIBW_BEFORE_ALL_LINUX: "yum update -y && yum group install -y \"Development Tools\" && yum install -y dbus-devel" + CIBW_ARCHS_LINUX: ${{ matrix.options.arch }} + CIBW_ARCHS_MACOS: ${{ matrix.options.arch }} + CIBW_ARCHS_WINDOWS: ${{ matrix.options.arch }} + CIBW_SKIP: "*musllinux_* pp*" + + - name: Upload wheels to job + uses: actions/upload-artifact@v3 + with: + name: simpleble-wheels + path: wheelhouse/*.whl + + - name: Check Packages + run: twine check wheelhouse/*.whl + + - name: Upload wheels to release + uses: svenstaro/upload-release-action@v2 + if: inputs.tag != '' && inputs.tag != null + env: + TAG: ${{ inputs.tag }} + with: + file: wheelhouse/*.whl + tag: ${{ env.TAG }} + overwrite: true + file_glob: true + + - name: Publish packages + run: twine upload --skip-existing wheelhouse/*.whl --verbose + env: + TWINE_USERNAME: ${{ secrets.PYPI_USER }} + TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} diff --git a/third_party/SimpleBLE/.github/workflows/ci_py_release_test.yml b/third_party/SimpleBLE/.github/workflows/ci_py_release_test.yml new file mode 100644 index 000000000..e3c6d45b5 --- /dev/null +++ b/third_party/SimpleBLE/.github/workflows/ci_py_release_test.yml @@ -0,0 +1,98 @@ +name: PyPI Test Release + +on: + # push: + # pull_request: + workflow_dispatch: + +jobs: + build_sdist: + runs-on: ubuntu-22.04 + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: 3.11 + cache: "pip" + + - name: Build source distribution + run: | + pip3 install build twine + python3 -m build --sdist + + - name: Upload files + uses: actions/upload-artifact@v3 + with: + name: simplepyble + path: dist/*.tar.gz + + - name: Check packages + run: twine check dist/*.tar.gz + + - name: Publish packages + if: ${{ env.HAS_TWINE_USERNAME == 'true' }} + run: | + twine upload --repository testpypi --skip-existing dist/*.tar.gz --verbose + env: + HAS_TWINE_USERNAME: ${{ secrets.TEST_PYPI_USER != '' }} + TWINE_USERNAME: ${{ secrets.TEST_PYPI_USER }} + TWINE_PASSWORD: ${{ secrets.TEST_PYPI_PASSWORD }} + + build_wheels: + runs-on: ${{ matrix.os }} + + strategy: + matrix: + os: [ubuntu-22.04 , windows-2022, macos-12] + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Set up QEMU + if: runner.os == 'Linux' + uses: docker/setup-qemu-action@v2 + with: + platforms: arm64 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: 3.11 + cache: "pip" + + - name: Install dependencies + run: pip install -r simplepyble/requirements.txt + + - name: Build wheel + uses: pypa/cibuildwheel@v2.16.5 + env: + CIBW_BUILD: cp39-* # Only build for Python 3.9 + CIBW_BUILD_VERBOSITY: 3 + CIBW_BEFORE_ALL_LINUX: "yum update -y && yum group install -y \"Development Tools\" && yum install -y dbus-devel" + CIBW_ARCHS_LINUX: x86_64 i686 aarch64 + CIBW_ARCHS_MACOS: x86_64 universal2 arm64 + CIBW_ARCHS_WINDOWS: AMD64 x86 + CIBW_SKIP: "*musllinux_* pp*" + + - name: Upload wheels + uses: actions/upload-artifact@v3 + with: + name: simpleble-wheels + path: wheelhouse/*.whl + + - name: Check Packages + run: twine check wheelhouse/*.whl + + - name: Publish packages + if: ${{ env.HAS_TWINE_USERNAME == 'true' }} + run: | + twine upload --repository testpypi --skip-existing wheelhouse/*.whl --verbose + env: + HAS_TWINE_USERNAME: ${{ secrets.TEST_PYPI_USER != '' }} + TWINE_USERNAME: ${{ secrets.TEST_PYPI_USER }} + TWINE_PASSWORD: ${{ secrets.TEST_PYPI_PASSWORD }} diff --git a/third_party/SimpleBLE/.github/workflows/ci_rust_build.yml b/third_party/SimpleBLE/.github/workflows/ci_rust_build.yml new file mode 100644 index 000000000..474072835 --- /dev/null +++ b/third_party/SimpleBLE/.github/workflows/ci_rust_build.yml @@ -0,0 +1,74 @@ +name: Rust Build + +on: [push, pull_request] + +jobs: + + # ------------------------------------------------------------ + # build-windows: + # runs-on: windows-2022 + + # strategy: + # fail-fast: false + # max-parallel: 4 + # matrix: + # arch: [Win32, x64] + # sdk: ["10.0.19041.0", "10.0.22000.0"] + + # steps: + # - name: Clone Repository + # uses: actions/checkout@v3 + + + # ------------------------------------------------------------ + + build-macos: + runs-on: ${{ matrix.os }} + + strategy: + fail-fast: false + max-parallel: 4 + matrix: + os: [macos-11, macos-12] + arch: [arm64, x86_64] + + steps: + - name: Clone Repository + uses: actions/checkout@v3 + - name: Install CMake + uses: jwlawson/actions-setup-cmake@v1.13 + with: + cmake-version: '3.21' + - name: Install Rust + uses: dtolnay/rust-toolchain@stable + - name: Compile SimpleBLE + run: cargo build + + # ------------------------------------------------------------ + + build-linux: + runs-on: ${{ matrix.os }} + + strategy: + fail-fast: false + max-parallel: 4 + matrix: + os: [ubuntu-20.04, ubuntu-22.04] + + steps: + - name: Clone Repository + uses: actions/checkout@v3 + - name: Install Dependencies + run: | + sudo -H apt-get update -y + sudo -H apt-get install -y libdbus-1-dev + env: + DEBIAN_FRONTEND: noninteractive + - name: Install CMake + uses: jwlawson/actions-setup-cmake@v1.13 + with: + cmake-version: '3.21' + - name: Install Rust + uses: dtolnay/rust-toolchain@stable + - name: Compile SimpleBLE + run: cargo build diff --git a/third_party/synchroni/build.cmake b/third_party/synchroni/build.cmake new file mode 100644 index 000000000..c7a9bac8e --- /dev/null +++ b/third_party/synchroni/build.cmake @@ -0,0 +1,170 @@ +SET (SYNCHRONI_SDK_WRAPPER_NAME "SynchroniLib") + +if (CMAKE_SIZEOF_VOID_P EQUAL 8) + if (APPLE) + SET (SYNCHRONI_SDK_WRAPPER_COMPILED_NAME "libSynchroniLib.dylib") + elseif (UNIX) + if (${CMAKE_SYSTEM_PROCESSOR} MATCHES "aarch64") + set(SYNCHRONI_SDK_WRAPPER_NAME "SynchroniLib_arm64") + SET (SYNCHRONI_SDK_WRAPPER_COMPILED_NAME "libSynchroniLib_arm64.so") + SET (SYNCHRONI_SDK_ARCH "arm64") + SET (SYNCHRONI_SDK_LINK_NAME_LIB "libsensor_arm64.so") + else () + set(SYNCHRONI_SDK_WRAPPER_NAME "SynchroniLib_x64") + SET (SYNCHRONI_SDK_WRAPPER_COMPILED_NAME "libSynchroniLib_x64.so") + SET (SYNCHRONI_SDK_ARCH "x86_64") + SET (SYNCHRONI_SDK_LINK_NAME_LIB "libsensor_x64.so") + endif () + else () + SET (SYNCHRONI_SDK_WRAPPER_COMPILED_NAME "SynchroniLib.dll") + SET (SYNCHRONI_SDK_WRAPPER_COMPILED_NAME_DOT_LIB "SynchroniLib.lib") + SET (SYNCHRONI_SDK_LINK_NAME_LIB "sensor") + SET (SYNCHRONI_SDK_LINK_NAME_DOT_LIB "sensor.lib") + SET (SYNCHRONI_SDK_ARCH "Win64") + endif (APPLE) +else (CMAKE_SIZEOF_VOID_P EQUAL 8) + if (APPLE) + SET (SYNCHRONI_SDK_WRAPPER_COMPILED_NAME "libSynchroniLib.dylib") + elseif (UNIX) + SET (SYNCHRONI_SDK_WRAPPER_COMPILED_NAME "libSynchroniLib.so") + else () + SET (SYNCHRONI_SDK_WRAPPER_NAME "SynchroniLib32") + SET (SYNCHRONI_SDK_WRAPPER_COMPILED_NAME "SynchroniLib32.dll") + SET (SYNCHRONI_SDK_WRAPPER_COMPILED_NAME_DOT_LIB "SynchroniLib32.lib") + SET (SYNCHRONI_SDK_LINK_NAME_LIB "sensor32") + SET (SYNCHRONI_SDK_LINK_NAME_DOT_LIB "sensor32.lib") + SET (SYNCHRONI_SDK_ARCH "Win32") + endif (APPLE) +endif (CMAKE_SIZEOF_VOID_P EQUAL 8) + + +SET (SYNCHRONI_WRAPPER_SRC + ${CMAKE_CURRENT_LIST_DIR}/src/synchroni_wrapper.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/utils/timestamp.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/board_controller/brainflow_boards.cpp +) + +add_library ( + ${SYNCHRONI_SDK_WRAPPER_NAME} SHARED + ${SYNCHRONI_WRAPPER_SRC} +) + +if (APPLE) + target_link_libraries (${SYNCHRONI_SDK_WRAPPER_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/synchroni/lib/mac/sensor.xcframework/macos-arm64_x86_64/sensor.framework) +elseif (UNIX) + target_link_libraries (${SYNCHRONI_SDK_WRAPPER_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/synchroni/lib/linux/${SYNCHRONI_SDK_ARCH}/For${CMAKE_BUILD_TYPE}/${SYNCHRONI_SDK_LINK_NAME_LIB}) +else () + target_link_libraries (${SYNCHRONI_SDK_WRAPPER_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/synchroni/lib/windows/${SYNCHRONI_SDK_ARCH}/For$/${SYNCHRONI_SDK_LINK_NAME_DOT_LIB}) +endif (APPLE) + + +target_compile_definitions(${SYNCHRONI_SDK_WRAPPER_NAME} PRIVATE -DUNICODE -D_UNICODE) + +target_include_directories ( + ${SYNCHRONI_SDK_WRAPPER_NAME} PRIVATE + ${CMAKE_CURRENT_LIST_DIR}/src/inc + ${CMAKE_CURRENT_LIST_DIR}/inc + ${CMAKE_CURRENT_LIST_DIR}/.. + ${CMAKE_CURRENT_SOURCE_DIR}/src/utils/inc + ${CMAKE_CURRENT_SOURCE_DIR}/src/board_controller/inc + ${CMAKE_CURRENT_SOURCE_DIR}/third_party/json +) + + +set_target_properties (${SYNCHRONI_SDK_WRAPPER_NAME} + PROPERTIES + ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/compiled + LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/compiled + RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/compiled +) + + +if (MSVC) + add_custom_command (TARGET ${SYNCHRONI_SDK_WRAPPER_NAME} POST_BUILD + COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_CURRENT_SOURCE_DIR}/compiled/$/${SYNCHRONI_SDK_WRAPPER_NAME}.dll" "${CMAKE_CURRENT_SOURCE_DIR}/matlab_package/brainflow/lib/${SYNCHRONI_SDK_WRAPPER_NAME}.dll" + COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_CURRENT_SOURCE_DIR}/compiled/$/${SYNCHRONI_SDK_WRAPPER_NAME}.dll" "${CMAKE_CURRENT_SOURCE_DIR}/python_package/brainflow/lib/${SYNCHRONI_SDK_WRAPPER_NAME}.dll" + COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_CURRENT_SOURCE_DIR}/compiled/$/${SYNCHRONI_SDK_WRAPPER_NAME}.dll" "${CMAKE_CURRENT_SOURCE_DIR}/csharp_package/brainflow/brainflow/lib/${SYNCHRONI_SDK_WRAPPER_NAME}.dll" + COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_CURRENT_SOURCE_DIR}/compiled/$/${SYNCHRONI_SDK_WRAPPER_NAME}.dll" "${CMAKE_CURRENT_SOURCE_DIR}/java_package/brainflow/src/main/resources/${SYNCHRONI_SDK_WRAPPER_NAME}.dll" + COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_CURRENT_SOURCE_DIR}/compiled/$/${SYNCHRONI_SDK_WRAPPER_NAME}.dll" "${CMAKE_CURRENT_SOURCE_DIR}/julia_package/brainflow/lib/${SYNCHRONI_SDK_WRAPPER_NAME}.dll" + COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_CURRENT_SOURCE_DIR}/compiled/$/${SYNCHRONI_SDK_WRAPPER_NAME}.dll" "${CMAKE_CURRENT_SOURCE_DIR}/nodejs_package/brainflow/lib/${SYNCHRONI_SDK_WRAPPER_NAME}.dll" + COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_CURRENT_SOURCE_DIR}/compiled/$/${SYNCHRONI_SDK_WRAPPER_NAME}.dll" "${CMAKE_CURRENT_SOURCE_DIR}/rust_package/brainflow/lib/${SYNCHRONI_SDK_WRAPPER_NAME}.dll" + COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_CURRENT_LIST_DIR}/lib/windows/${SYNCHRONI_SDK_ARCH}/For$/${SYNCHRONI_SDK_LINK_NAME_LIB}.dll" "${CMAKE_CURRENT_SOURCE_DIR}/matlab_package/brainflow/lib/${SYNCHRONI_SDK_LINK_NAME_LIB}.dll" + COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_CURRENT_LIST_DIR}/lib/windows/${SYNCHRONI_SDK_ARCH}/For$/${SYNCHRONI_SDK_LINK_NAME_LIB}.dll" "${CMAKE_CURRENT_SOURCE_DIR}/python_package/brainflow/lib/${SYNCHRONI_SDK_LINK_NAME_LIB}.dll" + COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_CURRENT_LIST_DIR}/lib/windows/${SYNCHRONI_SDK_ARCH}/For$/${SYNCHRONI_SDK_LINK_NAME_LIB}.dll" "${CMAKE_CURRENT_SOURCE_DIR}/csharp_package/brainflow/brainflow/lib/${SYNCHRONI_SDK_LINK_NAME_LIB}.dll" + COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_CURRENT_LIST_DIR}/lib/windows/${SYNCHRONI_SDK_ARCH}/For$/${SYNCHRONI_SDK_LINK_NAME_LIB}.dll" "${CMAKE_CURRENT_SOURCE_DIR}/java_package/brainflow/src/main/resources/${SYNCHRONI_SDK_LINK_NAME_LIB}.dll" + COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_CURRENT_LIST_DIR}/lib/windows/${SYNCHRONI_SDK_ARCH}/For$/${SYNCHRONI_SDK_LINK_NAME_LIB}.dll" "${CMAKE_CURRENT_SOURCE_DIR}/julia_package/brainflow/lib/${SYNCHRONI_SDK_LINK_NAME_LIB}.dll" + COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_CURRENT_LIST_DIR}/lib/windows/${SYNCHRONI_SDK_ARCH}/For$/${SYNCHRONI_SDK_LINK_NAME_LIB}.dll" "${CMAKE_CURRENT_SOURCE_DIR}/nodejs_package/brainflow/lib/${SYNCHRONI_SDK_LINK_NAME_LIB}.dll" + COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_CURRENT_LIST_DIR}/lib/windows/${SYNCHRONI_SDK_ARCH}/For$/${SYNCHRONI_SDK_LINK_NAME_LIB}.dll" "${CMAKE_CURRENT_SOURCE_DIR}/rust_package/brainflow/lib/${SYNCHRONI_SDK_LINK_NAME_LIB}.dll" + ) +endif (MSVC) + +if (APPLE) + add_custom_command (TARGET ${SYNCHRONI_SDK_WRAPPER_NAME} POST_BUILD + COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_CURRENT_SOURCE_DIR}/compiled/${SYNCHRONI_SDK_WRAPPER_COMPILED_NAME}" "${CMAKE_CURRENT_SOURCE_DIR}/nodejs_package/brainflow/lib/${SYNCHRONI_SDK_WRAPPER_COMPILED_NAME}" + COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_CURRENT_SOURCE_DIR}/compiled/${SYNCHRONI_SDK_WRAPPER_COMPILED_NAME}" "${CMAKE_CURRENT_SOURCE_DIR}/python_package/brainflow/lib/${SYNCHRONI_SDK_WRAPPER_COMPILED_NAME}" + COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_CURRENT_SOURCE_DIR}/compiled/${SYNCHRONI_SDK_WRAPPER_COMPILED_NAME}" "${CMAKE_CURRENT_SOURCE_DIR}/julia_package/brainflow/lib/${SYNCHRONI_SDK_WRAPPER_COMPILED_NAME}" + COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_CURRENT_SOURCE_DIR}/compiled/${SYNCHRONI_SDK_WRAPPER_COMPILED_NAME}" "${CMAKE_CURRENT_SOURCE_DIR}/java_package/brainflow/src/main/resources/${SYNCHRONI_SDK_WRAPPER_COMPILED_NAME}" + COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_CURRENT_SOURCE_DIR}/compiled/${SYNCHRONI_SDK_WRAPPER_COMPILED_NAME}" "${CMAKE_CURRENT_SOURCE_DIR}/csharp_package/brainflow/brainflow/lib/${SYNCHRONI_SDK_WRAPPER_COMPILED_NAME}" + COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_CURRENT_SOURCE_DIR}/compiled/${SYNCHRONI_SDK_WRAPPER_COMPILED_NAME}" "${CMAKE_CURRENT_SOURCE_DIR}/matlab_package/brainflow/lib/${SYNCHRONI_SDK_WRAPPER_COMPILED_NAME}" + COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_CURRENT_SOURCE_DIR}/compiled/${SYNCHRONI_SDK_WRAPPER_COMPILED_NAME}" "${CMAKE_CURRENT_SOURCE_DIR}/rust_package/brainflow/lib/${SYNCHRONI_SDK_WRAPPER_COMPILED_NAME}" + ) +elseif (UNIX) + add_custom_command (TARGET ${SYNCHRONI_SDK_WRAPPER_NAME} POST_BUILD + COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_CURRENT_SOURCE_DIR}/compiled/${SYNCHRONI_SDK_WRAPPER_COMPILED_NAME}" "${CMAKE_CURRENT_SOURCE_DIR}/nodejs_package/brainflow/lib/${SYNCHRONI_SDK_WRAPPER_COMPILED_NAME}" + COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_CURRENT_SOURCE_DIR}/compiled/${SYNCHRONI_SDK_WRAPPER_COMPILED_NAME}" "${CMAKE_CURRENT_SOURCE_DIR}/python_package/brainflow/lib/${SYNCHRONI_SDK_WRAPPER_COMPILED_NAME}" + COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_CURRENT_SOURCE_DIR}/compiled/${SYNCHRONI_SDK_WRAPPER_COMPILED_NAME}" "${CMAKE_CURRENT_SOURCE_DIR}/julia_package/brainflow/lib/${SYNCHRONI_SDK_WRAPPER_COMPILED_NAME}" + COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_CURRENT_SOURCE_DIR}/compiled/${SYNCHRONI_SDK_WRAPPER_COMPILED_NAME}" "${CMAKE_CURRENT_SOURCE_DIR}/java_package/brainflow/src/main/resources/${SYNCHRONI_SDK_WRAPPER_COMPILED_NAME}" + COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_CURRENT_SOURCE_DIR}/compiled/${SYNCHRONI_SDK_WRAPPER_COMPILED_NAME}" "${CMAKE_CURRENT_SOURCE_DIR}/csharp_package/brainflow/brainflow/lib/${SYNCHRONI_SDK_WRAPPER_COMPILED_NAME}" + COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_CURRENT_SOURCE_DIR}/compiled/${SYNCHRONI_SDK_WRAPPER_COMPILED_NAME}" "${CMAKE_CURRENT_SOURCE_DIR}/matlab_package/brainflow/lib/${SYNCHRONI_SDK_WRAPPER_COMPILED_NAME}" + COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_CURRENT_SOURCE_DIR}/compiled/${SYNCHRONI_SDK_WRAPPER_COMPILED_NAME}" "${CMAKE_CURRENT_SOURCE_DIR}/rust_package/brainflow/lib/${SYNCHRONI_SDK_WRAPPER_COMPILED_NAME}" + COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_CURRENT_LIST_DIR}/lib/linux/${SYNCHRONI_SDK_ARCH}/For${CMAKE_BUILD_TYPE}/${SYNCHRONI_SDK_LINK_NAME_LIB}" "${CMAKE_CURRENT_SOURCE_DIR}/matlab_package/brainflow/lib/${SYNCHRONI_SDK_LINK_NAME_LIB}" + COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_CURRENT_LIST_DIR}/lib/linux/${SYNCHRONI_SDK_ARCH}/For${CMAKE_BUILD_TYPE}/${SYNCHRONI_SDK_LINK_NAME_LIB}" "${CMAKE_CURRENT_SOURCE_DIR}/python_package/brainflow/lib/${SYNCHRONI_SDK_LINK_NAME_LIB}" + COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_CURRENT_LIST_DIR}/lib/linux/${SYNCHRONI_SDK_ARCH}/For${CMAKE_BUILD_TYPE}/${SYNCHRONI_SDK_LINK_NAME_LIB}" "${CMAKE_CURRENT_SOURCE_DIR}/csharp_package/brainflow/brainflow/lib/${SYNCHRONI_SDK_LINK_NAME_LIB}" + COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_CURRENT_LIST_DIR}/lib/linux/${SYNCHRONI_SDK_ARCH}/For${CMAKE_BUILD_TYPE}/${SYNCHRONI_SDK_LINK_NAME_LIB}" "${CMAKE_CURRENT_SOURCE_DIR}/java_package/brainflow/src/main/resources/${SYNCHRONI_SDK_LINK_NAME_LIB}" + COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_CURRENT_LIST_DIR}/lib/linux/${SYNCHRONI_SDK_ARCH}/For${CMAKE_BUILD_TYPE}/${SYNCHRONI_SDK_LINK_NAME_LIB}" "${CMAKE_CURRENT_SOURCE_DIR}/julia_package/brainflow/lib/${SYNCHRONI_SDK_LINK_NAME_LIB}" + COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_CURRENT_LIST_DIR}/lib/linux/${SYNCHRONI_SDK_ARCH}/For${CMAKE_BUILD_TYPE}/${SYNCHRONI_SDK_LINK_NAME_LIB}" "${CMAKE_CURRENT_SOURCE_DIR}/nodejs_package/brainflow/lib/${SYNCHRONI_SDK_LINK_NAME_LIB}" + COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_CURRENT_LIST_DIR}/lib/linux/${SYNCHRONI_SDK_ARCH}/For${CMAKE_BUILD_TYPE}/${SYNCHRONI_SDK_LINK_NAME_LIB}" "${CMAKE_CURRENT_SOURCE_DIR}/rust_package/brainflow/lib/${SYNCHRONI_SDK_LINK_NAME_LIB}" + ) +endif (APPLE) + +if (MSVC) + if (CMAKE_SIZEOF_VOID_P EQUAL 8) + install ( + FILES + ${CMAKE_CURRENT_SOURCE_DIR}/compiled/$/${SYNCHRONI_SDK_WRAPPER_NAME}.dll + ${CMAKE_CURRENT_SOURCE_DIR}/third_party/synchroni/lib/windows/${SYNCHRONI_SDK_ARCH}/For$/${SYNCHRONI_SDK_LINK_NAME_LIB}.dll + DESTINATION lib + ) + else (CMAKE_SIZEOF_VOID_P EQUAL 8) + install ( + FILES + ${CMAKE_CURRENT_SOURCE_DIR}/compiled/$/${SYNCHRONI_SDK_WRAPPER_NAME}.dll + ${CMAKE_CURRENT_SOURCE_DIR}/third_party/synchroni/lib/windows/${SYNCHRONI_SDK_ARCH}/For$/${SYNCHRONI_SDK_LINK_NAME_LIB}.dll + DESTINATION lib + ) + endif (CMAKE_SIZEOF_VOID_P EQUAL 8) +endif (MSVC) + +if (APPLE) + install ( + FILES + ${CMAKE_CURRENT_SOURCE_DIR}/compiled/${SYNCHRONI_SDK_WRAPPER_COMPILED_NAME} + DESTINATION lib + ) +elseif (UNIX) + install ( + FILES + ${CMAKE_CURRENT_SOURCE_DIR}/compiled/${SYNCHRONI_SDK_WRAPPER_COMPILED_NAME} + ${CMAKE_CURRENT_SOURCE_DIR}/third_party/synchroni/lib/linux/${SYNCHRONI_SDK_ARCH}/For${CMAKE_BUILD_TYPE}/${SYNCHRONI_SDK_LINK_NAME_LIB} + DESTINATION lib + ) +endif(APPLE) + +install ( + TARGETS ${SYNCHRONI_SDK_WRAPPER_NAME} + EXPORT ${TARGETS_EXPORT_NAME} + RUNTIME DESTINATION lib + LIBRARY DESTINATION lib + INCLUDES DESTINATION inc + ARCHIVE DESTINATION lib +) \ No newline at end of file diff --git a/third_party/synchroni/inc/SensorController.hpp b/third_party/synchroni/inc/SensorController.hpp new file mode 100644 index 000000000..32e83d23a --- /dev/null +++ b/third_party/synchroni/inc/SensorController.hpp @@ -0,0 +1,44 @@ +#ifndef SENSORCONTROLLER_H +#define SENSORCONTROLLER_H + +#include +#include +#include +#include "SensorProfile.hpp" +#include "export.h" + +namespace sensor { + + + +class SensorControllerDelegate +{ +public: + virtual void onSensorControllerEnableChanged(bool enabled){}; + virtual void onSensorScanResult(std::vector bleDevices){}; + virtual ~SensorControllerDelegate(){}; +}; + +class SENSORSDK_API SensorController +{ +public: + virtual ~SensorController() {}; + static std::shared_ptr getInstance(); + static void destory(); + virtual void setDelegate(std::weak_ptr delegate) = 0; + + virtual bool isEnable() = 0; + virtual bool isScaning() = 0; + virtual bool startScan(int periodInMS) = 0; + virtual bool stopScan() = 0; + + virtual BLEDevice getDevice(std::string deviceMac) = 0; + virtual std::shared_ptr getSensor(std::string deviceMac) = 0; + virtual std::vector> getSensors() = 0; + +}; + +}; + + +#endif // SENSORCONTROLLER_H diff --git a/third_party/synchroni/inc/SensorData.hpp b/third_party/synchroni/inc/SensorData.hpp new file mode 100644 index 000000000..9edb41bfb --- /dev/null +++ b/third_party/synchroni/inc/SensorData.hpp @@ -0,0 +1,57 @@ +#ifndef SENSORDATA_H +#define SENSORDATA_H + +#include +#include + +namespace sensor{ + +struct SensorData { + + enum Type{ + NTF_ACC_DATA = 1, + NTF_GYO_DATA = 2, + NTF_EEG = 16, + NTF_ECG = 17, + NTF_IMPEDANCE = 18, + NTF_IMU = 19, + NTF_ADS = 20, + NTF_BRTH = 21, + }; + + std::string deviceMac; + Type dataType; + int lastPackageCounter; + int lastPackageIndex; + int resolutionBits; + int sampleRate; + int channelCount; + unsigned long long channelMask; + int minPackageSampleCount; + int packageSampleCount; + double K; + + struct Sample { + int timeStampInMs; + int channelIndex; + int sampleIndex; + int rawData; + float data; + float impedance; + float saturation; + bool isLost; + }; + + std::vector> channelSamples; + + void clear() { + lastPackageCounter = 0; + lastPackageIndex = 0; + channelSamples.clear(); + } + +}; + +} + +#endif // SENSORDATA_H diff --git a/third_party/synchroni/inc/SensorProfile.hpp b/third_party/synchroni/inc/SensorProfile.hpp new file mode 100644 index 000000000..b727d0452 --- /dev/null +++ b/third_party/synchroni/inc/SensorProfile.hpp @@ -0,0 +1,75 @@ +#ifndef SENSORPROFILE_H +#define SENSORPROFILE_H + +#include +#include +#include +#include +#include "SensorData.hpp" + +namespace sensor { + +struct BLEDevice{ + enum class State{ + Disconnected, + Connecting, + Connected, + Ready, + Disconnecting, + Invalid + }; + + std::string name; + std::string mac; + int rssi; +}; + +struct DeviceInfo { + int MTUSize; + std::string deviceName; + std::string modelName; + std::string hardwareVersion; + std::string firmwareVersion; + bool isMTUFine; + int EEGChannelCount; + int ECGChannelCount; + int BRTHChannelCount; + int AccChannelCount; + int GyroChannelCount; +}; + +class SensorProfile; + +class SensorProfileDelegate { +public: + virtual void onErrorCallback(std::shared_ptr profile, std::string errorMsg) {}; + virtual void onStateChange(std::shared_ptr profile, BLEDevice::State newState) {}; + virtual void onSensorNotifyData(std::shared_ptr profile, const SensorData& rawData) {}; + virtual ~SensorProfileDelegate() {}; +}; + +class SensorProfile{ +public: + virtual BLEDevice getDevice() = 0; + virtual BLEDevice::State getDeviceState() = 0; + + virtual void setDelegate(std::weak_ptr delegate) = 0; + + virtual bool connect() = 0; + virtual void disconnect() = 0; + + virtual bool hasStartDataNotification() = 0; + virtual void startDataNotification(int timeoutInMS, std::function cb) = 0; + virtual void stopDataNotification(int timeoutInMS, std::function cb) = 0; + + virtual bool hasInit() = 0; + virtual void init(int inPackageSampleCount, int timeoutInMS, std::function cb) = 0; + virtual void getBatteryLevel(int timeoutInMS, std::function cb) = 0; + virtual void fetchDeviceInfo(int timeoutInMS, std::function cb) = 0; + virtual void setParam(int timeoutInMS, std::string key, std::string value, std::function cb) = 0; + SensorProfile() {}; + virtual ~SensorProfile() {}; +}; +} + +#endif // SENSORPROFILE_H diff --git a/third_party/synchroni/inc/export.h b/third_party/synchroni/inc/export.h new file mode 100644 index 000000000..d8d6eb511 --- /dev/null +++ b/third_party/synchroni/inc/export.h @@ -0,0 +1,60 @@ +/* + * Copyright 2017, OYMotion Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF + * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH + * DAMAGE. +* +*/ +/*! +* \file export.h +* \brief +* +* \version 0.1 +* \date 2017.4.20 +*/ +#pragma once +/// The following ifdef block is the standard way of creating macros which make exporting +/// from a DLL simpler. All files within this DLL are compiled with the SENSORSDK_EXPORTS +/// symbol defined on the command line. This symbol should not be defined on any project +/// that uses this DLL. This way any other project whose source files include this file see +/// GFORCESDK_API functions as being imported from a DLL, whereas this DLL sees symbols +/// defined with this macro as being exported. + +#ifdef WIN32 + +#ifdef SENSORSDK_EXPORTS +#define SENSORSDK_API __declspec(dllexport) +#else +#define SENSORSDK_API __declspec(dllimport) +#endif + +#else // #ifdef WIN32 + +#define SENSORSDK_API + +#endif + +#define DESTORY_SENSOR_CONTROLLER_DELAY struct _SensorControllerCleaner { ~_SensorControllerCleaner() { sensor::SensorController::destory(); } }_sensorControllerCleaner; \ No newline at end of file diff --git a/third_party/synchroni/lib/linux/arm64/ForDebug/libsensor_arm64.so b/third_party/synchroni/lib/linux/arm64/ForDebug/libsensor_arm64.so new file mode 100644 index 000000000..4e95a748e Binary files /dev/null and b/third_party/synchroni/lib/linux/arm64/ForDebug/libsensor_arm64.so differ diff --git a/third_party/synchroni/lib/linux/arm64/ForRelease/libsensor_arm64.so b/third_party/synchroni/lib/linux/arm64/ForRelease/libsensor_arm64.so new file mode 100644 index 000000000..95087c7d0 Binary files /dev/null and b/third_party/synchroni/lib/linux/arm64/ForRelease/libsensor_arm64.so differ diff --git a/third_party/synchroni/lib/linux/x86_64/ForDebug/libsensor_x64.so b/third_party/synchroni/lib/linux/x86_64/ForDebug/libsensor_x64.so new file mode 100644 index 000000000..5165d2902 Binary files /dev/null and b/third_party/synchroni/lib/linux/x86_64/ForDebug/libsensor_x64.so differ diff --git a/third_party/synchroni/lib/linux/x86_64/ForRelease/libsensor_x64.so b/third_party/synchroni/lib/linux/x86_64/ForRelease/libsensor_x64.so new file mode 100644 index 000000000..66fbea5bf Binary files /dev/null and b/third_party/synchroni/lib/linux/x86_64/ForRelease/libsensor_x64.so differ diff --git a/third_party/synchroni/lib/mac/sensor.xcframework/Info.plist b/third_party/synchroni/lib/mac/sensor.xcframework/Info.plist new file mode 100644 index 000000000..74e50704d --- /dev/null +++ b/third_party/synchroni/lib/mac/sensor.xcframework/Info.plist @@ -0,0 +1,68 @@ + + + + + AvailableLibraries + + + LibraryIdentifier + macos-arm64_x86_64 + LibraryPath + sensor.framework + SupportedArchitectures + + arm64 + x86_64 + + SupportedPlatform + macos + + + LibraryIdentifier + ios-arm64_x86_64-maccatalyst + LibraryPath + sensor.framework + SupportedArchitectures + + arm64 + x86_64 + + SupportedPlatform + ios + SupportedPlatformVariant + maccatalyst + + + LibraryIdentifier + ios-arm64_x86_64-simulator + LibraryPath + sensor.framework + SupportedArchitectures + + arm64 + x86_64 + + SupportedPlatform + ios + SupportedPlatformVariant + simulator + + + LibraryIdentifier + ios-arm64 + LibraryPath + sensor.framework + SupportedArchitectures + + arm64 + + SupportedPlatform + ios + + + CFBundlePackageType + XFWK + XCFrameworkFormatVersion + 1.0 + + diff --git a/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64/sensor.framework/Headers/BLEPeripheral.h b/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64/sensor.framework/Headers/BLEPeripheral.h new file mode 100644 index 000000000..c16fa59d3 --- /dev/null +++ b/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64/sensor.framework/Headers/BLEPeripheral.h @@ -0,0 +1,102 @@ +// +// BLEPeripheral.h +// TheOne +// +// Created by 王涛 on 2017/6/13. +// Copyright © 2017年 tcl. All rights reserved. +// + +#import +#import + + +@interface BLEPeripheral : NSObject + +@property (nonatomic, strong) CBPeripheral *cbPeripheral; +//deviceName +@property (nonatomic, copy) NSString *name; + +@property (nonatomic, copy) NSString *macAddress; + +@property (nonatomic, strong) NSNumber *rssi; + ++(NSString*)parseMacAddress:(NSDictionary*)advData; + +- (instancetype)initWithPeripheral:(CBPeripheral *)peripheral; + + +/** + * 订阅外设服务,注:未订阅的服务不提供读写操作 + * + * @param serviceUUID Serice UUID + * @param charactUUID Characteristic UUID + */ +- (void)addService:(NSString *)serviceUUID characteristic:(NSString *)charactUUID; + + +/** + * 注册生成已订阅的特征实例数据集 + * 用于特征读写 + * @param service 服务 + * @param characteristic 特征 + */ +- (void)registerForService:(CBService *)service characteristic:(CBCharacteristic *)characteristic; + +/** + * 已订阅的所有服务UUID + * + * @return UUID 数组 + */ +- (NSArray *)services; + +/** + * 已订阅服务的特征信息 + * + * @param uuidString service uuid string + * @return characteristic uuid string array + */ +- (NSArray *)characteristicForService:(NSString *)uuidString; + +/** + * 根据规则生成唯一UUID(不同服务存在相同特征) + * + @param serviceUUID 服务UUID + @param charactUUID 特征UUID + @return 唯一标识符 + */ ++ (NSString *)generateIdentifierWithService:(NSString *)serviceUUID characteristic:(NSString *)charactUUID; + +/** + * 判断订阅的服务特征是否启用通知功能 + * + * @param service 服务 + * @param characteristic 特征 + * @return 通知启用状态 + */ +- (BOOL)isNotifyForService:(CBService *)service characteristic:(CBCharacteristic *)characteristic; + +/** + Description + + @param data 传输数据 + @param identifier Serive & Charactersitic 合成的UUID +*/ +//- (void)writeValue:(NSData *)data forIdentifier:(NSString *)identifier; +- (void)writeValue:(NSData *)data forIdentifier:(NSString *)identifier; + +- (void)writeDataWithResponseValue:(NSData *)data forIdentifier:(NSString *)identifier; +/** + Description + + @param indetifier Serive & Charactersitic 合成的UUID + */ +- (void)readValueForIndetifier:(NSString *)indetifier; +/** + Description + + @param dict 转换macString rssi 设备距离 + */ +- (BOOL)transformMacStringWithAdvertisementData:(NSDictionary *)dict withRssi:(NSNumber *)rssi; + +- (void)setNotifyForIdetifier:(NSString*)indetifier enable:(BOOL)enable; +@end diff --git a/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64/sensor.framework/Headers/SensorController.h b/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64/sensor.framework/Headers/SensorController.h new file mode 100644 index 000000000..94a6bad6a --- /dev/null +++ b/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64/sensor.framework/Headers/SensorController.h @@ -0,0 +1,36 @@ +// +// SensorController.h +// test +// +// Created by 叶常青 on 2024/4/19. +// + +#import +#import +NS_ASSUME_NONNULL_BEGIN + + +@protocol SensorControllerDelegate +- (void)onSensorControllerEnableChange:(bool)enabled; +- (void)onSensorScanResult:(NSArray*) bleDevices; +@end + + +@interface SensorController : NSObject +@property (atomic, weak) id delegate; +@property (atomic, retain, readonly) NSArray* scanResults; +@property (atomic, assign, readonly) bool isEnable; +@property (atomic, assign, readonly) bool isScaning; ++ (instancetype)getInstance; ++ (void)destory; + +-(BLEPeripheral*)getDevice:(NSString*)deviceMac; +-(SensorProfile*)getSensor:(NSString*)deviceMac; +-(NSArray*)getSensors; +-(BOOL)startScan:(NSTimeInterval)scanInterval; +-(void)stopScan; + + +@end + +NS_ASSUME_NONNULL_END diff --git a/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64/sensor.framework/Headers/SensorController.hpp b/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64/sensor.framework/Headers/SensorController.hpp new file mode 100755 index 000000000..21738b67e --- /dev/null +++ b/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64/sensor.framework/Headers/SensorController.hpp @@ -0,0 +1,43 @@ +#ifndef SENSORCONTROLLER_H +#define SENSORCONTROLLER_H + +#include +#include +#include +#include "SensorProfile.hpp" + +namespace sensor { + + + +class SensorControllerDelegate +{ +public: + virtual void onSensorControllerEnableChanged(bool enabled){}; + virtual void onSensorScanResult(std::vector bleDevices){}; + virtual ~SensorControllerDelegate(){}; +}; + +class SensorController +{ +public: + virtual ~SensorController() {}; + static std::shared_ptr getInstance(); + static void destory(); + virtual void setDelegate(std::weak_ptr delegate) = 0; + + virtual bool isEnable() = 0; + virtual bool isScaning() = 0; + virtual bool startScan(int periodInMS) = 0; + virtual bool stopScan() = 0; + + virtual BLEDevice getDevice(std::string deviceMac) = 0; + virtual std::shared_ptr getSensor(std::string deviceMac) = 0; + virtual std::vector> getSensors() = 0; + +}; + +}; + + +#endif // SENSORCONTROLLER_H diff --git a/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64/sensor.framework/Headers/SensorData.hpp b/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64/sensor.framework/Headers/SensorData.hpp new file mode 100755 index 000000000..0738b7a34 --- /dev/null +++ b/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64/sensor.framework/Headers/SensorData.hpp @@ -0,0 +1,57 @@ +#ifndef SENSORDATA_H +#define SENSORDATA_H + +#include +#include + +namespace sensor{ + +struct SensorData { + + enum Type{ + NTF_ACC_DATA = 1, + NTF_GYO_DATA = 2, + NTF_EEG = 16, + NTF_ECG = 17, + NTF_IMPEDANCE = 18, + NTF_IMU = 19, + NTF_ADS = 20, + NTF_BRTH = 21, + }; + + std::string deviceMac; + Type dataType; + int lastPackageCounter; + int lastPackageIndex; + int resolutionBits; + int sampleRate; + int channelCount; + long channelMask; + int minPackageSampleCount; + int packageSampleCount; + double K; + + struct Sample { + int timeStampInMs; + int channelIndex; + int sampleIndex; + int rawData; + float data; + float impedance; + float saturation; + bool isLost; + }; + + std::vector> channelSamples; + + void clear() { + lastPackageCounter = 0; + lastPackageIndex = 0; + channelSamples.clear(); + } + +}; + +} + +#endif // SENSORDATA_H diff --git a/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64/sensor.framework/Headers/SensorProfile.hpp b/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64/sensor.framework/Headers/SensorProfile.hpp new file mode 100755 index 000000000..307a1f4a3 --- /dev/null +++ b/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64/sensor.framework/Headers/SensorProfile.hpp @@ -0,0 +1,75 @@ +#ifndef SENSORPROFILE_H +#define SENSORPROFILE_H + +#include +#include +#include +#include +#include "SensorData.hpp" + +namespace sensor { + +struct BLEDevice{ + enum State{ + Disconnected, + Connecting, + Connected, + Ready, + Disconnecting, + Invalid + }; + + std::string name; + std::string mac; + int rssi; +}; + +struct DeviceInfo { + int MTUSize; + std::string deviceName; + std::string modelName; + std::string hardwareVersion; + std::string firmwareVersion; + bool isMTUFine; + int EEGChannelCount; + int ECGChannelCount; + int BRTHChannelCount; + int AccChannelCount; + int GyroChannelCount; +}; + +class SensorProfile; + +class SensorProfileDelegate { +public: + virtual void onErrorCallback(std::shared_ptr profile, std::string errorMsg) {}; + virtual void onStateChange(std::shared_ptr profile, BLEDevice::State newState) {}; + virtual void onSensorNotifyData(std::shared_ptr profile, const SensorData& rawData) {}; + virtual ~SensorProfileDelegate() {}; +}; + +class SensorProfile{ +public: + virtual BLEDevice getDevice() = 0; + virtual BLEDevice::State getDeviceState() = 0; + + virtual void setDelegate(std::weak_ptr delegate) = 0; + + virtual bool connect() = 0; + virtual void disconnect() = 0; + + virtual bool hasStartDataNotification() = 0; + virtual void startDataNotification(int timeoutInMS, std::function cb) = 0; + virtual void stopDataNotification(int timeoutInMS, std::function cb) = 0; + + virtual bool hasInit() = 0; + virtual void init(int inPackageSampleCount, int timeoutInMS, std::function cb) = 0; + virtual void getBatteryLevel(int timeoutInMS, std::function cb) = 0; + virtual void fetchDeviceInfo(int timeoutInMS, std::function cb) = 0; + virtual void setParam(int timeoutInMS, std::string key, std::string value, std::function cb) = 0; + SensorProfile() {}; + virtual ~SensorProfile() {}; +}; +} + +#endif // SENSORPROFILE_H diff --git a/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64/sensor.framework/Headers/defines.h b/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64/sensor.framework/Headers/defines.h new file mode 100644 index 000000000..613022e22 --- /dev/null +++ b/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64/sensor.framework/Headers/defines.h @@ -0,0 +1,156 @@ +// +// sensordefines.h +// sensorprofile +// +// Created by 叶常青 on 2023/12/20. +// + +#ifndef sensordefines_h +#define sensordefines_h + + +typedef NS_ENUM(NSInteger, GF_RET_CODE) { + /// Method returns successfully. + GF_SUCCESS/*= 0*/, + + /// Method returns with a generic error. + GF_ERROR, + + /// Given parameters are not match required. + GF_ERROR_BAD_PARAM, + + /// Method call is not allowed by the inner state. + GF_ERROR_BAD_STATE, + + /// Method is not supported at this time. + GF_ERROR_NOT_SUPPORT, + + /// Hub is busying on device scan and cannot fulfill the call. + GF_ERROR_SCAN_BUSY, + + /// Insufficient resource to perform the call. + GF_ERROR_NO_RESOURCE, + + /// A preset timer is expired. + GF_ERROR_TIMEOUT, + + /// Target device is busy and cannot fulfill the call. + GF_ERROR_DEVICE_BUSY, + + /// The retrieving data is not ready yet + GF_ERROR_NOT_READY, +}; + +typedef NS_ENUM(NSInteger, ResponseResult) { + RSP_CODE_SUCCESS = 0x00, + RSP_CODE_NOT_SUPPORT = 0x01, + RSP_CODE_BAD_PARAM = 0x02, + RSP_CODE_FAILED = 0x03, + RSP_CODE_TIMEOUT = 0x04, + RSP_CODE_PARTIAL_PACKET = 0xFF +}; + +typedef NS_ENUM(NSInteger, FeatureMaps) { + GFD_FEAT_EMG = 0x000002000, + GFD_FEAT_EEG = 0x000400000, + GFD_FEAT_ECG = 0x000800000, + GFD_FEAT_IMPEDANCE = 0x001000000, + GFD_FEAT_IMU = 0x002000000, + GFD_FEAT_ADS = 0x004000000, + GFD_FEAT_BRTH = 0x008000000, +}; + +typedef NS_ENUM(NSInteger, DataNotifyFlags) { + /// Data Notify All Off + DNF_OFF = 0x00000000, + + /// Accelerate On(C.7) + DNF_ACCELERATE = 0x00000001, + + /// Gyroscope On(C.8) + DNF_GYROSCOPE = 0x00000002, + + /// Magnetometer On(C.9) + DNF_MAGNETOMETER = 0x00000004, + + /// Euler Angle On(C.10) + DNF_EULERANGLE = 0x00000008, + + /// Quaternion On(C.11) + DNF_QUATERNION = 0x00000010, + + /// Rotation Matrix On(C.12) + DNF_ROTATIONMATRIX = 0x00000020, + + /// EMG Gesture On(C.13) + DNF_EMG_GESTURE = 0x00000040, + + /// EMG Raw Data On(C.14) + DNF_EMG_RAW = 0x00000080, + + /// HID Mouse On(C.15) + DNF_HID_MOUSE = 0x00000100, + + /// HID Joystick On(C.16) + DNF_HID_JOYSTICK = 0x00000200, + + /// Device Status On(C.17) + DNF_DEVICE_STATUS = 0x00000400, + + /// Device Log On + DNF_LOG = 0x00000800, + + DNF_EEG = 0x00010000, + + DNF_ECG = 0x00020000, + + DNF_IMPEDANCE = 0x00040000, + + DNF_IMU = 0x00080000, + + DNF_ADS = 0x00100000, + + DNF_BRTH = 0x00200000, + /// Data Notify All On + DNF_ALL = 0xFFFFFFFF, +}; + + +typedef NS_ENUM(NSInteger, NotifyDataType) { + NTF_ACC_DATA = 0x01, + NTF_GYO_DATA, + NTF_MAG_DATA, + NTF_EULER_DATA, + NTF_QUAT_FLOAT_DATA, + NTF_ROTA_DATA, + NTF_EMG_GEST_DATA, + NTF_EMG_ADC_DATA, + NTF_HID_MOUSE, + NTF_HID_JOYSTICK, + NTF_DEV_STATUS, + NTF_LOG_DATA, + NTF_MAG_ANGLE_DATA, + NTF_MOT_CURRENT_DATA, + NTF_NEUCIR_STATUS, + NTF_EEG, + NTF_ECG, + NTF_IMPEDANCE, + NTF_IMU, + NTF_ADS, + NTF_BRTH, + NTF_DATA_TYPE_MAX, + NTF_PARTIAL_DATA = 0xFF +}; + + +typedef NS_ENUM(NSInteger, BLEState) +{ + BLEStateUnConnected, + BLEStateConnecting, + BLEStateConnected, + BLEStateReady, + BLEStateDisconnecting, + BLEStateInvalid, +}; + +#endif /* sensordefines_h */ diff --git a/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64/sensor.framework/Headers/sensor.h b/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64/sensor.framework/Headers/sensor.h new file mode 100644 index 000000000..2a3932e17 --- /dev/null +++ b/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64/sensor.framework/Headers/sensor.h @@ -0,0 +1,19 @@ +// +// sensorOC_Bridge.h +// sensor +// +// Created by 叶常青 on 2024/4/17. +// + +#ifndef sensorOC_Bridge_h +#define sensorOC_Bridge_h + +#import + +FOUNDATION_EXPORT double sensorVersionNumber = 1; + +FOUNDATION_EXPORT const unsigned char sensorVersionString[] = "1.0"; + +#import +#import +#endif /* sensorOC_Bridge_h */ diff --git a/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64/sensor.framework/Headers/sensorProfile.h b/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64/sensor.framework/Headers/sensorProfile.h new file mode 100644 index 000000000..f713b84f6 --- /dev/null +++ b/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64/sensor.framework/Headers/sensorProfile.h @@ -0,0 +1,101 @@ +// +// sensorProfile.h +// sensorProfile +// +// Created by 叶常青 on 2023/12/21. +// +#ifndef sensor_profile_h +#define sensor_profile_h + +#import +#import +#import +#import + +@interface DeviceInfo : NSObject + +@property (atomic, strong) NSString* deviceName; +@property (atomic, strong) NSString* modelName; +@property (atomic, strong) NSString* hardwareVersion; +@property (atomic, strong) NSString* firmwareVersion; +@property (atomic, assign) int MTUSize; +@property (atomic, assign) bool isMTUFine; +@property (atomic, assign) int EEGChannelCount; +@property (atomic, assign) int ECGChannelCount; +@property (atomic, assign) int BRTHChannelCount; +@property (atomic, assign) int AccChannelCount; +@property (atomic, assign) int GyroChannelCount; + +@end + +@interface Sample : NSObject +@property (atomic, assign) int timeStampInMs; +@property (atomic, assign) int sampleIndex; +@property (atomic, assign) int channelIndex; +@property (atomic, assign) BOOL isLost; +@property (atomic, assign) float rawData; +@property (atomic, assign) float convertData; +@property (atomic, assign) float impedance; +@property (atomic, assign) float saturation; +@end + +@interface SensorData : NSObject + +@property (atomic, assign) NotifyDataType dataType; +@property (atomic, assign) int lastPackageIndex; +@property (atomic, assign) int lastPackageCounter; +@property (atomic, assign) int resolutionBits; +@property (atomic, assign) int sampleRate; +@property (atomic, assign) int channelCount; +@property (atomic, assign) unsigned long long channelMask; +@property (atomic, assign) int packageSampleCount; +@property (atomic, assign) int minPackageSampleCount; +@property (atomic, assign) double K; +@property (atomic, strong) NSArray*>* channelSamples; +-(id)init; +-(void)clear; +-(NSArray*)flushSamples; +@end + +@protocol SensorProfileDelegate; + +@interface SensorProfile : NSObject +{ + +} +@property (atomic, weak) id delegate; +@property (atomic, assign, readonly) BLEState state; +@property (atomic, readonly) NSString* stateString; +@property (atomic, strong, readonly) BLEPeripheral* device; +@property (atomic, strong, readonly) DeviceInfo* deviceInfo; +@property (atomic, assign, readonly) bool hasInit; +@property (atomic, assign, readonly) bool hasStartDataNotification; + + +-(BOOL)connect; +-(void)disconnect; +-(BOOL)startDataNotification; +-(BOOL)stopDataNotification; + +- (void)initAll:(int)packageCount timeout:(NSTimeInterval)timeout completion:(void (^)(BOOL success, NSError * err))completionHandler; +- (void)initEEG:(int)packageCount timeout:(NSTimeInterval)timeout completion:(void (^)(BOOL success, NSError * err))completionHandler; +- (void)initECG:(int)packageCount timeout:(NSTimeInterval)timeout completion:(void (^)(BOOL success, NSError * err))completionHandler; +- (void)initIMU:(int)packageCount timeout:(NSTimeInterval)timeout completion:(void (^)(BOOL success, NSError * err))completionHandler; +- (void)initBRTH:(int)packageCount timeout:(NSTimeInterval)timeout completion:(void (^)(BOOL success, NSError * err))completionHandler; +- (void)initDataTransfer:(BOOL)isGetFeature timeout:(NSTimeInterval)timeout completion:(void (^)(int flag, NSError * err))completionHandler; +- (void)getBattery:(NSTimeInterval)timeout completion:(void (^)(int battery, NSError * err))completionHandler; +- (void)getDeviceInfo:(BOOL)onlyMTU timeout:(NSTimeInterval)timeout completion:(void (^)(DeviceInfo* deviceInfo, NSError * err))completionHandler; +- (void)startDataNotification:(NSTimeInterval)timeout completion:(void (^)(BOOL success, NSError * err))completionHandler; +- (void)stopDataNotification:(NSTimeInterval)timeout completion:(void (^)(BOOL success, NSError * err))completionHandler; + +- (void)setParam:(NSTimeInterval)timeout key:(NSString*_Nonnull)key value:(NSString*_Nonnull)value completion:(void (^_Nonnull)(NSString*_Nonnull result, NSError * _Nullable err))completionHandler; + +@end + +@protocol SensorProfileDelegate +- (void)onSensorErrorCallback:(SensorProfile*_Nonnull)profile err:(NSError*_Nonnull)err; +- (void)onSensorStateChange:(SensorProfile*_Nonnull)profile newState:(BLEState)newState; +- (void)onSensorNotifyData:(SensorProfile*_Nonnull)profile rawData:(SensorData*_Nonnull) rawData; +@end + +#endif diff --git a/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64/sensor.framework/Info.plist b/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64/sensor.framework/Info.plist new file mode 100644 index 000000000..1069c61ce Binary files /dev/null and b/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64/sensor.framework/Info.plist differ diff --git a/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64/sensor.framework/Modules/module.modulemap b/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64/sensor.framework/Modules/module.modulemap new file mode 100644 index 000000000..6391e2b80 --- /dev/null +++ b/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64/sensor.framework/Modules/module.modulemap @@ -0,0 +1,6 @@ +framework module sensor { + umbrella header "sensor.h" + + export * + module * { export * } +} diff --git a/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64/sensor.framework/_CodeSignature/CodeDirectory b/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64/sensor.framework/_CodeSignature/CodeDirectory new file mode 100644 index 000000000..95ef014c0 Binary files /dev/null and b/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64/sensor.framework/_CodeSignature/CodeDirectory differ diff --git a/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64/sensor.framework/_CodeSignature/CodeRequirements b/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64/sensor.framework/_CodeSignature/CodeRequirements new file mode 100644 index 000000000..83a81ef9b Binary files /dev/null and b/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64/sensor.framework/_CodeSignature/CodeRequirements differ diff --git a/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64/sensor.framework/_CodeSignature/CodeRequirements-1 b/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64/sensor.framework/_CodeSignature/CodeRequirements-1 new file mode 100644 index 000000000..0cb3871b6 Binary files /dev/null and b/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64/sensor.framework/_CodeSignature/CodeRequirements-1 differ diff --git a/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64/sensor.framework/_CodeSignature/CodeResources b/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64/sensor.framework/_CodeSignature/CodeResources new file mode 100644 index 000000000..67b1c3f54 --- /dev/null +++ b/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64/sensor.framework/_CodeSignature/CodeResources @@ -0,0 +1,237 @@ + + + + + files + + Headers/BLEPeripheral.h + + ScMKAnaRSunM5VR5LhzbqyPcMM8= + + Headers/SensorController.h + + LEKmoiwY0eFzOTC9jWaTAFwFai8= + + Headers/SensorController.hpp + + LKS2auDoV9yljRi3diaExNrPVDw= + + Headers/SensorData.hpp + + eSM6WcP/p94o6eDF2YcrxcIqpCk= + + Headers/SensorProfile.h + + AsLNZ4tujqDYaDt71hVilMqQa2M= + + Headers/SensorProfile.hpp + + ScoQnVZ0N0xsiftJ6s9IVfP+1Lo= + + Headers/defines.h + + 6JxT8sZUpjfdLWeH76NeOE1u2Jc= + + Headers/sensor.h + + j/aJB8fU9MHfSeXZ+MHuuzgRC8Y= + + Info.plist + + ABsL+AxzdLSuGgQSQoiqsO11cdU= + + Modules/module.modulemap + + PmkZKQtcJn9CbKZGFyH8DHGquDM= + + + files2 + + Headers/BLEPeripheral.h + + hash + + ScMKAnaRSunM5VR5LhzbqyPcMM8= + + hash2 + + xsCr5VEKnCj9s+H04uZnWmn5h03Zk1AZV5LEzEe7/BE= + + + Headers/SensorController.h + + hash + + LEKmoiwY0eFzOTC9jWaTAFwFai8= + + hash2 + + yanvVMbiv1Cx+bZAg9xhxsZb+tmdDMYX3/nLJsZSuAI= + + + Headers/SensorController.hpp + + hash + + LKS2auDoV9yljRi3diaExNrPVDw= + + hash2 + + d7iHF96PUrr0BFtR6o0JwYxMD4H+4AwDYvVxvJQgnrA= + + + Headers/SensorData.hpp + + hash + + eSM6WcP/p94o6eDF2YcrxcIqpCk= + + hash2 + + js9AVsuzZpBVqbwzT12WyxhH1jRJXbl2fYoJVn8nv9Q= + + + Headers/SensorProfile.h + + hash + + AsLNZ4tujqDYaDt71hVilMqQa2M= + + hash2 + + t90schmW6nLupfAHoxrCNZGKlR+A52LRPadI4gzQQxQ= + + + Headers/SensorProfile.hpp + + hash + + ScoQnVZ0N0xsiftJ6s9IVfP+1Lo= + + hash2 + + IZ53bEdxLyiAXDsV8Zmd3v9G/HUAKT4osOkCUKsSM4M= + + + Headers/defines.h + + hash + + 6JxT8sZUpjfdLWeH76NeOE1u2Jc= + + hash2 + + 3a4kW1afB639zCIMlgZm4dYSYIoRAod1GAls6v5tW/4= + + + Headers/sensor.h + + hash + + j/aJB8fU9MHfSeXZ+MHuuzgRC8Y= + + hash2 + + uPnFelYZa/cHn/pVLsX7I2UuJNNwD4cVXddGZtjd0QI= + + + Modules/module.modulemap + + hash + + PmkZKQtcJn9CbKZGFyH8DHGquDM= + + hash2 + + BDjL+me3BBqvaiEz6ERAoe4Mg+SwwX8q/IJQ++zKZL4= + + + + rules + + ^.* + + ^.*\.lproj/ + + optional + + weight + 1000 + + ^.*\.lproj/locversion.plist$ + + omit + + weight + 1100 + + ^Base\.lproj/ + + weight + 1010 + + ^version.plist$ + + + rules2 + + .*\.dSYM($|/) + + weight + 11 + + ^(.*/)?\.DS_Store$ + + omit + + weight + 2000 + + ^.* + + ^.*\.lproj/ + + optional + + weight + 1000 + + ^.*\.lproj/locversion.plist$ + + omit + + weight + 1100 + + ^Base\.lproj/ + + weight + 1010 + + ^Info\.plist$ + + omit + + weight + 20 + + ^PkgInfo$ + + omit + + weight + 20 + + ^embedded\.provisionprofile$ + + weight + 20 + + ^version\.plist$ + + weight + 20 + + + + diff --git a/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64/sensor.framework/_CodeSignature/CodeSignature b/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64/sensor.framework/_CodeSignature/CodeSignature new file mode 100644 index 000000000..2f256a9be Binary files /dev/null and b/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64/sensor.framework/_CodeSignature/CodeSignature differ diff --git a/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64/sensor.framework/sensor b/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64/sensor.framework/sensor new file mode 100644 index 000000000..15ff64c3f Binary files /dev/null and b/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64/sensor.framework/sensor differ diff --git a/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64_x86_64-maccatalyst/sensor.framework/Headers b/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64_x86_64-maccatalyst/sensor.framework/Headers new file mode 120000 index 000000000..a177d2a6b --- /dev/null +++ b/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64_x86_64-maccatalyst/sensor.framework/Headers @@ -0,0 +1 @@ +Versions/Current/Headers \ No newline at end of file diff --git a/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64_x86_64-maccatalyst/sensor.framework/Modules b/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64_x86_64-maccatalyst/sensor.framework/Modules new file mode 120000 index 000000000..5736f3186 --- /dev/null +++ b/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64_x86_64-maccatalyst/sensor.framework/Modules @@ -0,0 +1 @@ +Versions/Current/Modules \ No newline at end of file diff --git a/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64_x86_64-maccatalyst/sensor.framework/Resources b/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64_x86_64-maccatalyst/sensor.framework/Resources new file mode 120000 index 000000000..953ee36f3 --- /dev/null +++ b/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64_x86_64-maccatalyst/sensor.framework/Resources @@ -0,0 +1 @@ +Versions/Current/Resources \ No newline at end of file diff --git a/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64_x86_64-maccatalyst/sensor.framework/Versions/A/Headers/BLEPeripheral.h b/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64_x86_64-maccatalyst/sensor.framework/Versions/A/Headers/BLEPeripheral.h new file mode 100644 index 000000000..c16fa59d3 --- /dev/null +++ b/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64_x86_64-maccatalyst/sensor.framework/Versions/A/Headers/BLEPeripheral.h @@ -0,0 +1,102 @@ +// +// BLEPeripheral.h +// TheOne +// +// Created by 王涛 on 2017/6/13. +// Copyright © 2017年 tcl. All rights reserved. +// + +#import +#import + + +@interface BLEPeripheral : NSObject + +@property (nonatomic, strong) CBPeripheral *cbPeripheral; +//deviceName +@property (nonatomic, copy) NSString *name; + +@property (nonatomic, copy) NSString *macAddress; + +@property (nonatomic, strong) NSNumber *rssi; + ++(NSString*)parseMacAddress:(NSDictionary*)advData; + +- (instancetype)initWithPeripheral:(CBPeripheral *)peripheral; + + +/** + * 订阅外设服务,注:未订阅的服务不提供读写操作 + * + * @param serviceUUID Serice UUID + * @param charactUUID Characteristic UUID + */ +- (void)addService:(NSString *)serviceUUID characteristic:(NSString *)charactUUID; + + +/** + * 注册生成已订阅的特征实例数据集 + * 用于特征读写 + * @param service 服务 + * @param characteristic 特征 + */ +- (void)registerForService:(CBService *)service characteristic:(CBCharacteristic *)characteristic; + +/** + * 已订阅的所有服务UUID + * + * @return UUID 数组 + */ +- (NSArray *)services; + +/** + * 已订阅服务的特征信息 + * + * @param uuidString service uuid string + * @return characteristic uuid string array + */ +- (NSArray *)characteristicForService:(NSString *)uuidString; + +/** + * 根据规则生成唯一UUID(不同服务存在相同特征) + * + @param serviceUUID 服务UUID + @param charactUUID 特征UUID + @return 唯一标识符 + */ ++ (NSString *)generateIdentifierWithService:(NSString *)serviceUUID characteristic:(NSString *)charactUUID; + +/** + * 判断订阅的服务特征是否启用通知功能 + * + * @param service 服务 + * @param characteristic 特征 + * @return 通知启用状态 + */ +- (BOOL)isNotifyForService:(CBService *)service characteristic:(CBCharacteristic *)characteristic; + +/** + Description + + @param data 传输数据 + @param identifier Serive & Charactersitic 合成的UUID +*/ +//- (void)writeValue:(NSData *)data forIdentifier:(NSString *)identifier; +- (void)writeValue:(NSData *)data forIdentifier:(NSString *)identifier; + +- (void)writeDataWithResponseValue:(NSData *)data forIdentifier:(NSString *)identifier; +/** + Description + + @param indetifier Serive & Charactersitic 合成的UUID + */ +- (void)readValueForIndetifier:(NSString *)indetifier; +/** + Description + + @param dict 转换macString rssi 设备距离 + */ +- (BOOL)transformMacStringWithAdvertisementData:(NSDictionary *)dict withRssi:(NSNumber *)rssi; + +- (void)setNotifyForIdetifier:(NSString*)indetifier enable:(BOOL)enable; +@end diff --git a/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64_x86_64-maccatalyst/sensor.framework/Versions/A/Headers/SensorController.h b/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64_x86_64-maccatalyst/sensor.framework/Versions/A/Headers/SensorController.h new file mode 100644 index 000000000..94a6bad6a --- /dev/null +++ b/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64_x86_64-maccatalyst/sensor.framework/Versions/A/Headers/SensorController.h @@ -0,0 +1,36 @@ +// +// SensorController.h +// test +// +// Created by 叶常青 on 2024/4/19. +// + +#import +#import +NS_ASSUME_NONNULL_BEGIN + + +@protocol SensorControllerDelegate +- (void)onSensorControllerEnableChange:(bool)enabled; +- (void)onSensorScanResult:(NSArray*) bleDevices; +@end + + +@interface SensorController : NSObject +@property (atomic, weak) id delegate; +@property (atomic, retain, readonly) NSArray* scanResults; +@property (atomic, assign, readonly) bool isEnable; +@property (atomic, assign, readonly) bool isScaning; ++ (instancetype)getInstance; ++ (void)destory; + +-(BLEPeripheral*)getDevice:(NSString*)deviceMac; +-(SensorProfile*)getSensor:(NSString*)deviceMac; +-(NSArray*)getSensors; +-(BOOL)startScan:(NSTimeInterval)scanInterval; +-(void)stopScan; + + +@end + +NS_ASSUME_NONNULL_END diff --git a/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64_x86_64-maccatalyst/sensor.framework/Versions/A/Headers/SensorController.hpp b/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64_x86_64-maccatalyst/sensor.framework/Versions/A/Headers/SensorController.hpp new file mode 100755 index 000000000..21738b67e --- /dev/null +++ b/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64_x86_64-maccatalyst/sensor.framework/Versions/A/Headers/SensorController.hpp @@ -0,0 +1,43 @@ +#ifndef SENSORCONTROLLER_H +#define SENSORCONTROLLER_H + +#include +#include +#include +#include "SensorProfile.hpp" + +namespace sensor { + + + +class SensorControllerDelegate +{ +public: + virtual void onSensorControllerEnableChanged(bool enabled){}; + virtual void onSensorScanResult(std::vector bleDevices){}; + virtual ~SensorControllerDelegate(){}; +}; + +class SensorController +{ +public: + virtual ~SensorController() {}; + static std::shared_ptr getInstance(); + static void destory(); + virtual void setDelegate(std::weak_ptr delegate) = 0; + + virtual bool isEnable() = 0; + virtual bool isScaning() = 0; + virtual bool startScan(int periodInMS) = 0; + virtual bool stopScan() = 0; + + virtual BLEDevice getDevice(std::string deviceMac) = 0; + virtual std::shared_ptr getSensor(std::string deviceMac) = 0; + virtual std::vector> getSensors() = 0; + +}; + +}; + + +#endif // SENSORCONTROLLER_H diff --git a/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64_x86_64-maccatalyst/sensor.framework/Versions/A/Headers/SensorData.hpp b/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64_x86_64-maccatalyst/sensor.framework/Versions/A/Headers/SensorData.hpp new file mode 100755 index 000000000..0738b7a34 --- /dev/null +++ b/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64_x86_64-maccatalyst/sensor.framework/Versions/A/Headers/SensorData.hpp @@ -0,0 +1,57 @@ +#ifndef SENSORDATA_H +#define SENSORDATA_H + +#include +#include + +namespace sensor{ + +struct SensorData { + + enum Type{ + NTF_ACC_DATA = 1, + NTF_GYO_DATA = 2, + NTF_EEG = 16, + NTF_ECG = 17, + NTF_IMPEDANCE = 18, + NTF_IMU = 19, + NTF_ADS = 20, + NTF_BRTH = 21, + }; + + std::string deviceMac; + Type dataType; + int lastPackageCounter; + int lastPackageIndex; + int resolutionBits; + int sampleRate; + int channelCount; + long channelMask; + int minPackageSampleCount; + int packageSampleCount; + double K; + + struct Sample { + int timeStampInMs; + int channelIndex; + int sampleIndex; + int rawData; + float data; + float impedance; + float saturation; + bool isLost; + }; + + std::vector> channelSamples; + + void clear() { + lastPackageCounter = 0; + lastPackageIndex = 0; + channelSamples.clear(); + } + +}; + +} + +#endif // SENSORDATA_H diff --git a/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64_x86_64-maccatalyst/sensor.framework/Versions/A/Headers/SensorProfile.hpp b/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64_x86_64-maccatalyst/sensor.framework/Versions/A/Headers/SensorProfile.hpp new file mode 100755 index 000000000..307a1f4a3 --- /dev/null +++ b/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64_x86_64-maccatalyst/sensor.framework/Versions/A/Headers/SensorProfile.hpp @@ -0,0 +1,75 @@ +#ifndef SENSORPROFILE_H +#define SENSORPROFILE_H + +#include +#include +#include +#include +#include "SensorData.hpp" + +namespace sensor { + +struct BLEDevice{ + enum State{ + Disconnected, + Connecting, + Connected, + Ready, + Disconnecting, + Invalid + }; + + std::string name; + std::string mac; + int rssi; +}; + +struct DeviceInfo { + int MTUSize; + std::string deviceName; + std::string modelName; + std::string hardwareVersion; + std::string firmwareVersion; + bool isMTUFine; + int EEGChannelCount; + int ECGChannelCount; + int BRTHChannelCount; + int AccChannelCount; + int GyroChannelCount; +}; + +class SensorProfile; + +class SensorProfileDelegate { +public: + virtual void onErrorCallback(std::shared_ptr profile, std::string errorMsg) {}; + virtual void onStateChange(std::shared_ptr profile, BLEDevice::State newState) {}; + virtual void onSensorNotifyData(std::shared_ptr profile, const SensorData& rawData) {}; + virtual ~SensorProfileDelegate() {}; +}; + +class SensorProfile{ +public: + virtual BLEDevice getDevice() = 0; + virtual BLEDevice::State getDeviceState() = 0; + + virtual void setDelegate(std::weak_ptr delegate) = 0; + + virtual bool connect() = 0; + virtual void disconnect() = 0; + + virtual bool hasStartDataNotification() = 0; + virtual void startDataNotification(int timeoutInMS, std::function cb) = 0; + virtual void stopDataNotification(int timeoutInMS, std::function cb) = 0; + + virtual bool hasInit() = 0; + virtual void init(int inPackageSampleCount, int timeoutInMS, std::function cb) = 0; + virtual void getBatteryLevel(int timeoutInMS, std::function cb) = 0; + virtual void fetchDeviceInfo(int timeoutInMS, std::function cb) = 0; + virtual void setParam(int timeoutInMS, std::string key, std::string value, std::function cb) = 0; + SensorProfile() {}; + virtual ~SensorProfile() {}; +}; +} + +#endif // SENSORPROFILE_H diff --git a/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64_x86_64-maccatalyst/sensor.framework/Versions/A/Headers/defines.h b/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64_x86_64-maccatalyst/sensor.framework/Versions/A/Headers/defines.h new file mode 100644 index 000000000..613022e22 --- /dev/null +++ b/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64_x86_64-maccatalyst/sensor.framework/Versions/A/Headers/defines.h @@ -0,0 +1,156 @@ +// +// sensordefines.h +// sensorprofile +// +// Created by 叶常青 on 2023/12/20. +// + +#ifndef sensordefines_h +#define sensordefines_h + + +typedef NS_ENUM(NSInteger, GF_RET_CODE) { + /// Method returns successfully. + GF_SUCCESS/*= 0*/, + + /// Method returns with a generic error. + GF_ERROR, + + /// Given parameters are not match required. + GF_ERROR_BAD_PARAM, + + /// Method call is not allowed by the inner state. + GF_ERROR_BAD_STATE, + + /// Method is not supported at this time. + GF_ERROR_NOT_SUPPORT, + + /// Hub is busying on device scan and cannot fulfill the call. + GF_ERROR_SCAN_BUSY, + + /// Insufficient resource to perform the call. + GF_ERROR_NO_RESOURCE, + + /// A preset timer is expired. + GF_ERROR_TIMEOUT, + + /// Target device is busy and cannot fulfill the call. + GF_ERROR_DEVICE_BUSY, + + /// The retrieving data is not ready yet + GF_ERROR_NOT_READY, +}; + +typedef NS_ENUM(NSInteger, ResponseResult) { + RSP_CODE_SUCCESS = 0x00, + RSP_CODE_NOT_SUPPORT = 0x01, + RSP_CODE_BAD_PARAM = 0x02, + RSP_CODE_FAILED = 0x03, + RSP_CODE_TIMEOUT = 0x04, + RSP_CODE_PARTIAL_PACKET = 0xFF +}; + +typedef NS_ENUM(NSInteger, FeatureMaps) { + GFD_FEAT_EMG = 0x000002000, + GFD_FEAT_EEG = 0x000400000, + GFD_FEAT_ECG = 0x000800000, + GFD_FEAT_IMPEDANCE = 0x001000000, + GFD_FEAT_IMU = 0x002000000, + GFD_FEAT_ADS = 0x004000000, + GFD_FEAT_BRTH = 0x008000000, +}; + +typedef NS_ENUM(NSInteger, DataNotifyFlags) { + /// Data Notify All Off + DNF_OFF = 0x00000000, + + /// Accelerate On(C.7) + DNF_ACCELERATE = 0x00000001, + + /// Gyroscope On(C.8) + DNF_GYROSCOPE = 0x00000002, + + /// Magnetometer On(C.9) + DNF_MAGNETOMETER = 0x00000004, + + /// Euler Angle On(C.10) + DNF_EULERANGLE = 0x00000008, + + /// Quaternion On(C.11) + DNF_QUATERNION = 0x00000010, + + /// Rotation Matrix On(C.12) + DNF_ROTATIONMATRIX = 0x00000020, + + /// EMG Gesture On(C.13) + DNF_EMG_GESTURE = 0x00000040, + + /// EMG Raw Data On(C.14) + DNF_EMG_RAW = 0x00000080, + + /// HID Mouse On(C.15) + DNF_HID_MOUSE = 0x00000100, + + /// HID Joystick On(C.16) + DNF_HID_JOYSTICK = 0x00000200, + + /// Device Status On(C.17) + DNF_DEVICE_STATUS = 0x00000400, + + /// Device Log On + DNF_LOG = 0x00000800, + + DNF_EEG = 0x00010000, + + DNF_ECG = 0x00020000, + + DNF_IMPEDANCE = 0x00040000, + + DNF_IMU = 0x00080000, + + DNF_ADS = 0x00100000, + + DNF_BRTH = 0x00200000, + /// Data Notify All On + DNF_ALL = 0xFFFFFFFF, +}; + + +typedef NS_ENUM(NSInteger, NotifyDataType) { + NTF_ACC_DATA = 0x01, + NTF_GYO_DATA, + NTF_MAG_DATA, + NTF_EULER_DATA, + NTF_QUAT_FLOAT_DATA, + NTF_ROTA_DATA, + NTF_EMG_GEST_DATA, + NTF_EMG_ADC_DATA, + NTF_HID_MOUSE, + NTF_HID_JOYSTICK, + NTF_DEV_STATUS, + NTF_LOG_DATA, + NTF_MAG_ANGLE_DATA, + NTF_MOT_CURRENT_DATA, + NTF_NEUCIR_STATUS, + NTF_EEG, + NTF_ECG, + NTF_IMPEDANCE, + NTF_IMU, + NTF_ADS, + NTF_BRTH, + NTF_DATA_TYPE_MAX, + NTF_PARTIAL_DATA = 0xFF +}; + + +typedef NS_ENUM(NSInteger, BLEState) +{ + BLEStateUnConnected, + BLEStateConnecting, + BLEStateConnected, + BLEStateReady, + BLEStateDisconnecting, + BLEStateInvalid, +}; + +#endif /* sensordefines_h */ diff --git a/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64_x86_64-maccatalyst/sensor.framework/Versions/A/Headers/sensor.h b/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64_x86_64-maccatalyst/sensor.framework/Versions/A/Headers/sensor.h new file mode 100644 index 000000000..2a3932e17 --- /dev/null +++ b/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64_x86_64-maccatalyst/sensor.framework/Versions/A/Headers/sensor.h @@ -0,0 +1,19 @@ +// +// sensorOC_Bridge.h +// sensor +// +// Created by 叶常青 on 2024/4/17. +// + +#ifndef sensorOC_Bridge_h +#define sensorOC_Bridge_h + +#import + +FOUNDATION_EXPORT double sensorVersionNumber = 1; + +FOUNDATION_EXPORT const unsigned char sensorVersionString[] = "1.0"; + +#import +#import +#endif /* sensorOC_Bridge_h */ diff --git a/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64_x86_64-maccatalyst/sensor.framework/Versions/A/Headers/sensorProfile.h b/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64_x86_64-maccatalyst/sensor.framework/Versions/A/Headers/sensorProfile.h new file mode 100644 index 000000000..f713b84f6 --- /dev/null +++ b/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64_x86_64-maccatalyst/sensor.framework/Versions/A/Headers/sensorProfile.h @@ -0,0 +1,101 @@ +// +// sensorProfile.h +// sensorProfile +// +// Created by 叶常青 on 2023/12/21. +// +#ifndef sensor_profile_h +#define sensor_profile_h + +#import +#import +#import +#import + +@interface DeviceInfo : NSObject + +@property (atomic, strong) NSString* deviceName; +@property (atomic, strong) NSString* modelName; +@property (atomic, strong) NSString* hardwareVersion; +@property (atomic, strong) NSString* firmwareVersion; +@property (atomic, assign) int MTUSize; +@property (atomic, assign) bool isMTUFine; +@property (atomic, assign) int EEGChannelCount; +@property (atomic, assign) int ECGChannelCount; +@property (atomic, assign) int BRTHChannelCount; +@property (atomic, assign) int AccChannelCount; +@property (atomic, assign) int GyroChannelCount; + +@end + +@interface Sample : NSObject +@property (atomic, assign) int timeStampInMs; +@property (atomic, assign) int sampleIndex; +@property (atomic, assign) int channelIndex; +@property (atomic, assign) BOOL isLost; +@property (atomic, assign) float rawData; +@property (atomic, assign) float convertData; +@property (atomic, assign) float impedance; +@property (atomic, assign) float saturation; +@end + +@interface SensorData : NSObject + +@property (atomic, assign) NotifyDataType dataType; +@property (atomic, assign) int lastPackageIndex; +@property (atomic, assign) int lastPackageCounter; +@property (atomic, assign) int resolutionBits; +@property (atomic, assign) int sampleRate; +@property (atomic, assign) int channelCount; +@property (atomic, assign) unsigned long long channelMask; +@property (atomic, assign) int packageSampleCount; +@property (atomic, assign) int minPackageSampleCount; +@property (atomic, assign) double K; +@property (atomic, strong) NSArray*>* channelSamples; +-(id)init; +-(void)clear; +-(NSArray*)flushSamples; +@end + +@protocol SensorProfileDelegate; + +@interface SensorProfile : NSObject +{ + +} +@property (atomic, weak) id delegate; +@property (atomic, assign, readonly) BLEState state; +@property (atomic, readonly) NSString* stateString; +@property (atomic, strong, readonly) BLEPeripheral* device; +@property (atomic, strong, readonly) DeviceInfo* deviceInfo; +@property (atomic, assign, readonly) bool hasInit; +@property (atomic, assign, readonly) bool hasStartDataNotification; + + +-(BOOL)connect; +-(void)disconnect; +-(BOOL)startDataNotification; +-(BOOL)stopDataNotification; + +- (void)initAll:(int)packageCount timeout:(NSTimeInterval)timeout completion:(void (^)(BOOL success, NSError * err))completionHandler; +- (void)initEEG:(int)packageCount timeout:(NSTimeInterval)timeout completion:(void (^)(BOOL success, NSError * err))completionHandler; +- (void)initECG:(int)packageCount timeout:(NSTimeInterval)timeout completion:(void (^)(BOOL success, NSError * err))completionHandler; +- (void)initIMU:(int)packageCount timeout:(NSTimeInterval)timeout completion:(void (^)(BOOL success, NSError * err))completionHandler; +- (void)initBRTH:(int)packageCount timeout:(NSTimeInterval)timeout completion:(void (^)(BOOL success, NSError * err))completionHandler; +- (void)initDataTransfer:(BOOL)isGetFeature timeout:(NSTimeInterval)timeout completion:(void (^)(int flag, NSError * err))completionHandler; +- (void)getBattery:(NSTimeInterval)timeout completion:(void (^)(int battery, NSError * err))completionHandler; +- (void)getDeviceInfo:(BOOL)onlyMTU timeout:(NSTimeInterval)timeout completion:(void (^)(DeviceInfo* deviceInfo, NSError * err))completionHandler; +- (void)startDataNotification:(NSTimeInterval)timeout completion:(void (^)(BOOL success, NSError * err))completionHandler; +- (void)stopDataNotification:(NSTimeInterval)timeout completion:(void (^)(BOOL success, NSError * err))completionHandler; + +- (void)setParam:(NSTimeInterval)timeout key:(NSString*_Nonnull)key value:(NSString*_Nonnull)value completion:(void (^_Nonnull)(NSString*_Nonnull result, NSError * _Nullable err))completionHandler; + +@end + +@protocol SensorProfileDelegate +- (void)onSensorErrorCallback:(SensorProfile*_Nonnull)profile err:(NSError*_Nonnull)err; +- (void)onSensorStateChange:(SensorProfile*_Nonnull)profile newState:(BLEState)newState; +- (void)onSensorNotifyData:(SensorProfile*_Nonnull)profile rawData:(SensorData*_Nonnull) rawData; +@end + +#endif diff --git a/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64_x86_64-maccatalyst/sensor.framework/Versions/A/Modules/module.modulemap b/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64_x86_64-maccatalyst/sensor.framework/Versions/A/Modules/module.modulemap new file mode 100644 index 000000000..6391e2b80 --- /dev/null +++ b/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64_x86_64-maccatalyst/sensor.framework/Versions/A/Modules/module.modulemap @@ -0,0 +1,6 @@ +framework module sensor { + umbrella header "sensor.h" + + export * + module * { export * } +} diff --git a/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64_x86_64-maccatalyst/sensor.framework/Versions/A/Resources/Info.plist b/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64_x86_64-maccatalyst/sensor.framework/Versions/A/Resources/Info.plist new file mode 100644 index 000000000..8ed1b8e46 --- /dev/null +++ b/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64_x86_64-maccatalyst/sensor.framework/Versions/A/Resources/Info.plist @@ -0,0 +1,50 @@ + + + + + BuildMachineOSBuild + 21H1320 + CFBundleDevelopmentRegion + en + CFBundleExecutable + sensor + CFBundleIdentifier + com.sensor + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + sensor + CFBundlePackageType + FMWK + CFBundleShortVersionString + 1.0 + CFBundleSupportedPlatforms + + MacOSX + + CFBundleVersion + 1 + DTCompiler + com.apple.compilers.llvm.clang.1_0 + DTPlatformBuild + 14B47b + DTPlatformName + macosx + DTPlatformVersion + 13.0 + DTSDKBuild + 22A372 + DTSDKName + macosx13.0 + DTXcode + 1410 + DTXcodeBuild + 14B47b + LSMinimumSystemVersion + 10.15 + UIDeviceFamily + + 2 + + + diff --git a/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64_x86_64-maccatalyst/sensor.framework/Versions/A/_CodeSignature/CodeDirectory b/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64_x86_64-maccatalyst/sensor.framework/Versions/A/_CodeSignature/CodeDirectory new file mode 100644 index 000000000..47ec09cd6 Binary files /dev/null and b/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64_x86_64-maccatalyst/sensor.framework/Versions/A/_CodeSignature/CodeDirectory differ diff --git a/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64_x86_64-maccatalyst/sensor.framework/Versions/A/_CodeSignature/CodeRequirements b/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64_x86_64-maccatalyst/sensor.framework/Versions/A/_CodeSignature/CodeRequirements new file mode 100644 index 000000000..83a81ef9b Binary files /dev/null and b/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64_x86_64-maccatalyst/sensor.framework/Versions/A/_CodeSignature/CodeRequirements differ diff --git a/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64_x86_64-maccatalyst/sensor.framework/Versions/A/_CodeSignature/CodeRequirements-1 b/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64_x86_64-maccatalyst/sensor.framework/Versions/A/_CodeSignature/CodeRequirements-1 new file mode 100644 index 000000000..62f31c78b Binary files /dev/null and b/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64_x86_64-maccatalyst/sensor.framework/Versions/A/_CodeSignature/CodeRequirements-1 differ diff --git a/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64_x86_64-maccatalyst/sensor.framework/Versions/A/_CodeSignature/CodeResources b/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64_x86_64-maccatalyst/sensor.framework/Versions/A/_CodeSignature/CodeResources new file mode 100644 index 000000000..d66a5a0ea --- /dev/null +++ b/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64_x86_64-maccatalyst/sensor.framework/Versions/A/_CodeSignature/CodeResources @@ -0,0 +1,231 @@ + + + + + files + + Resources/Info.plist + + wT+TECBr94z77QAH5JakSh/vKQE= + + + files2 + + Headers/BLEPeripheral.h + + hash + + ScMKAnaRSunM5VR5LhzbqyPcMM8= + + hash2 + + xsCr5VEKnCj9s+H04uZnWmn5h03Zk1AZV5LEzEe7/BE= + + + Headers/SensorController.h + + hash + + LEKmoiwY0eFzOTC9jWaTAFwFai8= + + hash2 + + yanvVMbiv1Cx+bZAg9xhxsZb+tmdDMYX3/nLJsZSuAI= + + + Headers/SensorController.hpp + + hash + + LKS2auDoV9yljRi3diaExNrPVDw= + + hash2 + + d7iHF96PUrr0BFtR6o0JwYxMD4H+4AwDYvVxvJQgnrA= + + + Headers/SensorData.hpp + + hash + + eSM6WcP/p94o6eDF2YcrxcIqpCk= + + hash2 + + js9AVsuzZpBVqbwzT12WyxhH1jRJXbl2fYoJVn8nv9Q= + + + Headers/SensorProfile.h + + hash + + AsLNZ4tujqDYaDt71hVilMqQa2M= + + hash2 + + t90schmW6nLupfAHoxrCNZGKlR+A52LRPadI4gzQQxQ= + + + Headers/SensorProfile.hpp + + hash + + ScoQnVZ0N0xsiftJ6s9IVfP+1Lo= + + hash2 + + IZ53bEdxLyiAXDsV8Zmd3v9G/HUAKT4osOkCUKsSM4M= + + + Headers/defines.h + + hash + + 6JxT8sZUpjfdLWeH76NeOE1u2Jc= + + hash2 + + 3a4kW1afB639zCIMlgZm4dYSYIoRAod1GAls6v5tW/4= + + + Headers/sensor.h + + hash + + j/aJB8fU9MHfSeXZ+MHuuzgRC8Y= + + hash2 + + uPnFelYZa/cHn/pVLsX7I2UuJNNwD4cVXddGZtjd0QI= + + + Modules/module.modulemap + + hash + + PmkZKQtcJn9CbKZGFyH8DHGquDM= + + hash2 + + BDjL+me3BBqvaiEz6ERAoe4Mg+SwwX8q/IJQ++zKZL4= + + + Resources/Info.plist + + hash + + wT+TECBr94z77QAH5JakSh/vKQE= + + hash2 + + tWZVPaVpb4i6cgsLgVgsx9yiz2d0r2wO6qfsglbk5XU= + + + + rules + + ^Resources/ + + ^Resources/.*\.lproj/ + + optional + + weight + 1000 + + ^Resources/.*\.lproj/locversion.plist$ + + omit + + weight + 1100 + + ^Resources/Base\.lproj/ + + weight + 1010 + + ^version.plist$ + + + rules2 + + .*\.dSYM($|/) + + weight + 11 + + ^(.*/)?\.DS_Store$ + + omit + + weight + 2000 + + ^(Frameworks|SharedFrameworks|PlugIns|Plug-ins|XPCServices|Helpers|MacOS|Library/(Automator|Spotlight|LoginItems))/ + + nested + + weight + 10 + + ^.* + + ^Info\.plist$ + + omit + + weight + 20 + + ^PkgInfo$ + + omit + + weight + 20 + + ^Resources/ + + weight + 20 + + ^Resources/.*\.lproj/ + + optional + + weight + 1000 + + ^Resources/.*\.lproj/locversion.plist$ + + omit + + weight + 1100 + + ^Resources/Base\.lproj/ + + weight + 1010 + + ^[^/]+$ + + nested + + weight + 10 + + ^embedded\.provisionprofile$ + + weight + 20 + + ^version\.plist$ + + weight + 20 + + + + diff --git a/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64_x86_64-maccatalyst/sensor.framework/Versions/A/_CodeSignature/CodeSignature b/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64_x86_64-maccatalyst/sensor.framework/Versions/A/_CodeSignature/CodeSignature new file mode 100644 index 000000000..ef38a4328 Binary files /dev/null and b/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64_x86_64-maccatalyst/sensor.framework/Versions/A/_CodeSignature/CodeSignature differ diff --git a/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64_x86_64-maccatalyst/sensor.framework/Versions/A/sensor b/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64_x86_64-maccatalyst/sensor.framework/Versions/A/sensor new file mode 100644 index 000000000..7112c68ee Binary files /dev/null and b/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64_x86_64-maccatalyst/sensor.framework/Versions/A/sensor differ diff --git a/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64_x86_64-maccatalyst/sensor.framework/Versions/Current b/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64_x86_64-maccatalyst/sensor.framework/Versions/Current new file mode 120000 index 000000000..8c7e5a667 --- /dev/null +++ b/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64_x86_64-maccatalyst/sensor.framework/Versions/Current @@ -0,0 +1 @@ +A \ No newline at end of file diff --git a/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64_x86_64-maccatalyst/sensor.framework/sensor b/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64_x86_64-maccatalyst/sensor.framework/sensor new file mode 120000 index 000000000..23e8a4cca --- /dev/null +++ b/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64_x86_64-maccatalyst/sensor.framework/sensor @@ -0,0 +1 @@ +Versions/Current/sensor \ No newline at end of file diff --git a/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64_x86_64-simulator/sensor.framework/Headers/BLEPeripheral.h b/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64_x86_64-simulator/sensor.framework/Headers/BLEPeripheral.h new file mode 100644 index 000000000..c16fa59d3 --- /dev/null +++ b/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64_x86_64-simulator/sensor.framework/Headers/BLEPeripheral.h @@ -0,0 +1,102 @@ +// +// BLEPeripheral.h +// TheOne +// +// Created by 王涛 on 2017/6/13. +// Copyright © 2017年 tcl. All rights reserved. +// + +#import +#import + + +@interface BLEPeripheral : NSObject + +@property (nonatomic, strong) CBPeripheral *cbPeripheral; +//deviceName +@property (nonatomic, copy) NSString *name; + +@property (nonatomic, copy) NSString *macAddress; + +@property (nonatomic, strong) NSNumber *rssi; + ++(NSString*)parseMacAddress:(NSDictionary*)advData; + +- (instancetype)initWithPeripheral:(CBPeripheral *)peripheral; + + +/** + * 订阅外设服务,注:未订阅的服务不提供读写操作 + * + * @param serviceUUID Serice UUID + * @param charactUUID Characteristic UUID + */ +- (void)addService:(NSString *)serviceUUID characteristic:(NSString *)charactUUID; + + +/** + * 注册生成已订阅的特征实例数据集 + * 用于特征读写 + * @param service 服务 + * @param characteristic 特征 + */ +- (void)registerForService:(CBService *)service characteristic:(CBCharacteristic *)characteristic; + +/** + * 已订阅的所有服务UUID + * + * @return UUID 数组 + */ +- (NSArray *)services; + +/** + * 已订阅服务的特征信息 + * + * @param uuidString service uuid string + * @return characteristic uuid string array + */ +- (NSArray *)characteristicForService:(NSString *)uuidString; + +/** + * 根据规则生成唯一UUID(不同服务存在相同特征) + * + @param serviceUUID 服务UUID + @param charactUUID 特征UUID + @return 唯一标识符 + */ ++ (NSString *)generateIdentifierWithService:(NSString *)serviceUUID characteristic:(NSString *)charactUUID; + +/** + * 判断订阅的服务特征是否启用通知功能 + * + * @param service 服务 + * @param characteristic 特征 + * @return 通知启用状态 + */ +- (BOOL)isNotifyForService:(CBService *)service characteristic:(CBCharacteristic *)characteristic; + +/** + Description + + @param data 传输数据 + @param identifier Serive & Charactersitic 合成的UUID +*/ +//- (void)writeValue:(NSData *)data forIdentifier:(NSString *)identifier; +- (void)writeValue:(NSData *)data forIdentifier:(NSString *)identifier; + +- (void)writeDataWithResponseValue:(NSData *)data forIdentifier:(NSString *)identifier; +/** + Description + + @param indetifier Serive & Charactersitic 合成的UUID + */ +- (void)readValueForIndetifier:(NSString *)indetifier; +/** + Description + + @param dict 转换macString rssi 设备距离 + */ +- (BOOL)transformMacStringWithAdvertisementData:(NSDictionary *)dict withRssi:(NSNumber *)rssi; + +- (void)setNotifyForIdetifier:(NSString*)indetifier enable:(BOOL)enable; +@end diff --git a/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64_x86_64-simulator/sensor.framework/Headers/SensorController.h b/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64_x86_64-simulator/sensor.framework/Headers/SensorController.h new file mode 100644 index 000000000..94a6bad6a --- /dev/null +++ b/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64_x86_64-simulator/sensor.framework/Headers/SensorController.h @@ -0,0 +1,36 @@ +// +// SensorController.h +// test +// +// Created by 叶常青 on 2024/4/19. +// + +#import +#import +NS_ASSUME_NONNULL_BEGIN + + +@protocol SensorControllerDelegate +- (void)onSensorControllerEnableChange:(bool)enabled; +- (void)onSensorScanResult:(NSArray*) bleDevices; +@end + + +@interface SensorController : NSObject +@property (atomic, weak) id delegate; +@property (atomic, retain, readonly) NSArray* scanResults; +@property (atomic, assign, readonly) bool isEnable; +@property (atomic, assign, readonly) bool isScaning; ++ (instancetype)getInstance; ++ (void)destory; + +-(BLEPeripheral*)getDevice:(NSString*)deviceMac; +-(SensorProfile*)getSensor:(NSString*)deviceMac; +-(NSArray*)getSensors; +-(BOOL)startScan:(NSTimeInterval)scanInterval; +-(void)stopScan; + + +@end + +NS_ASSUME_NONNULL_END diff --git a/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64_x86_64-simulator/sensor.framework/Headers/SensorController.hpp b/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64_x86_64-simulator/sensor.framework/Headers/SensorController.hpp new file mode 100755 index 000000000..21738b67e --- /dev/null +++ b/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64_x86_64-simulator/sensor.framework/Headers/SensorController.hpp @@ -0,0 +1,43 @@ +#ifndef SENSORCONTROLLER_H +#define SENSORCONTROLLER_H + +#include +#include +#include +#include "SensorProfile.hpp" + +namespace sensor { + + + +class SensorControllerDelegate +{ +public: + virtual void onSensorControllerEnableChanged(bool enabled){}; + virtual void onSensorScanResult(std::vector bleDevices){}; + virtual ~SensorControllerDelegate(){}; +}; + +class SensorController +{ +public: + virtual ~SensorController() {}; + static std::shared_ptr getInstance(); + static void destory(); + virtual void setDelegate(std::weak_ptr delegate) = 0; + + virtual bool isEnable() = 0; + virtual bool isScaning() = 0; + virtual bool startScan(int periodInMS) = 0; + virtual bool stopScan() = 0; + + virtual BLEDevice getDevice(std::string deviceMac) = 0; + virtual std::shared_ptr getSensor(std::string deviceMac) = 0; + virtual std::vector> getSensors() = 0; + +}; + +}; + + +#endif // SENSORCONTROLLER_H diff --git a/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64_x86_64-simulator/sensor.framework/Headers/SensorData.hpp b/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64_x86_64-simulator/sensor.framework/Headers/SensorData.hpp new file mode 100755 index 000000000..0738b7a34 --- /dev/null +++ b/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64_x86_64-simulator/sensor.framework/Headers/SensorData.hpp @@ -0,0 +1,57 @@ +#ifndef SENSORDATA_H +#define SENSORDATA_H + +#include +#include + +namespace sensor{ + +struct SensorData { + + enum Type{ + NTF_ACC_DATA = 1, + NTF_GYO_DATA = 2, + NTF_EEG = 16, + NTF_ECG = 17, + NTF_IMPEDANCE = 18, + NTF_IMU = 19, + NTF_ADS = 20, + NTF_BRTH = 21, + }; + + std::string deviceMac; + Type dataType; + int lastPackageCounter; + int lastPackageIndex; + int resolutionBits; + int sampleRate; + int channelCount; + long channelMask; + int minPackageSampleCount; + int packageSampleCount; + double K; + + struct Sample { + int timeStampInMs; + int channelIndex; + int sampleIndex; + int rawData; + float data; + float impedance; + float saturation; + bool isLost; + }; + + std::vector> channelSamples; + + void clear() { + lastPackageCounter = 0; + lastPackageIndex = 0; + channelSamples.clear(); + } + +}; + +} + +#endif // SENSORDATA_H diff --git a/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64_x86_64-simulator/sensor.framework/Headers/SensorProfile.hpp b/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64_x86_64-simulator/sensor.framework/Headers/SensorProfile.hpp new file mode 100755 index 000000000..307a1f4a3 --- /dev/null +++ b/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64_x86_64-simulator/sensor.framework/Headers/SensorProfile.hpp @@ -0,0 +1,75 @@ +#ifndef SENSORPROFILE_H +#define SENSORPROFILE_H + +#include +#include +#include +#include +#include "SensorData.hpp" + +namespace sensor { + +struct BLEDevice{ + enum State{ + Disconnected, + Connecting, + Connected, + Ready, + Disconnecting, + Invalid + }; + + std::string name; + std::string mac; + int rssi; +}; + +struct DeviceInfo { + int MTUSize; + std::string deviceName; + std::string modelName; + std::string hardwareVersion; + std::string firmwareVersion; + bool isMTUFine; + int EEGChannelCount; + int ECGChannelCount; + int BRTHChannelCount; + int AccChannelCount; + int GyroChannelCount; +}; + +class SensorProfile; + +class SensorProfileDelegate { +public: + virtual void onErrorCallback(std::shared_ptr profile, std::string errorMsg) {}; + virtual void onStateChange(std::shared_ptr profile, BLEDevice::State newState) {}; + virtual void onSensorNotifyData(std::shared_ptr profile, const SensorData& rawData) {}; + virtual ~SensorProfileDelegate() {}; +}; + +class SensorProfile{ +public: + virtual BLEDevice getDevice() = 0; + virtual BLEDevice::State getDeviceState() = 0; + + virtual void setDelegate(std::weak_ptr delegate) = 0; + + virtual bool connect() = 0; + virtual void disconnect() = 0; + + virtual bool hasStartDataNotification() = 0; + virtual void startDataNotification(int timeoutInMS, std::function cb) = 0; + virtual void stopDataNotification(int timeoutInMS, std::function cb) = 0; + + virtual bool hasInit() = 0; + virtual void init(int inPackageSampleCount, int timeoutInMS, std::function cb) = 0; + virtual void getBatteryLevel(int timeoutInMS, std::function cb) = 0; + virtual void fetchDeviceInfo(int timeoutInMS, std::function cb) = 0; + virtual void setParam(int timeoutInMS, std::string key, std::string value, std::function cb) = 0; + SensorProfile() {}; + virtual ~SensorProfile() {}; +}; +} + +#endif // SENSORPROFILE_H diff --git a/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64_x86_64-simulator/sensor.framework/Headers/defines.h b/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64_x86_64-simulator/sensor.framework/Headers/defines.h new file mode 100644 index 000000000..613022e22 --- /dev/null +++ b/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64_x86_64-simulator/sensor.framework/Headers/defines.h @@ -0,0 +1,156 @@ +// +// sensordefines.h +// sensorprofile +// +// Created by 叶常青 on 2023/12/20. +// + +#ifndef sensordefines_h +#define sensordefines_h + + +typedef NS_ENUM(NSInteger, GF_RET_CODE) { + /// Method returns successfully. + GF_SUCCESS/*= 0*/, + + /// Method returns with a generic error. + GF_ERROR, + + /// Given parameters are not match required. + GF_ERROR_BAD_PARAM, + + /// Method call is not allowed by the inner state. + GF_ERROR_BAD_STATE, + + /// Method is not supported at this time. + GF_ERROR_NOT_SUPPORT, + + /// Hub is busying on device scan and cannot fulfill the call. + GF_ERROR_SCAN_BUSY, + + /// Insufficient resource to perform the call. + GF_ERROR_NO_RESOURCE, + + /// A preset timer is expired. + GF_ERROR_TIMEOUT, + + /// Target device is busy and cannot fulfill the call. + GF_ERROR_DEVICE_BUSY, + + /// The retrieving data is not ready yet + GF_ERROR_NOT_READY, +}; + +typedef NS_ENUM(NSInteger, ResponseResult) { + RSP_CODE_SUCCESS = 0x00, + RSP_CODE_NOT_SUPPORT = 0x01, + RSP_CODE_BAD_PARAM = 0x02, + RSP_CODE_FAILED = 0x03, + RSP_CODE_TIMEOUT = 0x04, + RSP_CODE_PARTIAL_PACKET = 0xFF +}; + +typedef NS_ENUM(NSInteger, FeatureMaps) { + GFD_FEAT_EMG = 0x000002000, + GFD_FEAT_EEG = 0x000400000, + GFD_FEAT_ECG = 0x000800000, + GFD_FEAT_IMPEDANCE = 0x001000000, + GFD_FEAT_IMU = 0x002000000, + GFD_FEAT_ADS = 0x004000000, + GFD_FEAT_BRTH = 0x008000000, +}; + +typedef NS_ENUM(NSInteger, DataNotifyFlags) { + /// Data Notify All Off + DNF_OFF = 0x00000000, + + /// Accelerate On(C.7) + DNF_ACCELERATE = 0x00000001, + + /// Gyroscope On(C.8) + DNF_GYROSCOPE = 0x00000002, + + /// Magnetometer On(C.9) + DNF_MAGNETOMETER = 0x00000004, + + /// Euler Angle On(C.10) + DNF_EULERANGLE = 0x00000008, + + /// Quaternion On(C.11) + DNF_QUATERNION = 0x00000010, + + /// Rotation Matrix On(C.12) + DNF_ROTATIONMATRIX = 0x00000020, + + /// EMG Gesture On(C.13) + DNF_EMG_GESTURE = 0x00000040, + + /// EMG Raw Data On(C.14) + DNF_EMG_RAW = 0x00000080, + + /// HID Mouse On(C.15) + DNF_HID_MOUSE = 0x00000100, + + /// HID Joystick On(C.16) + DNF_HID_JOYSTICK = 0x00000200, + + /// Device Status On(C.17) + DNF_DEVICE_STATUS = 0x00000400, + + /// Device Log On + DNF_LOG = 0x00000800, + + DNF_EEG = 0x00010000, + + DNF_ECG = 0x00020000, + + DNF_IMPEDANCE = 0x00040000, + + DNF_IMU = 0x00080000, + + DNF_ADS = 0x00100000, + + DNF_BRTH = 0x00200000, + /// Data Notify All On + DNF_ALL = 0xFFFFFFFF, +}; + + +typedef NS_ENUM(NSInteger, NotifyDataType) { + NTF_ACC_DATA = 0x01, + NTF_GYO_DATA, + NTF_MAG_DATA, + NTF_EULER_DATA, + NTF_QUAT_FLOAT_DATA, + NTF_ROTA_DATA, + NTF_EMG_GEST_DATA, + NTF_EMG_ADC_DATA, + NTF_HID_MOUSE, + NTF_HID_JOYSTICK, + NTF_DEV_STATUS, + NTF_LOG_DATA, + NTF_MAG_ANGLE_DATA, + NTF_MOT_CURRENT_DATA, + NTF_NEUCIR_STATUS, + NTF_EEG, + NTF_ECG, + NTF_IMPEDANCE, + NTF_IMU, + NTF_ADS, + NTF_BRTH, + NTF_DATA_TYPE_MAX, + NTF_PARTIAL_DATA = 0xFF +}; + + +typedef NS_ENUM(NSInteger, BLEState) +{ + BLEStateUnConnected, + BLEStateConnecting, + BLEStateConnected, + BLEStateReady, + BLEStateDisconnecting, + BLEStateInvalid, +}; + +#endif /* sensordefines_h */ diff --git a/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64_x86_64-simulator/sensor.framework/Headers/sensor.h b/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64_x86_64-simulator/sensor.framework/Headers/sensor.h new file mode 100644 index 000000000..2a3932e17 --- /dev/null +++ b/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64_x86_64-simulator/sensor.framework/Headers/sensor.h @@ -0,0 +1,19 @@ +// +// sensorOC_Bridge.h +// sensor +// +// Created by 叶常青 on 2024/4/17. +// + +#ifndef sensorOC_Bridge_h +#define sensorOC_Bridge_h + +#import + +FOUNDATION_EXPORT double sensorVersionNumber = 1; + +FOUNDATION_EXPORT const unsigned char sensorVersionString[] = "1.0"; + +#import +#import +#endif /* sensorOC_Bridge_h */ diff --git a/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64_x86_64-simulator/sensor.framework/Headers/sensorProfile.h b/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64_x86_64-simulator/sensor.framework/Headers/sensorProfile.h new file mode 100644 index 000000000..f713b84f6 --- /dev/null +++ b/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64_x86_64-simulator/sensor.framework/Headers/sensorProfile.h @@ -0,0 +1,101 @@ +// +// sensorProfile.h +// sensorProfile +// +// Created by 叶常青 on 2023/12/21. +// +#ifndef sensor_profile_h +#define sensor_profile_h + +#import +#import +#import +#import + +@interface DeviceInfo : NSObject + +@property (atomic, strong) NSString* deviceName; +@property (atomic, strong) NSString* modelName; +@property (atomic, strong) NSString* hardwareVersion; +@property (atomic, strong) NSString* firmwareVersion; +@property (atomic, assign) int MTUSize; +@property (atomic, assign) bool isMTUFine; +@property (atomic, assign) int EEGChannelCount; +@property (atomic, assign) int ECGChannelCount; +@property (atomic, assign) int BRTHChannelCount; +@property (atomic, assign) int AccChannelCount; +@property (atomic, assign) int GyroChannelCount; + +@end + +@interface Sample : NSObject +@property (atomic, assign) int timeStampInMs; +@property (atomic, assign) int sampleIndex; +@property (atomic, assign) int channelIndex; +@property (atomic, assign) BOOL isLost; +@property (atomic, assign) float rawData; +@property (atomic, assign) float convertData; +@property (atomic, assign) float impedance; +@property (atomic, assign) float saturation; +@end + +@interface SensorData : NSObject + +@property (atomic, assign) NotifyDataType dataType; +@property (atomic, assign) int lastPackageIndex; +@property (atomic, assign) int lastPackageCounter; +@property (atomic, assign) int resolutionBits; +@property (atomic, assign) int sampleRate; +@property (atomic, assign) int channelCount; +@property (atomic, assign) unsigned long long channelMask; +@property (atomic, assign) int packageSampleCount; +@property (atomic, assign) int minPackageSampleCount; +@property (atomic, assign) double K; +@property (atomic, strong) NSArray*>* channelSamples; +-(id)init; +-(void)clear; +-(NSArray*)flushSamples; +@end + +@protocol SensorProfileDelegate; + +@interface SensorProfile : NSObject +{ + +} +@property (atomic, weak) id delegate; +@property (atomic, assign, readonly) BLEState state; +@property (atomic, readonly) NSString* stateString; +@property (atomic, strong, readonly) BLEPeripheral* device; +@property (atomic, strong, readonly) DeviceInfo* deviceInfo; +@property (atomic, assign, readonly) bool hasInit; +@property (atomic, assign, readonly) bool hasStartDataNotification; + + +-(BOOL)connect; +-(void)disconnect; +-(BOOL)startDataNotification; +-(BOOL)stopDataNotification; + +- (void)initAll:(int)packageCount timeout:(NSTimeInterval)timeout completion:(void (^)(BOOL success, NSError * err))completionHandler; +- (void)initEEG:(int)packageCount timeout:(NSTimeInterval)timeout completion:(void (^)(BOOL success, NSError * err))completionHandler; +- (void)initECG:(int)packageCount timeout:(NSTimeInterval)timeout completion:(void (^)(BOOL success, NSError * err))completionHandler; +- (void)initIMU:(int)packageCount timeout:(NSTimeInterval)timeout completion:(void (^)(BOOL success, NSError * err))completionHandler; +- (void)initBRTH:(int)packageCount timeout:(NSTimeInterval)timeout completion:(void (^)(BOOL success, NSError * err))completionHandler; +- (void)initDataTransfer:(BOOL)isGetFeature timeout:(NSTimeInterval)timeout completion:(void (^)(int flag, NSError * err))completionHandler; +- (void)getBattery:(NSTimeInterval)timeout completion:(void (^)(int battery, NSError * err))completionHandler; +- (void)getDeviceInfo:(BOOL)onlyMTU timeout:(NSTimeInterval)timeout completion:(void (^)(DeviceInfo* deviceInfo, NSError * err))completionHandler; +- (void)startDataNotification:(NSTimeInterval)timeout completion:(void (^)(BOOL success, NSError * err))completionHandler; +- (void)stopDataNotification:(NSTimeInterval)timeout completion:(void (^)(BOOL success, NSError * err))completionHandler; + +- (void)setParam:(NSTimeInterval)timeout key:(NSString*_Nonnull)key value:(NSString*_Nonnull)value completion:(void (^_Nonnull)(NSString*_Nonnull result, NSError * _Nullable err))completionHandler; + +@end + +@protocol SensorProfileDelegate +- (void)onSensorErrorCallback:(SensorProfile*_Nonnull)profile err:(NSError*_Nonnull)err; +- (void)onSensorStateChange:(SensorProfile*_Nonnull)profile newState:(BLEState)newState; +- (void)onSensorNotifyData:(SensorProfile*_Nonnull)profile rawData:(SensorData*_Nonnull) rawData; +@end + +#endif diff --git a/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64_x86_64-simulator/sensor.framework/Info.plist b/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64_x86_64-simulator/sensor.framework/Info.plist new file mode 100644 index 000000000..200de5103 Binary files /dev/null and b/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64_x86_64-simulator/sensor.framework/Info.plist differ diff --git a/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64_x86_64-simulator/sensor.framework/Modules/module.modulemap b/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64_x86_64-simulator/sensor.framework/Modules/module.modulemap new file mode 100644 index 000000000..6391e2b80 --- /dev/null +++ b/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64_x86_64-simulator/sensor.framework/Modules/module.modulemap @@ -0,0 +1,6 @@ +framework module sensor { + umbrella header "sensor.h" + + export * + module * { export * } +} diff --git a/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64_x86_64-simulator/sensor.framework/_CodeSignature/CodeDirectory b/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64_x86_64-simulator/sensor.framework/_CodeSignature/CodeDirectory new file mode 100644 index 000000000..29c86010c Binary files /dev/null and b/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64_x86_64-simulator/sensor.framework/_CodeSignature/CodeDirectory differ diff --git a/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64_x86_64-simulator/sensor.framework/_CodeSignature/CodeRequirements b/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64_x86_64-simulator/sensor.framework/_CodeSignature/CodeRequirements new file mode 100644 index 000000000..dbf9d6144 Binary files /dev/null and b/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64_x86_64-simulator/sensor.framework/_CodeSignature/CodeRequirements differ diff --git a/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64_x86_64-simulator/sensor.framework/_CodeSignature/CodeRequirements-1 b/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64_x86_64-simulator/sensor.framework/_CodeSignature/CodeRequirements-1 new file mode 100644 index 000000000..9fe505298 Binary files /dev/null and b/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64_x86_64-simulator/sensor.framework/_CodeSignature/CodeRequirements-1 differ diff --git a/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64_x86_64-simulator/sensor.framework/_CodeSignature/CodeResources b/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64_x86_64-simulator/sensor.framework/_CodeSignature/CodeResources new file mode 100644 index 000000000..9bbd53867 --- /dev/null +++ b/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64_x86_64-simulator/sensor.framework/_CodeSignature/CodeResources @@ -0,0 +1,237 @@ + + + + + files + + Headers/BLEPeripheral.h + + ScMKAnaRSunM5VR5LhzbqyPcMM8= + + Headers/SensorController.h + + LEKmoiwY0eFzOTC9jWaTAFwFai8= + + Headers/SensorController.hpp + + LKS2auDoV9yljRi3diaExNrPVDw= + + Headers/SensorData.hpp + + eSM6WcP/p94o6eDF2YcrxcIqpCk= + + Headers/SensorProfile.h + + AsLNZ4tujqDYaDt71hVilMqQa2M= + + Headers/SensorProfile.hpp + + ScoQnVZ0N0xsiftJ6s9IVfP+1Lo= + + Headers/defines.h + + 6JxT8sZUpjfdLWeH76NeOE1u2Jc= + + Headers/sensor.h + + j/aJB8fU9MHfSeXZ+MHuuzgRC8Y= + + Info.plist + + KFJlAUby+aXBVLtBB5TTGRsdBto= + + Modules/module.modulemap + + PmkZKQtcJn9CbKZGFyH8DHGquDM= + + + files2 + + Headers/BLEPeripheral.h + + hash + + ScMKAnaRSunM5VR5LhzbqyPcMM8= + + hash2 + + xsCr5VEKnCj9s+H04uZnWmn5h03Zk1AZV5LEzEe7/BE= + + + Headers/SensorController.h + + hash + + LEKmoiwY0eFzOTC9jWaTAFwFai8= + + hash2 + + yanvVMbiv1Cx+bZAg9xhxsZb+tmdDMYX3/nLJsZSuAI= + + + Headers/SensorController.hpp + + hash + + LKS2auDoV9yljRi3diaExNrPVDw= + + hash2 + + d7iHF96PUrr0BFtR6o0JwYxMD4H+4AwDYvVxvJQgnrA= + + + Headers/SensorData.hpp + + hash + + eSM6WcP/p94o6eDF2YcrxcIqpCk= + + hash2 + + js9AVsuzZpBVqbwzT12WyxhH1jRJXbl2fYoJVn8nv9Q= + + + Headers/SensorProfile.h + + hash + + AsLNZ4tujqDYaDt71hVilMqQa2M= + + hash2 + + t90schmW6nLupfAHoxrCNZGKlR+A52LRPadI4gzQQxQ= + + + Headers/SensorProfile.hpp + + hash + + ScoQnVZ0N0xsiftJ6s9IVfP+1Lo= + + hash2 + + IZ53bEdxLyiAXDsV8Zmd3v9G/HUAKT4osOkCUKsSM4M= + + + Headers/defines.h + + hash + + 6JxT8sZUpjfdLWeH76NeOE1u2Jc= + + hash2 + + 3a4kW1afB639zCIMlgZm4dYSYIoRAod1GAls6v5tW/4= + + + Headers/sensor.h + + hash + + j/aJB8fU9MHfSeXZ+MHuuzgRC8Y= + + hash2 + + uPnFelYZa/cHn/pVLsX7I2UuJNNwD4cVXddGZtjd0QI= + + + Modules/module.modulemap + + hash + + PmkZKQtcJn9CbKZGFyH8DHGquDM= + + hash2 + + BDjL+me3BBqvaiEz6ERAoe4Mg+SwwX8q/IJQ++zKZL4= + + + + rules + + ^.* + + ^.*\.lproj/ + + optional + + weight + 1000 + + ^.*\.lproj/locversion.plist$ + + omit + + weight + 1100 + + ^Base\.lproj/ + + weight + 1010 + + ^version.plist$ + + + rules2 + + .*\.dSYM($|/) + + weight + 11 + + ^(.*/)?\.DS_Store$ + + omit + + weight + 2000 + + ^.* + + ^.*\.lproj/ + + optional + + weight + 1000 + + ^.*\.lproj/locversion.plist$ + + omit + + weight + 1100 + + ^Base\.lproj/ + + weight + 1010 + + ^Info\.plist$ + + omit + + weight + 20 + + ^PkgInfo$ + + omit + + weight + 20 + + ^embedded\.provisionprofile$ + + weight + 20 + + ^version\.plist$ + + weight + 20 + + + + diff --git a/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64_x86_64-simulator/sensor.framework/_CodeSignature/CodeSignature b/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64_x86_64-simulator/sensor.framework/_CodeSignature/CodeSignature new file mode 100644 index 000000000..e69de29bb diff --git a/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64_x86_64-simulator/sensor.framework/sensor b/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64_x86_64-simulator/sensor.framework/sensor new file mode 100644 index 000000000..3ac2ce0da Binary files /dev/null and b/third_party/synchroni/lib/mac/sensor.xcframework/ios-arm64_x86_64-simulator/sensor.framework/sensor differ diff --git a/third_party/synchroni/lib/mac/sensor.xcframework/macos-arm64_x86_64/sensor.framework/Headers b/third_party/synchroni/lib/mac/sensor.xcframework/macos-arm64_x86_64/sensor.framework/Headers new file mode 120000 index 000000000..a177d2a6b --- /dev/null +++ b/third_party/synchroni/lib/mac/sensor.xcframework/macos-arm64_x86_64/sensor.framework/Headers @@ -0,0 +1 @@ +Versions/Current/Headers \ No newline at end of file diff --git a/third_party/synchroni/lib/mac/sensor.xcframework/macos-arm64_x86_64/sensor.framework/Modules b/third_party/synchroni/lib/mac/sensor.xcframework/macos-arm64_x86_64/sensor.framework/Modules new file mode 120000 index 000000000..5736f3186 --- /dev/null +++ b/third_party/synchroni/lib/mac/sensor.xcframework/macos-arm64_x86_64/sensor.framework/Modules @@ -0,0 +1 @@ +Versions/Current/Modules \ No newline at end of file diff --git a/third_party/synchroni/lib/mac/sensor.xcframework/macos-arm64_x86_64/sensor.framework/Resources b/third_party/synchroni/lib/mac/sensor.xcframework/macos-arm64_x86_64/sensor.framework/Resources new file mode 120000 index 000000000..953ee36f3 --- /dev/null +++ b/third_party/synchroni/lib/mac/sensor.xcframework/macos-arm64_x86_64/sensor.framework/Resources @@ -0,0 +1 @@ +Versions/Current/Resources \ No newline at end of file diff --git a/third_party/synchroni/lib/mac/sensor.xcframework/macos-arm64_x86_64/sensor.framework/Versions/A/Headers/BLEPeripheral.h b/third_party/synchroni/lib/mac/sensor.xcframework/macos-arm64_x86_64/sensor.framework/Versions/A/Headers/BLEPeripheral.h new file mode 100644 index 000000000..c16fa59d3 --- /dev/null +++ b/third_party/synchroni/lib/mac/sensor.xcframework/macos-arm64_x86_64/sensor.framework/Versions/A/Headers/BLEPeripheral.h @@ -0,0 +1,102 @@ +// +// BLEPeripheral.h +// TheOne +// +// Created by 王涛 on 2017/6/13. +// Copyright © 2017年 tcl. All rights reserved. +// + +#import +#import + + +@interface BLEPeripheral : NSObject + +@property (nonatomic, strong) CBPeripheral *cbPeripheral; +//deviceName +@property (nonatomic, copy) NSString *name; + +@property (nonatomic, copy) NSString *macAddress; + +@property (nonatomic, strong) NSNumber *rssi; + ++(NSString*)parseMacAddress:(NSDictionary*)advData; + +- (instancetype)initWithPeripheral:(CBPeripheral *)peripheral; + + +/** + * 订阅外设服务,注:未订阅的服务不提供读写操作 + * + * @param serviceUUID Serice UUID + * @param charactUUID Characteristic UUID + */ +- (void)addService:(NSString *)serviceUUID characteristic:(NSString *)charactUUID; + + +/** + * 注册生成已订阅的特征实例数据集 + * 用于特征读写 + * @param service 服务 + * @param characteristic 特征 + */ +- (void)registerForService:(CBService *)service characteristic:(CBCharacteristic *)characteristic; + +/** + * 已订阅的所有服务UUID + * + * @return UUID 数组 + */ +- (NSArray *)services; + +/** + * 已订阅服务的特征信息 + * + * @param uuidString service uuid string + * @return characteristic uuid string array + */ +- (NSArray *)characteristicForService:(NSString *)uuidString; + +/** + * 根据规则生成唯一UUID(不同服务存在相同特征) + * + @param serviceUUID 服务UUID + @param charactUUID 特征UUID + @return 唯一标识符 + */ ++ (NSString *)generateIdentifierWithService:(NSString *)serviceUUID characteristic:(NSString *)charactUUID; + +/** + * 判断订阅的服务特征是否启用通知功能 + * + * @param service 服务 + * @param characteristic 特征 + * @return 通知启用状态 + */ +- (BOOL)isNotifyForService:(CBService *)service characteristic:(CBCharacteristic *)characteristic; + +/** + Description + + @param data 传输数据 + @param identifier Serive & Charactersitic 合成的UUID +*/ +//- (void)writeValue:(NSData *)data forIdentifier:(NSString *)identifier; +- (void)writeValue:(NSData *)data forIdentifier:(NSString *)identifier; + +- (void)writeDataWithResponseValue:(NSData *)data forIdentifier:(NSString *)identifier; +/** + Description + + @param indetifier Serive & Charactersitic 合成的UUID + */ +- (void)readValueForIndetifier:(NSString *)indetifier; +/** + Description + + @param dict 转换macString rssi 设备距离 + */ +- (BOOL)transformMacStringWithAdvertisementData:(NSDictionary *)dict withRssi:(NSNumber *)rssi; + +- (void)setNotifyForIdetifier:(NSString*)indetifier enable:(BOOL)enable; +@end diff --git a/third_party/synchroni/lib/mac/sensor.xcframework/macos-arm64_x86_64/sensor.framework/Versions/A/Headers/SensorController.h b/third_party/synchroni/lib/mac/sensor.xcframework/macos-arm64_x86_64/sensor.framework/Versions/A/Headers/SensorController.h new file mode 100644 index 000000000..94a6bad6a --- /dev/null +++ b/third_party/synchroni/lib/mac/sensor.xcframework/macos-arm64_x86_64/sensor.framework/Versions/A/Headers/SensorController.h @@ -0,0 +1,36 @@ +// +// SensorController.h +// test +// +// Created by 叶常青 on 2024/4/19. +// + +#import +#import +NS_ASSUME_NONNULL_BEGIN + + +@protocol SensorControllerDelegate +- (void)onSensorControllerEnableChange:(bool)enabled; +- (void)onSensorScanResult:(NSArray*) bleDevices; +@end + + +@interface SensorController : NSObject +@property (atomic, weak) id delegate; +@property (atomic, retain, readonly) NSArray* scanResults; +@property (atomic, assign, readonly) bool isEnable; +@property (atomic, assign, readonly) bool isScaning; ++ (instancetype)getInstance; ++ (void)destory; + +-(BLEPeripheral*)getDevice:(NSString*)deviceMac; +-(SensorProfile*)getSensor:(NSString*)deviceMac; +-(NSArray*)getSensors; +-(BOOL)startScan:(NSTimeInterval)scanInterval; +-(void)stopScan; + + +@end + +NS_ASSUME_NONNULL_END diff --git a/third_party/synchroni/lib/mac/sensor.xcframework/macos-arm64_x86_64/sensor.framework/Versions/A/Headers/SensorController.hpp b/third_party/synchroni/lib/mac/sensor.xcframework/macos-arm64_x86_64/sensor.framework/Versions/A/Headers/SensorController.hpp new file mode 100755 index 000000000..21738b67e --- /dev/null +++ b/third_party/synchroni/lib/mac/sensor.xcframework/macos-arm64_x86_64/sensor.framework/Versions/A/Headers/SensorController.hpp @@ -0,0 +1,43 @@ +#ifndef SENSORCONTROLLER_H +#define SENSORCONTROLLER_H + +#include +#include +#include +#include "SensorProfile.hpp" + +namespace sensor { + + + +class SensorControllerDelegate +{ +public: + virtual void onSensorControllerEnableChanged(bool enabled){}; + virtual void onSensorScanResult(std::vector bleDevices){}; + virtual ~SensorControllerDelegate(){}; +}; + +class SensorController +{ +public: + virtual ~SensorController() {}; + static std::shared_ptr getInstance(); + static void destory(); + virtual void setDelegate(std::weak_ptr delegate) = 0; + + virtual bool isEnable() = 0; + virtual bool isScaning() = 0; + virtual bool startScan(int periodInMS) = 0; + virtual bool stopScan() = 0; + + virtual BLEDevice getDevice(std::string deviceMac) = 0; + virtual std::shared_ptr getSensor(std::string deviceMac) = 0; + virtual std::vector> getSensors() = 0; + +}; + +}; + + +#endif // SENSORCONTROLLER_H diff --git a/third_party/synchroni/lib/mac/sensor.xcframework/macos-arm64_x86_64/sensor.framework/Versions/A/Headers/SensorData.hpp b/third_party/synchroni/lib/mac/sensor.xcframework/macos-arm64_x86_64/sensor.framework/Versions/A/Headers/SensorData.hpp new file mode 100755 index 000000000..0738b7a34 --- /dev/null +++ b/third_party/synchroni/lib/mac/sensor.xcframework/macos-arm64_x86_64/sensor.framework/Versions/A/Headers/SensorData.hpp @@ -0,0 +1,57 @@ +#ifndef SENSORDATA_H +#define SENSORDATA_H + +#include +#include + +namespace sensor{ + +struct SensorData { + + enum Type{ + NTF_ACC_DATA = 1, + NTF_GYO_DATA = 2, + NTF_EEG = 16, + NTF_ECG = 17, + NTF_IMPEDANCE = 18, + NTF_IMU = 19, + NTF_ADS = 20, + NTF_BRTH = 21, + }; + + std::string deviceMac; + Type dataType; + int lastPackageCounter; + int lastPackageIndex; + int resolutionBits; + int sampleRate; + int channelCount; + long channelMask; + int minPackageSampleCount; + int packageSampleCount; + double K; + + struct Sample { + int timeStampInMs; + int channelIndex; + int sampleIndex; + int rawData; + float data; + float impedance; + float saturation; + bool isLost; + }; + + std::vector> channelSamples; + + void clear() { + lastPackageCounter = 0; + lastPackageIndex = 0; + channelSamples.clear(); + } + +}; + +} + +#endif // SENSORDATA_H diff --git a/third_party/synchroni/lib/mac/sensor.xcframework/macos-arm64_x86_64/sensor.framework/Versions/A/Headers/SensorProfile.hpp b/third_party/synchroni/lib/mac/sensor.xcframework/macos-arm64_x86_64/sensor.framework/Versions/A/Headers/SensorProfile.hpp new file mode 100755 index 000000000..307a1f4a3 --- /dev/null +++ b/third_party/synchroni/lib/mac/sensor.xcframework/macos-arm64_x86_64/sensor.framework/Versions/A/Headers/SensorProfile.hpp @@ -0,0 +1,75 @@ +#ifndef SENSORPROFILE_H +#define SENSORPROFILE_H + +#include +#include +#include +#include +#include "SensorData.hpp" + +namespace sensor { + +struct BLEDevice{ + enum State{ + Disconnected, + Connecting, + Connected, + Ready, + Disconnecting, + Invalid + }; + + std::string name; + std::string mac; + int rssi; +}; + +struct DeviceInfo { + int MTUSize; + std::string deviceName; + std::string modelName; + std::string hardwareVersion; + std::string firmwareVersion; + bool isMTUFine; + int EEGChannelCount; + int ECGChannelCount; + int BRTHChannelCount; + int AccChannelCount; + int GyroChannelCount; +}; + +class SensorProfile; + +class SensorProfileDelegate { +public: + virtual void onErrorCallback(std::shared_ptr profile, std::string errorMsg) {}; + virtual void onStateChange(std::shared_ptr profile, BLEDevice::State newState) {}; + virtual void onSensorNotifyData(std::shared_ptr profile, const SensorData& rawData) {}; + virtual ~SensorProfileDelegate() {}; +}; + +class SensorProfile{ +public: + virtual BLEDevice getDevice() = 0; + virtual BLEDevice::State getDeviceState() = 0; + + virtual void setDelegate(std::weak_ptr delegate) = 0; + + virtual bool connect() = 0; + virtual void disconnect() = 0; + + virtual bool hasStartDataNotification() = 0; + virtual void startDataNotification(int timeoutInMS, std::function cb) = 0; + virtual void stopDataNotification(int timeoutInMS, std::function cb) = 0; + + virtual bool hasInit() = 0; + virtual void init(int inPackageSampleCount, int timeoutInMS, std::function cb) = 0; + virtual void getBatteryLevel(int timeoutInMS, std::function cb) = 0; + virtual void fetchDeviceInfo(int timeoutInMS, std::function cb) = 0; + virtual void setParam(int timeoutInMS, std::string key, std::string value, std::function cb) = 0; + SensorProfile() {}; + virtual ~SensorProfile() {}; +}; +} + +#endif // SENSORPROFILE_H diff --git a/third_party/synchroni/lib/mac/sensor.xcframework/macos-arm64_x86_64/sensor.framework/Versions/A/Headers/defines.h b/third_party/synchroni/lib/mac/sensor.xcframework/macos-arm64_x86_64/sensor.framework/Versions/A/Headers/defines.h new file mode 100644 index 000000000..613022e22 --- /dev/null +++ b/third_party/synchroni/lib/mac/sensor.xcframework/macos-arm64_x86_64/sensor.framework/Versions/A/Headers/defines.h @@ -0,0 +1,156 @@ +// +// sensordefines.h +// sensorprofile +// +// Created by 叶常青 on 2023/12/20. +// + +#ifndef sensordefines_h +#define sensordefines_h + + +typedef NS_ENUM(NSInteger, GF_RET_CODE) { + /// Method returns successfully. + GF_SUCCESS/*= 0*/, + + /// Method returns with a generic error. + GF_ERROR, + + /// Given parameters are not match required. + GF_ERROR_BAD_PARAM, + + /// Method call is not allowed by the inner state. + GF_ERROR_BAD_STATE, + + /// Method is not supported at this time. + GF_ERROR_NOT_SUPPORT, + + /// Hub is busying on device scan and cannot fulfill the call. + GF_ERROR_SCAN_BUSY, + + /// Insufficient resource to perform the call. + GF_ERROR_NO_RESOURCE, + + /// A preset timer is expired. + GF_ERROR_TIMEOUT, + + /// Target device is busy and cannot fulfill the call. + GF_ERROR_DEVICE_BUSY, + + /// The retrieving data is not ready yet + GF_ERROR_NOT_READY, +}; + +typedef NS_ENUM(NSInteger, ResponseResult) { + RSP_CODE_SUCCESS = 0x00, + RSP_CODE_NOT_SUPPORT = 0x01, + RSP_CODE_BAD_PARAM = 0x02, + RSP_CODE_FAILED = 0x03, + RSP_CODE_TIMEOUT = 0x04, + RSP_CODE_PARTIAL_PACKET = 0xFF +}; + +typedef NS_ENUM(NSInteger, FeatureMaps) { + GFD_FEAT_EMG = 0x000002000, + GFD_FEAT_EEG = 0x000400000, + GFD_FEAT_ECG = 0x000800000, + GFD_FEAT_IMPEDANCE = 0x001000000, + GFD_FEAT_IMU = 0x002000000, + GFD_FEAT_ADS = 0x004000000, + GFD_FEAT_BRTH = 0x008000000, +}; + +typedef NS_ENUM(NSInteger, DataNotifyFlags) { + /// Data Notify All Off + DNF_OFF = 0x00000000, + + /// Accelerate On(C.7) + DNF_ACCELERATE = 0x00000001, + + /// Gyroscope On(C.8) + DNF_GYROSCOPE = 0x00000002, + + /// Magnetometer On(C.9) + DNF_MAGNETOMETER = 0x00000004, + + /// Euler Angle On(C.10) + DNF_EULERANGLE = 0x00000008, + + /// Quaternion On(C.11) + DNF_QUATERNION = 0x00000010, + + /// Rotation Matrix On(C.12) + DNF_ROTATIONMATRIX = 0x00000020, + + /// EMG Gesture On(C.13) + DNF_EMG_GESTURE = 0x00000040, + + /// EMG Raw Data On(C.14) + DNF_EMG_RAW = 0x00000080, + + /// HID Mouse On(C.15) + DNF_HID_MOUSE = 0x00000100, + + /// HID Joystick On(C.16) + DNF_HID_JOYSTICK = 0x00000200, + + /// Device Status On(C.17) + DNF_DEVICE_STATUS = 0x00000400, + + /// Device Log On + DNF_LOG = 0x00000800, + + DNF_EEG = 0x00010000, + + DNF_ECG = 0x00020000, + + DNF_IMPEDANCE = 0x00040000, + + DNF_IMU = 0x00080000, + + DNF_ADS = 0x00100000, + + DNF_BRTH = 0x00200000, + /// Data Notify All On + DNF_ALL = 0xFFFFFFFF, +}; + + +typedef NS_ENUM(NSInteger, NotifyDataType) { + NTF_ACC_DATA = 0x01, + NTF_GYO_DATA, + NTF_MAG_DATA, + NTF_EULER_DATA, + NTF_QUAT_FLOAT_DATA, + NTF_ROTA_DATA, + NTF_EMG_GEST_DATA, + NTF_EMG_ADC_DATA, + NTF_HID_MOUSE, + NTF_HID_JOYSTICK, + NTF_DEV_STATUS, + NTF_LOG_DATA, + NTF_MAG_ANGLE_DATA, + NTF_MOT_CURRENT_DATA, + NTF_NEUCIR_STATUS, + NTF_EEG, + NTF_ECG, + NTF_IMPEDANCE, + NTF_IMU, + NTF_ADS, + NTF_BRTH, + NTF_DATA_TYPE_MAX, + NTF_PARTIAL_DATA = 0xFF +}; + + +typedef NS_ENUM(NSInteger, BLEState) +{ + BLEStateUnConnected, + BLEStateConnecting, + BLEStateConnected, + BLEStateReady, + BLEStateDisconnecting, + BLEStateInvalid, +}; + +#endif /* sensordefines_h */ diff --git a/third_party/synchroni/lib/mac/sensor.xcframework/macos-arm64_x86_64/sensor.framework/Versions/A/Headers/sensor.h b/third_party/synchroni/lib/mac/sensor.xcframework/macos-arm64_x86_64/sensor.framework/Versions/A/Headers/sensor.h new file mode 100644 index 000000000..2a3932e17 --- /dev/null +++ b/third_party/synchroni/lib/mac/sensor.xcframework/macos-arm64_x86_64/sensor.framework/Versions/A/Headers/sensor.h @@ -0,0 +1,19 @@ +// +// sensorOC_Bridge.h +// sensor +// +// Created by 叶常青 on 2024/4/17. +// + +#ifndef sensorOC_Bridge_h +#define sensorOC_Bridge_h + +#import + +FOUNDATION_EXPORT double sensorVersionNumber = 1; + +FOUNDATION_EXPORT const unsigned char sensorVersionString[] = "1.0"; + +#import +#import +#endif /* sensorOC_Bridge_h */ diff --git a/third_party/synchroni/lib/mac/sensor.xcframework/macos-arm64_x86_64/sensor.framework/Versions/A/Headers/sensorProfile.h b/third_party/synchroni/lib/mac/sensor.xcframework/macos-arm64_x86_64/sensor.framework/Versions/A/Headers/sensorProfile.h new file mode 100644 index 000000000..f713b84f6 --- /dev/null +++ b/third_party/synchroni/lib/mac/sensor.xcframework/macos-arm64_x86_64/sensor.framework/Versions/A/Headers/sensorProfile.h @@ -0,0 +1,101 @@ +// +// sensorProfile.h +// sensorProfile +// +// Created by 叶常青 on 2023/12/21. +// +#ifndef sensor_profile_h +#define sensor_profile_h + +#import +#import +#import +#import + +@interface DeviceInfo : NSObject + +@property (atomic, strong) NSString* deviceName; +@property (atomic, strong) NSString* modelName; +@property (atomic, strong) NSString* hardwareVersion; +@property (atomic, strong) NSString* firmwareVersion; +@property (atomic, assign) int MTUSize; +@property (atomic, assign) bool isMTUFine; +@property (atomic, assign) int EEGChannelCount; +@property (atomic, assign) int ECGChannelCount; +@property (atomic, assign) int BRTHChannelCount; +@property (atomic, assign) int AccChannelCount; +@property (atomic, assign) int GyroChannelCount; + +@end + +@interface Sample : NSObject +@property (atomic, assign) int timeStampInMs; +@property (atomic, assign) int sampleIndex; +@property (atomic, assign) int channelIndex; +@property (atomic, assign) BOOL isLost; +@property (atomic, assign) float rawData; +@property (atomic, assign) float convertData; +@property (atomic, assign) float impedance; +@property (atomic, assign) float saturation; +@end + +@interface SensorData : NSObject + +@property (atomic, assign) NotifyDataType dataType; +@property (atomic, assign) int lastPackageIndex; +@property (atomic, assign) int lastPackageCounter; +@property (atomic, assign) int resolutionBits; +@property (atomic, assign) int sampleRate; +@property (atomic, assign) int channelCount; +@property (atomic, assign) unsigned long long channelMask; +@property (atomic, assign) int packageSampleCount; +@property (atomic, assign) int minPackageSampleCount; +@property (atomic, assign) double K; +@property (atomic, strong) NSArray*>* channelSamples; +-(id)init; +-(void)clear; +-(NSArray*)flushSamples; +@end + +@protocol SensorProfileDelegate; + +@interface SensorProfile : NSObject +{ + +} +@property (atomic, weak) id delegate; +@property (atomic, assign, readonly) BLEState state; +@property (atomic, readonly) NSString* stateString; +@property (atomic, strong, readonly) BLEPeripheral* device; +@property (atomic, strong, readonly) DeviceInfo* deviceInfo; +@property (atomic, assign, readonly) bool hasInit; +@property (atomic, assign, readonly) bool hasStartDataNotification; + + +-(BOOL)connect; +-(void)disconnect; +-(BOOL)startDataNotification; +-(BOOL)stopDataNotification; + +- (void)initAll:(int)packageCount timeout:(NSTimeInterval)timeout completion:(void (^)(BOOL success, NSError * err))completionHandler; +- (void)initEEG:(int)packageCount timeout:(NSTimeInterval)timeout completion:(void (^)(BOOL success, NSError * err))completionHandler; +- (void)initECG:(int)packageCount timeout:(NSTimeInterval)timeout completion:(void (^)(BOOL success, NSError * err))completionHandler; +- (void)initIMU:(int)packageCount timeout:(NSTimeInterval)timeout completion:(void (^)(BOOL success, NSError * err))completionHandler; +- (void)initBRTH:(int)packageCount timeout:(NSTimeInterval)timeout completion:(void (^)(BOOL success, NSError * err))completionHandler; +- (void)initDataTransfer:(BOOL)isGetFeature timeout:(NSTimeInterval)timeout completion:(void (^)(int flag, NSError * err))completionHandler; +- (void)getBattery:(NSTimeInterval)timeout completion:(void (^)(int battery, NSError * err))completionHandler; +- (void)getDeviceInfo:(BOOL)onlyMTU timeout:(NSTimeInterval)timeout completion:(void (^)(DeviceInfo* deviceInfo, NSError * err))completionHandler; +- (void)startDataNotification:(NSTimeInterval)timeout completion:(void (^)(BOOL success, NSError * err))completionHandler; +- (void)stopDataNotification:(NSTimeInterval)timeout completion:(void (^)(BOOL success, NSError * err))completionHandler; + +- (void)setParam:(NSTimeInterval)timeout key:(NSString*_Nonnull)key value:(NSString*_Nonnull)value completion:(void (^_Nonnull)(NSString*_Nonnull result, NSError * _Nullable err))completionHandler; + +@end + +@protocol SensorProfileDelegate +- (void)onSensorErrorCallback:(SensorProfile*_Nonnull)profile err:(NSError*_Nonnull)err; +- (void)onSensorStateChange:(SensorProfile*_Nonnull)profile newState:(BLEState)newState; +- (void)onSensorNotifyData:(SensorProfile*_Nonnull)profile rawData:(SensorData*_Nonnull) rawData; +@end + +#endif diff --git a/third_party/synchroni/lib/mac/sensor.xcframework/macos-arm64_x86_64/sensor.framework/Versions/A/Modules/module.modulemap b/third_party/synchroni/lib/mac/sensor.xcframework/macos-arm64_x86_64/sensor.framework/Versions/A/Modules/module.modulemap new file mode 100644 index 000000000..6391e2b80 --- /dev/null +++ b/third_party/synchroni/lib/mac/sensor.xcframework/macos-arm64_x86_64/sensor.framework/Versions/A/Modules/module.modulemap @@ -0,0 +1,6 @@ +framework module sensor { + umbrella header "sensor.h" + + export * + module * { export * } +} diff --git a/third_party/synchroni/lib/mac/sensor.xcframework/macos-arm64_x86_64/sensor.framework/Versions/A/Resources/Info.plist b/third_party/synchroni/lib/mac/sensor.xcframework/macos-arm64_x86_64/sensor.framework/Versions/A/Resources/Info.plist new file mode 100644 index 000000000..ae00bc1e3 --- /dev/null +++ b/third_party/synchroni/lib/mac/sensor.xcframework/macos-arm64_x86_64/sensor.framework/Versions/A/Resources/Info.plist @@ -0,0 +1,46 @@ + + + + + BuildMachineOSBuild + 21H1320 + CFBundleDevelopmentRegion + en + CFBundleExecutable + sensor + CFBundleIdentifier + com.sensor + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + sensor + CFBundlePackageType + FMWK + CFBundleShortVersionString + 1.0 + CFBundleSupportedPlatforms + + MacOSX + + CFBundleVersion + 1 + DTCompiler + com.apple.compilers.llvm.clang.1_0 + DTPlatformBuild + 14B47b + DTPlatformName + macosx + DTPlatformVersion + 13.0 + DTSDKBuild + 22A372 + DTSDKName + macosx13.0 + DTXcode + 1410 + DTXcodeBuild + 14B47b + LSMinimumSystemVersion + 10.13 + + diff --git a/third_party/synchroni/lib/mac/sensor.xcframework/macos-arm64_x86_64/sensor.framework/Versions/A/_CodeSignature/CodeDirectory b/third_party/synchroni/lib/mac/sensor.xcframework/macos-arm64_x86_64/sensor.framework/Versions/A/_CodeSignature/CodeDirectory new file mode 100644 index 000000000..dac78f398 Binary files /dev/null and b/third_party/synchroni/lib/mac/sensor.xcframework/macos-arm64_x86_64/sensor.framework/Versions/A/_CodeSignature/CodeDirectory differ diff --git a/third_party/synchroni/lib/mac/sensor.xcframework/macos-arm64_x86_64/sensor.framework/Versions/A/_CodeSignature/CodeRequirements b/third_party/synchroni/lib/mac/sensor.xcframework/macos-arm64_x86_64/sensor.framework/Versions/A/_CodeSignature/CodeRequirements new file mode 100644 index 000000000..83a81ef9b Binary files /dev/null and b/third_party/synchroni/lib/mac/sensor.xcframework/macos-arm64_x86_64/sensor.framework/Versions/A/_CodeSignature/CodeRequirements differ diff --git a/third_party/synchroni/lib/mac/sensor.xcframework/macos-arm64_x86_64/sensor.framework/Versions/A/_CodeSignature/CodeRequirements-1 b/third_party/synchroni/lib/mac/sensor.xcframework/macos-arm64_x86_64/sensor.framework/Versions/A/_CodeSignature/CodeRequirements-1 new file mode 100644 index 000000000..bbf1239f9 Binary files /dev/null and b/third_party/synchroni/lib/mac/sensor.xcframework/macos-arm64_x86_64/sensor.framework/Versions/A/_CodeSignature/CodeRequirements-1 differ diff --git a/third_party/synchroni/lib/mac/sensor.xcframework/macos-arm64_x86_64/sensor.framework/Versions/A/_CodeSignature/CodeResources b/third_party/synchroni/lib/mac/sensor.xcframework/macos-arm64_x86_64/sensor.framework/Versions/A/_CodeSignature/CodeResources new file mode 100644 index 000000000..c24e4fbd6 --- /dev/null +++ b/third_party/synchroni/lib/mac/sensor.xcframework/macos-arm64_x86_64/sensor.framework/Versions/A/_CodeSignature/CodeResources @@ -0,0 +1,231 @@ + + + + + files + + Resources/Info.plist + + yx0nhsuUR+xRR/JG2t83VUnxjBE= + + + files2 + + Headers/BLEPeripheral.h + + hash + + ScMKAnaRSunM5VR5LhzbqyPcMM8= + + hash2 + + xsCr5VEKnCj9s+H04uZnWmn5h03Zk1AZV5LEzEe7/BE= + + + Headers/SensorController.h + + hash + + LEKmoiwY0eFzOTC9jWaTAFwFai8= + + hash2 + + yanvVMbiv1Cx+bZAg9xhxsZb+tmdDMYX3/nLJsZSuAI= + + + Headers/SensorController.hpp + + hash + + LKS2auDoV9yljRi3diaExNrPVDw= + + hash2 + + d7iHF96PUrr0BFtR6o0JwYxMD4H+4AwDYvVxvJQgnrA= + + + Headers/SensorData.hpp + + hash + + eSM6WcP/p94o6eDF2YcrxcIqpCk= + + hash2 + + js9AVsuzZpBVqbwzT12WyxhH1jRJXbl2fYoJVn8nv9Q= + + + Headers/SensorProfile.h + + hash + + AsLNZ4tujqDYaDt71hVilMqQa2M= + + hash2 + + t90schmW6nLupfAHoxrCNZGKlR+A52LRPadI4gzQQxQ= + + + Headers/SensorProfile.hpp + + hash + + ScoQnVZ0N0xsiftJ6s9IVfP+1Lo= + + hash2 + + IZ53bEdxLyiAXDsV8Zmd3v9G/HUAKT4osOkCUKsSM4M= + + + Headers/defines.h + + hash + + 6JxT8sZUpjfdLWeH76NeOE1u2Jc= + + hash2 + + 3a4kW1afB639zCIMlgZm4dYSYIoRAod1GAls6v5tW/4= + + + Headers/sensor.h + + hash + + j/aJB8fU9MHfSeXZ+MHuuzgRC8Y= + + hash2 + + uPnFelYZa/cHn/pVLsX7I2UuJNNwD4cVXddGZtjd0QI= + + + Modules/module.modulemap + + hash + + PmkZKQtcJn9CbKZGFyH8DHGquDM= + + hash2 + + BDjL+me3BBqvaiEz6ERAoe4Mg+SwwX8q/IJQ++zKZL4= + + + Resources/Info.plist + + hash + + yx0nhsuUR+xRR/JG2t83VUnxjBE= + + hash2 + + uxTb3BbhQFQzXxqC3n53Yx/UifRYBxolOnIzuWEvzIE= + + + + rules + + ^Resources/ + + ^Resources/.*\.lproj/ + + optional + + weight + 1000 + + ^Resources/.*\.lproj/locversion.plist$ + + omit + + weight + 1100 + + ^Resources/Base\.lproj/ + + weight + 1010 + + ^version.plist$ + + + rules2 + + .*\.dSYM($|/) + + weight + 11 + + ^(.*/)?\.DS_Store$ + + omit + + weight + 2000 + + ^(Frameworks|SharedFrameworks|PlugIns|Plug-ins|XPCServices|Helpers|MacOS|Library/(Automator|Spotlight|LoginItems))/ + + nested + + weight + 10 + + ^.* + + ^Info\.plist$ + + omit + + weight + 20 + + ^PkgInfo$ + + omit + + weight + 20 + + ^Resources/ + + weight + 20 + + ^Resources/.*\.lproj/ + + optional + + weight + 1000 + + ^Resources/.*\.lproj/locversion.plist$ + + omit + + weight + 1100 + + ^Resources/Base\.lproj/ + + weight + 1010 + + ^[^/]+$ + + nested + + weight + 10 + + ^embedded\.provisionprofile$ + + weight + 20 + + ^version\.plist$ + + weight + 20 + + + + diff --git a/third_party/synchroni/lib/mac/sensor.xcframework/macos-arm64_x86_64/sensor.framework/Versions/A/_CodeSignature/CodeSignature b/third_party/synchroni/lib/mac/sensor.xcframework/macos-arm64_x86_64/sensor.framework/Versions/A/_CodeSignature/CodeSignature new file mode 100644 index 000000000..7c4152301 Binary files /dev/null and b/third_party/synchroni/lib/mac/sensor.xcframework/macos-arm64_x86_64/sensor.framework/Versions/A/_CodeSignature/CodeSignature differ diff --git a/third_party/synchroni/lib/mac/sensor.xcframework/macos-arm64_x86_64/sensor.framework/Versions/A/sensor b/third_party/synchroni/lib/mac/sensor.xcframework/macos-arm64_x86_64/sensor.framework/Versions/A/sensor new file mode 100644 index 000000000..3ae3c2787 Binary files /dev/null and b/third_party/synchroni/lib/mac/sensor.xcframework/macos-arm64_x86_64/sensor.framework/Versions/A/sensor differ diff --git a/third_party/synchroni/lib/mac/sensor.xcframework/macos-arm64_x86_64/sensor.framework/Versions/Current b/third_party/synchroni/lib/mac/sensor.xcframework/macos-arm64_x86_64/sensor.framework/Versions/Current new file mode 120000 index 000000000..8c7e5a667 --- /dev/null +++ b/third_party/synchroni/lib/mac/sensor.xcframework/macos-arm64_x86_64/sensor.framework/Versions/Current @@ -0,0 +1 @@ +A \ No newline at end of file diff --git a/third_party/synchroni/lib/mac/sensor.xcframework/macos-arm64_x86_64/sensor.framework/sensor b/third_party/synchroni/lib/mac/sensor.xcframework/macos-arm64_x86_64/sensor.framework/sensor new file mode 120000 index 000000000..23e8a4cca --- /dev/null +++ b/third_party/synchroni/lib/mac/sensor.xcframework/macos-arm64_x86_64/sensor.framework/sensor @@ -0,0 +1 @@ +Versions/Current/sensor \ No newline at end of file diff --git a/third_party/synchroni/lib/windows/Win32/ForDebug/sensor32.dll b/third_party/synchroni/lib/windows/Win32/ForDebug/sensor32.dll new file mode 100644 index 000000000..1dbc01432 Binary files /dev/null and b/third_party/synchroni/lib/windows/Win32/ForDebug/sensor32.dll differ diff --git a/third_party/synchroni/lib/windows/Win32/ForDebug/sensor32.exp b/third_party/synchroni/lib/windows/Win32/ForDebug/sensor32.exp new file mode 100644 index 000000000..afaa8a63e Binary files /dev/null and b/third_party/synchroni/lib/windows/Win32/ForDebug/sensor32.exp differ diff --git a/third_party/synchroni/lib/windows/Win32/ForDebug/sensor32.lib b/third_party/synchroni/lib/windows/Win32/ForDebug/sensor32.lib new file mode 100644 index 000000000..6ae141e8e Binary files /dev/null and b/third_party/synchroni/lib/windows/Win32/ForDebug/sensor32.lib differ diff --git a/third_party/synchroni/lib/windows/Win32/ForRelease/sensor32.dll b/third_party/synchroni/lib/windows/Win32/ForRelease/sensor32.dll new file mode 100644 index 000000000..d073703c7 Binary files /dev/null and b/third_party/synchroni/lib/windows/Win32/ForRelease/sensor32.dll differ diff --git a/third_party/synchroni/lib/windows/Win32/ForRelease/sensor32.exp b/third_party/synchroni/lib/windows/Win32/ForRelease/sensor32.exp new file mode 100644 index 000000000..05a634b8e Binary files /dev/null and b/third_party/synchroni/lib/windows/Win32/ForRelease/sensor32.exp differ diff --git a/third_party/synchroni/lib/windows/Win32/ForRelease/sensor32.lib b/third_party/synchroni/lib/windows/Win32/ForRelease/sensor32.lib new file mode 100644 index 000000000..6ae141e8e Binary files /dev/null and b/third_party/synchroni/lib/windows/Win32/ForRelease/sensor32.lib differ diff --git a/third_party/synchroni/lib/windows/Win64/ForDebug/sensor.dll b/third_party/synchroni/lib/windows/Win64/ForDebug/sensor.dll new file mode 100644 index 000000000..87609058a Binary files /dev/null and b/third_party/synchroni/lib/windows/Win64/ForDebug/sensor.dll differ diff --git a/third_party/synchroni/lib/windows/Win64/ForDebug/sensor.exp b/third_party/synchroni/lib/windows/Win64/ForDebug/sensor.exp new file mode 100644 index 000000000..662e3136c Binary files /dev/null and b/third_party/synchroni/lib/windows/Win64/ForDebug/sensor.exp differ diff --git a/third_party/synchroni/lib/windows/Win64/ForDebug/sensor.lib b/third_party/synchroni/lib/windows/Win64/ForDebug/sensor.lib new file mode 100644 index 000000000..533348d2c Binary files /dev/null and b/third_party/synchroni/lib/windows/Win64/ForDebug/sensor.lib differ diff --git a/third_party/synchroni/lib/windows/Win64/ForRelease/sensor.dll b/third_party/synchroni/lib/windows/Win64/ForRelease/sensor.dll new file mode 100644 index 000000000..5ca28e186 Binary files /dev/null and b/third_party/synchroni/lib/windows/Win64/ForRelease/sensor.dll differ diff --git a/third_party/synchroni/lib/windows/Win64/ForRelease/sensor.exp b/third_party/synchroni/lib/windows/Win64/ForRelease/sensor.exp new file mode 100644 index 000000000..0c4ca7a32 Binary files /dev/null and b/third_party/synchroni/lib/windows/Win64/ForRelease/sensor.exp differ diff --git a/third_party/synchroni/lib/windows/Win64/ForRelease/sensor.lib b/third_party/synchroni/lib/windows/Win64/ForRelease/sensor.lib new file mode 100644 index 000000000..533348d2c Binary files /dev/null and b/third_party/synchroni/lib/windows/Win64/ForRelease/sensor.lib differ diff --git a/third_party/synchroni/src/inc/synchroni_wrapper.h b/third_party/synchroni/src/inc/synchroni_wrapper.h new file mode 100644 index 000000000..04874135e --- /dev/null +++ b/third_party/synchroni/src/inc/synchroni_wrapper.h @@ -0,0 +1,20 @@ +#include "shared_export.h" + + +#ifdef __cplusplus +extern "C" +{ +#endif + SHARED_EXPORT int CALLING_CONVENTION synchroni_initialize (void *param); + SHARED_EXPORT int CALLING_CONVENTION synchroni_open_device (void *param); + SHARED_EXPORT int CALLING_CONVENTION synchroni_stop_stream (void *param); + SHARED_EXPORT int CALLING_CONVENTION synchroni_start_stream (void *param); + SHARED_EXPORT int CALLING_CONVENTION synchroni_close_device (void *param); + SHARED_EXPORT int CALLING_CONVENTION synchroni_get_data_default (void *param); + SHARED_EXPORT int CALLING_CONVENTION synchroni_get_data_aux (void *param); + SHARED_EXPORT int CALLING_CONVENTION synchroni_get_data_anc (void *param); + SHARED_EXPORT int CALLING_CONVENTION synchroni_release (void *param); + SHARED_EXPORT int CALLING_CONVENTION synchroni_config_device (void *param); +#ifdef __cplusplus +} +#endif diff --git a/third_party/synchroni/src/synchroni_wrapper.cpp b/third_party/synchroni/src/synchroni_wrapper.cpp new file mode 100644 index 000000000..5b8872dd6 --- /dev/null +++ b/third_party/synchroni/src/synchroni_wrapper.cpp @@ -0,0 +1,666 @@ +#if defined __APPLE__ +#include +#else +#include "SensorController.hpp" +#endif + +#include "board_info_getter.h" +#include "brainflow_boards.h" +#include "brainflow_input_params.h" +#include "spdlog/sinks/null_sink.h" +#include "spdlog/spdlog.h" +#include "synchroni_wrapper.h" +#include "timestamp.h" +#include +#include +#include +// #define ENABLE_LOGGER + +using namespace std; +using namespace sensor; + +const int PACKAGE_COUNT = 1; + +class SynchroniBoardWrapper : public sensor::SensorProfileDelegate, + public enable_shared_from_this +{ +public: + std::shared_ptr profile; + + int board_id; + struct BrainFlowInputParams params; + json board_descr; + + deque lastEEG; + deque lastECG; + mutex dataMutex; + + DeviceInfo deviceInfo; + double startStreamTimeStamp; + + SynchroniBoardWrapper () + { + } + + virtual ~SynchroniBoardWrapper () + { + profile = NULL; + } + + virtual void onErrorCallback ( + std::shared_ptr profile, std::string errorMsg) + { + } + + virtual void onStateChange ( + std::shared_ptr profile, sensor::BLEDevice::State newState) + { + + // throw BrainFlowException ("failed to get board info", res); + } + + virtual void onSensorNotifyData ( + std::shared_ptr profile, const sensor::SensorData &rawData) + { + if (profile != this->profile) + { + return; + } + if (rawData.dataType == sensor::SensorData::NTF_EEG) + { + dataMutex.lock (); + lastEEG.push_back (rawData); + dataMutex.unlock (); + } + if (rawData.dataType == sensor::SensorData::NTF_ECG) + { + dataMutex.lock (); + lastECG.push_back (rawData); + dataMutex.unlock (); + } + } +}; + + +class SynchroniControllerDelegate : public sensor::SensorControllerDelegate, + public enable_shared_from_this +{ +public: + SynchroniControllerDelegate () + { + +#ifdef ENABLE_LOGGER + logger = spdlog::stderr_logger_mt ("SynchroniLogger"); + logger->set_level (spdlog::level::level_enum (0)); + logger->flush_on (spdlog::level::level_enum (0)); +#else + logger = spdlog::create ("SynchroniLogger"); +#endif + } + virtual ~SynchroniControllerDelegate () + { + } + + map> boardMap; + std::mutex boardMapMutex; + std::shared_ptr logger; + + static std::shared_ptr sensorControllerDelegate; + + virtual void onSensorControllerEnableChanged (bool enabled) + { + } + + virtual void onSensorScanResult (vector bleDevices) + { + } +}; + +std::shared_ptr SynchroniControllerDelegate::sensorControllerDelegate; + +std::once_flag initFlag; + +//////////////////////////////////////// + + +int synchroni_initialize (void *param) +{ + std::call_once (initFlag, + [] () + { + SynchroniControllerDelegate::sensorControllerDelegate = + make_shared (); + SensorController::getInstance ()->setDelegate ( + SynchroniControllerDelegate::sensorControllerDelegate); + }); + + std::tuple *info = + (std::tuple *)(param); + + int board_id = std::get<0> (*info); + struct BrainFlowInputParams params = std::get<1> (*info); + json board_descr = std::get<2> (*info); + + SynchroniControllerDelegate::sensorControllerDelegate->boardMapMutex.lock (); + if (SynchroniControllerDelegate::sensorControllerDelegate->boardMap[params.mac_address] != NULL) + { + SynchroniControllerDelegate::sensorControllerDelegate->boardMapMutex.unlock (); + return (int)BrainFlowExitCodes::ANOTHER_BOARD_IS_CREATED_ERROR; + } + auto wrapper = make_shared (); + wrapper->params = params; + wrapper->board_id = board_id; + wrapper->board_descr = board_descr; + SynchroniControllerDelegate::sensorControllerDelegate->boardMap[params.mac_address] = wrapper; + SynchroniControllerDelegate::sensorControllerDelegate->boardMapMutex.unlock (); + + return 0; +} +int synchroni_open_device (void *param) +{ + std::tuple *info = (std::tuple *)(param); + std::string mac_address = std::get<0> (*info); + + SynchroniControllerDelegate::sensorControllerDelegate->boardMapMutex.lock (); + if (SynchroniControllerDelegate::sensorControllerDelegate->boardMap[mac_address] == NULL) + { + SynchroniControllerDelegate::sensorControllerDelegate->boardMapMutex.unlock (); + return (int)BrainFlowExitCodes::BOARD_NOT_CREATED_ERROR; + } + auto wrapper = SynchroniControllerDelegate::sensorControllerDelegate->boardMap[mac_address]; + SynchroniControllerDelegate::sensorControllerDelegate->boardMapMutex.unlock (); + int timeout = wrapper->params.timeout; + if (timeout < 1) + { + timeout = 5; + } + if (wrapper->profile == NULL) + { + SynchroniControllerDelegate::sensorControllerDelegate->logger->log ( + spdlog::level::info, "Use timeout for discovery: {}", timeout); + auto controller = sensor::SensorController::getInstance (); + if (!controller->isScaning ()) + { + controller->startScan (2 * 1000); + } + + auto profile = controller->getSensor (mac_address); + + for (int index = 0; index < timeout; ++index) + { + profile = controller->getSensor (mac_address); + if (profile == NULL) + { +#ifdef _WIN32 + Sleep (1000); +#else + sleep (1); +#endif + } + else + { + break; + } + } + controller->stopScan (); + + if (profile == NULL) + { + return (int)BrainFlowExitCodes::BOARD_NOT_CREATED_ERROR; + } + + wrapper->profile = profile; + profile->setDelegate (wrapper); + } + + if (wrapper->profile->getDeviceState () != BLEDevice::State::Ready) + { + wrapper->profile->connect (); + + for (int index = 0; index < timeout; ++index) + { + if (wrapper->profile->getDeviceState () != BLEDevice::State::Ready) + { +#ifdef _WIN32 + Sleep (1000); +#else + sleep (1); +#endif + } + else + { + break; + } + } + + if (wrapper->profile->getDeviceState () != BLEDevice::State::Ready) + { + return (int)BrainFlowExitCodes::BOARD_NOT_READY_ERROR; + } + } + + if (!wrapper->profile->hasInit ()) + { + wrapper->profile->init (PACKAGE_COUNT, timeout * 1000, + [] (bool succeed, string err) + { + if (err != "") + { + SynchroniControllerDelegate::sensorControllerDelegate->logger->log ( + spdlog::level::err, "init error: " + err); + } + }); + + for (int index = 0; index < timeout; ++index) + { + if (!wrapper->profile->hasInit ()) + { +#ifdef _WIN32 + Sleep (1000); +#else + sleep (1); +#endif + } + else + { + break; + } + } + + if (!wrapper->profile->hasInit ()) + { + return (int)BrainFlowExitCodes::BOARD_NOT_READY_ERROR; + } + } + + std::atomic deviceMatch (false); + int eegChannel = int(wrapper->board_descr["default"]["eeg_channels"].size ()); + wrapper->profile->fetchDeviceInfo (timeout * 1000, + [&deviceMatch, eegChannel, &wrapper] (DeviceInfo info, string err) + { + wrapper->deviceInfo = info; + if (info.EEGChannelCount == eegChannel) + { + deviceMatch = true; + } + }); + for (int index = 0; index < timeout; ++index) + { + if (!deviceMatch) + { +#ifdef _WIN32 + Sleep (1000); +#else + sleep (1); +#endif + } + else + { + break; + } + } + if (!deviceMatch) + { + wrapper->profile->disconnect (); + return (int)BrainFlowExitCodes::UNSUPPORTED_BOARD_ERROR; + } + SynchroniControllerDelegate::sensorControllerDelegate->logger->log ( + spdlog::level::info, "Session is prepared"); + return 0; +} + +int synchroni_start_stream (void *param) +{ + std::tuple *info = (std::tuple *)(param); + std::string mac_address = std::get<0> (*info); + + SynchroniControllerDelegate::sensorControllerDelegate->boardMapMutex.lock (); + if (SynchroniControllerDelegate::sensorControllerDelegate->boardMap[mac_address] == NULL) + { + SynchroniControllerDelegate::sensorControllerDelegate->boardMapMutex.unlock (); + return (int)BrainFlowExitCodes::BOARD_NOT_CREATED_ERROR; + } + auto wrapper = SynchroniControllerDelegate::sensorControllerDelegate->boardMap[mac_address]; + SynchroniControllerDelegate::sensorControllerDelegate->boardMapMutex.unlock (); + if (wrapper->profile == NULL) + { + return (int)BrainFlowExitCodes::BOARD_NOT_READY_ERROR; + } + if (!wrapper->profile->hasInit ()) + { + return (int)BrainFlowExitCodes::BOARD_NOT_READY_ERROR; + } + if (wrapper->profile->hasStartDataNotification ()) + { + return (int)BrainFlowExitCodes::STREAM_ALREADY_RUN_ERROR; + } + + int timeout = wrapper->params.timeout; + if (timeout < 1) + { + timeout = 5; + } + std::atomic hasSucceed {false}; + std::atomic finished {false}; + + wrapper->profile->startDataNotification (timeout * 1000, + [&finished, &hasSucceed, &wrapper] (bool succeed, string err) + { + hasSucceed = succeed; + if (err != "") + { + SynchroniControllerDelegate::sensorControllerDelegate->logger->log ( + spdlog::level::err, "Start stream error: " + err); + } + wrapper->startStreamTimeStamp = get_timestamp (); + finished = true; + }); + + for (int index = 0; index < timeout; ++index) + { + if (!finished) + { +#ifdef _WIN32 + Sleep (1000); +#else + sleep (1); +#endif + } + else + { + break; + } + } + if (!hasSucceed) + return (int)BrainFlowExitCodes::SYNC_TIMEOUT_ERROR; + + return 0; +} + +int synchroni_stop_stream (void *param) +{ + std::tuple *info = (std::tuple *)(param); + std::string mac_address = std::get<0> (*info); + + SynchroniControllerDelegate::sensorControllerDelegate->boardMapMutex.lock (); + if (SynchroniControllerDelegate::sensorControllerDelegate->boardMap[mac_address] == NULL) + { + SynchroniControllerDelegate::sensorControllerDelegate->boardMapMutex.unlock (); + return (int)BrainFlowExitCodes::BOARD_NOT_CREATED_ERROR; + } + auto wrapper = SynchroniControllerDelegate::sensorControllerDelegate->boardMap[mac_address]; + SynchroniControllerDelegate::sensorControllerDelegate->boardMapMutex.unlock (); + if (wrapper->profile == NULL) + { + return (int)BrainFlowExitCodes::BOARD_NOT_READY_ERROR; + } + if (!wrapper->profile->hasInit ()) + { + return (int)BrainFlowExitCodes::BOARD_NOT_READY_ERROR; + } + int timeout = wrapper->params.timeout; + if (timeout < 1) + { + timeout = 5; + } + std::atomic hasSucceed {false}; + std::atomic finished {false}; + + wrapper->profile->stopDataNotification (timeout * 1000, + [&finished, &hasSucceed] (bool succeed, string err) + { + hasSucceed = succeed; + if (err != "") + { + SynchroniControllerDelegate::sensorControllerDelegate->logger->log ( + spdlog::level::err, "Stop stream error: " + err); + } + finished = true; + }); + + for (int index = 0; index < timeout; ++index) + { + if (!finished) + { +#ifdef _WIN32 + Sleep (1000); +#else + sleep (1); +#endif + } + else + { + break; + } + } + if (!hasSucceed) + return (int)BrainFlowExitCodes::SYNC_TIMEOUT_ERROR; + + return 0; +} + +int synchroni_close_device (void *param) +{ + std::tuple *info = (std::tuple *)(param); + std::string mac_address = std::get<0> (*info); + + SynchroniControllerDelegate::sensorControllerDelegate->boardMapMutex.lock (); + if (SynchroniControllerDelegate::sensorControllerDelegate->boardMap[mac_address] == NULL) + { + SynchroniControllerDelegate::sensorControllerDelegate->boardMapMutex.unlock (); + return (int)BrainFlowExitCodes::BOARD_NOT_CREATED_ERROR; + } + auto wrapper = SynchroniControllerDelegate::sensorControllerDelegate->boardMap[mac_address]; + SynchroniControllerDelegate::sensorControllerDelegate->boardMapMutex.unlock (); + if (wrapper->profile == NULL) + { + return (int)BrainFlowExitCodes::BOARD_NOT_READY_ERROR; + } + int timeout = wrapper->params.timeout; + if (timeout < 1) + { + timeout = 5; + } + wrapper->profile->disconnect (); + for (int index = 0; index < timeout; ++index) + { + if (wrapper->profile->getDeviceState () != BLEDevice::State::Disconnected) + { +#ifdef _WIN32 + Sleep (1000); +#else + sleep (1); +#endif + } + else + { + break; + } + } + if (wrapper->profile->getDeviceState () != BLEDevice::State::Disconnected) + return (int)BrainFlowExitCodes::SYNC_TIMEOUT_ERROR; + + return 0; +} +int synchroni_get_data_default (void *param) +{ + std::tuple *info = + (std::tuple *)(param); + + std::string mac_address = std::get<0> (*info); + double *data = std::get<1> (*info); + int numOfRows = std::get<2> (*info); + + SynchroniControllerDelegate::sensorControllerDelegate->boardMapMutex.lock (); + if (SynchroniControllerDelegate::sensorControllerDelegate->boardMap[mac_address] == NULL) + { + SynchroniControllerDelegate::sensorControllerDelegate->boardMapMutex.unlock (); + return (int)BrainFlowExitCodes::BOARD_NOT_CREATED_ERROR; + } + auto wrapper = SynchroniControllerDelegate::sensorControllerDelegate->boardMap[mac_address]; + SynchroniControllerDelegate::sensorControllerDelegate->boardMapMutex.unlock (); + if (wrapper->profile == NULL) + { + return (int)BrainFlowExitCodes::BOARD_NOT_READY_ERROR; + } + if (!wrapper->profile->hasStartDataNotification ()) + { + return (int)BrainFlowExitCodes::SYNC_TIMEOUT_ERROR; + } + wrapper->dataMutex.lock (); + if (wrapper->deviceInfo.EEGChannelCount > 0 && wrapper->lastEEG.empty ()) + { + wrapper->dataMutex.unlock (); + return (int)BrainFlowExitCodes::EMPTY_BUFFER_ERROR; + } + if (wrapper->deviceInfo.ECGChannelCount > 0 && wrapper->lastECG.empty ()) + { + wrapper->dataMutex.unlock (); + return (int)BrainFlowExitCodes::EMPTY_BUFFER_ERROR; + } + SensorData lastEEG; + SensorData lastECG; + if (wrapper->deviceInfo.EEGChannelCount > 0) + { + lastEEG = wrapper->lastEEG.at (0); + wrapper->lastEEG.pop_front (); + } + if (wrapper->deviceInfo.ECGChannelCount > 0) + { + lastECG = wrapper->lastECG.at (0); + wrapper->lastECG.pop_front (); + } + wrapper->dataMutex.unlock (); + + auto &board_descr = wrapper->board_descr; + try + { + double *board_data = (double *)data; + + if (wrapper->deviceInfo.EEGChannelCount > 0) + { + board_data[board_descr["default"]["package_num_channel"].get ()] = + lastEEG.channelSamples[0][0].sampleIndex; + + double timeStamp = + wrapper->startStreamTimeStamp + lastEEG.channelSamples[0][0].timeStampInMs / 1000.0; + board_data[board_descr["default"]["timestamp_channel"].get ()] = timeStamp; + + int eegStart = board_descr["default"]["eeg_channels"][0].get (); + for (int i = 0; i < lastEEG.channelCount; i++) + { + board_data[i + eegStart] = lastEEG.channelSamples[i][0].data; + } + } + + if (wrapper->deviceInfo.ECGChannelCount > 0) + { + int ecgStart = board_descr["default"]["ecg_channels"][0].get (); + for (int i = 0; i < lastECG.channelCount; i++) + { + board_data[i + ecgStart] = lastECG.channelSamples[i][0].data; + } + } + } + catch (...) + { + return (int)BrainFlowExitCodes::EMPTY_BUFFER_ERROR; + } + return (int)BrainFlowExitCodes::STATUS_OK; +} +int synchroni_release (void *param) +{ + std::tuple *info = (std::tuple *)(param); + std::string mac_address = std::get<0> (*info); + + SynchroniControllerDelegate::sensorControllerDelegate->boardMapMutex.lock (); + SynchroniControllerDelegate::sensorControllerDelegate->boardMap.erase (mac_address); + SynchroniControllerDelegate::sensorControllerDelegate->boardMapMutex.unlock (); + return 0; +} +int synchroni_config_device (void *param) +{ + std::tuple *info = + (std::tuple *)(param); + + std::string mac_address = std::get<0> (*info); + std::string key_char = std::get<1> (*info); + char *result_char = std::get<2> (*info); + int buffer_size = std::get<3> (*info); + + SynchroniControllerDelegate::sensorControllerDelegate->boardMapMutex.lock (); + if (SynchroniControllerDelegate::sensorControllerDelegate->boardMap[mac_address] == NULL) + { + SynchroniControllerDelegate::sensorControllerDelegate->boardMapMutex.unlock (); + return (int)BrainFlowExitCodes::BOARD_NOT_CREATED_ERROR; + } + auto wrapper = SynchroniControllerDelegate::sensorControllerDelegate->boardMap[mac_address]; + SynchroniControllerDelegate::sensorControllerDelegate->boardMapMutex.unlock (); + if (wrapper->profile == NULL) + { + return (int)BrainFlowExitCodes::BOARD_NOT_READY_ERROR; + } + int timeout = wrapper->params.timeout; + if (timeout < 1) + { + timeout = 5; + } + atomic finished (false); + wrapper->profile->setParam (timeout * 1000, key_char, "", + [&finished, result_char, buffer_size] (string result, string err) + { + strncpy (result_char, result.c_str (), buffer_size); + finished = true; + }); + for (int index = 0; index < timeout; ++index) + { + if (!finished) + { +#ifdef _WIN32 + Sleep (1000); +#else + sleep (1); +#endif + } + else + { + break; + } + } + return 0; +} + +#ifdef _WIN32 +BOOL WINAPI DllMain (HINSTANCE hinstDLL, // handle to DLL module + DWORD fdwReason, // reason for calling function + LPVOID lpvReserved) // reserved +{ + // Perform actions based on the reason for calling. + switch (fdwReason) + { + case DLL_PROCESS_ATTACH: + // Initialize once for each new process. + // Return FALSE to fail DLL load. + break; + + case DLL_THREAD_ATTACH: + // Do thread-specific initialization. + break; + + case DLL_THREAD_DETACH: + // Do thread-specific cleanup. + break; + + case DLL_PROCESS_DETACH: + + if (lpvReserved != nullptr) + { + break; // do not do cleanup if process termination scenario + } + sensor::SensorController::destory (); + // Perform any necessary cleanup. + break; + } + return TRUE; // Successful DLL_PROCESS_ATTACH. +} +#endif diff --git a/tools/build.py b/tools/build.py index 5e38bcb4b..5a93d08bd 100644 --- a/tools/build.py +++ b/tools/build.py @@ -136,6 +136,7 @@ def prepare_args(): parser.add_argument( '--no-oymotion', dest='oymotion', action='store_false') parser.set_defaults(oymotion=False) + parser.add_argument('--msvc-runtime', type=str, choices=[ 'static', 'dynamic'], help='how to link MSVC runtime', required=False, default='static') @@ -180,6 +181,8 @@ def prepare_args(): parser.add_argument('--cmake-osx-deployment-target', type=str, help='min supported version of osx', required=False, default='10.15') parser.add_argument('--use-libftdi', action='store_true') + + try: output = subprocess.check_output(['ninja', '--version']) print(output) @@ -203,6 +206,11 @@ def prepare_args(): required=False, default=os.path.join(cur_folder, '..', 'installed')) parser.add_argument('--use-openmp', action='store_true') parser.add_argument('--onnx', action='store_true') + + parser.add_argument('--synchroni', dest='synchroni', action='store_true') + parser.add_argument('--no-synchroni', dest='synchroni', action='store_false') + parser.set_defaults(synchroni='store_false') + parser.add_argument('--warnings-as-errors', action='store_true') parser.add_argument('--debug', action='store_true') parser.add_argument('--clear-build-dir', action='store_true') @@ -215,6 +223,7 @@ def prepare_args(): parser.add_argument('--ble', dest='ble', action='store_true') parser.add_argument('--no-ble', dest='ble', action='store_false') parser.set_defaults(ble=ble_default) + parser.add_argument('--tests', dest='tests', action='store_true') parser.add_argument('--no-tests', dest='tests', action='store_false') parser.set_defaults(tests=tests_default) @@ -272,6 +281,8 @@ def config(args): cmd_config.append('-DBUILD_BLUETOOTH=ON') if hasattr(args, 'ble') and args.ble: cmd_config.append('-DBUILD_BLE=ON') + if hasattr(args, 'synchroni') and args.synchroni: + cmd_config.append('-DBUILD_SYNCHRONI_SDK=ON') if hasattr(args, 'onnx') and args.onnx: cmd_config.append('-DBUILD_ONNX=ON') if hasattr(args, 'tests') and args.tests: