@glassly/bluetooth-sdk 0.1.0-dev.26
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 +563 -0
- package/android/build.gradle +450 -0
- package/android/gradle.properties.example +9 -0
- package/android/lc3Lib/CMakeLists.txt +6 -0
- package/android/lc3Lib/build.gradle +212 -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/glassly/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 +4 -0
- package/android/silero/LICENSE.md +17 -0
- package/android/silero/build.gradle +50 -0
- package/android/silero/proguard-rules.pro +24 -0
- package/android/silero/src/androidTest/assets/hello.wav +0 -0
- package/android/silero/src/androidTest/java/com/konovalov/vad/silero/VadSileroTest.kt +79 -0
- package/android/silero/src/main/assets/LICENSE +21 -0
- package/android/silero/src/main/assets/silero_vad.onnx +0 -0
- package/android/silero/src/main/java/com/konovalov/vad/silero/Vad.kt +160 -0
- package/android/silero/src/main/java/com/konovalov/vad/silero/VadSilero.kt +449 -0
- package/android/silero/src/main/java/com/konovalov/vad/silero/config/FrameSize.kt +15 -0
- package/android/silero/src/main/java/com/konovalov/vad/silero/config/Mode.kt +14 -0
- package/android/silero/src/main/java/com/konovalov/vad/silero/config/SampleRate.kt +12 -0
- package/android/silero/src/main/java/com/konovalov/vad/silero/utils/AudioUtils.kt +47 -0
- package/android/silero/src/main/java/com/konovalov/vad/silero/utils/TensorMap.kt +41 -0
- package/android/silero/src/test/java/com/konovalov/vad/silero/utils/AudioUtilsTest.kt +44 -0
- package/android/src/main/AndroidManifest.xml +42 -0
- package/android/src/main/assets/G2Firmware/README.md +11 -0
- package/android/src/main/java/com/glassly/bluetoothsdk/BluetoothSdk.kt +2325 -0
- package/android/src/main/java/com/glassly/bluetoothsdk/BluetoothSdkAnalytics.kt +216 -0
- package/android/src/main/java/com/glassly/bluetoothsdk/BluetoothSdkDebug.kt +14 -0
- package/android/src/main/java/com/glassly/bluetoothsdk/BluetoothSdkDefaults.kt +7 -0
- package/android/src/main/java/com/glassly/bluetoothsdk/BluetoothSdkModule.kt +1088 -0
- package/android/src/main/java/com/glassly/bluetoothsdk/Bridge.kt +953 -0
- package/android/src/main/java/com/glassly/bluetoothsdk/DeviceManager.kt +2528 -0
- package/android/src/main/java/com/glassly/bluetoothsdk/DeviceStore.kt +360 -0
- package/android/src/main/java/com/glassly/bluetoothsdk/GeneratedChangelogCatalog.kt +8 -0
- package/android/src/main/java/com/glassly/bluetoothsdk/GeneratedReleaseMetadata.kt +11 -0
- package/android/src/main/java/com/glassly/bluetoothsdk/LocalNetworkModule.kt +414 -0
- package/android/src/main/java/com/glassly/bluetoothsdk/ObservableStore.kt +88 -0
- package/android/src/main/java/com/glassly/bluetoothsdk/OtaManifest.kt +191 -0
- package/android/src/main/java/com/glassly/bluetoothsdk/ReleaseChangelog.kt +61 -0
- package/android/src/main/java/com/glassly/bluetoothsdk/ScopedNetworkReadiness.kt +17 -0
- package/android/src/main/java/com/glassly/bluetoothsdk/audio/AudioModels.kt +144 -0
- package/android/src/main/java/com/glassly/bluetoothsdk/camera/CameraModels.kt +486 -0
- package/android/src/main/java/com/glassly/bluetoothsdk/connection/ConnectionModels.kt +78 -0
- package/android/src/main/java/com/glassly/bluetoothsdk/controllers/ControllerManager.kt +158 -0
- package/android/src/main/java/com/glassly/bluetoothsdk/controllers/R1.kt +937 -0
- package/android/src/main/java/com/glassly/bluetoothsdk/debug/BleTraceLogger.kt +165 -0
- package/android/src/main/java/com/glassly/bluetoothsdk/events/BluetoothEvents.kt +178 -0
- package/android/src/main/java/com/glassly/bluetoothsdk/internal/MapParsing.kt +140 -0
- package/android/src/main/java/com/glassly/bluetoothsdk/net/LocalIpv4.kt +57 -0
- package/android/src/main/java/com/glassly/bluetoothsdk/otaserver/LocalOtaServer.kt +304 -0
- package/android/src/main/java/com/glassly/bluetoothsdk/otaserver/OtaServerModule.kt +120 -0
- package/android/src/main/java/com/glassly/bluetoothsdk/photoreceiver/LocalPhotoReceiverRegistry.java +108 -0
- package/android/src/main/java/com/glassly/bluetoothsdk/photoreceiver/LocalPhotoUploadServer.kt +622 -0
- package/android/src/main/java/com/glassly/bluetoothsdk/photoreceiver/PhotoReceiverModule.kt +156 -0
- package/android/src/main/java/com/glassly/bluetoothsdk/requests/DisplayRequests.kt +56 -0
- package/android/src/main/java/com/glassly/bluetoothsdk/services/Foreground.kt +272 -0
- package/android/src/main/java/com/glassly/bluetoothsdk/services/PhoneMic.kt +1195 -0
- package/android/src/main/java/com/glassly/bluetoothsdk/sgcs/Ar99.java +2653 -0
- package/android/src/main/java/com/glassly/bluetoothsdk/sgcs/BesOtaHeartbeatGuard.kt +49 -0
- package/android/src/main/java/com/glassly/bluetoothsdk/sgcs/BesOtaProgressMapper.kt +27 -0
- package/android/src/main/java/com/glassly/bluetoothsdk/sgcs/G1.kt +3878 -0
- package/android/src/main/java/com/glassly/bluetoothsdk/sgcs/G1TextSanitizer.kt +38 -0
- package/android/src/main/java/com/glassly/bluetoothsdk/sgcs/G2.kt +6428 -0
- package/android/src/main/java/com/glassly/bluetoothsdk/sgcs/G2CfwClassification.kt +49 -0
- package/android/src/main/java/com/glassly/bluetoothsdk/sgcs/G2CfwRenderer.kt +1241 -0
- package/android/src/main/java/com/glassly/bluetoothsdk/sgcs/G2CfwTextureCache.kt +270 -0
- package/android/src/main/java/com/glassly/bluetoothsdk/sgcs/G2FlashProtocol.kt +291 -0
- package/android/src/main/java/com/glassly/bluetoothsdk/sgcs/G2Flasher.kt +411 -0
- package/android/src/main/java/com/glassly/bluetoothsdk/sgcs/GlasslyBle.java +43189 -0
- package/android/src/main/java/com/glassly/bluetoothsdk/sgcs/Mach1.kt +1280 -0
- package/android/src/main/java/com/glassly/bluetoothsdk/sgcs/MentraLive.kt +10817 -0
- package/android/src/main/java/com/glassly/bluetoothsdk/sgcs/MentraLiveL2capChannel.kt +274 -0
- package/android/src/main/java/com/glassly/bluetoothsdk/sgcs/MentraLivePairingAdvertisement.kt +54 -0
- package/android/src/main/java/com/glassly/bluetoothsdk/sgcs/MentraNex.kt +2011 -0
- package/android/src/main/java/com/glassly/bluetoothsdk/sgcs/Nimo.kt +2532 -0
- package/android/src/main/java/com/glassly/bluetoothsdk/sgcs/SGCManager.kt +470 -0
- package/android/src/main/java/com/glassly/bluetoothsdk/sgcs/Simulated.kt +228 -0
- package/android/src/main/java/com/glassly/bluetoothsdk/sgcs/ar99/ota/Ar99OtaManager.java +566 -0
- package/android/src/main/java/com/glassly/bluetoothsdk/sgcs/ar99/ota/OtaByteUtils.java +18 -0
- package/android/src/main/java/com/glassly/bluetoothsdk/sgcs/ar99/ota/OtaCommandConstants.java +35 -0
- package/android/src/main/java/com/glassly/bluetoothsdk/sgcs/ar99/ota/OtaCrc32Util.java +13 -0
- package/android/src/main/java/com/glassly/bluetoothsdk/sgcs/ar99/ota/OtaGattTransport.java +11 -0
- package/android/src/main/java/com/glassly/bluetoothsdk/sgcs/ar99/ota/OtaProtocol.java +92 -0
- package/android/src/main/java/com/glassly/bluetoothsdk/speakerid/SpeakerIdEngine.kt +525 -0
- package/android/src/main/java/com/glassly/bluetoothsdk/status/DeviceStatus.kt +669 -0
- package/android/src/main/java/com/glassly/bluetoothsdk/status/RuntimeState.kt +201 -0
- package/android/src/main/java/com/glassly/bluetoothsdk/status/WifiHotspotStatus.kt +189 -0
- package/android/src/main/java/com/glassly/bluetoothsdk/streaming/StreamModels.kt +518 -0
- package/android/src/main/java/com/glassly/bluetoothsdk/stt/STTTools.kt +391 -0
- package/android/src/main/java/com/glassly/bluetoothsdk/stt/SherpaOnnxTranscriber.kt +518 -0
- package/android/src/main/java/com/glassly/bluetoothsdk/stt/VadGateSpeechPolicy.kt +229 -0
- package/android/src/main/java/com/glassly/bluetoothsdk/tts/TTSTools.kt +248 -0
- package/android/src/main/java/com/glassly/bluetoothsdk/types/DeviceModels.kt +96 -0
- package/android/src/main/java/com/glassly/bluetoothsdk/utils/AES.java +106 -0
- package/android/src/main/java/com/glassly/bluetoothsdk/utils/AudioSessionMonitor.kt +189 -0
- package/android/src/main/java/com/glassly/bluetoothsdk/utils/AvifExifStripper.java +573 -0
- package/android/src/main/java/com/glassly/bluetoothsdk/utils/BitmapJavaUtils.java +169 -0
- package/android/src/main/java/com/glassly/bluetoothsdk/utils/BleJsonCompact.java +496 -0
- package/android/src/main/java/com/glassly/bluetoothsdk/utils/BlePhotoUploadService.java +677 -0
- package/android/src/main/java/com/glassly/bluetoothsdk/utils/BleWireProtocol.java +108 -0
- package/android/src/main/java/com/glassly/bluetoothsdk/utils/Constants.kt +46 -0
- package/android/src/main/java/com/glassly/bluetoothsdk/utils/G1Text.kt +436 -0
- package/android/src/main/java/com/glassly/bluetoothsdk/utils/HeifExifTagReader.java +199 -0
- package/android/src/main/java/com/glassly/bluetoothsdk/utils/IncidentLogBleRelayNaming.java +29 -0
- package/android/src/main/java/com/glassly/bluetoothsdk/utils/IncidentLogBleUploadService.java +77 -0
- package/android/src/main/java/com/glassly/bluetoothsdk/utils/K900LengthCodec.java +115 -0
- package/android/src/main/java/com/glassly/bluetoothsdk/utils/K900ProtocolUtils.java +827 -0
- package/android/src/main/java/com/glassly/bluetoothsdk/utils/MessageChunkReassembler.java +228 -0
- package/android/src/main/java/com/glassly/bluetoothsdk/utils/MessageChunker.java +325 -0
- package/android/src/main/java/com/glassly/bluetoothsdk/utils/NexSGCUtils.kt +698 -0
- package/android/src/main/java/com/glassly/bluetoothsdk/utils/PhoneAudioMonitor.kt +348 -0
- package/android/src/main/java/com/glassly/bluetoothsdk/utils/SmartGlassesConnectionState.java +9 -0
- package/android/src/main/java/com/glassly/bluetoothsdk/utils/audio/Ar99OpusPcmDecoder.java +398 -0
- package/android/src/main/java/com/glassly/bluetoothsdk/utils/audio/ByteUtilAudioPlayer.java +655 -0
- package/android/src/main/java/com/glassly/bluetoothsdk/utils/audio/Lc3Player.java +441 -0
- package/android/src/main/java/com/glassly/bluetoothsdk/utils/audio/PCMAudioPlayer.java +431 -0
- package/android/src/main/java/com/glassly/bluetoothsdk/utils/audio/PcmStreamPlayer.kt +328 -0
- package/android/src/main/res/values/strings.xml +4 -0
- package/android/src/test/java/com/glassly/bluetoothsdk/BluetoothSdkExceptionTest.kt +18 -0
- package/android/src/test/java/com/glassly/bluetoothsdk/OtaManifestDowngradeTest.kt +86 -0
- package/android/src/test/java/com/glassly/bluetoothsdk/OtaStartResponsePolicyTest.kt +30 -0
- package/android/src/test/java/com/glassly/bluetoothsdk/ReleaseChangelogTest.kt +13 -0
- package/android/src/test/java/com/glassly/bluetoothsdk/ScopedNetworkReadinessTest.kt +39 -0
- package/android/src/test/java/com/glassly/bluetoothsdk/StreamStatusEventTest.kt +29 -0
- package/android/src/test/java/com/glassly/bluetoothsdk/camera/PhotoRequestTest.kt +141 -0
- package/android/src/test/java/com/glassly/bluetoothsdk/otaserver/LocalOtaServerTest.kt +82 -0
- package/android/src/test/java/com/glassly/bluetoothsdk/photoreceiver/LocalPhotoReceiverRegistryTest.java +75 -0
- package/android/src/test/java/com/glassly/bluetoothsdk/services/ForegroundServiceTypeTest.kt +69 -0
- package/android/src/test/java/com/glassly/bluetoothsdk/sgcs/Ar99AdvertisementMatcherTest.java +22 -0
- package/android/src/test/java/com/glassly/bluetoothsdk/sgcs/BesOtaHeartbeatGuardTest.kt +73 -0
- package/android/src/test/java/com/glassly/bluetoothsdk/sgcs/BesOtaProgressMapperTest.kt +67 -0
- package/android/src/test/java/com/glassly/bluetoothsdk/sgcs/EvenRleTest.kt +63 -0
- package/android/src/test/java/com/glassly/bluetoothsdk/sgcs/G1TextSanitizerTest.kt +31 -0
- package/android/src/test/java/com/glassly/bluetoothsdk/sgcs/G2CfwClassificationTest.kt +89 -0
- package/android/src/test/java/com/glassly/bluetoothsdk/sgcs/G2CfwRendererTest.kt +344 -0
- package/android/src/test/java/com/glassly/bluetoothsdk/sgcs/G2CfwTextureCacheTest.kt +200 -0
- package/android/src/test/java/com/glassly/bluetoothsdk/sgcs/G2FlashProtocolTest.kt +131 -0
- package/android/src/test/java/com/glassly/bluetoothsdk/sgcs/MentraLiveGattCharacteristicsTest.kt +39 -0
- package/android/src/test/java/com/glassly/bluetoothsdk/sgcs/MentraLivePairingAdvertisementParserTest.kt +133 -0
- package/android/src/test/java/com/glassly/bluetoothsdk/sgcs/NimoProtocolTest.kt +333 -0
- package/android/src/test/java/com/glassly/bluetoothsdk/utils/AvifExifStripperTest.java +46 -0
- package/android/src/test/java/com/glassly/bluetoothsdk/utils/BinaryMessageChunkerTest.java +84 -0
- package/android/src/test/java/com/glassly/bluetoothsdk/utils/BleJsonCompactTest.java +319 -0
- package/android/src/test/java/com/glassly/bluetoothsdk/utils/BlePhotoUploadServiceTest.java +107 -0
- package/android/src/test/java/com/glassly/bluetoothsdk/utils/K900ProtocolUtilsEndiannessTest.java +172 -0
- package/android/src/test/java/com/glassly/bluetoothsdk/utils/K900ProtocolUtilsTest.java +24 -0
- package/android/src/test/java/com/glassly/bluetoothsdk/utils/PhoneAudioMonitorTest.kt +45 -0
- package/android/src/test/resources/avif_with_exif.avif +0 -0
- package/app.plugin.js +3 -0
- package/build/BluetoothSdk.types.d.ts +1354 -0
- package/build/BluetoothSdk.types.d.ts.map +1 -0
- package/build/BluetoothSdk.types.js +41 -0
- package/build/BluetoothSdk.types.js.map +1 -0
- package/build/_internal.d.ts +17 -0
- package/build/_internal.d.ts.map +1 -0
- package/build/_internal.js +16 -0
- package/build/_internal.js.map +1 -0
- package/build/_private/BluetoothSdkModule.d.ts +172 -0
- package/build/_private/BluetoothSdkModule.d.ts.map +1 -0
- package/build/_private/BluetoothSdkModule.js +300 -0
- package/build/_private/BluetoothSdkModule.js.map +1 -0
- package/build/_private/LocalNetworkModule.d.ts +38 -0
- package/build/_private/LocalNetworkModule.d.ts.map +1 -0
- package/build/_private/LocalNetworkModule.js +3 -0
- package/build/_private/LocalNetworkModule.js.map +1 -0
- package/build/_private/cameraRequestPayload.d.ts +4 -0
- package/build/_private/cameraRequestPayload.d.ts.map +1 -0
- package/build/_private/cameraRequestPayload.js +32 -0
- package/build/_private/cameraRequestPayload.js.map +1 -0
- package/build/_private/photoRequestPayload.d.ts +6 -0
- package/build/_private/photoRequestPayload.d.ts.map +1 -0
- package/build/_private/photoRequestPayload.js +86 -0
- package/build/_private/photoRequestPayload.js.map +1 -0
- package/build/_private/sdkOtaManifest.d.ts +11 -0
- package/build/_private/sdkOtaManifest.d.ts.map +1 -0
- package/build/_private/sdkOtaManifest.js +15 -0
- package/build/_private/sdkOtaManifest.js.map +1 -0
- package/build/changelogs.d.ts +7 -0
- package/build/changelogs.d.ts.map +1 -0
- package/build/changelogs.js +46 -0
- package/build/changelogs.js.map +1 -0
- package/build/debug.d.ts +3 -0
- package/build/debug.d.ts.map +1 -0
- package/build/debug.js +8 -0
- package/build/debug.js.map +1 -0
- package/build/generated/changelogCatalog.d.ts +9 -0
- package/build/generated/changelogCatalog.d.ts.map +1 -0
- package/build/generated/changelogCatalog.js +12 -0
- package/build/generated/changelogCatalog.js.map +1 -0
- package/build/generated/releaseMetadata.d.ts +12 -0
- package/build/generated/releaseMetadata.d.ts.map +1 -0
- package/build/generated/releaseMetadata.js +10 -0
- package/build/generated/releaseMetadata.js.map +1 -0
- package/build/index.d.ts +6 -0
- package/build/index.d.ts.map +1 -0
- package/build/index.js +171 -0
- package/build/index.js.map +1 -0
- package/build/ota-server/OtaServer.types.d.ts +14 -0
- package/build/ota-server/OtaServer.types.d.ts.map +1 -0
- package/build/ota-server/OtaServer.types.js +2 -0
- package/build/ota-server/OtaServer.types.js.map +1 -0
- package/build/ota-server/OtaServerModule.d.ts +21 -0
- package/build/ota-server/OtaServerModule.d.ts.map +1 -0
- package/build/ota-server/OtaServerModule.js +3 -0
- package/build/ota-server/OtaServerModule.js.map +1 -0
- package/build/ota-server/OtaServerModule.web.d.ts +10 -0
- package/build/ota-server/OtaServerModule.web.d.ts.map +1 -0
- package/build/ota-server/OtaServerModule.web.js +12 -0
- package/build/ota-server/OtaServerModule.web.js.map +1 -0
- package/build/ota-server/index.d.ts +3 -0
- package/build/ota-server/index.d.ts.map +1 -0
- package/build/ota-server/index.js +3 -0
- package/build/ota-server/index.js.map +1 -0
- package/build/ota-transport/index.d.ts +67 -0
- package/build/ota-transport/index.d.ts.map +1 -0
- package/build/ota-transport/index.js +58 -0
- package/build/ota-transport/index.js.map +1 -0
- package/build/photo-receiver/PhotoReceiver.types.d.ts +18 -0
- package/build/photo-receiver/PhotoReceiver.types.d.ts.map +1 -0
- package/build/photo-receiver/PhotoReceiver.types.js +2 -0
- package/build/photo-receiver/PhotoReceiver.types.js.map +1 -0
- package/build/photo-receiver/PhotoReceiverModule.d.ts +10 -0
- package/build/photo-receiver/PhotoReceiverModule.d.ts.map +1 -0
- package/build/photo-receiver/PhotoReceiverModule.js +3 -0
- package/build/photo-receiver/PhotoReceiverModule.js.map +1 -0
- package/build/photo-receiver/PhotoReceiverModule.web.d.ts +10 -0
- package/build/photo-receiver/PhotoReceiverModule.web.d.ts.map +1 -0
- package/build/photo-receiver/PhotoReceiverModule.web.js +12 -0
- package/build/photo-receiver/PhotoReceiverModule.web.js.map +1 -0
- package/build/photo-receiver/index.d.ts +3 -0
- package/build/photo-receiver/index.d.ts.map +1 -0
- package/build/photo-receiver/index.js +3 -0
- package/build/photo-receiver/index.js.map +1 -0
- package/build/react/index.d.ts +5 -0
- package/build/react/index.d.ts.map +1 -0
- package/build/react/index.js +4 -0
- package/build/react/index.js.map +1 -0
- package/build/react/useBluetooth.d.ts +100 -0
- package/build/react/useBluetooth.d.ts.map +1 -0
- package/build/react/useBluetooth.js +167 -0
- package/build/react/useBluetooth.js.map +1 -0
- package/build/react/useBluetoothEvent.d.ts +6 -0
- package/build/react/useBluetoothEvent.d.ts.map +1 -0
- package/build/react/useBluetoothEvent.js +21 -0
- package/build/react/useBluetoothEvent.js.map +1 -0
- package/build/react/useBluetoothScan.d.ts +22 -0
- package/build/react/useBluetoothScan.d.ts.map +1 -0
- package/build/react/useBluetoothScan.js +135 -0
- package/build/react/useBluetoothScan.js.map +1 -0
- package/build/react/useBluetoothStatus.d.ts +16 -0
- package/build/react/useBluetoothStatus.d.ts.map +1 -0
- package/build/react/useBluetoothStatus.js +137 -0
- package/build/react/useBluetoothStatus.js.map +1 -0
- package/build/react/useGlassesConnection.d.ts +29 -0
- package/build/react/useGlassesConnection.d.ts.map +1 -0
- package/build/react/useGlassesConnection.js +153 -0
- package/build/react/useGlassesConnection.js.map +1 -0
- package/build/types/index.d.ts +3 -0
- package/build/types/index.d.ts.map +1 -0
- package/build/types/index.js +2 -0
- package/build/types/index.js.map +1 -0
- package/expo-module.config.json +14 -0
- package/ios/BackgroundOtaArtifactDownloader.swift +125 -0
- package/ios/BluetoothSdkModule.swift +1034 -0
- package/ios/GlasslyBluetoothSDK.podspec +106 -0
- package/ios/LocalIPv4.swift +150 -0
- package/ios/LocalOtaServer.swift +309 -0
- package/ios/LocalPhotoUploadServer.swift +754 -0
- package/ios/OtaServerModule.swift +147 -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/include/PcmConverter.h +22 -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 +2383 -0
- package/ios/Packages/SherpaOnnx/sherpa-onnx.xcframework/Info.plist +48 -0
- package/ios/Packages/SherpaOnnx/sherpa-onnx.xcframework/ios-arm64/Headers/sherpa-onnx/c-api/c-api.h +4689 -0
- package/ios/Packages/SherpaOnnx/sherpa-onnx.xcframework/ios-arm64/Headers/sherpa-onnx/c-api/cxx-api.h +2036 -0
- package/ios/Packages/SherpaOnnx/sherpa-onnx.xcframework/ios-arm64/libsherpa-onnx.a +0 -0
- package/ios/Packages/SherpaOnnx/sherpa-onnx.xcframework/ios-arm64_x86_64-simulator/Headers/sherpa-onnx/c-api/c-api.h +4689 -0
- package/ios/Packages/SherpaOnnx/sherpa-onnx.xcframework/ios-arm64_x86_64-simulator/Headers/sherpa-onnx/c-api/cxx-api.h +2036 -0
- package/ios/Packages/SherpaOnnx/sherpa-onnx.xcframework/ios-arm64_x86_64-simulator/libsherpa-onnx.a +0 -0
- package/ios/Packages/libbz2/module.modulemap +5 -0
- package/ios/Packages/libbz2/shim.h +1 -0
- package/ios/PhotoReceiverModule.swift +129 -0
- package/ios/Source/BluetoothSDK.swift +2303 -0
- package/ios/Source/BluetoothSDKDebug.swift +12 -0
- package/ios/Source/BluetoothSdkDefaults.swift +29 -0
- package/ios/Source/Bridge.swift +708 -0
- package/ios/Source/Bridging-Header.h +16 -0
- package/ios/Source/DeviceManager.swift +2109 -0
- package/ios/Source/DeviceStore.swift +336 -0
- package/ios/Source/GeneratedChangelogCatalog.swift +7 -0
- package/ios/Source/GeneratedReleaseMetadata.swift +11 -0
- package/ios/Source/ObservableStore.swift +118 -0
- package/ios/Source/OtaManifest.swift +211 -0
- package/ios/Source/PrivacyInfo.xcprivacy +23 -0
- package/ios/Source/ReleaseChangelog.swift +65 -0
- package/ios/Source/Resources/G2Firmware/README.md +10 -0
- package/ios/Source/audio/AudioModels.swift +178 -0
- package/ios/Source/audio/PcmStreamPlayer.swift +410 -0
- package/ios/Source/camera/CameraModels.swift +866 -0
- package/ios/Source/connection/ScanSession.swift +27 -0
- package/ios/Source/controllers/ControllerManager.swift +184 -0
- package/ios/Source/controllers/R1.swift +829 -0
- package/ios/Source/errors/BluetoothSdkError.swift +19 -0
- package/ios/Source/events/BluetoothEvents.swift +342 -0
- package/ios/Source/internal/BleTraceLogger.swift +192 -0
- package/ios/Source/internal/BluetoothAvailability.swift +78 -0
- package/ios/Source/internal/BluetoothSdkAnalytics.swift +199 -0
- package/ios/Source/internal/ValueParsing.swift +99 -0
- package/ios/Source/requests/DisplayRequests.swift +82 -0
- package/ios/Source/services/PhoneMic.swift +662 -0
- package/ios/Source/sgcs/Ar99.swift +2451 -0
- package/ios/Source/sgcs/Frame.swift +649 -0
- package/ios/Source/sgcs/G1.swift +2554 -0
- package/ios/Source/sgcs/G2.swift +6887 -0
- package/ios/Source/sgcs/G2CfwClassification.swift +43 -0
- package/ios/Source/sgcs/G2CfwRenderer.swift +1279 -0
- package/ios/Source/sgcs/G2CfwTextureCache.swift +233 -0
- package/ios/Source/sgcs/G2FlashProtocol.swift +312 -0
- package/ios/Source/sgcs/G2Flasher.swift +773 -0
- package/ios/Source/sgcs/Mach1.swift +541 -0
- package/ios/Source/sgcs/MentraLive.swift +7011 -0
- package/ios/Source/sgcs/MentraLiveL2capChannel.swift +183 -0
- package/ios/Source/sgcs/MentraLivePairingAdvertisement.swift +64 -0
- package/ios/Source/sgcs/MentraNex.swift +3221 -0
- package/ios/Source/sgcs/Nimo.swift +1886 -0
- package/ios/Source/sgcs/SGCManager.swift +608 -0
- package/ios/Source/sgcs/Simulated.swift +274 -0
- package/ios/Source/sgcs/ar99/ota/Ar99OtaManager.swift +637 -0
- package/ios/Source/sgcs/glassly_ble.pb.swift +4354 -0
- package/ios/Source/speakerid/SpeakerIdEngine.swift +573 -0
- package/ios/Source/status/DeviceStatus.swift +981 -0
- package/ios/Source/status/RuntimeState.swift +359 -0
- package/ios/Source/status/WifiHotspotStatus.swift +345 -0
- package/ios/Source/streaming/StreamModels.swift +693 -0
- package/ios/Source/stt/STTTools.swift +191 -0
- package/ios/Source/stt/SherpaOnnxTranscriber.swift +466 -0
- package/ios/Source/tts/TTSTools.swift +171 -0
- package/ios/Source/types/DeviceModels.swift +177 -0
- package/ios/Source/utils/AudioSessionMonitor.swift +283 -0
- package/ios/Source/utils/BinaryCodec.swift +61 -0
- package/ios/Source/utils/BleJsonCompact.swift +405 -0
- package/ios/Source/utils/BleWireProtocol.swift +92 -0
- package/ios/Source/utils/Constants.swift +78 -0
- package/ios/Source/utils/Enums.swift +95 -0
- package/ios/Source/utils/G1Text.swift +2096 -0
- package/ios/Source/utils/JSCExperiment.swift +241 -0
- package/ios/Source/utils/MemoryMonitor.swift +44 -0
- package/ios/Source/utils/MessageChunkReassembler.swift +190 -0
- package/ios/Source/utils/MessageChunker.swift +294 -0
- package/ios/Source/utils/Models.swift +135 -0
- package/ios/Source/utils/PhoneAudioMonitor.swift +230 -0
- package/ios/Source/utils/TarBz2Extractor.swift +257 -0
- package/ios/Tests/BluetoothSDKTests/G2CfwClassificationTests.swift +78 -0
- package/ios/Tests/BluetoothSDKTests/G2CfwRendererTests.swift +372 -0
- package/ios/Tests/BluetoothSDKTests/G2CfwTextureCacheTests.swift +162 -0
- package/ios/Tests/BluetoothSDKTests/G2FlashProtocolTests.swift +182 -0
- package/ios/Tests/MentraLivePairingAdvertisementTests.swift +160 -0
- package/ios/Tests/ReleaseChangelogTests.swift +13 -0
- package/package.json +129 -0
- package/plugin/build/index.d.ts +10 -0
- package/plugin/build/index.js +12 -0
- package/plugin/build/withAndroid.d.ts +3 -0
- package/plugin/build/withAndroid.js +190 -0
- package/plugin/build/withIos.d.ts +5 -0
- package/plugin/build/withIos.js +108 -0
- package/scripts/inject-ios-sdk-version.mjs +65 -0
- package/scripts/public-ota-api.test.mjs +37 -0
- package/scripts/verify-release-package.mjs +45 -0
- package/scripts/write-release-metadata.mjs +152 -0
- package/scripts/write-release-metadata.test.mjs +37 -0
- package/src/BluetoothSdk.types.ts +1623 -0
- package/src/_internal.ts +16 -0
- package/src/_private/BluetoothSdkModule.ts +684 -0
- package/src/_private/LocalNetworkModule.ts +50 -0
- package/src/_private/cameraRequestPayload.ts +34 -0
- package/src/_private/photoRequestPayload.ts +90 -0
- package/src/_private/sdkOtaManifest.ts +18 -0
- package/src/changelogs.ts +46 -0
- package/src/debug.ts +9 -0
- package/src/generated/changelogCatalog.ts +13 -0
- package/src/generated/releaseMetadata.ts +20 -0
- package/src/index.ts +321 -0
- package/src/ota-server/OtaServer.types.ts +10 -0
- package/src/ota-server/OtaServerModule.ts +23 -0
- package/src/ota-server/OtaServerModule.web.ts +17 -0
- package/src/ota-server/index.ts +2 -0
- package/src/ota-transport/index.ts +116 -0
- package/src/photo-receiver/PhotoReceiver.types.ts +20 -0
- package/src/photo-receiver/PhotoReceiverModule.ts +11 -0
- package/src/photo-receiver/PhotoReceiverModule.web.ts +17 -0
- package/src/photo-receiver/index.ts +2 -0
- package/src/react/index.ts +21 -0
- package/src/react/useBluetooth.ts +309 -0
- package/src/react/useBluetoothEvent.ts +35 -0
- package/src/react/useBluetoothScan.ts +173 -0
- package/src/react/useBluetoothStatus.ts +180 -0
- package/src/react/useGlassesConnection.ts +202 -0
- package/src/types/index.ts +12 -0
|
@@ -0,0 +1,1034 @@
|
|
|
1
|
+
import CryptoKit
|
|
2
|
+
import ExpoModulesCore
|
|
3
|
+
import Foundation
|
|
4
|
+
|
|
5
|
+
public class BluetoothSdkModule: Module, BluetoothSDKDelegate {
|
|
6
|
+
private var sdk: BluetoothSDK?
|
|
7
|
+
|
|
8
|
+
public func definition() -> ModuleDefinition {
|
|
9
|
+
Name("BluetoothSdk")
|
|
10
|
+
|
|
11
|
+
// Define events that can be sent to JavaScript
|
|
12
|
+
Events(
|
|
13
|
+
"glasses_status",
|
|
14
|
+
"bluetooth_status",
|
|
15
|
+
"log",
|
|
16
|
+
"device_discovered",
|
|
17
|
+
"default_device_changed",
|
|
18
|
+
// Individual event handlers
|
|
19
|
+
"glasses_not_ready",
|
|
20
|
+
"button_press",
|
|
21
|
+
"touch_event",
|
|
22
|
+
"accel_event",
|
|
23
|
+
"compass_heading",
|
|
24
|
+
"compass_calibration",
|
|
25
|
+
"navigation_mode_change",
|
|
26
|
+
"navigation_view_change",
|
|
27
|
+
"head_up",
|
|
28
|
+
"voice_activity_detection_status",
|
|
29
|
+
"speaking_status",
|
|
30
|
+
"battery_status",
|
|
31
|
+
"wifi_status_change",
|
|
32
|
+
"wifi_scan_result",
|
|
33
|
+
"hotspot_status_change",
|
|
34
|
+
"hotspot_error",
|
|
35
|
+
"photo_response",
|
|
36
|
+
"photo_status",
|
|
37
|
+
"camera_status",
|
|
38
|
+
"video_recording_status",
|
|
39
|
+
"media_success",
|
|
40
|
+
"media_error",
|
|
41
|
+
"gallery_status",
|
|
42
|
+
"compatible_glasses_search_stop",
|
|
43
|
+
"heartbeat_sent",
|
|
44
|
+
"heartbeat_received",
|
|
45
|
+
"swipe_volume_status",
|
|
46
|
+
"switch_status",
|
|
47
|
+
"rgb_led_control_response",
|
|
48
|
+
"settings_ack",
|
|
49
|
+
"version_info",
|
|
50
|
+
"pair_failure",
|
|
51
|
+
"pairing_info",
|
|
52
|
+
"entering_pairing_mode",
|
|
53
|
+
"owner_replaced",
|
|
54
|
+
"audio_pairing_needed",
|
|
55
|
+
"audio_connected",
|
|
56
|
+
"audio_disconnected",
|
|
57
|
+
"save_setting",
|
|
58
|
+
"local_transcription",
|
|
59
|
+
"speaker_detected",
|
|
60
|
+
"speaker_enroll_progress",
|
|
61
|
+
"speaker_enroll_result",
|
|
62
|
+
"phone_notification",
|
|
63
|
+
"phone_notification_dismissed",
|
|
64
|
+
"ws_text",
|
|
65
|
+
"ws_bin",
|
|
66
|
+
"mic_pcm",
|
|
67
|
+
"mic_lc3",
|
|
68
|
+
"mic_health",
|
|
69
|
+
"stream_status",
|
|
70
|
+
"keep_alive_ack",
|
|
71
|
+
"mtk_update_complete",
|
|
72
|
+
"glasses_session_changed",
|
|
73
|
+
"ota_progress",
|
|
74
|
+
"ota_start_ack",
|
|
75
|
+
"ota_status",
|
|
76
|
+
"ar99_ota_status",
|
|
77
|
+
"g2_firmware_flash_progress",
|
|
78
|
+
"send_command_to_ble",
|
|
79
|
+
"receive_command_from_ble",
|
|
80
|
+
"miniapp_selected",
|
|
81
|
+
"captions_tester_incident",
|
|
82
|
+
"extraction_progress"
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
OnCreate {
|
|
86
|
+
JSCExperiment.maybeAutoBenchmark()
|
|
87
|
+
Task { @MainActor [weak self] in
|
|
88
|
+
_ = self?.bluetoothSdk()
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
OnDestroy {
|
|
93
|
+
Task {
|
|
94
|
+
await PcmStreamManager.abortAll()
|
|
95
|
+
}
|
|
96
|
+
Task { @MainActor [weak self] in
|
|
97
|
+
self?.sdk?.invalidate()
|
|
98
|
+
self?.sdk = nil
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// MARK: - Observable Store Functions
|
|
103
|
+
|
|
104
|
+
Function("getGlassesStatus") { () -> [String: Any] in
|
|
105
|
+
self.readOnMainActor {
|
|
106
|
+
self.bluetoothSdk().glassesStatus.dictionary
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
Function("getBluetoothStatus") { () -> [String: Any] in
|
|
111
|
+
self.readOnMainActor {
|
|
112
|
+
self.bluetoothSdk().bluetoothStatus.values
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
Function("getDefaultDevice") { () -> [String: Any]? in
|
|
117
|
+
self.readOnMainActor {
|
|
118
|
+
self.bluetoothSdk().getDefaultDevice()?.dictionary
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
AsyncFunction("update") { (category: String, values: [String: Any]) in
|
|
123
|
+
await MainActor.run {
|
|
124
|
+
let normalizedCategory = ObservableStore.normalizeCategory(category)
|
|
125
|
+
for (key, value) in values {
|
|
126
|
+
if value is NSNull {
|
|
127
|
+
continue
|
|
128
|
+
}
|
|
129
|
+
DeviceStore.shared.apply(normalizedCategory, key, value)
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// MARK: - Display Commands
|
|
135
|
+
|
|
136
|
+
AsyncFunction("displayEvent") { (params: [String: Any]) in
|
|
137
|
+
let sdk = await MainActor.run { self.bluetoothSdk() }
|
|
138
|
+
try? await sdk.displayEvent(DisplayEventRequest(values: params))
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
AsyncFunction("displayText") { (text: String, x: Int?, y: Int?, size: Int?) in
|
|
142
|
+
let sdk = await MainActor.run { self.bluetoothSdk() }
|
|
143
|
+
try? await sdk.displayText(text, x: x ?? 0, y: y ?? 0, size: size ?? 24)
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// MARK: - Native Navigation Commands (glasses-rendered nav UI)
|
|
147
|
+
|
|
148
|
+
AsyncFunction("navigationModeStart") {
|
|
149
|
+
await MainActor.run {
|
|
150
|
+
self.bluetoothSdk().navigationModeStart()
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
AsyncFunction("navigationModeStop") { (arrived: Bool) in
|
|
155
|
+
await MainActor.run {
|
|
156
|
+
self.bluetoothSdk().navigationModeStop(arrived: arrived)
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
AsyncFunction("navigationUpdateInfo") { (params: [String: Any]) in
|
|
161
|
+
await MainActor.run {
|
|
162
|
+
self.bluetoothSdk().navigationUpdateInfo(params)
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
AsyncFunction("navigationMiniMap") { (params: [String: Any]) in
|
|
167
|
+
await MainActor.run {
|
|
168
|
+
self.bluetoothSdk().navigationMiniMap(params)
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
AsyncFunction("navigationOverviewMap") { (params: [String: Any]) in
|
|
173
|
+
await MainActor.run {
|
|
174
|
+
self.bluetoothSdk().navigationOverviewMap(params)
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
// MARK: - Connection Commands
|
|
179
|
+
|
|
180
|
+
AsyncFunction("connectDefault") {
|
|
181
|
+
try await MainActor.run {
|
|
182
|
+
try self.bluetoothSdk().connectDefault()
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
AsyncFunction("connectDefaultWithOptions") { (options: [String: Any]) in
|
|
187
|
+
try await MainActor.run {
|
|
188
|
+
try self.bluetoothSdk().connectDefault(options: ConnectOptions(dictionary: options))
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
AsyncFunction("setDefaultDevice") { (device: [String: Any]?) in
|
|
193
|
+
await MainActor.run {
|
|
194
|
+
self.bluetoothSdk().setDefaultDevice(Device(dictionary: device))
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
AsyncFunction("clearDefaultDevice") {
|
|
199
|
+
await MainActor.run {
|
|
200
|
+
self.bluetoothSdk().clearDefaultDevice()
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
AsyncFunction("connectWithOptions") { (device: [String: Any], options: [String: Any]) in
|
|
205
|
+
try await MainActor.run {
|
|
206
|
+
guard let target = Device(dictionary: device) else {
|
|
207
|
+
throw BluetoothSdkError(
|
|
208
|
+
code: "invalid_device",
|
|
209
|
+
message: "connect requires a Device with model and name."
|
|
210
|
+
)
|
|
211
|
+
}
|
|
212
|
+
try self.bluetoothSdk().connect(to: target, options: ConnectOptions(dictionary: options))
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
AsyncFunction("connectDefaultController") {
|
|
217
|
+
await MainActor.run {
|
|
218
|
+
DeviceManager.shared.connectDefaultController()
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
AsyncFunction("connectSimulated") {
|
|
223
|
+
await MainActor.run {
|
|
224
|
+
self.bluetoothSdk().connectSimulated()
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
AsyncFunction("disconnect") {
|
|
229
|
+
await MainActor.run {
|
|
230
|
+
self.bluetoothSdk().disconnect()
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
AsyncFunction("disconnectController") {
|
|
235
|
+
await MainActor.run {
|
|
236
|
+
DeviceManager.shared.disconnectController()
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
AsyncFunction("forget") {
|
|
241
|
+
await MainActor.run {
|
|
242
|
+
self.bluetoothSdk().forget()
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
AsyncFunction("forgetController") {
|
|
247
|
+
await MainActor.run {
|
|
248
|
+
DeviceManager.shared.forgetController()
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
AsyncFunction("startScan") { (model: String) in
|
|
253
|
+
try await MainActor.run {
|
|
254
|
+
try self.bluetoothSdk().startScan(model: DeviceModel.fromDeviceType(model))
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
AsyncFunction("stopScan") {
|
|
259
|
+
await MainActor.run {
|
|
260
|
+
self.bluetoothSdk().stopScan()
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
AsyncFunction("cancelConnectionAttempt") {
|
|
265
|
+
await MainActor.run {
|
|
266
|
+
self.bluetoothSdk().cancelConnectionAttempt()
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
AsyncFunction("showDashboard") {
|
|
271
|
+
await MainActor.run {
|
|
272
|
+
self.bluetoothSdk().showDashboard()
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
AsyncFunction("toggleHeadUp") {
|
|
277
|
+
await MainActor.run {
|
|
278
|
+
self.bluetoothSdk().toggleHeadUp()
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
AsyncFunction("showNativeNotificationPanel") {
|
|
283
|
+
await MainActor.run {
|
|
284
|
+
self.bluetoothSdk().showNotificationsPanel()
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
AsyncFunction("ping") {
|
|
289
|
+
await MainActor.run {
|
|
290
|
+
DeviceManager.shared.ping()
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
AsyncFunction("dbg1") {
|
|
295
|
+
await MainActor.run {
|
|
296
|
+
DeviceManager.shared.dbg1()
|
|
297
|
+
DeviceManager.shared.sgc?.dbg1()
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
AsyncFunction("dbg2") {
|
|
302
|
+
await MainActor.run {
|
|
303
|
+
DeviceManager.shared.dbg2()
|
|
304
|
+
DeviceManager.shared.sgc?.dbg2()
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
Function("getMemoryMB") { () -> Double in
|
|
309
|
+
MemoryMonitor.currentMemoryMB()
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
Function("jscSpawn") { (count: Int) -> Int in
|
|
313
|
+
JSCExperiment.spawn(count: count)
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
Function("jscKillAll") { () in
|
|
317
|
+
JSCExperiment.killAll()
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
Function("jscAliveCount") { () -> Int in
|
|
321
|
+
JSCExperiment.aliveCount()
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
Function("jscSpawnAndMeasure") { (count: Int, baselineMB: Double) -> [String: Any] in
|
|
325
|
+
JSCExperiment.spawnAndMeasure(count: count, baselineMB: baselineMB)
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
Function("jscRunBenchmark") { () in
|
|
329
|
+
JSCExperiment.runBenchmark()
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
// MARK: - Incident Reporting
|
|
333
|
+
|
|
334
|
+
AsyncFunction("sendIncidentId") { (incidentId: String, apiBaseUrl: String?) in
|
|
335
|
+
await MainActor.run {
|
|
336
|
+
self.bluetoothSdk().sendIncidentId(incidentId, apiBaseUrl: apiBaseUrl)
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
// MARK: - WiFi Commands
|
|
341
|
+
|
|
342
|
+
AsyncFunction("requestWifiScan") {
|
|
343
|
+
let sdk = await MainActor.run { self.bluetoothSdk() }
|
|
344
|
+
return try await sdk.requestWifiScan().map(\.dictionary)
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
AsyncFunction("sendWifiCredentials") { (ssid: String, password: String) in
|
|
348
|
+
let sdk = await MainActor.run { self.bluetoothSdk() }
|
|
349
|
+
return try await sdk.sendWifiCredentials(ssid: ssid, password: password).values
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
AsyncFunction("forgetWifiNetwork") { (ssid: String) in
|
|
353
|
+
let sdk = await MainActor.run { self.bluetoothSdk() }
|
|
354
|
+
return try await sdk.forgetWifiNetwork(ssid: ssid).values
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
AsyncFunction("setHotspotState") { (enabled: Bool) in
|
|
358
|
+
let sdk = await MainActor.run { self.bluetoothSdk() }
|
|
359
|
+
return try await sdk.setHotspotState(enabled: enabled).values
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
AsyncFunction("setWifiAdbState") { (enabled: Bool) in
|
|
363
|
+
let sdk = await MainActor.run { self.bluetoothSdk() }
|
|
364
|
+
try await sdk.setWifiAdbState(enabled: enabled)
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
AsyncFunction("setSystemTime") { (timestampMs: Double) in
|
|
368
|
+
let maxTimestamp = Double(Int64.max).nextDown
|
|
369
|
+
guard timestampMs.isFinite,
|
|
370
|
+
timestampMs >= Double(Int64.min),
|
|
371
|
+
timestampMs <= maxTimestamp
|
|
372
|
+
else {
|
|
373
|
+
throw BluetoothSdkError(
|
|
374
|
+
code: "invalid_timestamp",
|
|
375
|
+
message: "setSystemTime timestampMs must be a finite Int64 millisecond timestamp."
|
|
376
|
+
)
|
|
377
|
+
}
|
|
378
|
+
let timestamp = Int64(timestampMs)
|
|
379
|
+
await MainActor.run {
|
|
380
|
+
self.bluetoothSdk().setSystemTime(timestampMs: timestamp)
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
// MARK: - Gallery Commands
|
|
385
|
+
|
|
386
|
+
AsyncFunction("setGalleryModeEnabled") { (enabled: Bool) in
|
|
387
|
+
let sdk = await MainActor.run { self.bluetoothSdk() }
|
|
388
|
+
return try await sdk.setGalleryModeEnabled(enabled).values
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
AsyncFunction("setVoiceActivityDetectionEnabled") { (enabled: Bool) in
|
|
392
|
+
let sdk = await MainActor.run { self.bluetoothSdk() }
|
|
393
|
+
try await sdk.setVoiceActivityDetectionEnabled(enabled)
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
AsyncFunction("setLoudnessGateEnabled") { (enabled: Bool) in
|
|
397
|
+
let sdk = await MainActor.run { self.bluetoothSdk() }
|
|
398
|
+
try await sdk.setLoudnessGateEnabled(enabled)
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
AsyncFunction("setPhotoCaptureDefaults") { (params: [String: Any]) in
|
|
402
|
+
let sdk = await MainActor.run { self.bluetoothSdk() }
|
|
403
|
+
return try await sdk.setPhotoCaptureDefaults(PhotoCaptureDefaults.from(params: params)).values
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
AsyncFunction("setVideoRecordingDefaults") { (width: Int, height: Int, fps: Int) in
|
|
407
|
+
let sdk = await MainActor.run { self.bluetoothSdk() }
|
|
408
|
+
return try await sdk.setVideoRecordingDefaults(VideoRecordingDefaults(width: width, height: height, fps: fps)).values
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
AsyncFunction("setMaxVideoRecordingDuration") { (minutes: Int) in
|
|
412
|
+
let sdk = await MainActor.run { self.bluetoothSdk() }
|
|
413
|
+
return try await sdk.setMaxVideoRecordingDuration(minutes: minutes).values
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
AsyncFunction("setCameraFov") { (fov: [String: Any]) in
|
|
417
|
+
let value = intValue(fov["fov"]) ?? CameraFov.defaultFov
|
|
418
|
+
let roiPosition = CameraRoiPosition.from(
|
|
419
|
+
rawValue: intValue(fov["roiPosition"]) ?? intValue(fov["roi_position"])
|
|
420
|
+
)
|
|
421
|
+
let sdk = await MainActor.run { self.bluetoothSdk() }
|
|
422
|
+
return try await sdk.setCameraFov(CameraFov(fov: value, roiPosition: roiPosition)).values
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
AsyncFunction("setLegacyCameraFov") { (fov: [String: Any]) in
|
|
426
|
+
let value = intValue(fov["fov"]) ?? CameraFov.defaultFov
|
|
427
|
+
let roiPosition = CameraRoiPosition.from(
|
|
428
|
+
rawValue: intValue(fov["roiPosition"]) ?? intValue(fov["roi_position"])
|
|
429
|
+
)
|
|
430
|
+
let sdk = await MainActor.run { self.bluetoothSdk() }
|
|
431
|
+
return try sdk.setLegacyCameraFov(CameraFov(fov: value, roiPosition: roiPosition)).values
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
AsyncFunction("restoreLegacyCameraFov") {
|
|
435
|
+
let sdk = await MainActor.run { self.bluetoothSdk() }
|
|
436
|
+
try sdk.restoreLegacyCameraFov()
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
AsyncFunction("setCameraFovOverride") { (params: [String: Any]) in
|
|
440
|
+
guard let leaseId = params["leaseId"] as? String, !leaseId.isEmpty else {
|
|
441
|
+
throw BluetoothSdkError(code: "invalid_request", message: "leaseId is required")
|
|
442
|
+
}
|
|
443
|
+
let value = intValue(params["fov"]) ?? CameraFov.defaultFov
|
|
444
|
+
let roiPosition = CameraRoiPosition.from(
|
|
445
|
+
rawValue: intValue(params["roiPosition"]) ?? intValue(params["roi_position"])
|
|
446
|
+
)
|
|
447
|
+
let ttlMs = intValue(params["ttlMs"]) ?? 300_000
|
|
448
|
+
let sdk = await MainActor.run { self.bluetoothSdk() }
|
|
449
|
+
return try await sdk.setCameraFovOverride(
|
|
450
|
+
leaseId: leaseId,
|
|
451
|
+
fov: CameraFov(fov: value, roiPosition: roiPosition),
|
|
452
|
+
ttlMs: ttlMs
|
|
453
|
+
).values
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
AsyncFunction("releaseCameraFovOverride") { (leaseId: String) in
|
|
457
|
+
let sdk = await MainActor.run { self.bluetoothSdk() }
|
|
458
|
+
return try await sdk.releaseCameraFovOverride(leaseId: leaseId).values
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
AsyncFunction("setCameraTuningConfig") { (anrOn: Bool, gainOn: Bool) in
|
|
462
|
+
let sdk = await MainActor.run { self.bluetoothSdk() }
|
|
463
|
+
return try await sdk.setCameraTuningConfig(anrOn: anrOn, gainOn: gainOn).values
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
AsyncFunction("queryGalleryStatus") {
|
|
467
|
+
let sdk = await MainActor.run { self.bluetoothSdk() }
|
|
468
|
+
return try await sdk.queryGalleryStatus().values
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
AsyncFunction("requestPhoto") { (params: [String: Any]) in
|
|
472
|
+
let req = try PhotoRequest.from(params: params)
|
|
473
|
+
Bridge.log(
|
|
474
|
+
"NATIVE: PHOTO PIPELINE [3/6] BluetoothSdk.requestPhoto requestId=\(req.requestId) size=\(req.size.rawValue) compress=\(req.compress?.rawValue ?? "none") aeDivisor=\(req.aeExposureDivisor.map { String($0) } ?? "nil")"
|
|
475
|
+
)
|
|
476
|
+
|
|
477
|
+
let sdk = await MainActor.run { self.bluetoothSdk() }
|
|
478
|
+
return try await sdk.requestPhoto(req).values
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
AsyncFunction("warmUpCamera") { (params: [String: Any]) in
|
|
482
|
+
let requestId = params["requestId"] as? String
|
|
483
|
+
let sizeRaw = params["size"] as? String ?? "medium"
|
|
484
|
+
let size = PhotoSize(normalizedRawValue: sizeRaw)
|
|
485
|
+
let mode = PhotoMode(normalizedRawValue: params["mode"] as? String)
|
|
486
|
+
let exposureTimeNs: Double?
|
|
487
|
+
switch params["exposureTimeNs"] {
|
|
488
|
+
case let value as Double:
|
|
489
|
+
exposureTimeNs = value.isFinite && value > 0 ? value : nil
|
|
490
|
+
case let value as Int:
|
|
491
|
+
exposureTimeNs = value > 0 ? Double(value) : nil
|
|
492
|
+
case let value as NSNumber:
|
|
493
|
+
let d = value.doubleValue
|
|
494
|
+
exposureTimeNs = d.isFinite && d > 0 ? d : nil
|
|
495
|
+
default:
|
|
496
|
+
exposureTimeNs = nil
|
|
497
|
+
}
|
|
498
|
+
let durationRaw = intValue(params["durationMs"]) ?? 0
|
|
499
|
+
let durationMs = durationRaw > 0 ? durationRaw : 15000
|
|
500
|
+
let zsl = params["zsl"] as? Bool
|
|
501
|
+
let mfnr = params["mfnr"] as? Bool
|
|
502
|
+
|
|
503
|
+
let sdk = await MainActor.run { self.bluetoothSdk() }
|
|
504
|
+
return try await sdk.warmUpCamera(
|
|
505
|
+
requestId: requestId,
|
|
506
|
+
size: size,
|
|
507
|
+
mode: mode,
|
|
508
|
+
exposureTimeNs: exposureTimeNs,
|
|
509
|
+
durationMs: durationMs,
|
|
510
|
+
zsl: zsl,
|
|
511
|
+
mfnr: mfnr
|
|
512
|
+
).values
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
AsyncFunction("stopCameraWarmUp") { (requestId: String) in
|
|
516
|
+
let sdk = await MainActor.run { self.bluetoothSdk() }
|
|
517
|
+
try sdk.stopCameraWarmUp(requestId: requestId)
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
// MARK: - OTA Commands
|
|
521
|
+
|
|
522
|
+
Function("setOtaVersionUrl") { (otaVersionUrl: String) in
|
|
523
|
+
try self.readOnMainActor {
|
|
524
|
+
let sdk = self.bluetoothSdk()
|
|
525
|
+
try sdk.setOtaVersionUrl(otaVersionUrl)
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
Function("getOtaVersionUrl") {
|
|
530
|
+
try self.readOnMainActor {
|
|
531
|
+
let sdk = self.bluetoothSdk()
|
|
532
|
+
return try sdk.getOtaVersionUrl()
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
AsyncFunction("checkForOtaUpdate") {
|
|
537
|
+
let sdk = await MainActor.run { self.bluetoothSdk() }
|
|
538
|
+
return try await sdk.checkForOtaUpdate()
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
AsyncFunction("startOtaUpdate") { (otaVersionUrl: String?) in
|
|
542
|
+
let sdk = await MainActor.run { self.bluetoothSdk() }
|
|
543
|
+
if let otaVersionUrl, !otaVersionUrl.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty {
|
|
544
|
+
return try await sdk.startOtaUpdate(otaVersionUrl: otaVersionUrl).values
|
|
545
|
+
}
|
|
546
|
+
return try await sdk.startOtaUpdate().values
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
AsyncFunction("sendOtaQueryStatus") {
|
|
550
|
+
let sdk = await MainActor.run { self.bluetoothSdk() }
|
|
551
|
+
return try await sdk.sendOtaQueryStatus().values
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
AsyncFunction("startAr99OtaFromFile") { (path: String) in
|
|
555
|
+
let sdk = await MainActor.run { self.bluetoothSdk() }
|
|
556
|
+
return try await MainActor.run { try sdk.startAr99OtaFromFile(path) }
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
AsyncFunction("cancelAr99Ota") {
|
|
560
|
+
let sdk = await MainActor.run { self.bluetoothSdk() }
|
|
561
|
+
await MainActor.run { sdk.cancelAr99Ota() }
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
AsyncFunction("sendAr99FactoryReset") {
|
|
565
|
+
let sdk = await MainActor.run { self.bluetoothSdk() }
|
|
566
|
+
try await MainActor.run { try sdk.sendAr99FactoryReset() }
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
Function("buildAr99OtaSignature") { (secret: String, appName: String, currentVersion: String, serialNumber: String, nonce: String) in
|
|
570
|
+
let raw = secret + appName + "juxinOTA" + currentVersion + serialNumber.trimmingCharacters(in: .whitespacesAndNewlines) + nonce
|
|
571
|
+
let digest = Insecure.MD5.hash(data: Data(raw.utf8))
|
|
572
|
+
return digest.map { String(format: "%02x", $0) }.joined()
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
// MARK: - Version Info Commands
|
|
576
|
+
|
|
577
|
+
AsyncFunction("requestVersionInfo") {
|
|
578
|
+
let sdk = await MainActor.run { self.bluetoothSdk() }
|
|
579
|
+
return try await sdk.requestVersionInfo().dictionary
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
AsyncFunction("availableG2FirmwareArtifacts") {
|
|
583
|
+
let sdk = await MainActor.run { self.bluetoothSdk() }
|
|
584
|
+
return try await MainActor.run { try sdk.availableG2FirmwareArtifacts() }
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
AsyncFunction("startG2FirmwareFlash") { (target: String) in
|
|
588
|
+
let sdk = await MainActor.run { self.bluetoothSdk() }
|
|
589
|
+
return try await sdk.startG2FirmwareFlash(target: target)
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
// MARK: - Power Control Commands
|
|
593
|
+
|
|
594
|
+
AsyncFunction("sendShutdown") {
|
|
595
|
+
await MainActor.run {
|
|
596
|
+
self.bluetoothSdk().sendShutdown()
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
AsyncFunction("sendReboot") {
|
|
601
|
+
await MainActor.run {
|
|
602
|
+
self.bluetoothSdk().sendReboot()
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
// MARK: - Video Recording Commands
|
|
607
|
+
|
|
608
|
+
AsyncFunction("startVideoRecording") {
|
|
609
|
+
(requestId: String, save: Bool, sound: Bool, settings: [String: Any]?) in
|
|
610
|
+
/// Optional per-recording {width,height,fps}. Absent fields stay 0, which
|
|
611
|
+
/// the glasses treat as "use the saved button-video default". JS numbers
|
|
612
|
+
/// arrive as Double across the bridge, so coerce to Int.
|
|
613
|
+
func dim(_ key: String) -> Int {
|
|
614
|
+
(settings?[key] as? NSNumber)?.intValue ?? 0
|
|
615
|
+
}
|
|
616
|
+
let sdk = await MainActor.run { self.bluetoothSdk() }
|
|
617
|
+
return try await sdk.startVideoRecording(
|
|
618
|
+
VideoRecordingRequest(
|
|
619
|
+
requestId: requestId, save: save, sound: sound,
|
|
620
|
+
width: dim("width"), height: dim("height"), fps: dim("fps"),
|
|
621
|
+
maxRecordingTimeMinutes: dim("maxRecordingTimeMinutes")
|
|
622
|
+
)
|
|
623
|
+
).values
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
// webhookUrl/authToken are supplied at stop (not start) so the token is
|
|
627
|
+
// fresh when the upload runs. Empty/nil webhook = keep on device.
|
|
628
|
+
AsyncFunction("stopVideoRecording") {
|
|
629
|
+
(requestId: String, webhookUrl: String?, authToken: String?) in
|
|
630
|
+
let sdk = await MainActor.run { self.bluetoothSdk() }
|
|
631
|
+
return try await sdk.stopVideoRecording(
|
|
632
|
+
requestId: requestId, webhookUrl: webhookUrl, authToken: authToken
|
|
633
|
+
).values
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
AsyncFunction("queryVideoRecordingStatus") { (requestId: String) in
|
|
637
|
+
let sdk = await MainActor.run { self.bluetoothSdk() }
|
|
638
|
+
return try await sdk.queryVideoRecordingStatus(requestId: requestId).values
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
// MARK: - Stream Commands
|
|
642
|
+
|
|
643
|
+
AsyncFunction("startStream") { (params: [String: Any]) in
|
|
644
|
+
let sdk = await MainActor.run { self.bluetoothSdk() }
|
|
645
|
+
return try await sdk.startStream(StreamRequest(values: params)).values
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
AsyncFunction("startExternallyManagedStream") { (params: [String: Any]) in
|
|
649
|
+
let sdk = await MainActor.run { self.bluetoothSdk() }
|
|
650
|
+
return try await sdk.startExternallyManagedStream(StreamRequest(values: params)).values
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
AsyncFunction("stopStream") {
|
|
654
|
+
let sdk = await MainActor.run { self.bluetoothSdk() }
|
|
655
|
+
return try await sdk.stopStream().values
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
AsyncFunction("sendExternallyManagedStreamKeepAlive") { (params: [String: Any]) in
|
|
659
|
+
await MainActor.run {
|
|
660
|
+
self.bluetoothSdk().sendExternallyManagedStreamKeepAlive(StreamKeepAliveRequest(values: params))
|
|
661
|
+
}
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
// MARK: - Audio Playback Monitoring
|
|
665
|
+
|
|
666
|
+
AsyncFunction("setOwnAppAudioPlaying") { (playing: Bool) in
|
|
667
|
+
await MainActor.run {
|
|
668
|
+
self.bluetoothSdk().setOwnAppAudioPlaying(playing)
|
|
669
|
+
}
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
// MARK: - Live PCM output stream (miniapp speaker.createStream)
|
|
673
|
+
|
|
674
|
+
AsyncFunction("pcmStreamOpen") {
|
|
675
|
+
(streamId: String, sampleRate: Int, channels: Int, volume: Double) async throws in
|
|
676
|
+
try PcmStreamManager.open(
|
|
677
|
+
streamId: streamId,
|
|
678
|
+
sampleRate: sampleRate,
|
|
679
|
+
channels: channels,
|
|
680
|
+
volume: Float(volume)
|
|
681
|
+
)
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
AsyncFunction("pcmStreamWrite") {
|
|
685
|
+
(streamId: String, base64: String) async throws -> [String: Int64] in
|
|
686
|
+
try ["bufferedMs": await PcmStreamManager.write(streamId: streamId, base64: base64)]
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
AsyncFunction("pcmStreamClose") {
|
|
690
|
+
(streamId: String) async throws -> [String: Int64] in
|
|
691
|
+
try ["durationMs": await PcmStreamManager.close(streamId: streamId)]
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
AsyncFunction("pcmStreamAbort") { (streamId: String) async in
|
|
695
|
+
await PcmStreamManager.abort(streamId: streamId)
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
AsyncFunction("getGlassesMediaVolume") { () async throws -> [String: Any] in
|
|
699
|
+
try await DeviceManager.shared.getGlassesMediaVolume()
|
|
700
|
+
}
|
|
701
|
+
|
|
702
|
+
AsyncFunction("setGlassesMediaVolume") { (level: Int) async throws -> [String: Any] in
|
|
703
|
+
try await DeviceManager.shared.setGlassesMediaVolume(level: level)
|
|
704
|
+
}
|
|
705
|
+
|
|
706
|
+
// MARK: - RGB LED Control
|
|
707
|
+
|
|
708
|
+
AsyncFunction("rgbLedControl") {
|
|
709
|
+
(
|
|
710
|
+
requestId: String, packageName: String?, action: String, color: String?,
|
|
711
|
+
onDurationMs: Int, offDurationMs: Int, count: Int
|
|
712
|
+
) in
|
|
713
|
+
let sdk = await MainActor.run { self.bluetoothSdk() }
|
|
714
|
+
return try await sdk.rgbLedControl(
|
|
715
|
+
RgbLedRequest(
|
|
716
|
+
requestId: requestId,
|
|
717
|
+
packageName: packageName,
|
|
718
|
+
action: RgbLedAction(rawValue: action) ?? .off,
|
|
719
|
+
color: color.flatMap(RgbLedColor.init(rawValue:)),
|
|
720
|
+
onDurationMs: onDurationMs,
|
|
721
|
+
offDurationMs: offDurationMs,
|
|
722
|
+
count: count
|
|
723
|
+
)
|
|
724
|
+
).values
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
// MARK: - Microphone Commands
|
|
728
|
+
|
|
729
|
+
AsyncFunction("setMicState") { (
|
|
730
|
+
enabled: Bool,
|
|
731
|
+
useGlassesMic: Bool?,
|
|
732
|
+
sendTranscript: Bool?,
|
|
733
|
+
sendLc3Data: Bool?
|
|
734
|
+
) in
|
|
735
|
+
await MainActor.run {
|
|
736
|
+
self.bluetoothSdk().setMicState(
|
|
737
|
+
enabled: enabled,
|
|
738
|
+
useGlassesMic: useGlassesMic ?? true,
|
|
739
|
+
sendTranscript: sendTranscript ?? false,
|
|
740
|
+
sendLc3Data: sendLc3Data ?? false
|
|
741
|
+
)
|
|
742
|
+
}
|
|
743
|
+
}
|
|
744
|
+
|
|
745
|
+
AsyncFunction("restartTranscriber") {
|
|
746
|
+
await MainActor.run {
|
|
747
|
+
DeviceManager.shared.restartTranscriber()
|
|
748
|
+
}
|
|
749
|
+
}
|
|
750
|
+
|
|
751
|
+
// MARK: - Speaker Identification
|
|
752
|
+
|
|
753
|
+
AsyncFunction("setSpeakerIdEnabled") { (enabled: Bool) in
|
|
754
|
+
await MainActor.run {
|
|
755
|
+
DeviceManager.shared.setSpeakerIdEnabled(enabled)
|
|
756
|
+
}
|
|
757
|
+
}
|
|
758
|
+
|
|
759
|
+
AsyncFunction("setSpeakerIdModelPath") { (path: String) in
|
|
760
|
+
await MainActor.run {
|
|
761
|
+
DeviceManager.shared.setSpeakerIdModelPath(path)
|
|
762
|
+
}
|
|
763
|
+
}
|
|
764
|
+
|
|
765
|
+
AsyncFunction("checkSpeakerIdModelAvailable") { () -> Bool in
|
|
766
|
+
return SpeakerIdEngine.isModelAvailable()
|
|
767
|
+
}
|
|
768
|
+
|
|
769
|
+
AsyncFunction("setSpeakerProfiles") { (profiles: [[String: Any]]) in
|
|
770
|
+
await MainActor.run {
|
|
771
|
+
DeviceManager.shared.setSpeakerProfiles(profiles)
|
|
772
|
+
}
|
|
773
|
+
}
|
|
774
|
+
|
|
775
|
+
AsyncFunction("startSpeakerEnrollment") { (params: [String: Any]) in
|
|
776
|
+
let target = (params["targetSpeechSeconds"] as? NSNumber)?.doubleValue ?? 20.0
|
|
777
|
+
await MainActor.run {
|
|
778
|
+
DeviceManager.shared.startSpeakerEnrollment(targetSpeechSeconds: target)
|
|
779
|
+
}
|
|
780
|
+
}
|
|
781
|
+
|
|
782
|
+
AsyncFunction("cancelSpeakerEnrollment") {
|
|
783
|
+
await MainActor.run {
|
|
784
|
+
DeviceManager.shared.cancelSpeakerEnrollment()
|
|
785
|
+
}
|
|
786
|
+
}
|
|
787
|
+
|
|
788
|
+
// MARK: - Display Commands
|
|
789
|
+
|
|
790
|
+
AsyncFunction("clearDisplay") {
|
|
791
|
+
let sdk = await MainActor.run { self.bluetoothSdk() }
|
|
792
|
+
try? await sdk.clearDisplay()
|
|
793
|
+
}
|
|
794
|
+
|
|
795
|
+
// MARK: - STT Model Management
|
|
796
|
+
|
|
797
|
+
AsyncFunction("setSttModelDetails") { (path: String, languageCode: String) in
|
|
798
|
+
STTTools.setSttModelDetails(path, languageCode)
|
|
799
|
+
}
|
|
800
|
+
|
|
801
|
+
AsyncFunction("getSttModelPath") { () -> String in
|
|
802
|
+
return STTTools.getSttModelPath()
|
|
803
|
+
}
|
|
804
|
+
|
|
805
|
+
AsyncFunction("checkSttModelAvailable") { () -> Bool in
|
|
806
|
+
return STTTools.checkSTTModelAvailable()
|
|
807
|
+
}
|
|
808
|
+
|
|
809
|
+
AsyncFunction("validateSttModel") { (path: String) -> Bool in
|
|
810
|
+
return STTTools.validateSTTModel(path)
|
|
811
|
+
}
|
|
812
|
+
|
|
813
|
+
AsyncFunction("extractTarBz2") { (sourcePath: String, destinationPath: String) -> Bool in
|
|
814
|
+
return STTTools.extractTarBz2(sourcePath: sourcePath, destinationPath: destinationPath)
|
|
815
|
+
}
|
|
816
|
+
|
|
817
|
+
// MARK: - TTS Model Management
|
|
818
|
+
|
|
819
|
+
AsyncFunction("setTtsModelDetails") { (path: String, languageCode: String) in
|
|
820
|
+
TTSTools.setTtsModelDetails(path, languageCode)
|
|
821
|
+
}
|
|
822
|
+
|
|
823
|
+
AsyncFunction("getTtsModelPath") { () -> String in
|
|
824
|
+
return TTSTools.getTtsModelPath()
|
|
825
|
+
}
|
|
826
|
+
|
|
827
|
+
AsyncFunction("getTtsModelLanguage") { () -> String in
|
|
828
|
+
return TTSTools.getTtsModelLanguage()
|
|
829
|
+
}
|
|
830
|
+
|
|
831
|
+
AsyncFunction("checkTtsModelAvailable") { () -> Bool in
|
|
832
|
+
return TTSTools.checkTTSModelAvailable()
|
|
833
|
+
}
|
|
834
|
+
|
|
835
|
+
AsyncFunction("validateTtsModel") { (path: String) -> Bool in
|
|
836
|
+
return TTSTools.validateTTSModel(path)
|
|
837
|
+
}
|
|
838
|
+
|
|
839
|
+
AsyncFunction("generateTtsAudio") {
|
|
840
|
+
(text: String, modelPath: String, outputPath: String, speakerId: Int, speed: Double) -> Bool in
|
|
841
|
+
return TTSTools.generateTtsAudio(
|
|
842
|
+
text: text,
|
|
843
|
+
modelPath: modelPath,
|
|
844
|
+
outputPath: outputPath,
|
|
845
|
+
speakerId: speakerId,
|
|
846
|
+
speed: speed
|
|
847
|
+
)
|
|
848
|
+
}
|
|
849
|
+
}
|
|
850
|
+
|
|
851
|
+
@MainActor
|
|
852
|
+
private func bluetoothSdk() -> BluetoothSDK {
|
|
853
|
+
if let sdk {
|
|
854
|
+
return sdk
|
|
855
|
+
}
|
|
856
|
+
|
|
857
|
+
let sdk = BluetoothSDK(
|
|
858
|
+
configuration: BluetoothSDKConfiguration(
|
|
859
|
+
analytics: BluetoothSdkAnalyticsConfiguration().withSurface("react_native")
|
|
860
|
+
)
|
|
861
|
+
)
|
|
862
|
+
sdk.delegate = self
|
|
863
|
+
self.sdk = sdk
|
|
864
|
+
return sdk
|
|
865
|
+
}
|
|
866
|
+
|
|
867
|
+
private func readOnMainActor<T>(_ body: @MainActor () throws -> T) rethrows -> T {
|
|
868
|
+
if Thread.isMainThread {
|
|
869
|
+
return try MainActor.assumeIsolated {
|
|
870
|
+
try body()
|
|
871
|
+
}
|
|
872
|
+
}
|
|
873
|
+
|
|
874
|
+
return try DispatchQueue.main.sync {
|
|
875
|
+
try MainActor.assumeIsolated {
|
|
876
|
+
try body()
|
|
877
|
+
}
|
|
878
|
+
}
|
|
879
|
+
}
|
|
880
|
+
|
|
881
|
+
@MainActor
|
|
882
|
+
public func bluetoothSDK(_ sdk: BluetoothSDK, didUpdateGlasses _: GlassesRuntimeState) {
|
|
883
|
+
sendEvent("glasses_status", sdk.glassesStatus.dictionary)
|
|
884
|
+
}
|
|
885
|
+
|
|
886
|
+
@MainActor
|
|
887
|
+
public func bluetoothSDK(_ sdk: BluetoothSDK, didUpdateSdkState _: PhoneSdkRuntimeState) {
|
|
888
|
+
sendEvent("bluetooth_status", sdk.bluetoothStatus.values)
|
|
889
|
+
}
|
|
890
|
+
|
|
891
|
+
@MainActor
|
|
892
|
+
public func bluetoothSDK(_: BluetoothSDK, didDiscover device: Device) {
|
|
893
|
+
sendEvent("device_discovered", device.dictionary)
|
|
894
|
+
}
|
|
895
|
+
|
|
896
|
+
@MainActor
|
|
897
|
+
public func bluetoothSDK(_: BluetoothSDK, didStopScan reason: ScanStopReason) {
|
|
898
|
+
guard reason == .completed else { return }
|
|
899
|
+
let status = bluetoothSdk().bluetoothStatus
|
|
900
|
+
let deviceModel = status.pendingWearable.isEmpty ? status.defaultWearable : status.pendingWearable
|
|
901
|
+
sendEvent(
|
|
902
|
+
"compatible_glasses_search_stop",
|
|
903
|
+
[
|
|
904
|
+
"type": "compatible_glasses_search_stop",
|
|
905
|
+
"deviceModel": deviceModel,
|
|
906
|
+
]
|
|
907
|
+
)
|
|
908
|
+
}
|
|
909
|
+
|
|
910
|
+
@MainActor
|
|
911
|
+
public func bluetoothSDK(_: BluetoothSDK, didReceive event: BluetoothEvent) {
|
|
912
|
+
switch event {
|
|
913
|
+
case let .buttonPress(button):
|
|
914
|
+
sendEvent(
|
|
915
|
+
"button_press",
|
|
916
|
+
[
|
|
917
|
+
"buttonId": button.buttonId,
|
|
918
|
+
"pressType": button.pressType,
|
|
919
|
+
"timestamp": button.timestamp ?? Int(Date().timeIntervalSince1970 * 1000),
|
|
920
|
+
]
|
|
921
|
+
)
|
|
922
|
+
case let .touch(touch):
|
|
923
|
+
sendEvent("touch_event", touch.values)
|
|
924
|
+
case let .voiceActivityDetectionStatus(status):
|
|
925
|
+
sendEvent("voice_activity_detection_status", status.values)
|
|
926
|
+
case let .speakingStatus(status):
|
|
927
|
+
sendEvent("speaking_status", status.values)
|
|
928
|
+
case let .micHealth(health):
|
|
929
|
+
sendEvent("mic_health", health.values)
|
|
930
|
+
case let .wifiStatus(status):
|
|
931
|
+
sendEvent("wifi_status_change", status.values)
|
|
932
|
+
case let .hotspotStatus(status):
|
|
933
|
+
sendEvent("hotspot_status_change", status.values)
|
|
934
|
+
case let .hotspotError(error):
|
|
935
|
+
sendEvent("hotspot_error", error.values)
|
|
936
|
+
case let .photoResponse(response):
|
|
937
|
+
sendEvent("photo_response", response.values)
|
|
938
|
+
case let .photoStatus(status):
|
|
939
|
+
sendEvent("photo_status", status.values)
|
|
940
|
+
case let .cameraStatus(status):
|
|
941
|
+
sendEvent("camera_status", status.values)
|
|
942
|
+
case let .videoRecordingStatus(status):
|
|
943
|
+
sendEvent("video_recording_status", status.values)
|
|
944
|
+
case let .mediaUpload(event):
|
|
945
|
+
sendEvent(event.type, event.values)
|
|
946
|
+
case let .rgbLedControlResponse(response):
|
|
947
|
+
sendEvent("rgb_led_control_response", response.values)
|
|
948
|
+
case let .streamStatus(status):
|
|
949
|
+
sendEvent("stream_status", status.values)
|
|
950
|
+
case let .keepAliveAck(ack):
|
|
951
|
+
sendEvent("keep_alive_ack", ack.values)
|
|
952
|
+
case let .otaStartAck(event):
|
|
953
|
+
sendEvent("ota_start_ack", event.values)
|
|
954
|
+
case let .otaStatus(event):
|
|
955
|
+
sendEvent("ota_status", event.values)
|
|
956
|
+
case let .settingsAck(event):
|
|
957
|
+
sendEvent("settings_ack", event.values)
|
|
958
|
+
case let .versionInfo(event):
|
|
959
|
+
var values = event.dictionary
|
|
960
|
+
values["type"] = "version_info"
|
|
961
|
+
sendEvent("version_info", values)
|
|
962
|
+
case let .localTranscription(transcription):
|
|
963
|
+
sendEvent("local_transcription", transcription.values)
|
|
964
|
+
case let .raw(name, values):
|
|
965
|
+
sendEvent(name, values)
|
|
966
|
+
}
|
|
967
|
+
}
|
|
968
|
+
|
|
969
|
+
@MainActor
|
|
970
|
+
public func bluetoothSDK(_: BluetoothSDK, didReceiveMicPcm event: MicPcmEvent) {
|
|
971
|
+
sendEvent("mic_pcm", event.values)
|
|
972
|
+
}
|
|
973
|
+
|
|
974
|
+
@MainActor
|
|
975
|
+
public func bluetoothSDK(_: BluetoothSDK, didReceiveMicLc3 event: MicLc3Event) {
|
|
976
|
+
sendEvent("mic_lc3", event.values)
|
|
977
|
+
}
|
|
978
|
+
|
|
979
|
+
@MainActor
|
|
980
|
+
public func bluetoothSDK(_: BluetoothSDK, didChangeDefaultDevice device: Device?) {
|
|
981
|
+
var event: [String: Any] = [:]
|
|
982
|
+
if let device {
|
|
983
|
+
event["device"] = device.dictionary
|
|
984
|
+
}
|
|
985
|
+
sendEvent("default_device_changed", event)
|
|
986
|
+
}
|
|
987
|
+
|
|
988
|
+
@MainActor
|
|
989
|
+
public func bluetoothSDK(_: BluetoothSDK, didLog message: String) {
|
|
990
|
+
sendEvent("log", ["message": message])
|
|
991
|
+
}
|
|
992
|
+
|
|
993
|
+
@MainActor
|
|
994
|
+
public func bluetoothSDK(_: BluetoothSDK, didFail error: BluetoothSdkError) {
|
|
995
|
+
sendEvent("pair_failure", ["error": error.message])
|
|
996
|
+
}
|
|
997
|
+
}
|
|
998
|
+
|
|
999
|
+
private extension Device {
|
|
1000
|
+
init?(dictionary values: [String: Any]?) {
|
|
1001
|
+
guard let values else { return nil }
|
|
1002
|
+
guard let model = values["model"] as? String ?? values["deviceModel"] as? String else { return nil }
|
|
1003
|
+
guard let name = values["name"] as? String ?? values["deviceName"] as? String else { return nil }
|
|
1004
|
+
let identifier = values["address"] as? String ?? values["deviceAddress"] as? String
|
|
1005
|
+
let rssi: Int?
|
|
1006
|
+
switch values["rssi"] {
|
|
1007
|
+
case let value as Int:
|
|
1008
|
+
rssi = value
|
|
1009
|
+
case let value as Double:
|
|
1010
|
+
rssi = Int(value)
|
|
1011
|
+
case let value as NSNumber:
|
|
1012
|
+
rssi = value.intValue
|
|
1013
|
+
default:
|
|
1014
|
+
rssi = nil
|
|
1015
|
+
}
|
|
1016
|
+
let id = values["id"] as? String
|
|
1017
|
+
self.init(
|
|
1018
|
+
model: DeviceModel.fromDeviceType(model),
|
|
1019
|
+
name: name,
|
|
1020
|
+
identifier: identifier?.isEmpty == true ? nil : identifier,
|
|
1021
|
+
rssi: rssi,
|
|
1022
|
+
id: id
|
|
1023
|
+
)
|
|
1024
|
+
}
|
|
1025
|
+
}
|
|
1026
|
+
|
|
1027
|
+
private extension ConnectOptions {
|
|
1028
|
+
init(dictionary values: [String: Any]?) {
|
|
1029
|
+
self.init(
|
|
1030
|
+
saveAsDefault: values?["saveAsDefault"] as? Bool ?? true,
|
|
1031
|
+
cancelExistingConnectionAttempt: values?["cancelExistingConnectionAttempt"] as? Bool ?? true
|
|
1032
|
+
)
|
|
1033
|
+
}
|
|
1034
|
+
}
|