@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,405 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
|
|
3
|
+
/// BLE Wire Protocol v2 JSON compaction with lossless fallback for ambiguous payloads.
|
|
4
|
+
enum BleJsonCompact {
|
|
5
|
+
static let keyResolvedConfigHash = "rch"
|
|
6
|
+
|
|
7
|
+
private static let longToShort: [String: String] = [
|
|
8
|
+
"type": "t",
|
|
9
|
+
"requestId": "r",
|
|
10
|
+
"timestamp": "ts",
|
|
11
|
+
"status": "s",
|
|
12
|
+
"kind": "k",
|
|
13
|
+
"source": "src",
|
|
14
|
+
"requestedCaptureConfig": "rcc",
|
|
15
|
+
"meteredPreview": "mp",
|
|
16
|
+
"exposureTimeNs": "etn",
|
|
17
|
+
"captureMetadata": "cm",
|
|
18
|
+
"aeStateName": "aes",
|
|
19
|
+
"transferMethod": "tm",
|
|
20
|
+
"manual": "m",
|
|
21
|
+
"reconnecting": "rc",
|
|
22
|
+
"stats": "st",
|
|
23
|
+
"width": "w",
|
|
24
|
+
"height": "h",
|
|
25
|
+
"bitrate": "br",
|
|
26
|
+
"fps": "f",
|
|
27
|
+
"droppedFrames": "df",
|
|
28
|
+
"duration": "du",
|
|
29
|
+
"temperatureC": "tc",
|
|
30
|
+
]
|
|
31
|
+
|
|
32
|
+
private static let shortToLong: [String: String] = {
|
|
33
|
+
var map: [String: String] = [:]
|
|
34
|
+
for (longKey, shortKey) in longToShort {
|
|
35
|
+
map[shortKey] = longKey
|
|
36
|
+
}
|
|
37
|
+
return map
|
|
38
|
+
}()
|
|
39
|
+
|
|
40
|
+
private static let photoStatusToInt: [String: Int] = [
|
|
41
|
+
"accepted": 0, "queued": 1, "configuring": 2, "capturing": 3,
|
|
42
|
+
"captured": 4, "uploading": 5, "uploaded": 6, "failed": 7,
|
|
43
|
+
]
|
|
44
|
+
private static let photoStatusFromInt: [Int: String] = {
|
|
45
|
+
var map: [Int: String] = [:]
|
|
46
|
+
for (key, value) in photoStatusToInt { map[value] = key }
|
|
47
|
+
return map
|
|
48
|
+
}()
|
|
49
|
+
|
|
50
|
+
private static let kindToInt = ["lifecycle": 0, "snapshot": 1]
|
|
51
|
+
private static let kindFromInt: [Int: String] = [0: "lifecycle", 1: "snapshot"]
|
|
52
|
+
|
|
53
|
+
private static let sourceToInt = ["sdk": 0, "button": 1]
|
|
54
|
+
private static let sourceFromInt: [Int: String] = [0: "sdk", 1: "button"]
|
|
55
|
+
|
|
56
|
+
private static let aeStateToInt: [String: Int] = [
|
|
57
|
+
"CONVERGED": 0, "SEARCHING": 1, "INACTIVE": 2,
|
|
58
|
+
"LOCKED": 3, "FLASH_REQUIRED": 4, "PRECAPTURE": 5,
|
|
59
|
+
]
|
|
60
|
+
private static let aeStateFromInt: [Int: String] = {
|
|
61
|
+
var map: [Int: String] = [:]
|
|
62
|
+
for (key, value) in aeStateToInt { map[value] = key }
|
|
63
|
+
return map
|
|
64
|
+
}()
|
|
65
|
+
|
|
66
|
+
private static var sessionConnectEpochMs: Int64 = 0
|
|
67
|
+
private static var resolvedConfigByHash: [String: [String: Any]] = [:]
|
|
68
|
+
|
|
69
|
+
private static let highRoiMessageTypes: Set<String> = [
|
|
70
|
+
"photo_status",
|
|
71
|
+
"stream_status",
|
|
72
|
+
"wifi_scan_result",
|
|
73
|
+
"start_stream",
|
|
74
|
+
"photo_response",
|
|
75
|
+
]
|
|
76
|
+
|
|
77
|
+
private static let chunkMessageTypes: Set<String> = ["ck", "chunked_msg"]
|
|
78
|
+
|
|
79
|
+
static func shouldCompactOutbound(_ messageType: String) -> Bool {
|
|
80
|
+
highRoiMessageTypes.contains(messageType)
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
static func supportsCompactInbound(_ messageType: String) -> Bool {
|
|
84
|
+
!messageType.isEmpty
|
|
85
|
+
&& (highRoiMessageTypes.contains(messageType) || chunkMessageTypes.contains(messageType))
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
static func isCompactWireForm(_ json: [String: Any]) -> Bool {
|
|
89
|
+
json["t"] != nil && json["type"] == nil
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
static func extractMessageType(_ json: [String: Any]) -> String {
|
|
93
|
+
if let type = stringValue(json["type"]) {
|
|
94
|
+
return type
|
|
95
|
+
}
|
|
96
|
+
if let compactType = stringValue(json["t"]) {
|
|
97
|
+
return compactType
|
|
98
|
+
}
|
|
99
|
+
return ""
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
static func resetSession() {
|
|
103
|
+
sessionConnectEpochMs = 0
|
|
104
|
+
resolvedConfigByHash.removeAll()
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
static func markSessionConnected(epochMs: Int64) {
|
|
108
|
+
resetSession()
|
|
109
|
+
sessionConnectEpochMs = epochMs
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
static func isCameraCommandJson(_ jsonData: String) -> Bool {
|
|
113
|
+
jsonData.contains("cs_pho")
|
|
114
|
+
|| jsonData.contains("cs_cpho")
|
|
115
|
+
|| jsonData.contains("cs_vid")
|
|
116
|
+
|| jsonData.contains("\"type\":\"take_photo\"")
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
static func encode(_ json: [String: Any]) -> [String: Any] {
|
|
120
|
+
if isCameraCommandJson(jsonString(json) ?? "") {
|
|
121
|
+
return json
|
|
122
|
+
}
|
|
123
|
+
let messageType = extractMessageType(json)
|
|
124
|
+
if !shouldCompactOutbound(messageType) || !canCompactLosslessly(json, topLevel: true) {
|
|
125
|
+
return json
|
|
126
|
+
}
|
|
127
|
+
return compactObject(json, topLevel: true)
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
static func encode(jsonString: String) -> [String: Any]? {
|
|
131
|
+
guard let data = jsonString.data(using: .utf8),
|
|
132
|
+
let json = try? JSONSerialization.jsonObject(with: data) as? [String: Any]
|
|
133
|
+
else {
|
|
134
|
+
return nil
|
|
135
|
+
}
|
|
136
|
+
return encode(json)
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
static func decode(_ json: [String: Any]) -> [String: Any] {
|
|
140
|
+
if isCameraCommandJson(jsonString(json) ?? "") {
|
|
141
|
+
return json
|
|
142
|
+
}
|
|
143
|
+
return expandObject(json, topLevel: true)
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
static func decodeIfSupported(_ json: [String: Any]) -> [String: Any]? {
|
|
147
|
+
if isCameraCommandJson(jsonString(json) ?? "") {
|
|
148
|
+
return json
|
|
149
|
+
}
|
|
150
|
+
if !isCompactWireForm(json) {
|
|
151
|
+
return json
|
|
152
|
+
}
|
|
153
|
+
let compactType = stringValue(json["t"]) ?? ""
|
|
154
|
+
if !supportsCompactInbound(compactType) {
|
|
155
|
+
return nil
|
|
156
|
+
}
|
|
157
|
+
return expandObject(json, topLevel: true)
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
static func decode(jsonString: String) -> [String: Any]? {
|
|
161
|
+
guard let data = jsonString.data(using: .utf8),
|
|
162
|
+
let json = try? JSONSerialization.jsonObject(with: data) as? [String: Any]
|
|
163
|
+
else {
|
|
164
|
+
return nil
|
|
165
|
+
}
|
|
166
|
+
return decode(json)
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/// Compact JSON reserves short keys and enum integers. Fall back to verbose JSON whenever an
|
|
170
|
+
/// otherwise valid future payload already uses one of those wire representations.
|
|
171
|
+
private static func canCompactLosslessly(
|
|
172
|
+
_ input: [String: Any],
|
|
173
|
+
topLevel: Bool
|
|
174
|
+
) -> Bool {
|
|
175
|
+
let messageType = stringValue(input["type"]) ?? stringValue(input["t"]) ?? ""
|
|
176
|
+
for (key, value) in input {
|
|
177
|
+
if shortToLong[key] != nil
|
|
178
|
+
|| (topLevel && key == keyResolvedConfigHash)
|
|
179
|
+
|| isAmbiguousEnumValue(key: key, value: value, messageType: messageType)
|
|
180
|
+
{
|
|
181
|
+
return false
|
|
182
|
+
}
|
|
183
|
+
if let nested = value as? [String: Any],
|
|
184
|
+
!canCompactLosslessly(nested, topLevel: false)
|
|
185
|
+
{
|
|
186
|
+
return false
|
|
187
|
+
}
|
|
188
|
+
if let array = value as? [Any], !canCompactArrayLosslessly(array) {
|
|
189
|
+
return false
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
return true
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
private static func canCompactArrayLosslessly(_ array: [Any]) -> Bool {
|
|
196
|
+
for value in array {
|
|
197
|
+
if let nested = value as? [String: Any],
|
|
198
|
+
!canCompactLosslessly(nested, topLevel: false)
|
|
199
|
+
{
|
|
200
|
+
return false
|
|
201
|
+
}
|
|
202
|
+
if let nestedArray = value as? [Any],
|
|
203
|
+
!canCompactArrayLosslessly(nestedArray)
|
|
204
|
+
{
|
|
205
|
+
return false
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
return true
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
private static func isAmbiguousEnumValue(
|
|
212
|
+
key: String,
|
|
213
|
+
value: Any,
|
|
214
|
+
messageType: String
|
|
215
|
+
) -> Bool {
|
|
216
|
+
guard let number = value as? NSNumber,
|
|
217
|
+
CFGetTypeID(number) != CFBooleanGetTypeID()
|
|
218
|
+
else {
|
|
219
|
+
return false
|
|
220
|
+
}
|
|
221
|
+
return key == "kind"
|
|
222
|
+
|| key == "source"
|
|
223
|
+
|| key == "aeStateName"
|
|
224
|
+
|| (key == "status" && messageType == "photo_status")
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
private static func compactObject(_ input: [String: Any], topLevel: Bool) -> [String: Any] {
|
|
228
|
+
var output: [String: Any] = [:]
|
|
229
|
+
let messageType = stringValue(input["type"]) ?? stringValue(input["t"]) ?? ""
|
|
230
|
+
|
|
231
|
+
for (key, value) in input {
|
|
232
|
+
if let compacted = compactValue(longKey: key, value: value, messageType: messageType) {
|
|
233
|
+
// Legacy peers treat top-level `ts` as a session-relative delta. Preserve the
|
|
234
|
+
// verbose key so an absolute timestamp remains absolute across mixed versions.
|
|
235
|
+
let wireKey = topLevel && key == "timestamp" ? key : (longToShort[key] ?? key)
|
|
236
|
+
output[wireKey] = compacted
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
return output
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
private static func compactValue(longKey: String, value: Any, messageType: String) -> Any? {
|
|
243
|
+
if value is NSNull { return NSNull() }
|
|
244
|
+
if let nested = value as? [String: Any] {
|
|
245
|
+
return compactObject(nested, topLevel: false)
|
|
246
|
+
}
|
|
247
|
+
if let array = value as? [Any] {
|
|
248
|
+
return array.map { item -> Any in
|
|
249
|
+
if let nested = item as? [String: Any] {
|
|
250
|
+
return compactObject(nested, topLevel: false)
|
|
251
|
+
}
|
|
252
|
+
return item
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
if let boolValue = value as? Bool { return boolValue }
|
|
256
|
+
if let number = value as? NSNumber, CFGetTypeID(number) != CFBooleanGetTypeID() {
|
|
257
|
+
return number
|
|
258
|
+
}
|
|
259
|
+
if let str = value as? String {
|
|
260
|
+
if longKey == "status", messageType == "photo_status", let code = photoStatusToInt[str] {
|
|
261
|
+
return code
|
|
262
|
+
}
|
|
263
|
+
if longKey == "kind", let code = kindToInt[str] { return code }
|
|
264
|
+
if longKey == "source", let code = sourceToInt[str] { return code }
|
|
265
|
+
if longKey == "aeStateName", let code = aeStateToInt[str] { return code }
|
|
266
|
+
return str
|
|
267
|
+
}
|
|
268
|
+
return value
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
private static func expandObject(_ input: [String: Any], topLevel: Bool) -> [String: Any] {
|
|
272
|
+
var output: [String: Any] = [:]
|
|
273
|
+
let messageType = stringValue(input["type"]) ?? stringValue(input["t"]) ?? ""
|
|
274
|
+
|
|
275
|
+
for (key, value) in input {
|
|
276
|
+
if topLevel, key == "ts" {
|
|
277
|
+
output["ts"] = value
|
|
278
|
+
continue
|
|
279
|
+
}
|
|
280
|
+
let longKey = shortToLong[key] ?? key
|
|
281
|
+
if let expanded = expandValue(longKey: longKey, value: value, messageType: messageType) {
|
|
282
|
+
output[longKey] = expanded
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
if topLevel {
|
|
287
|
+
expandTimestamp(&output)
|
|
288
|
+
expandResolvedConfigHash(&output)
|
|
289
|
+
cacheResolvedConfigIfPresent(&output)
|
|
290
|
+
}
|
|
291
|
+
return output
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
private static func cacheResolvedConfigIfPresent(_ output: inout [String: Any]) {
|
|
295
|
+
guard let resolvedConfig = output["resolvedConfig"] as? [String: Any] else { return }
|
|
296
|
+
let hash = hashConfig(resolvedConfig)
|
|
297
|
+
resolvedConfigByHash[hash] = resolvedConfig
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
private static func expandResolvedConfigHash(_ output: inout [String: Any]) {
|
|
301
|
+
guard output["resolvedConfig"] == nil,
|
|
302
|
+
let hash = output[keyResolvedConfigHash] as? String,
|
|
303
|
+
let cached = resolvedConfigByHash[hash]
|
|
304
|
+
else {
|
|
305
|
+
return
|
|
306
|
+
}
|
|
307
|
+
output["resolvedConfig"] = cached
|
|
308
|
+
output.removeValue(forKey: keyResolvedConfigHash)
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
private static func expandValue(longKey: String, value: Any, messageType: String) -> Any? {
|
|
312
|
+
if value is NSNull { return NSNull() }
|
|
313
|
+
if let nested = value as? [String: Any] {
|
|
314
|
+
return expandObject(nested, topLevel: false)
|
|
315
|
+
}
|
|
316
|
+
if let array = value as? [Any] {
|
|
317
|
+
return array.map { item -> Any in
|
|
318
|
+
if let nested = item as? [String: Any] {
|
|
319
|
+
return expandObject(nested, topLevel: false)
|
|
320
|
+
}
|
|
321
|
+
return item
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
if longKey == "status", messageType == "photo_status", let code = value as? Int {
|
|
325
|
+
return photoStatusFromInt[code] ?? value
|
|
326
|
+
}
|
|
327
|
+
if longKey == "kind", let code = value as? Int {
|
|
328
|
+
return kindFromInt[code] ?? value
|
|
329
|
+
}
|
|
330
|
+
if longKey == "source", let code = value as? Int {
|
|
331
|
+
return sourceFromInt[code] ?? value
|
|
332
|
+
}
|
|
333
|
+
if longKey == "aeStateName", let code = value as? Int {
|
|
334
|
+
return aeStateFromInt[code] ?? value
|
|
335
|
+
}
|
|
336
|
+
return value
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
private static func expandTimestamp(_ output: inout [String: Any]) {
|
|
340
|
+
guard output["timestamp"] == nil, let timestamp = output["ts"] else { return }
|
|
341
|
+
guard let delta = int64Value(timestamp) else {
|
|
342
|
+
output["timestamp"] = timestamp
|
|
343
|
+
output.removeValue(forKey: "ts")
|
|
344
|
+
return
|
|
345
|
+
}
|
|
346
|
+
let absolute = sessionConnectEpochMs > 0 ? sessionConnectEpochMs + delta : delta
|
|
347
|
+
output["timestamp"] = absolute
|
|
348
|
+
output.removeValue(forKey: "ts")
|
|
349
|
+
if sessionConnectEpochMs <= 0 {
|
|
350
|
+
sessionConnectEpochMs = absolute - delta
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
static func hashConfig(_ config: [String: Any]) -> String {
|
|
355
|
+
fnv1a32Hex(canonicalJsonString(config))
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
private static func canonicalJsonString(_ object: [String: Any]) -> String {
|
|
359
|
+
let sortedKeys = object.keys.sorted()
|
|
360
|
+
var parts: [String] = []
|
|
361
|
+
for key in sortedKeys {
|
|
362
|
+
guard let value = object[key] else { continue }
|
|
363
|
+
let encodedValue: String
|
|
364
|
+
if let nested = value as? [String: Any] {
|
|
365
|
+
encodedValue = canonicalJsonString(nested)
|
|
366
|
+
} else if let str = value as? String {
|
|
367
|
+
encodedValue = "\"\(str)\""
|
|
368
|
+
} else if let boolValue = value as? Bool {
|
|
369
|
+
encodedValue = boolValue ? "true" : "false"
|
|
370
|
+
} else if let number = value as? NSNumber {
|
|
371
|
+
encodedValue = "\(number)"
|
|
372
|
+
} else {
|
|
373
|
+
encodedValue = "null"
|
|
374
|
+
}
|
|
375
|
+
parts.append("\"\(key)\":\(encodedValue)")
|
|
376
|
+
}
|
|
377
|
+
return "{\(parts.joined(separator: ","))}"
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
private static func fnv1a32Hex(_ value: String) -> String {
|
|
381
|
+
var hash: UInt32 = 0x811c9dc5
|
|
382
|
+
for byte in value.utf8 {
|
|
383
|
+
hash ^= UInt32(byte)
|
|
384
|
+
hash = hash &* 0x01000193
|
|
385
|
+
}
|
|
386
|
+
return String(format: "%08x", hash)
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
private static func stringValue(_ value: Any?) -> String? {
|
|
390
|
+
if let str = value as? String { return str }
|
|
391
|
+
if let number = value as? NSNumber { return number.stringValue }
|
|
392
|
+
return nil
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
private static func int64Value(_ value: Any?) -> Int64? {
|
|
396
|
+
if let number = value as? NSNumber { return number.int64Value }
|
|
397
|
+
if let str = value as? String, let parsed = Int64(str) { return parsed }
|
|
398
|
+
return nil
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
private static func jsonString(_ json: [String: Any]) -> String? {
|
|
402
|
+
guard let data = try? JSONSerialization.data(withJSONObject: json) else { return nil }
|
|
403
|
+
return String(data: data, encoding: .utf8)
|
|
404
|
+
}
|
|
405
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
|
|
3
|
+
/// BLE Wire Protocol v2 shared constants and binary frame helpers.
|
|
4
|
+
/// All multi-byte fields use little-endian byte order.
|
|
5
|
+
enum BleWireProtocol {
|
|
6
|
+
static let cmdTypeBinaryMsg: UInt8 = 0x40
|
|
7
|
+
|
|
8
|
+
static let flagFirstFrag: UInt8 = 0x01
|
|
9
|
+
static let flagLastFrag: UInt8 = 0x02
|
|
10
|
+
static let flagWake: UInt8 = 0x04
|
|
11
|
+
static let flagHandshake: UInt8 = 0x08
|
|
12
|
+
static let flagAckRequested: UInt8 = 0x10
|
|
13
|
+
|
|
14
|
+
static let binaryHeaderSize = 7
|
|
15
|
+
static let maxFragmentPayload = 480
|
|
16
|
+
static let mtuTarget = 509
|
|
17
|
+
|
|
18
|
+
static let handshakePayloadV2 = "v2"
|
|
19
|
+
static let protocolV1 = 1
|
|
20
|
+
static let protocolV2 = 2
|
|
21
|
+
|
|
22
|
+
struct BinaryFragmentInfo {
|
|
23
|
+
let flags: UInt8
|
|
24
|
+
let msgId: UInt16
|
|
25
|
+
let fragIdx: UInt8
|
|
26
|
+
let fragCount: UInt8
|
|
27
|
+
let payload: Data
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
static func isBinaryFrame(_ data: Data) -> Bool {
|
|
31
|
+
guard data.count >= 7 else { return false }
|
|
32
|
+
let bytes = [UInt8](data)
|
|
33
|
+
return bytes[0] == 0x23 && bytes[1] == 0x23 && bytes[2] == cmdTypeBinaryMsg
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
static func packBinaryFragment(
|
|
37
|
+
flags: UInt8,
|
|
38
|
+
msgId: UInt16,
|
|
39
|
+
fragIdx: UInt8,
|
|
40
|
+
fragCount: UInt8,
|
|
41
|
+
payload: Data
|
|
42
|
+
) -> Data? {
|
|
43
|
+
var inner = Data(capacity: binaryHeaderSize + payload.count)
|
|
44
|
+
inner.append(flags)
|
|
45
|
+
inner.append(UInt8(msgId & 0xFF))
|
|
46
|
+
inner.append(UInt8((msgId >> 8) & 0xFF))
|
|
47
|
+
inner.append(fragIdx)
|
|
48
|
+
inner.append(fragCount)
|
|
49
|
+
let payloadLen = UInt16(payload.count)
|
|
50
|
+
inner.append(UInt8(payloadLen & 0xFF))
|
|
51
|
+
inner.append(UInt8((payloadLen >> 8) & 0xFF))
|
|
52
|
+
inner.append(payload)
|
|
53
|
+
return packDataToK900(inner, cmdType: cmdTypeBinaryMsg)
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
static func extractBinaryFragmentInfo(_ frame: Data) -> BinaryFragmentInfo? {
|
|
57
|
+
guard isBinaryFrame(frame) else { return nil }
|
|
58
|
+
let bytes = [UInt8](frame)
|
|
59
|
+
let innerLen = Int(bytes[3]) | (Int(bytes[4]) << 8)
|
|
60
|
+
guard innerLen >= binaryHeaderSize, frame.count >= 7 + innerLen else { return nil }
|
|
61
|
+
|
|
62
|
+
let offset = 5
|
|
63
|
+
let payloadLen = Int(bytes[offset + 5]) | (Int(bytes[offset + 6]) << 8)
|
|
64
|
+
guard binaryHeaderSize + payloadLen <= innerLen else { return nil }
|
|
65
|
+
|
|
66
|
+
let payload = frame.subdata(in: (offset + binaryHeaderSize) ..< (offset + binaryHeaderSize + payloadLen))
|
|
67
|
+
return BinaryFragmentInfo(
|
|
68
|
+
flags: bytes[offset],
|
|
69
|
+
msgId: UInt16(bytes[offset + 1]) | (UInt16(bytes[offset + 2]) << 8),
|
|
70
|
+
fragIdx: bytes[offset + 3],
|
|
71
|
+
fragCount: bytes[offset + 4],
|
|
72
|
+
payload: payload
|
|
73
|
+
)
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
static func isHandshakeV2(_ info: BinaryFragmentInfo) -> Bool {
|
|
77
|
+
guard (info.flags & flagHandshake) != 0 else { return false }
|
|
78
|
+
return String(data: info.payload, encoding: .utf8) == handshakePayloadV2
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
private static func packDataToK900(_ data: Data, cmdType: UInt8) -> Data? {
|
|
82
|
+
var result = Data(capacity: data.count + 7)
|
|
83
|
+
result.append(contentsOf: [0x23, 0x23])
|
|
84
|
+
result.append(cmdType)
|
|
85
|
+
let dataLength = UInt16(data.count)
|
|
86
|
+
result.append(UInt8(dataLength & 0xFF))
|
|
87
|
+
result.append(UInt8((dataLength >> 8) & 0xFF))
|
|
88
|
+
result.append(data)
|
|
89
|
+
result.append(contentsOf: [0x24, 0x24])
|
|
90
|
+
return result
|
|
91
|
+
}
|
|
92
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
struct DeviceTypes {
|
|
2
|
+
static let SIMULATED = "Simulated Glasses"
|
|
3
|
+
static let G1 = "Even Realities G1"
|
|
4
|
+
static let G2 = "Even Realities G2"
|
|
5
|
+
static let LIVE = "Mentra Live"
|
|
6
|
+
static let MACH1 = "Mentra Mach1"
|
|
7
|
+
static let Z100 = "Vuzix Z100"
|
|
8
|
+
static let NEX = "Mentra Display"
|
|
9
|
+
static let FRAME = "Brilliant Frame"
|
|
10
|
+
static let NIMO = "NIMO"
|
|
11
|
+
static let AR99 = "AR99"
|
|
12
|
+
|
|
13
|
+
static let ALL = [
|
|
14
|
+
SIMULATED,
|
|
15
|
+
G1,
|
|
16
|
+
G2,
|
|
17
|
+
MACH1,
|
|
18
|
+
LIVE,
|
|
19
|
+
Z100,
|
|
20
|
+
NEX,
|
|
21
|
+
FRAME,
|
|
22
|
+
NIMO,
|
|
23
|
+
AR99,
|
|
24
|
+
]
|
|
25
|
+
|
|
26
|
+
/// Private init to prevent instantiation
|
|
27
|
+
private init() {}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
struct ControllerTypes {
|
|
31
|
+
static let R1 = "Even Realities R1"
|
|
32
|
+
|
|
33
|
+
static let ALL = [
|
|
34
|
+
R1,
|
|
35
|
+
]
|
|
36
|
+
|
|
37
|
+
/// Private init to prevent instantiation
|
|
38
|
+
private init() {}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
struct ConnTypes {
|
|
42
|
+
static let CONNECTING = "CONNECTING"
|
|
43
|
+
static let CONNECTED = "CONNECTED"
|
|
44
|
+
static let DISCONNECTED = "DISCONNECTED"
|
|
45
|
+
static let SCANNING = "SCANNING"
|
|
46
|
+
static let BONDING = "BONDING"
|
|
47
|
+
|
|
48
|
+
/// Private init to prevent instantiation
|
|
49
|
+
private init() {}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
struct MicTypes {
|
|
53
|
+
static let PHONE_INTERNAL = "phone"
|
|
54
|
+
static let GLASSES_CUSTOM = "glasses"
|
|
55
|
+
static let BLUETOOTH_CLASSIC = "bluetoothClassic"
|
|
56
|
+
static let BLUETOOTH = "bluetooth"
|
|
57
|
+
|
|
58
|
+
static let ALL = [
|
|
59
|
+
PHONE_INTERNAL,
|
|
60
|
+
GLASSES_CUSTOM,
|
|
61
|
+
BLUETOOTH_CLASSIC,
|
|
62
|
+
BLUETOOTH,
|
|
63
|
+
]
|
|
64
|
+
|
|
65
|
+
/// Private init to prevent instantiation
|
|
66
|
+
private init() {}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
enum MicMap {
|
|
70
|
+
static var map: [String: [String]] = [
|
|
71
|
+
"auto": [
|
|
72
|
+
MicTypes.GLASSES_CUSTOM, MicTypes.PHONE_INTERNAL, MicTypes.BLUETOOTH, MicTypes.BLUETOOTH_CLASSIC,
|
|
73
|
+
],
|
|
74
|
+
"glasses": [MicTypes.GLASSES_CUSTOM],
|
|
75
|
+
"phone": [MicTypes.PHONE_INTERNAL, MicTypes.GLASSES_CUSTOM],
|
|
76
|
+
"bluetooth": [MicTypes.BLUETOOTH, MicTypes.BLUETOOTH_CLASSIC, MicTypes.PHONE_INTERNAL, MicTypes.GLASSES_CUSTOM],
|
|
77
|
+
]
|
|
78
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Enums.swift
|
|
3
|
+
// Glassly_Manager
|
|
4
|
+
//
|
|
5
|
+
// Created by Matthew Fosse on 3/3/25.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
import Foundation
|
|
9
|
+
|
|
10
|
+
enum CommandResponse: UInt8 {
|
|
11
|
+
case ACK = 0xC9
|
|
12
|
+
case CONTINUE = 0xCB
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
enum Commands: UInt8 {
|
|
16
|
+
case BLE_EXIT_ALL_FUNCTIONS = 0x18
|
|
17
|
+
case BLE_REQ_INIT = 0x4D
|
|
18
|
+
case BLE_REQ_BATTERY = 0x2C
|
|
19
|
+
case BLE_REQ_HEARTBEAT = 0x25
|
|
20
|
+
case BLE_REQ_EVENAI = 0x4E
|
|
21
|
+
case BLE_REQ_TRANSFER_MIC_DATA = 0xF1
|
|
22
|
+
case BLE_REQ_DEVICE_ORDER = 0xF5
|
|
23
|
+
case BLE_REQ_MIC_ON = 0x0E
|
|
24
|
+
case QUICK_NOTE_ADD = 0x1E
|
|
25
|
+
case CRC_CHECK = 0x16
|
|
26
|
+
case BMP_END = 0x20
|
|
27
|
+
case BRIGHTNESS = 0x01
|
|
28
|
+
case WHITELIST = 0x04
|
|
29
|
+
case SILENT_MODE = 0x03
|
|
30
|
+
case DASHBOARD_LAYOUT_COMMAND = 0x26
|
|
31
|
+
case DASHBOARD_SHOW = 0x06
|
|
32
|
+
case HEAD_UP_ANGLE = 0x0B
|
|
33
|
+
case UNK_2 = 0x39
|
|
34
|
+
case UNK_1 = 0x50
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
enum DeviceOrders: UInt8 {
|
|
38
|
+
case DISPLAY_READY = 0x00
|
|
39
|
+
case TRIGGER_CHANGE_PAGE = 0x01
|
|
40
|
+
case TRIGGER_FOR_AI = 0x17
|
|
41
|
+
case TRIGGER_FOR_STOP_RECORDING = 0x18
|
|
42
|
+
case G1_IS_READY = 0x09
|
|
43
|
+
case HEAD_UP = 0x1E
|
|
44
|
+
case HEAD_DOWN = 0x1F
|
|
45
|
+
case SILENCED = 0x04
|
|
46
|
+
case ACTIVATED = 0x05
|
|
47
|
+
case HEAD_UP2 = 0x02
|
|
48
|
+
case HEAD_DOWN2 = 0x03
|
|
49
|
+
case CASE_REMOVED = 0x07
|
|
50
|
+
case CASE_REMOVED2 = 0x06
|
|
51
|
+
case CASE_OPEN = 0x08
|
|
52
|
+
case CASE_CLOSED = 0x0B
|
|
53
|
+
case CASE_CHARGING_STATUS = 0x0E
|
|
54
|
+
case CASE_CHARGE_INFO = 0x0F
|
|
55
|
+
case DOUBLE_TAP = 0x20
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
enum DisplayStatus: UInt8 {
|
|
59
|
+
case NORMAL_TEXT = 0x30
|
|
60
|
+
case FINAL_TEXT = 0x40
|
|
61
|
+
case MANUAL_PAGE = 0x50
|
|
62
|
+
case ERROR_TEXT = 0x60
|
|
63
|
+
case SIMPLE_TEXT = 0x70
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
public enum DashboardHeight: UInt8 {
|
|
67
|
+
case position0 = 0x00 // Bottom
|
|
68
|
+
case position1 = 0x01
|
|
69
|
+
case position2 = 0x02
|
|
70
|
+
case position3 = 0x03
|
|
71
|
+
case position4 = 0x04
|
|
72
|
+
case position5 = 0x05
|
|
73
|
+
case position6 = 0x06
|
|
74
|
+
case position7 = 0x07
|
|
75
|
+
case position8 = 0x08 // Top
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
public enum DashboardDepth: UInt8 {
|
|
79
|
+
case position0 = 0x00 // Bottom
|
|
80
|
+
case position1 = 0x01
|
|
81
|
+
case position2 = 0x02
|
|
82
|
+
case position3 = 0x03
|
|
83
|
+
case position4 = 0x04
|
|
84
|
+
case position5 = 0x05
|
|
85
|
+
case position6 = 0x06
|
|
86
|
+
case position7 = 0x07
|
|
87
|
+
case position8 = 0x08
|
|
88
|
+
case position9 = 0x09
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
public enum DashboardMode: UInt8 {
|
|
92
|
+
case full = 0x00
|
|
93
|
+
case dual = 0x01
|
|
94
|
+
case minimal = 0x02
|
|
95
|
+
}
|