@mentra/bluetooth-sdk 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +278 -0
- package/android/build.gradle +167 -0
- package/android/lc3Lib/CMakeLists.txt +6 -0
- package/android/lc3Lib/build.gradle +109 -0
- package/android/lc3Lib/proguard-rules.pro +33 -0
- package/android/lc3Lib/src/main/AndroidManifest.xml +2 -0
- package/android/lc3Lib/src/main/cpp/CMakeLists.txt +8 -0
- package/android/lc3Lib/src/main/cpp/google_opus_stuff/CMakeLists.txt +30 -0
- package/android/lc3Lib/src/main/cpp/google_opus_stuff/jni/CMakeLists.txt +7 -0
- package/android/lc3Lib/src/main/cpp/google_opus_stuff/jni/ogg_opus_encoder.cc +96 -0
- package/android/lc3Lib/src/main/cpp/google_opus_stuff/jni/ogg_opus_encoder.h +53 -0
- package/android/lc3Lib/src/main/cpp/google_opus_stuff/libogg/Makefile.am +6 -0
- package/android/lc3Lib/src/main/cpp/google_opus_stuff/libogg/config_types.h +26 -0
- package/android/lc3Lib/src/main/cpp/google_opus_stuff/libogg/config_types.h.in +26 -0
- package/android/lc3Lib/src/main/cpp/google_opus_stuff/libogg/ogg.h +209 -0
- package/android/lc3Lib/src/main/cpp/google_opus_stuff/libogg/os_types.h +158 -0
- package/android/lc3Lib/src/main/cpp/google_opus_stuff/libopus/opus.h +981 -0
- package/android/lc3Lib/src/main/cpp/google_opus_stuff/libopus/opus_custom.h +342 -0
- package/android/lc3Lib/src/main/cpp/google_opus_stuff/libopus/opus_defines.h +799 -0
- package/android/lc3Lib/src/main/cpp/google_opus_stuff/libopus/opus_multistream.h +660 -0
- package/android/lc3Lib/src/main/cpp/google_opus_stuff/libopus/opus_projection.h +568 -0
- package/android/lc3Lib/src/main/cpp/google_opus_stuff/libopus/opus_types.h +166 -0
- package/android/lc3Lib/src/main/cpp/google_opus_stuff/ogg_opus_encoder.cc +268 -0
- package/android/lc3Lib/src/main/cpp/google_opus_stuff/ogg_opus_encoder.h +115 -0
- package/android/lc3Lib/src/main/cpp/google_opus_stuff/opus_tools/opus_header.h +59 -0
- package/android/lc3Lib/src/main/cpp/liblc3/CMakeLists.txt +38 -0
- package/android/lc3Lib/src/main/cpp/liblc3/include/lc3.h +309 -0
- package/android/lc3Lib/src/main/cpp/liblc3/include/lc3_private.h +162 -0
- package/android/lc3Lib/src/main/cpp/liblc3/include/rnnoise.h +114 -0
- package/android/lc3Lib/src/main/cpp/liblc3/liblc3/CMakeLists.txt +19 -0
- package/android/lc3Lib/src/main/cpp/liblc3/liblc3/attdet.c +92 -0
- package/android/lc3Lib/src/main/cpp/liblc3/liblc3/attdet.h +44 -0
- package/android/lc3Lib/src/main/cpp/liblc3/liblc3/bits.c +375 -0
- package/android/lc3Lib/src/main/cpp/liblc3/liblc3/bits.h +315 -0
- package/android/lc3Lib/src/main/cpp/liblc3/liblc3/bwdet.c +129 -0
- package/android/lc3Lib/src/main/cpp/liblc3/liblc3/bwdet.h +69 -0
- package/android/lc3Lib/src/main/cpp/liblc3/liblc3/common.h +148 -0
- package/android/lc3Lib/src/main/cpp/liblc3/liblc3/energy.c +70 -0
- package/android/lc3Lib/src/main/cpp/liblc3/liblc3/energy.h +43 -0
- package/android/lc3Lib/src/main/cpp/liblc3/liblc3/fastmath.h +158 -0
- package/android/lc3Lib/src/main/cpp/liblc3/liblc3/lc3.c +702 -0
- package/android/lc3Lib/src/main/cpp/liblc3/liblc3/ltpf.c +893 -0
- package/android/lc3Lib/src/main/cpp/liblc3/liblc3/ltpf.h +111 -0
- package/android/lc3Lib/src/main/cpp/liblc3/liblc3/ltpf_arm.h +506 -0
- package/android/lc3Lib/src/main/cpp/liblc3/liblc3/ltpf_neon.h +281 -0
- package/android/lc3Lib/src/main/cpp/liblc3/liblc3/makefile.mk +35 -0
- package/android/lc3Lib/src/main/cpp/liblc3/liblc3/mdct.c +452 -0
- package/android/lc3Lib/src/main/cpp/liblc3/liblc3/mdct.h +57 -0
- package/android/lc3Lib/src/main/cpp/liblc3/liblc3/mdct_neon.h +296 -0
- package/android/lc3Lib/src/main/cpp/liblc3/liblc3/meson.build +46 -0
- package/android/lc3Lib/src/main/cpp/liblc3/liblc3/plc.c +61 -0
- package/android/lc3Lib/src/main/cpp/liblc3/liblc3/plc.h +57 -0
- package/android/lc3Lib/src/main/cpp/liblc3/liblc3/sns.c +880 -0
- package/android/lc3Lib/src/main/cpp/liblc3/liblc3/sns.h +103 -0
- package/android/lc3Lib/src/main/cpp/liblc3/liblc3/spec.c +904 -0
- package/android/lc3Lib/src/main/cpp/liblc3/liblc3/spec.h +119 -0
- package/android/lc3Lib/src/main/cpp/liblc3/liblc3/tables.c +3457 -0
- package/android/lc3Lib/src/main/cpp/liblc3/liblc3/tables.h +94 -0
- package/android/lc3Lib/src/main/cpp/liblc3/liblc3/tns.c +457 -0
- package/android/lc3Lib/src/main/cpp/liblc3/liblc3/tns.h +99 -0
- package/android/lc3Lib/src/main/cpp/liblc3/liblc3.cpp +159 -0
- package/android/lc3Lib/src/main/cpp/liblc3/rnnoise/_kiss_fft_guts.h +182 -0
- package/android/lc3Lib/src/main/cpp/liblc3/rnnoise/arch.h +261 -0
- package/android/lc3Lib/src/main/cpp/liblc3/rnnoise/celt_lpc.c +279 -0
- package/android/lc3Lib/src/main/cpp/liblc3/rnnoise/celt_lpc.h +59 -0
- package/android/lc3Lib/src/main/cpp/liblc3/rnnoise/common.h +48 -0
- package/android/lc3Lib/src/main/cpp/liblc3/rnnoise/compile.sh +3 -0
- package/android/lc3Lib/src/main/cpp/liblc3/rnnoise/denoise.c +646 -0
- package/android/lc3Lib/src/main/cpp/liblc3/rnnoise/kiss_fft.c +601 -0
- package/android/lc3Lib/src/main/cpp/liblc3/rnnoise/kiss_fft.h +203 -0
- package/android/lc3Lib/src/main/cpp/liblc3/rnnoise/opus_types.h +159 -0
- package/android/lc3Lib/src/main/cpp/liblc3/rnnoise/pitch.c +526 -0
- package/android/lc3Lib/src/main/cpp/liblc3/rnnoise/pitch.h +149 -0
- package/android/lc3Lib/src/main/cpp/liblc3/rnnoise/rnn.c +178 -0
- package/android/lc3Lib/src/main/cpp/liblc3/rnnoise/rnn.h +69 -0
- package/android/lc3Lib/src/main/cpp/liblc3/rnnoise/rnn_data.c +11051 -0
- package/android/lc3Lib/src/main/cpp/liblc3/rnnoise/rnn_data.h +34 -0
- package/android/lc3Lib/src/main/cpp/liblc3/rnnoise/rnn_reader.c +168 -0
- package/android/lc3Lib/src/main/cpp/liblc3/rnnoise/rnn_train.py +66 -0
- package/android/lc3Lib/src/main/cpp/liblc3/rnnoise/tansig_table.h +45 -0
- package/android/lc3Lib/src/main/java/com/mentra/lc3Lib/Lc3Cpp.java +38 -0
- package/android/lc3Lib/third_party/CMakeLists.txt +23 -0
- package/android/lc3Lib/third_party/CMakeLists_libogg.txt +18 -0
- package/android/lc3Lib/third_party/CMakeLists_libopus.txt +18 -0
- package/android/lc3Lib/third_party/CMakeLists_opus-tools.txt +23 -0
- package/android/lc3Lib/third_party/opus_tools/src/AUTHORS +5 -0
- package/android/lc3Lib/third_party/opus_tools/src/CMakeLists.txt +4 -0
- package/android/lc3Lib/third_party/opus_tools/src/COPYING +371 -0
- package/android/lc3Lib/third_party/opus_tools/src/ChangeLog +3 -0
- package/android/lc3Lib/third_party/opus_tools/src/Makefile.am +42 -0
- package/android/lc3Lib/third_party/opus_tools/src/Makefile.unix +23 -0
- package/android/lc3Lib/third_party/opus_tools/src/NEWS +0 -0
- package/android/lc3Lib/third_party/opus_tools/src/README +0 -0
- package/android/lc3Lib/third_party/opus_tools/src/autogen.sh +115 -0
- package/android/lc3Lib/third_party/opus_tools/src/configure.ac +293 -0
- package/android/lc3Lib/third_party/opus_tools/src/src/arch.h +239 -0
- package/android/lc3Lib/third_party/opus_tools/src/src/audio-in.c +1046 -0
- package/android/lc3Lib/third_party/opus_tools/src/src/diag_range.c +245 -0
- package/android/lc3Lib/third_party/opus_tools/src/src/diag_range.h +28 -0
- package/android/lc3Lib/third_party/opus_tools/src/src/info_opus.c +320 -0
- package/android/lc3Lib/third_party/opus_tools/src/src/info_opus.h +51 -0
- package/android/lc3Lib/third_party/opus_tools/src/src/lpc.c +157 -0
- package/android/lc3Lib/third_party/opus_tools/src/src/lpc.h +27 -0
- package/android/lc3Lib/third_party/opus_tools/src/src/opus_header.c +286 -0
- package/android/lc3Lib/third_party/opus_tools/src/src/opus_header.h +59 -0
- package/android/lc3Lib/third_party/opus_tools/src/src/opusdec.c +884 -0
- package/android/lc3Lib/third_party/opus_tools/src/src/opusenc.c +1021 -0
- package/android/lc3Lib/third_party/opus_tools/src/src/opusenc.h +101 -0
- package/android/lc3Lib/third_party/opus_tools/src/src/opusinfo.c +639 -0
- package/android/lc3Lib/third_party/opus_tools/src/src/opusinfo.h +51 -0
- package/android/lc3Lib/third_party/opus_tools/src/src/os_support.h +167 -0
- package/android/lc3Lib/third_party/opus_tools/src/src/resample.c +1137 -0
- package/android/lc3Lib/third_party/opus_tools/src/src/speex_resampler.h +344 -0
- package/android/lc3Lib/third_party/opus_tools/src/src/stack_alloc.h +115 -0
- package/android/lc3Lib/third_party/opus_tools/src/src/wav_io.c +125 -0
- package/android/lc3Lib/third_party/opus_tools/src/src/wav_io.h +62 -0
- package/android/lc3Lib/third_party/opus_tools/src/src/wave_out.c +223 -0
- package/android/lc3Lib/third_party/opus_tools/src/src/wave_out.h +60 -0
- package/android/settings.gradle +1 -0
- package/android/src/main/AndroidManifest.xml +40 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/BluetoothSdkModule.kt +528 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/Bridge.kt +610 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/DeviceManager.kt +1616 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/DeviceStore.kt +314 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/MentraBluetoothModels.kt +1710 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/MentraBluetoothSdk.kt +554 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/ObservableStore.kt +68 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/controllers/ControllerManager.kt +158 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/controllers/R1.kt +934 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/services/Foreground.kt +175 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/services/PhoneMic.kt +1109 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/G1.java +3974 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/G2.kt +3551 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/Mach1.java +1327 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/MentraLive.java +6959 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/MentraNex.kt +1655 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/MentraosBle.java +53675 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/SGCManager.kt +202 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/Simulated.kt +224 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/stt/STTTools.kt +340 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/stt/SherpaOnnxTranscriber.kt +465 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/stt/VadGateSpeechPolicy.kt +221 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/utils/AES.java +106 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/utils/AudioSessionMonitor.kt +189 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/utils/BitmapJavaUtils.java +169 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/utils/BlePhotoUploadService.java +179 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/utils/Constants.kt +44 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/utils/G1Text.kt +436 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/utils/IncidentLogBleRelayNaming.java +29 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/utils/IncidentLogBleUploadService.java +76 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/utils/K900ProtocolUtils.java +791 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/utils/MessageChunker.java +186 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/utils/NexSGCUtils.kt +589 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/utils/PhoneAudioMonitor.kt +303 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/utils/SmartGlassesConnectionState.java +9 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/utils/audio/ByteUtilAudioPlayer.java +655 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/utils/audio/Lc3Player.java +441 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/utils/audio/PCMAudioPlayer.java +431 -0
- package/android/src/main/res/values/strings.xml +4 -0
- package/app.plugin.js +1 -0
- package/build/BluetoothSdk.types.d.ts +498 -0
- package/build/BluetoothSdk.types.d.ts.map +1 -0
- package/build/BluetoothSdk.types.js +23 -0
- package/build/BluetoothSdk.types.js.map +1 -0
- package/build/BluetoothSdkModule.d.ts +71 -0
- package/build/BluetoothSdkModule.d.ts.map +1 -0
- package/build/BluetoothSdkModule.js +106 -0
- package/build/BluetoothSdkModule.js.map +1 -0
- package/build/index.d.ts +3 -0
- package/build/index.d.ts.map +1 -0
- package/build/index.js +5 -0
- package/build/index.js.map +1 -0
- package/expo-module.config.json +9 -0
- package/ios/BluetoothSdkModule.swift +665 -0
- package/ios/MentraBluetoothSDK.podspec +77 -0
- package/ios/Packages/CoreObjC/CoreObjC.xcodeproj/project.pbxproj +213 -0
- package/ios/Packages/CoreObjC/PcmConverter.h +22 -0
- package/ios/Packages/CoreObjC/PcmConverter.m +266 -0
- package/ios/Packages/CoreObjC/attdet.c +92 -0
- package/ios/Packages/CoreObjC/attdet.h +44 -0
- package/ios/Packages/CoreObjC/bits.c +375 -0
- package/ios/Packages/CoreObjC/bits.h +315 -0
- package/ios/Packages/CoreObjC/bwdet.c +129 -0
- package/ios/Packages/CoreObjC/bwdet.h +69 -0
- package/ios/Packages/CoreObjC/common.h +151 -0
- package/ios/Packages/CoreObjC/energy.c +70 -0
- package/ios/Packages/CoreObjC/energy.h +43 -0
- package/ios/Packages/CoreObjC/fastmath.h +158 -0
- package/ios/Packages/CoreObjC/lc3.c +704 -0
- package/ios/Packages/CoreObjC/lc3.h +313 -0
- package/ios/Packages/CoreObjC/lc3_cpp.h +283 -0
- package/ios/Packages/CoreObjC/lc3_private.h +163 -0
- package/ios/Packages/CoreObjC/ltpf.c +905 -0
- package/ios/Packages/CoreObjC/ltpf.h +111 -0
- package/ios/Packages/CoreObjC/ltpf_arm.h +506 -0
- package/ios/Packages/CoreObjC/ltpf_neon.h +281 -0
- package/ios/Packages/CoreObjC/makefile.mk +35 -0
- package/ios/Packages/CoreObjC/mdct.c +469 -0
- package/ios/Packages/CoreObjC/mdct.h +57 -0
- package/ios/Packages/CoreObjC/mdct_neon.h +296 -0
- package/ios/Packages/CoreObjC/meson.build +61 -0
- package/ios/Packages/CoreObjC/plc.c +61 -0
- package/ios/Packages/CoreObjC/plc.h +57 -0
- package/ios/Packages/CoreObjC/rnnoise.h +114 -0
- package/ios/Packages/CoreObjC/sns.c +880 -0
- package/ios/Packages/CoreObjC/sns.h +103 -0
- package/ios/Packages/CoreObjC/spec.c +907 -0
- package/ios/Packages/CoreObjC/spec.h +119 -0
- package/ios/Packages/CoreObjC/tables.c +3457 -0
- package/ios/Packages/CoreObjC/tables.h +94 -0
- package/ios/Packages/CoreObjC/tns.c +457 -0
- package/ios/Packages/CoreObjC/tns.h +99 -0
- package/ios/Packages/SherpaOnnx/Model/joiner.onnx +0 -0
- package/ios/Packages/SherpaOnnx/Model/tokens.txt +502 -0
- package/ios/Packages/SherpaOnnx/SherpaOnnx.swift +1659 -0
- package/ios/Packages/SherpaOnnx/sherpa-onnx.xcframework/Headers/cargs.h +162 -0
- package/ios/Packages/SherpaOnnx/sherpa-onnx.xcframework/Headers/sherpa-onnx/c-api/c-api.h +1852 -0
- package/ios/Packages/SherpaOnnx/sherpa-onnx.xcframework/Headers/sherpa-onnx/c-api/cxx-api.h +674 -0
- package/ios/Packages/SherpaOnnx/sherpa-onnx.xcframework/Info.plist +44 -0
- package/ios/Packages/SherpaOnnx/sherpa-onnx.xcframework/ios-arm64/libsherpa-onnx.a +0 -0
- package/ios/Packages/SherpaOnnx/sherpa-onnx.xcframework/ios-arm64/sherpa-onnx.a +0 -0
- package/ios/Packages/SherpaOnnx/sherpa-onnx.xcframework/ios-arm64_x86_64-simulator/libsherpa-onnx.a +0 -0
- package/ios/Packages/SherpaOnnx/sherpa-onnx.xcframework/ios-arm64_x86_64-simulator/sherpa-onnx.a +0 -0
- package/ios/Packages/VAD/Common/VAD/VADQuality.swift +41 -0
- package/ios/Packages/VAD/Common/VAD/VADState.swift +26 -0
- package/ios/Packages/VAD/Common/VAD/VADStrategy.swift +29 -0
- package/ios/Packages/VAD/Common/VAD/VADType.swift +14 -0
- package/ios/Packages/VAD/Data/Configuration.swift +68 -0
- package/ios/Packages/VAD/Data/FrameSize.swift +39 -0
- package/ios/Packages/VAD/Data/Record.swift +13 -0
- package/ios/Packages/VAD/Data/Result.swift +22 -0
- package/ios/Packages/VAD/Data/SampleRate.swift +48 -0
- package/ios/Packages/VAD/Silero/Model/silero_vad.onnx +0 -0
- package/ios/Packages/VAD/Silero/SileroVAD.swift +284 -0
- package/ios/Packages/VAD/Silero/SileroVADStrategy.swift +64 -0
- package/ios/Packages/libbz2/module.modulemap +5 -0
- package/ios/Packages/libbz2/shim.h +1 -0
- package/ios/Source/Bridge.swift +353 -0
- package/ios/Source/Bridging-Header.h +16 -0
- package/ios/Source/DeviceManager.swift +1478 -0
- package/ios/Source/DeviceStore.swift +295 -0
- package/ios/Source/MentraBluetoothSDK.swift +2439 -0
- package/ios/Source/ObservableStore.swift +88 -0
- package/ios/Source/PrivacyInfo.xcprivacy +23 -0
- package/ios/Source/controllers/ControllerManager.swift +187 -0
- package/ios/Source/controllers/R1.swift +827 -0
- package/ios/Source/services/PhoneMic.swift +662 -0
- package/ios/Source/sgcs/Frame.swift +651 -0
- package/ios/Source/sgcs/G1.swift +2505 -0
- package/ios/Source/sgcs/G2.swift +3730 -0
- package/ios/Source/sgcs/Mach1.swift +543 -0
- package/ios/Source/sgcs/MentraLive.swift +4708 -0
- package/ios/Source/sgcs/MentraNex.swift +2479 -0
- package/ios/Source/sgcs/SGCManager.swift +243 -0
- package/ios/Source/sgcs/Simulated.swift +270 -0
- package/ios/Source/sgcs/mentraos_ble.pb.swift +3811 -0
- package/ios/Source/stt/STTTools.swift +154 -0
- package/ios/Source/stt/SherpaOnnxTranscriber.swift +401 -0
- package/ios/Source/utils/AudioSessionMonitor.swift +283 -0
- package/ios/Source/utils/Constants.swift +74 -0
- package/ios/Source/utils/Enums.swift +95 -0
- package/ios/Source/utils/G1Text.swift +2067 -0
- package/ios/Source/utils/JSCExperiment.swift +241 -0
- package/ios/Source/utils/MemoryMonitor.swift +44 -0
- package/ios/Source/utils/MessageChunker.swift +164 -0
- package/ios/Source/utils/Models.swift +135 -0
- package/ios/Source/utils/PhoneAudioMonitor.swift +226 -0
- package/ios/Source/utils/TarBz2Extractor.swift +206 -0
- package/package.json +78 -0
- package/plugin/build/index.d.ts +6 -0
- package/plugin/build/index.js +12 -0
- package/plugin/build/withAndroid.d.ts +4 -0
- package/plugin/build/withAndroid.js +80 -0
- package/plugin/build/withIos.d.ts +4 -0
- package/plugin/build/withIos.js +64 -0
- package/src/BluetoothSdk.types.ts +581 -0
- package/src/BluetoothSdkModule.ts +259 -0
- package/src/index.ts +4 -0
|
@@ -0,0 +1,543 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Mach1.swift
|
|
3
|
+
// MentraOS_Manager
|
|
4
|
+
//
|
|
5
|
+
// Created by Mach1 Device Integration
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
import Combine
|
|
9
|
+
import CoreBluetooth
|
|
10
|
+
import Foundation
|
|
11
|
+
import UIKit
|
|
12
|
+
import UltraliteSDK
|
|
13
|
+
|
|
14
|
+
@MainActor
|
|
15
|
+
class Mach1: UltraliteBaseViewController, SGCManager {
|
|
16
|
+
func sendIncidentId(_: String, apiBaseUrl _: String?) {}
|
|
17
|
+
|
|
18
|
+
func requestPhoto(
|
|
19
|
+
_: String, appId _: String, size _: String?, webhookUrl _: String?, authToken _: String?,
|
|
20
|
+
compress _: String?, flash _: Bool, sound _: Bool
|
|
21
|
+
) {}
|
|
22
|
+
|
|
23
|
+
func sendGalleryMode() {}
|
|
24
|
+
|
|
25
|
+
func sendButtonMaxRecordingTime() {}
|
|
26
|
+
|
|
27
|
+
var connectionState: String = ConnTypes.DISCONNECTED
|
|
28
|
+
|
|
29
|
+
func sendOtaStart() {}
|
|
30
|
+
func sendOtaQueryStatus() {}
|
|
31
|
+
|
|
32
|
+
func sendJson(_: [String: Any], wakeUp _: Bool, requireAck _: Bool) {}
|
|
33
|
+
|
|
34
|
+
func sendButtonPhotoSettings() {}
|
|
35
|
+
|
|
36
|
+
func sendButtonVideoRecordingSettings() {}
|
|
37
|
+
|
|
38
|
+
func sendButtonMaxRecordingTime(_: Int) {}
|
|
39
|
+
|
|
40
|
+
func sendButtonCameraLedSetting() {}
|
|
41
|
+
|
|
42
|
+
func sendCameraFovSetting() {}
|
|
43
|
+
|
|
44
|
+
func exit() {}
|
|
45
|
+
|
|
46
|
+
func sendShutdown() {
|
|
47
|
+
Bridge.log("sendShutdown - not supported on Mach1")
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
func sendReboot() {
|
|
51
|
+
Bridge.log("sendReboot - not supported on Mach1")
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
func sendRgbLedControl(
|
|
55
|
+
requestId: String, packageName _: String?, action _: String, color _: String?,
|
|
56
|
+
ontime _: Int, offtime _: Int, count _: Int
|
|
57
|
+
) {
|
|
58
|
+
Bridge.sendRgbLedControlResponse(
|
|
59
|
+
requestId: requestId, success: false, error: "device_not_supported"
|
|
60
|
+
)
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
func requestWifiScan() {}
|
|
64
|
+
|
|
65
|
+
func sendWifiCredentials(_: String, _: String) {}
|
|
66
|
+
|
|
67
|
+
func forgetWifiNetwork(_: String) {}
|
|
68
|
+
|
|
69
|
+
func sendHotspotState(_: Bool) {}
|
|
70
|
+
|
|
71
|
+
func sendUserEmailToGlasses(_: String) {}
|
|
72
|
+
|
|
73
|
+
func queryGalleryStatus() {}
|
|
74
|
+
|
|
75
|
+
func requestVersionInfo() {
|
|
76
|
+
Bridge.log("Mach1: requestVersionInfo - not supported on Mach1")
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
func showDashboard() {}
|
|
80
|
+
|
|
81
|
+
func setDashboardPosition(_: Int, _: Int) {}
|
|
82
|
+
|
|
83
|
+
func setSilentMode(_: Bool) {}
|
|
84
|
+
|
|
85
|
+
func sendJson(_: [String: Any]) {}
|
|
86
|
+
|
|
87
|
+
func startStream(_: [String: Any]) {}
|
|
88
|
+
|
|
89
|
+
func stopStream() {}
|
|
90
|
+
|
|
91
|
+
func sendStreamKeepAlive(_: [String: Any]) {}
|
|
92
|
+
|
|
93
|
+
func startVideoRecording(requestId _: String, save _: Bool, flash _: Bool, sound _: Bool) {}
|
|
94
|
+
|
|
95
|
+
func stopVideoRecording(requestId _: String) {}
|
|
96
|
+
|
|
97
|
+
func setHeadUpAngle(_: Int) {}
|
|
98
|
+
|
|
99
|
+
func getBatteryStatus() {}
|
|
100
|
+
|
|
101
|
+
func setBrightness(_: Int, autoMode _: Bool) {}
|
|
102
|
+
|
|
103
|
+
func cleanup() {}
|
|
104
|
+
|
|
105
|
+
func ping() {}
|
|
106
|
+
func dbg1() {}
|
|
107
|
+
func dbg2() {}
|
|
108
|
+
func connectController() {}
|
|
109
|
+
func disconnectController() {}
|
|
110
|
+
|
|
111
|
+
var type: String = DeviceTypes.MACH1
|
|
112
|
+
var hasMic: Bool = false
|
|
113
|
+
|
|
114
|
+
func setMicEnabled(_: Bool) {
|
|
115
|
+
// N/A
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
func sortMicRanking(list: [String]) -> [String] {
|
|
119
|
+
return list
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
var CONNECTING_DEVICE = ""
|
|
123
|
+
var onConnectionStateChanged: (() -> Void)?
|
|
124
|
+
@Published var batteryLevel: Int = -1
|
|
125
|
+
@Published var isConnected: Bool = false
|
|
126
|
+
var ready: Bool {
|
|
127
|
+
get { DeviceStore.shared.get("glasses", "fullyBooted") as? Bool ?? false }
|
|
128
|
+
set {
|
|
129
|
+
let oldValue = DeviceStore.shared.get("glasses", "fullyBooted") as? Bool ?? false
|
|
130
|
+
DeviceStore.shared.apply("glasses", "fullyBooted", newValue)
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
private var connected: Bool {
|
|
135
|
+
get { DeviceStore.shared.get("glasses", "connected") as? Bool ?? false }
|
|
136
|
+
set { DeviceStore.shared.apply("glasses", "connected", newValue) }
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/// Store discovered peripherals by their identifier
|
|
140
|
+
private var discoveredPeripherals: [String: CBPeripheral] = [:]
|
|
141
|
+
|
|
142
|
+
private var textHandle: Int?
|
|
143
|
+
private var tapTextHandle: Int?
|
|
144
|
+
private var autoScroller: ScrollLayout.AutoScroller?
|
|
145
|
+
private var currentLayout: Ultralite.Layout?
|
|
146
|
+
private var isConnectedListener: BondListener<Bool>?
|
|
147
|
+
private var batteryLevelListener: BondListener<Int>?
|
|
148
|
+
private var setupDone: Bool = false
|
|
149
|
+
|
|
150
|
+
func setup() {
|
|
151
|
+
if setupDone { return }
|
|
152
|
+
isConnectedListener = BondListener(listener: { [weak self] value in
|
|
153
|
+
guard let self else { return }
|
|
154
|
+
Bridge.log("MACH1: isConnectedListener: \(value)")
|
|
155
|
+
|
|
156
|
+
if value {
|
|
157
|
+
// Try to request control
|
|
158
|
+
let gotControl = UltraliteManager.shared.currentDevice?.requestControl(
|
|
159
|
+
layout: UltraliteSDK.Ultralite.Layout.textBottomLeftAlign,
|
|
160
|
+
timeout: 0,
|
|
161
|
+
hideStatusBar: true,
|
|
162
|
+
showTapAnimation: true,
|
|
163
|
+
maxNumTaps: 3
|
|
164
|
+
)
|
|
165
|
+
|
|
166
|
+
Bridge.log("MACH1: gotControl: \(gotControl ?? false)")
|
|
167
|
+
if batteryLevel != -1 {
|
|
168
|
+
ready = true
|
|
169
|
+
connected = true
|
|
170
|
+
}
|
|
171
|
+
} else {
|
|
172
|
+
ready = false
|
|
173
|
+
connected = false
|
|
174
|
+
}
|
|
175
|
+
})
|
|
176
|
+
|
|
177
|
+
batteryLevelListener = BondListener(listener: { [weak self] value in
|
|
178
|
+
guard let self else { return }
|
|
179
|
+
Bridge.log("MACH1: batteryLevelListener: \(value)")
|
|
180
|
+
batteryLevel = value
|
|
181
|
+
DeviceStore.shared.apply("glasses", "batteryLevel", value)
|
|
182
|
+
ready = true
|
|
183
|
+
connected = true
|
|
184
|
+
})
|
|
185
|
+
|
|
186
|
+
NotificationCenter.default.addObserver(
|
|
187
|
+
self,
|
|
188
|
+
selector: #selector(handleTapEvent(_:)),
|
|
189
|
+
name: .tap,
|
|
190
|
+
object: nil
|
|
191
|
+
)
|
|
192
|
+
|
|
193
|
+
Bridge.log("MACH1: setup done")
|
|
194
|
+
setupDone = true
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/// Handle the tap event
|
|
198
|
+
@objc func handleTapEvent(_ notification: Notification) {
|
|
199
|
+
Bridge.log("MACH1: handleTapEvent called!")
|
|
200
|
+
|
|
201
|
+
guard let userInfo = notification.userInfo else {
|
|
202
|
+
Bridge.log("MACH1: handleTapEvent: no userInfo")
|
|
203
|
+
return
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
guard let tap = userInfo["tap"] else {
|
|
207
|
+
Bridge.log("MACH1: handleTapEvent: no tap in userInfo")
|
|
208
|
+
return
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
let hack = "\(tap)"
|
|
212
|
+
// get the number between the parentheses Optional(3)
|
|
213
|
+
let tapNumber = hack.split(separator: "(").last?.split(separator: ")").first
|
|
214
|
+
let tapNumberInt = Int(tapNumber ?? "0") ?? -1
|
|
215
|
+
|
|
216
|
+
Bridge.log("MACH1: Tap detected! Count: \(tapNumberInt)")
|
|
217
|
+
|
|
218
|
+
if tapNumberInt >= 2 {
|
|
219
|
+
let hUp = DeviceStore.shared.get("glasses", "headUp") as? Bool ?? false
|
|
220
|
+
DeviceStore.shared.apply("glasses", "headUp", !hUp)
|
|
221
|
+
|
|
222
|
+
// start a timer and auto turn off the dashboard after 15 seconds:
|
|
223
|
+
if !hUp {
|
|
224
|
+
DispatchQueue.main.asyncAfter(deadline: .now() + 15) {
|
|
225
|
+
let currentHeadUp =
|
|
226
|
+
DeviceStore.shared.get("glasses", "headUp") as? Bool ?? false
|
|
227
|
+
if currentHeadUp {
|
|
228
|
+
DeviceStore.shared.apply("glasses", "headUp", false)
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
func linked(unk _: UltraliteSDK.Ultralite?) {
|
|
236
|
+
Bridge.log("Mach1Manager: Linked")
|
|
237
|
+
UltraliteManager.shared.currentDevice?.isConnected.bind(listener: isConnectedListener!)
|
|
238
|
+
UltraliteManager.shared.currentDevice?.batteryLevel.bind(listener: batteryLevelListener!)
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
func connectById(_ id: String) {
|
|
242
|
+
setup()
|
|
243
|
+
|
|
244
|
+
// Extract the ID from the device name if it contains brackets
|
|
245
|
+
// e.g., "Vuzix Z100 [f1b87c]" -> "f1b87c"
|
|
246
|
+
var peripheralId = id
|
|
247
|
+
if let deviceId = id.split(separator: "[").last?.split(separator: "]").first {
|
|
248
|
+
peripheralId = String(deviceId)
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
let isLinked = UltraliteManager.shared.isLinked.value
|
|
252
|
+
let currentDevice = UltraliteManager.shared.currentDevice
|
|
253
|
+
let isConnected =
|
|
254
|
+
isLinked && currentDevice != nil && currentDevice!.isPaired
|
|
255
|
+
&& currentDevice!.isConnected.value
|
|
256
|
+
let peripheral = discoveredPeripherals[peripheralId] ?? currentDevice?.peripheral
|
|
257
|
+
|
|
258
|
+
// Bind listeners to get notified when device connects
|
|
259
|
+
UltraliteManager.shared.currentDevice?.isConnected.bind(listener: isConnectedListener!)
|
|
260
|
+
UltraliteManager.shared.currentDevice?.batteryLevel.bind(listener: batteryLevelListener!)
|
|
261
|
+
|
|
262
|
+
if isConnected {
|
|
263
|
+
// Already connected, request control now
|
|
264
|
+
let gotControl = currentDevice?.requestControl(
|
|
265
|
+
layout: UltraliteSDK.Ultralite.Layout.textBottomLeftAlign, timeout: 0,
|
|
266
|
+
hideStatusBar: true, showTapAnimation: true, maxNumTaps: 3
|
|
267
|
+
)
|
|
268
|
+
Bridge.log("MACH1: Already connected, gotControl: \(gotControl ?? false)")
|
|
269
|
+
ready = true
|
|
270
|
+
connected = true
|
|
271
|
+
return
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
if !isLinked {
|
|
275
|
+
if peripheral == nil {
|
|
276
|
+
Bridge.log("Mach1Manager: No peripheral found or stored with ID: \(peripheralId)")
|
|
277
|
+
CONNECTING_DEVICE = peripheralId
|
|
278
|
+
UltraliteManager.shared.startScan(callback: foundDevice2)
|
|
279
|
+
return
|
|
280
|
+
}
|
|
281
|
+
Bridge.log("Mach1Manager: Connecting to peripheral with ID: \(peripheralId)")
|
|
282
|
+
|
|
283
|
+
// Stop scanning and clear connecting state before linking
|
|
284
|
+
UltraliteManager.shared.stopScan()
|
|
285
|
+
CONNECTING_DEVICE = ""
|
|
286
|
+
|
|
287
|
+
UltraliteManager.shared.link(device: peripheral!, callback: linked)
|
|
288
|
+
UltraliteManager.shared.currentDevice?.isConnected.bind(listener: isConnectedListener!)
|
|
289
|
+
UltraliteManager.shared.currentDevice?.batteryLevel.bind(
|
|
290
|
+
listener: batteryLevelListener!
|
|
291
|
+
)
|
|
292
|
+
return
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
func clearDisplay() {
|
|
297
|
+
guard let device = UltraliteManager.shared.currentDevice else {
|
|
298
|
+
Bridge.log("Mach1Manager: No current device")
|
|
299
|
+
ready = false
|
|
300
|
+
connected = false
|
|
301
|
+
return
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
if !device.isConnected.value {
|
|
305
|
+
Bridge.log("Mach1Manager: Device not connected")
|
|
306
|
+
ready = false
|
|
307
|
+
connected = false
|
|
308
|
+
return
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
device.screenOff()
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
func getConnectedBluetoothName() -> String? {
|
|
315
|
+
UltraliteManager.shared.currentDevice?.peripheral?.name
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
func disconnect() {
|
|
319
|
+
UltraliteManager.shared.stopScan()
|
|
320
|
+
ready = false
|
|
321
|
+
connected = false
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
func stopScan() {
|
|
325
|
+
UltraliteManager.shared.stopScan()
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
func sendTextWall(_ text: String) {
|
|
329
|
+
// displayTextWall(text)
|
|
330
|
+
guard let device = UltraliteManager.shared.currentDevice else {
|
|
331
|
+
Bridge.log("Mach1Manager: No current device")
|
|
332
|
+
ready = false
|
|
333
|
+
connected = false
|
|
334
|
+
return
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
if !device.isConnected.value {
|
|
338
|
+
Bridge.log("Mach1Manager: Device not connected")
|
|
339
|
+
ready = false
|
|
340
|
+
connected = false
|
|
341
|
+
return
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
Bridge.log("MACH1: Sending text: \(text)")
|
|
345
|
+
|
|
346
|
+
device.sendText(text: text)
|
|
347
|
+
device.canvas.commit()
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
/// Display pre-composed double text wall (two columns) on the glasses.
|
|
351
|
+
///
|
|
352
|
+
/// NOTE: DisplayProcessor now composes double_text_wall into a single text_wall
|
|
353
|
+
/// with pixel-precise column alignment using ColumnComposer. This method may
|
|
354
|
+
/// not be called anymore for new flows, but is kept for backwards compatibility.
|
|
355
|
+
///
|
|
356
|
+
/// Column composition is handled by DisplayProcessor in React Native.
|
|
357
|
+
/// This method is a "dumb pipe" - it just combines and sends the text.
|
|
358
|
+
func sendDoubleTextWall(_ topText: String, _ bottomText: String) {
|
|
359
|
+
guard let device = UltraliteManager.shared.currentDevice else {
|
|
360
|
+
Bridge.log("Mach1Manager: No current device")
|
|
361
|
+
ready = false
|
|
362
|
+
connected = false
|
|
363
|
+
return
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
if !device.isConnected.value {
|
|
367
|
+
Bridge.log("Mach1Manager: Device not connected")
|
|
368
|
+
ready = false
|
|
369
|
+
connected = false
|
|
370
|
+
return
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
// Text is already composed by DisplayProcessor's ColumnComposer
|
|
374
|
+
// Just combine and send - no custom wrapping logic needed
|
|
375
|
+
let combinedText = "\(topText)\n\n\n\(bottomText)"
|
|
376
|
+
|
|
377
|
+
Bridge.log("MACH1: Sending double text wall")
|
|
378
|
+
device.sendText(text: combinedText)
|
|
379
|
+
device.canvas.commit()
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
func foundDevice(_ device: CBPeripheral) {
|
|
383
|
+
// log the found devices:
|
|
384
|
+
Bridge.log(device.name ?? "Unknown Device")
|
|
385
|
+
|
|
386
|
+
guard let name = device.name else { return }
|
|
387
|
+
|
|
388
|
+
// just get the part inside the brackets
|
|
389
|
+
let deviceName = name.split(separator: "[").last?.split(separator: "]").first
|
|
390
|
+
|
|
391
|
+
guard let deviceName else { return }
|
|
392
|
+
|
|
393
|
+
let id = String(deviceName)
|
|
394
|
+
|
|
395
|
+
// Store the peripheral by its identifier
|
|
396
|
+
discoveredPeripherals[id] = device
|
|
397
|
+
Bridge.sendDiscoveredDevice(type, name) // Use self.type to support both Mach1 and Z100
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
func foundDevice2(_ device: CBPeripheral) {
|
|
401
|
+
guard let name = device.name else { return }
|
|
402
|
+
|
|
403
|
+
// just get the part inside the brackets
|
|
404
|
+
let deviceName = name.split(separator: "[").last?.split(separator: "]").first
|
|
405
|
+
|
|
406
|
+
guard let deviceName else { return }
|
|
407
|
+
|
|
408
|
+
let id = String(deviceName)
|
|
409
|
+
|
|
410
|
+
discoveredPeripherals[id] = device
|
|
411
|
+
|
|
412
|
+
if id == CONNECTING_DEVICE {
|
|
413
|
+
connectById(id)
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
func findCompatibleDevices() {
|
|
418
|
+
setup()
|
|
419
|
+
Bridge.log("@@@@@@@@@@@@@@@@@@@@@ FINDING COMPATIBLE DEVICES @@@@@@@@@@@@@@@@@@@@@@")
|
|
420
|
+
UltraliteManager.shared.setBluetoothManger()
|
|
421
|
+
let scanResult = UltraliteManager.shared.startScan(callback: foundDevice)
|
|
422
|
+
Bridge.log("Mach1: \(scanResult)")
|
|
423
|
+
if scanResult
|
|
424
|
+
== UltraliteSDK.UltraliteManager.BluetoothScanResult.BLUETOOTH_PERMISSION_NEEDED
|
|
425
|
+
{
|
|
426
|
+
// call this function again in 5 seconds:
|
|
427
|
+
DispatchQueue.main.asyncAfter(deadline: .now() + 5) {
|
|
428
|
+
self.findCompatibleDevices()
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
func displayBitmap(base64ImageData: String) async -> Bool {
|
|
434
|
+
guard let bmpData = Data(base64Encoded: base64ImageData) else {
|
|
435
|
+
Bridge.log("MACH1: Failed to decode base64 image data")
|
|
436
|
+
return false
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
Bridge.log("MACH1: ✅ Successfully decoded base64 image data to \(bmpData.count) bytes")
|
|
440
|
+
|
|
441
|
+
// Convert data to UIImage
|
|
442
|
+
guard let uiImage = UIImage(data: bmpData) else {
|
|
443
|
+
Bridge.log("MACH1: Failed to create UIImage from data")
|
|
444
|
+
return false
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
// Resize the image to 620x460
|
|
448
|
+
let targetSize = CGSize(width: 620, height: 460)
|
|
449
|
+
UIGraphicsBeginImageContextWithOptions(targetSize, false, 0.0)
|
|
450
|
+
uiImage.draw(in: CGRect(origin: .zero, size: targetSize))
|
|
451
|
+
let resizedImage = UIGraphicsGetImageFromCurrentImageContext()
|
|
452
|
+
UIGraphicsEndImageContext()
|
|
453
|
+
|
|
454
|
+
guard let resizedImage,
|
|
455
|
+
let cgImage = resizedImage.cgImage
|
|
456
|
+
else {
|
|
457
|
+
Bridge.log("MACH1: Failed to resize image or get CGImage")
|
|
458
|
+
return false
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
guard let device = UltraliteManager.shared.currentDevice else {
|
|
462
|
+
Bridge.log("MACH1: No current device")
|
|
463
|
+
DeviceManager.shared.forget()
|
|
464
|
+
return false
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
if !device.isConnected.value {
|
|
468
|
+
Bridge.log("MACH1: Device not connected")
|
|
469
|
+
return false
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
Bridge.log("MACH1: Sending bitmap")
|
|
473
|
+
|
|
474
|
+
// Draw the background image at position (50, 80)
|
|
475
|
+
// device.canvas.drawBackground(image: cgImage, x: 50, y: 80)
|
|
476
|
+
device.canvas.drawBackground(image: cgImage, x: 50, y: 80)
|
|
477
|
+
device.canvas.commit()
|
|
478
|
+
|
|
479
|
+
return true
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
func forget() {
|
|
483
|
+
UltraliteManager.shared.unlink()
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
func setBrightness(_ brightness: Int) {
|
|
487
|
+
guard let device = UltraliteManager.shared.currentDevice else {
|
|
488
|
+
Bridge.log("Mach1Manager: No current device")
|
|
489
|
+
ready = false
|
|
490
|
+
return
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
device.setIntProperty(Ultralite.Property.brightness, value: Int64(brightness))
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
override func viewDidLoad() {
|
|
497
|
+
super.viewDidLoad()
|
|
498
|
+
// if let device = UltraliteManager.shared.currentDevice, device.isConnected.value == true {
|
|
499
|
+
// // we have a device and are connected
|
|
500
|
+
// draw()
|
|
501
|
+
// }
|
|
502
|
+
// else if UltraliteManager.shared.currentDevice != nil {
|
|
503
|
+
// // // we have a device but it isn't connected
|
|
504
|
+
// // isConnectedListener = BondListener(listener: { [weak self] value in
|
|
505
|
+
// // if value {
|
|
506
|
+
// // draw()
|
|
507
|
+
// // }
|
|
508
|
+
// // })
|
|
509
|
+
// // UltraliteManager.shared.currentDevice?.isConnected.bind(listener: isConnectedListener!)
|
|
510
|
+
// }
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
override func viewDidAppear(_ animated: Bool) {
|
|
514
|
+
super.viewDidAppear(animated)
|
|
515
|
+
|
|
516
|
+
// if UltraliteManager.shared.currentDevice == nil {
|
|
517
|
+
// // we have no device, show show the user the picker
|
|
518
|
+
// showPairingPicker()
|
|
519
|
+
// }
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
func draw() {
|
|
523
|
+
// guard let device = UltraliteManager.shared.currentDevice else {
|
|
524
|
+
// return
|
|
525
|
+
// }
|
|
526
|
+
//
|
|
527
|
+
// // start control
|
|
528
|
+
// layout = .canvas
|
|
529
|
+
// startControl()
|
|
530
|
+
//
|
|
531
|
+
// if let image = UIImage(systemName: "face.smiling")?.cgImage {
|
|
532
|
+
// // draw something to the screen
|
|
533
|
+
// device.canvas.drawBackground(image: image, x: 100, y: 100)
|
|
534
|
+
// // don't forget to commit, this is a common mistake.
|
|
535
|
+
// device.canvas.commit()
|
|
536
|
+
// }
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
override func onTapEvent(taps: Int) {
|
|
540
|
+
Bridge.log("MACH1: Tap Event: \(taps)")
|
|
541
|
+
// draw()
|
|
542
|
+
}
|
|
543
|
+
}
|