@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.
Files changed (548) hide show
  1. package/README.md +563 -0
  2. package/android/build.gradle +450 -0
  3. package/android/gradle.properties.example +9 -0
  4. package/android/lc3Lib/CMakeLists.txt +6 -0
  5. package/android/lc3Lib/build.gradle +212 -0
  6. package/android/lc3Lib/proguard-rules.pro +33 -0
  7. package/android/lc3Lib/src/main/AndroidManifest.xml +2 -0
  8. package/android/lc3Lib/src/main/cpp/CMakeLists.txt +8 -0
  9. package/android/lc3Lib/src/main/cpp/google_opus_stuff/CMakeLists.txt +30 -0
  10. package/android/lc3Lib/src/main/cpp/google_opus_stuff/jni/CMakeLists.txt +7 -0
  11. package/android/lc3Lib/src/main/cpp/google_opus_stuff/jni/ogg_opus_encoder.cc +96 -0
  12. package/android/lc3Lib/src/main/cpp/google_opus_stuff/jni/ogg_opus_encoder.h +53 -0
  13. package/android/lc3Lib/src/main/cpp/google_opus_stuff/libogg/Makefile.am +6 -0
  14. package/android/lc3Lib/src/main/cpp/google_opus_stuff/libogg/config_types.h +26 -0
  15. package/android/lc3Lib/src/main/cpp/google_opus_stuff/libogg/config_types.h.in +26 -0
  16. package/android/lc3Lib/src/main/cpp/google_opus_stuff/libogg/ogg.h +209 -0
  17. package/android/lc3Lib/src/main/cpp/google_opus_stuff/libogg/os_types.h +158 -0
  18. package/android/lc3Lib/src/main/cpp/google_opus_stuff/libopus/opus.h +981 -0
  19. package/android/lc3Lib/src/main/cpp/google_opus_stuff/libopus/opus_custom.h +342 -0
  20. package/android/lc3Lib/src/main/cpp/google_opus_stuff/libopus/opus_defines.h +799 -0
  21. package/android/lc3Lib/src/main/cpp/google_opus_stuff/libopus/opus_multistream.h +660 -0
  22. package/android/lc3Lib/src/main/cpp/google_opus_stuff/libopus/opus_projection.h +568 -0
  23. package/android/lc3Lib/src/main/cpp/google_opus_stuff/libopus/opus_types.h +166 -0
  24. package/android/lc3Lib/src/main/cpp/google_opus_stuff/ogg_opus_encoder.cc +268 -0
  25. package/android/lc3Lib/src/main/cpp/google_opus_stuff/ogg_opus_encoder.h +115 -0
  26. package/android/lc3Lib/src/main/cpp/google_opus_stuff/opus_tools/opus_header.h +59 -0
  27. package/android/lc3Lib/src/main/cpp/liblc3/CMakeLists.txt +38 -0
  28. package/android/lc3Lib/src/main/cpp/liblc3/include/lc3.h +309 -0
  29. package/android/lc3Lib/src/main/cpp/liblc3/include/lc3_private.h +162 -0
  30. package/android/lc3Lib/src/main/cpp/liblc3/include/rnnoise.h +114 -0
  31. package/android/lc3Lib/src/main/cpp/liblc3/liblc3/CMakeLists.txt +19 -0
  32. package/android/lc3Lib/src/main/cpp/liblc3/liblc3/attdet.c +92 -0
  33. package/android/lc3Lib/src/main/cpp/liblc3/liblc3/attdet.h +44 -0
  34. package/android/lc3Lib/src/main/cpp/liblc3/liblc3/bits.c +375 -0
  35. package/android/lc3Lib/src/main/cpp/liblc3/liblc3/bits.h +315 -0
  36. package/android/lc3Lib/src/main/cpp/liblc3/liblc3/bwdet.c +129 -0
  37. package/android/lc3Lib/src/main/cpp/liblc3/liblc3/bwdet.h +69 -0
  38. package/android/lc3Lib/src/main/cpp/liblc3/liblc3/common.h +148 -0
  39. package/android/lc3Lib/src/main/cpp/liblc3/liblc3/energy.c +70 -0
  40. package/android/lc3Lib/src/main/cpp/liblc3/liblc3/energy.h +43 -0
  41. package/android/lc3Lib/src/main/cpp/liblc3/liblc3/fastmath.h +158 -0
  42. package/android/lc3Lib/src/main/cpp/liblc3/liblc3/lc3.c +702 -0
  43. package/android/lc3Lib/src/main/cpp/liblc3/liblc3/ltpf.c +893 -0
  44. package/android/lc3Lib/src/main/cpp/liblc3/liblc3/ltpf.h +111 -0
  45. package/android/lc3Lib/src/main/cpp/liblc3/liblc3/ltpf_arm.h +506 -0
  46. package/android/lc3Lib/src/main/cpp/liblc3/liblc3/ltpf_neon.h +281 -0
  47. package/android/lc3Lib/src/main/cpp/liblc3/liblc3/makefile.mk +35 -0
  48. package/android/lc3Lib/src/main/cpp/liblc3/liblc3/mdct.c +452 -0
  49. package/android/lc3Lib/src/main/cpp/liblc3/liblc3/mdct.h +57 -0
  50. package/android/lc3Lib/src/main/cpp/liblc3/liblc3/mdct_neon.h +296 -0
  51. package/android/lc3Lib/src/main/cpp/liblc3/liblc3/meson.build +46 -0
  52. package/android/lc3Lib/src/main/cpp/liblc3/liblc3/plc.c +61 -0
  53. package/android/lc3Lib/src/main/cpp/liblc3/liblc3/plc.h +57 -0
  54. package/android/lc3Lib/src/main/cpp/liblc3/liblc3/sns.c +880 -0
  55. package/android/lc3Lib/src/main/cpp/liblc3/liblc3/sns.h +103 -0
  56. package/android/lc3Lib/src/main/cpp/liblc3/liblc3/spec.c +904 -0
  57. package/android/lc3Lib/src/main/cpp/liblc3/liblc3/spec.h +119 -0
  58. package/android/lc3Lib/src/main/cpp/liblc3/liblc3/tables.c +3457 -0
  59. package/android/lc3Lib/src/main/cpp/liblc3/liblc3/tables.h +94 -0
  60. package/android/lc3Lib/src/main/cpp/liblc3/liblc3/tns.c +457 -0
  61. package/android/lc3Lib/src/main/cpp/liblc3/liblc3/tns.h +99 -0
  62. package/android/lc3Lib/src/main/cpp/liblc3/liblc3.cpp +159 -0
  63. package/android/lc3Lib/src/main/cpp/liblc3/rnnoise/_kiss_fft_guts.h +182 -0
  64. package/android/lc3Lib/src/main/cpp/liblc3/rnnoise/arch.h +261 -0
  65. package/android/lc3Lib/src/main/cpp/liblc3/rnnoise/celt_lpc.c +279 -0
  66. package/android/lc3Lib/src/main/cpp/liblc3/rnnoise/celt_lpc.h +59 -0
  67. package/android/lc3Lib/src/main/cpp/liblc3/rnnoise/common.h +48 -0
  68. package/android/lc3Lib/src/main/cpp/liblc3/rnnoise/compile.sh +3 -0
  69. package/android/lc3Lib/src/main/cpp/liblc3/rnnoise/denoise.c +646 -0
  70. package/android/lc3Lib/src/main/cpp/liblc3/rnnoise/kiss_fft.c +601 -0
  71. package/android/lc3Lib/src/main/cpp/liblc3/rnnoise/kiss_fft.h +203 -0
  72. package/android/lc3Lib/src/main/cpp/liblc3/rnnoise/opus_types.h +159 -0
  73. package/android/lc3Lib/src/main/cpp/liblc3/rnnoise/pitch.c +526 -0
  74. package/android/lc3Lib/src/main/cpp/liblc3/rnnoise/pitch.h +149 -0
  75. package/android/lc3Lib/src/main/cpp/liblc3/rnnoise/rnn.c +178 -0
  76. package/android/lc3Lib/src/main/cpp/liblc3/rnnoise/rnn.h +69 -0
  77. package/android/lc3Lib/src/main/cpp/liblc3/rnnoise/rnn_data.c +11051 -0
  78. package/android/lc3Lib/src/main/cpp/liblc3/rnnoise/rnn_data.h +34 -0
  79. package/android/lc3Lib/src/main/cpp/liblc3/rnnoise/rnn_reader.c +168 -0
  80. package/android/lc3Lib/src/main/cpp/liblc3/rnnoise/rnn_train.py +66 -0
  81. package/android/lc3Lib/src/main/cpp/liblc3/rnnoise/tansig_table.h +45 -0
  82. package/android/lc3Lib/src/main/java/com/glassly/lc3Lib/Lc3Cpp.java +38 -0
  83. package/android/lc3Lib/third_party/CMakeLists.txt +23 -0
  84. package/android/lc3Lib/third_party/CMakeLists_libogg.txt +18 -0
  85. package/android/lc3Lib/third_party/CMakeLists_libopus.txt +18 -0
  86. package/android/lc3Lib/third_party/CMakeLists_opus-tools.txt +23 -0
  87. package/android/lc3Lib/third_party/opus_tools/src/AUTHORS +5 -0
  88. package/android/lc3Lib/third_party/opus_tools/src/CMakeLists.txt +4 -0
  89. package/android/lc3Lib/third_party/opus_tools/src/COPYING +371 -0
  90. package/android/lc3Lib/third_party/opus_tools/src/ChangeLog +3 -0
  91. package/android/lc3Lib/third_party/opus_tools/src/Makefile.am +42 -0
  92. package/android/lc3Lib/third_party/opus_tools/src/Makefile.unix +23 -0
  93. package/android/lc3Lib/third_party/opus_tools/src/NEWS +0 -0
  94. package/android/lc3Lib/third_party/opus_tools/src/README +0 -0
  95. package/android/lc3Lib/third_party/opus_tools/src/autogen.sh +115 -0
  96. package/android/lc3Lib/third_party/opus_tools/src/configure.ac +293 -0
  97. package/android/lc3Lib/third_party/opus_tools/src/src/arch.h +239 -0
  98. package/android/lc3Lib/third_party/opus_tools/src/src/audio-in.c +1046 -0
  99. package/android/lc3Lib/third_party/opus_tools/src/src/diag_range.c +245 -0
  100. package/android/lc3Lib/third_party/opus_tools/src/src/diag_range.h +28 -0
  101. package/android/lc3Lib/third_party/opus_tools/src/src/info_opus.c +320 -0
  102. package/android/lc3Lib/third_party/opus_tools/src/src/info_opus.h +51 -0
  103. package/android/lc3Lib/third_party/opus_tools/src/src/lpc.c +157 -0
  104. package/android/lc3Lib/third_party/opus_tools/src/src/lpc.h +27 -0
  105. package/android/lc3Lib/third_party/opus_tools/src/src/opus_header.c +286 -0
  106. package/android/lc3Lib/third_party/opus_tools/src/src/opus_header.h +59 -0
  107. package/android/lc3Lib/third_party/opus_tools/src/src/opusdec.c +884 -0
  108. package/android/lc3Lib/third_party/opus_tools/src/src/opusenc.c +1021 -0
  109. package/android/lc3Lib/third_party/opus_tools/src/src/opusenc.h +101 -0
  110. package/android/lc3Lib/third_party/opus_tools/src/src/opusinfo.c +639 -0
  111. package/android/lc3Lib/third_party/opus_tools/src/src/opusinfo.h +51 -0
  112. package/android/lc3Lib/third_party/opus_tools/src/src/os_support.h +167 -0
  113. package/android/lc3Lib/third_party/opus_tools/src/src/resample.c +1137 -0
  114. package/android/lc3Lib/third_party/opus_tools/src/src/speex_resampler.h +344 -0
  115. package/android/lc3Lib/third_party/opus_tools/src/src/stack_alloc.h +115 -0
  116. package/android/lc3Lib/third_party/opus_tools/src/src/wav_io.c +125 -0
  117. package/android/lc3Lib/third_party/opus_tools/src/src/wav_io.h +62 -0
  118. package/android/lc3Lib/third_party/opus_tools/src/src/wave_out.c +223 -0
  119. package/android/lc3Lib/third_party/opus_tools/src/src/wave_out.h +60 -0
  120. package/android/settings.gradle +4 -0
  121. package/android/silero/LICENSE.md +17 -0
  122. package/android/silero/build.gradle +50 -0
  123. package/android/silero/proguard-rules.pro +24 -0
  124. package/android/silero/src/androidTest/assets/hello.wav +0 -0
  125. package/android/silero/src/androidTest/java/com/konovalov/vad/silero/VadSileroTest.kt +79 -0
  126. package/android/silero/src/main/assets/LICENSE +21 -0
  127. package/android/silero/src/main/assets/silero_vad.onnx +0 -0
  128. package/android/silero/src/main/java/com/konovalov/vad/silero/Vad.kt +160 -0
  129. package/android/silero/src/main/java/com/konovalov/vad/silero/VadSilero.kt +449 -0
  130. package/android/silero/src/main/java/com/konovalov/vad/silero/config/FrameSize.kt +15 -0
  131. package/android/silero/src/main/java/com/konovalov/vad/silero/config/Mode.kt +14 -0
  132. package/android/silero/src/main/java/com/konovalov/vad/silero/config/SampleRate.kt +12 -0
  133. package/android/silero/src/main/java/com/konovalov/vad/silero/utils/AudioUtils.kt +47 -0
  134. package/android/silero/src/main/java/com/konovalov/vad/silero/utils/TensorMap.kt +41 -0
  135. package/android/silero/src/test/java/com/konovalov/vad/silero/utils/AudioUtilsTest.kt +44 -0
  136. package/android/src/main/AndroidManifest.xml +42 -0
  137. package/android/src/main/assets/G2Firmware/README.md +11 -0
  138. package/android/src/main/java/com/glassly/bluetoothsdk/BluetoothSdk.kt +2325 -0
  139. package/android/src/main/java/com/glassly/bluetoothsdk/BluetoothSdkAnalytics.kt +216 -0
  140. package/android/src/main/java/com/glassly/bluetoothsdk/BluetoothSdkDebug.kt +14 -0
  141. package/android/src/main/java/com/glassly/bluetoothsdk/BluetoothSdkDefaults.kt +7 -0
  142. package/android/src/main/java/com/glassly/bluetoothsdk/BluetoothSdkModule.kt +1088 -0
  143. package/android/src/main/java/com/glassly/bluetoothsdk/Bridge.kt +953 -0
  144. package/android/src/main/java/com/glassly/bluetoothsdk/DeviceManager.kt +2528 -0
  145. package/android/src/main/java/com/glassly/bluetoothsdk/DeviceStore.kt +360 -0
  146. package/android/src/main/java/com/glassly/bluetoothsdk/GeneratedChangelogCatalog.kt +8 -0
  147. package/android/src/main/java/com/glassly/bluetoothsdk/GeneratedReleaseMetadata.kt +11 -0
  148. package/android/src/main/java/com/glassly/bluetoothsdk/LocalNetworkModule.kt +414 -0
  149. package/android/src/main/java/com/glassly/bluetoothsdk/ObservableStore.kt +88 -0
  150. package/android/src/main/java/com/glassly/bluetoothsdk/OtaManifest.kt +191 -0
  151. package/android/src/main/java/com/glassly/bluetoothsdk/ReleaseChangelog.kt +61 -0
  152. package/android/src/main/java/com/glassly/bluetoothsdk/ScopedNetworkReadiness.kt +17 -0
  153. package/android/src/main/java/com/glassly/bluetoothsdk/audio/AudioModels.kt +144 -0
  154. package/android/src/main/java/com/glassly/bluetoothsdk/camera/CameraModels.kt +486 -0
  155. package/android/src/main/java/com/glassly/bluetoothsdk/connection/ConnectionModels.kt +78 -0
  156. package/android/src/main/java/com/glassly/bluetoothsdk/controllers/ControllerManager.kt +158 -0
  157. package/android/src/main/java/com/glassly/bluetoothsdk/controllers/R1.kt +937 -0
  158. package/android/src/main/java/com/glassly/bluetoothsdk/debug/BleTraceLogger.kt +165 -0
  159. package/android/src/main/java/com/glassly/bluetoothsdk/events/BluetoothEvents.kt +178 -0
  160. package/android/src/main/java/com/glassly/bluetoothsdk/internal/MapParsing.kt +140 -0
  161. package/android/src/main/java/com/glassly/bluetoothsdk/net/LocalIpv4.kt +57 -0
  162. package/android/src/main/java/com/glassly/bluetoothsdk/otaserver/LocalOtaServer.kt +304 -0
  163. package/android/src/main/java/com/glassly/bluetoothsdk/otaserver/OtaServerModule.kt +120 -0
  164. package/android/src/main/java/com/glassly/bluetoothsdk/photoreceiver/LocalPhotoReceiverRegistry.java +108 -0
  165. package/android/src/main/java/com/glassly/bluetoothsdk/photoreceiver/LocalPhotoUploadServer.kt +622 -0
  166. package/android/src/main/java/com/glassly/bluetoothsdk/photoreceiver/PhotoReceiverModule.kt +156 -0
  167. package/android/src/main/java/com/glassly/bluetoothsdk/requests/DisplayRequests.kt +56 -0
  168. package/android/src/main/java/com/glassly/bluetoothsdk/services/Foreground.kt +272 -0
  169. package/android/src/main/java/com/glassly/bluetoothsdk/services/PhoneMic.kt +1195 -0
  170. package/android/src/main/java/com/glassly/bluetoothsdk/sgcs/Ar99.java +2653 -0
  171. package/android/src/main/java/com/glassly/bluetoothsdk/sgcs/BesOtaHeartbeatGuard.kt +49 -0
  172. package/android/src/main/java/com/glassly/bluetoothsdk/sgcs/BesOtaProgressMapper.kt +27 -0
  173. package/android/src/main/java/com/glassly/bluetoothsdk/sgcs/G1.kt +3878 -0
  174. package/android/src/main/java/com/glassly/bluetoothsdk/sgcs/G1TextSanitizer.kt +38 -0
  175. package/android/src/main/java/com/glassly/bluetoothsdk/sgcs/G2.kt +6428 -0
  176. package/android/src/main/java/com/glassly/bluetoothsdk/sgcs/G2CfwClassification.kt +49 -0
  177. package/android/src/main/java/com/glassly/bluetoothsdk/sgcs/G2CfwRenderer.kt +1241 -0
  178. package/android/src/main/java/com/glassly/bluetoothsdk/sgcs/G2CfwTextureCache.kt +270 -0
  179. package/android/src/main/java/com/glassly/bluetoothsdk/sgcs/G2FlashProtocol.kt +291 -0
  180. package/android/src/main/java/com/glassly/bluetoothsdk/sgcs/G2Flasher.kt +411 -0
  181. package/android/src/main/java/com/glassly/bluetoothsdk/sgcs/GlasslyBle.java +43189 -0
  182. package/android/src/main/java/com/glassly/bluetoothsdk/sgcs/Mach1.kt +1280 -0
  183. package/android/src/main/java/com/glassly/bluetoothsdk/sgcs/MentraLive.kt +10817 -0
  184. package/android/src/main/java/com/glassly/bluetoothsdk/sgcs/MentraLiveL2capChannel.kt +274 -0
  185. package/android/src/main/java/com/glassly/bluetoothsdk/sgcs/MentraLivePairingAdvertisement.kt +54 -0
  186. package/android/src/main/java/com/glassly/bluetoothsdk/sgcs/MentraNex.kt +2011 -0
  187. package/android/src/main/java/com/glassly/bluetoothsdk/sgcs/Nimo.kt +2532 -0
  188. package/android/src/main/java/com/glassly/bluetoothsdk/sgcs/SGCManager.kt +470 -0
  189. package/android/src/main/java/com/glassly/bluetoothsdk/sgcs/Simulated.kt +228 -0
  190. package/android/src/main/java/com/glassly/bluetoothsdk/sgcs/ar99/ota/Ar99OtaManager.java +566 -0
  191. package/android/src/main/java/com/glassly/bluetoothsdk/sgcs/ar99/ota/OtaByteUtils.java +18 -0
  192. package/android/src/main/java/com/glassly/bluetoothsdk/sgcs/ar99/ota/OtaCommandConstants.java +35 -0
  193. package/android/src/main/java/com/glassly/bluetoothsdk/sgcs/ar99/ota/OtaCrc32Util.java +13 -0
  194. package/android/src/main/java/com/glassly/bluetoothsdk/sgcs/ar99/ota/OtaGattTransport.java +11 -0
  195. package/android/src/main/java/com/glassly/bluetoothsdk/sgcs/ar99/ota/OtaProtocol.java +92 -0
  196. package/android/src/main/java/com/glassly/bluetoothsdk/speakerid/SpeakerIdEngine.kt +525 -0
  197. package/android/src/main/java/com/glassly/bluetoothsdk/status/DeviceStatus.kt +669 -0
  198. package/android/src/main/java/com/glassly/bluetoothsdk/status/RuntimeState.kt +201 -0
  199. package/android/src/main/java/com/glassly/bluetoothsdk/status/WifiHotspotStatus.kt +189 -0
  200. package/android/src/main/java/com/glassly/bluetoothsdk/streaming/StreamModels.kt +518 -0
  201. package/android/src/main/java/com/glassly/bluetoothsdk/stt/STTTools.kt +391 -0
  202. package/android/src/main/java/com/glassly/bluetoothsdk/stt/SherpaOnnxTranscriber.kt +518 -0
  203. package/android/src/main/java/com/glassly/bluetoothsdk/stt/VadGateSpeechPolicy.kt +229 -0
  204. package/android/src/main/java/com/glassly/bluetoothsdk/tts/TTSTools.kt +248 -0
  205. package/android/src/main/java/com/glassly/bluetoothsdk/types/DeviceModels.kt +96 -0
  206. package/android/src/main/java/com/glassly/bluetoothsdk/utils/AES.java +106 -0
  207. package/android/src/main/java/com/glassly/bluetoothsdk/utils/AudioSessionMonitor.kt +189 -0
  208. package/android/src/main/java/com/glassly/bluetoothsdk/utils/AvifExifStripper.java +573 -0
  209. package/android/src/main/java/com/glassly/bluetoothsdk/utils/BitmapJavaUtils.java +169 -0
  210. package/android/src/main/java/com/glassly/bluetoothsdk/utils/BleJsonCompact.java +496 -0
  211. package/android/src/main/java/com/glassly/bluetoothsdk/utils/BlePhotoUploadService.java +677 -0
  212. package/android/src/main/java/com/glassly/bluetoothsdk/utils/BleWireProtocol.java +108 -0
  213. package/android/src/main/java/com/glassly/bluetoothsdk/utils/Constants.kt +46 -0
  214. package/android/src/main/java/com/glassly/bluetoothsdk/utils/G1Text.kt +436 -0
  215. package/android/src/main/java/com/glassly/bluetoothsdk/utils/HeifExifTagReader.java +199 -0
  216. package/android/src/main/java/com/glassly/bluetoothsdk/utils/IncidentLogBleRelayNaming.java +29 -0
  217. package/android/src/main/java/com/glassly/bluetoothsdk/utils/IncidentLogBleUploadService.java +77 -0
  218. package/android/src/main/java/com/glassly/bluetoothsdk/utils/K900LengthCodec.java +115 -0
  219. package/android/src/main/java/com/glassly/bluetoothsdk/utils/K900ProtocolUtils.java +827 -0
  220. package/android/src/main/java/com/glassly/bluetoothsdk/utils/MessageChunkReassembler.java +228 -0
  221. package/android/src/main/java/com/glassly/bluetoothsdk/utils/MessageChunker.java +325 -0
  222. package/android/src/main/java/com/glassly/bluetoothsdk/utils/NexSGCUtils.kt +698 -0
  223. package/android/src/main/java/com/glassly/bluetoothsdk/utils/PhoneAudioMonitor.kt +348 -0
  224. package/android/src/main/java/com/glassly/bluetoothsdk/utils/SmartGlassesConnectionState.java +9 -0
  225. package/android/src/main/java/com/glassly/bluetoothsdk/utils/audio/Ar99OpusPcmDecoder.java +398 -0
  226. package/android/src/main/java/com/glassly/bluetoothsdk/utils/audio/ByteUtilAudioPlayer.java +655 -0
  227. package/android/src/main/java/com/glassly/bluetoothsdk/utils/audio/Lc3Player.java +441 -0
  228. package/android/src/main/java/com/glassly/bluetoothsdk/utils/audio/PCMAudioPlayer.java +431 -0
  229. package/android/src/main/java/com/glassly/bluetoothsdk/utils/audio/PcmStreamPlayer.kt +328 -0
  230. package/android/src/main/res/values/strings.xml +4 -0
  231. package/android/src/test/java/com/glassly/bluetoothsdk/BluetoothSdkExceptionTest.kt +18 -0
  232. package/android/src/test/java/com/glassly/bluetoothsdk/OtaManifestDowngradeTest.kt +86 -0
  233. package/android/src/test/java/com/glassly/bluetoothsdk/OtaStartResponsePolicyTest.kt +30 -0
  234. package/android/src/test/java/com/glassly/bluetoothsdk/ReleaseChangelogTest.kt +13 -0
  235. package/android/src/test/java/com/glassly/bluetoothsdk/ScopedNetworkReadinessTest.kt +39 -0
  236. package/android/src/test/java/com/glassly/bluetoothsdk/StreamStatusEventTest.kt +29 -0
  237. package/android/src/test/java/com/glassly/bluetoothsdk/camera/PhotoRequestTest.kt +141 -0
  238. package/android/src/test/java/com/glassly/bluetoothsdk/otaserver/LocalOtaServerTest.kt +82 -0
  239. package/android/src/test/java/com/glassly/bluetoothsdk/photoreceiver/LocalPhotoReceiverRegistryTest.java +75 -0
  240. package/android/src/test/java/com/glassly/bluetoothsdk/services/ForegroundServiceTypeTest.kt +69 -0
  241. package/android/src/test/java/com/glassly/bluetoothsdk/sgcs/Ar99AdvertisementMatcherTest.java +22 -0
  242. package/android/src/test/java/com/glassly/bluetoothsdk/sgcs/BesOtaHeartbeatGuardTest.kt +73 -0
  243. package/android/src/test/java/com/glassly/bluetoothsdk/sgcs/BesOtaProgressMapperTest.kt +67 -0
  244. package/android/src/test/java/com/glassly/bluetoothsdk/sgcs/EvenRleTest.kt +63 -0
  245. package/android/src/test/java/com/glassly/bluetoothsdk/sgcs/G1TextSanitizerTest.kt +31 -0
  246. package/android/src/test/java/com/glassly/bluetoothsdk/sgcs/G2CfwClassificationTest.kt +89 -0
  247. package/android/src/test/java/com/glassly/bluetoothsdk/sgcs/G2CfwRendererTest.kt +344 -0
  248. package/android/src/test/java/com/glassly/bluetoothsdk/sgcs/G2CfwTextureCacheTest.kt +200 -0
  249. package/android/src/test/java/com/glassly/bluetoothsdk/sgcs/G2FlashProtocolTest.kt +131 -0
  250. package/android/src/test/java/com/glassly/bluetoothsdk/sgcs/MentraLiveGattCharacteristicsTest.kt +39 -0
  251. package/android/src/test/java/com/glassly/bluetoothsdk/sgcs/MentraLivePairingAdvertisementParserTest.kt +133 -0
  252. package/android/src/test/java/com/glassly/bluetoothsdk/sgcs/NimoProtocolTest.kt +333 -0
  253. package/android/src/test/java/com/glassly/bluetoothsdk/utils/AvifExifStripperTest.java +46 -0
  254. package/android/src/test/java/com/glassly/bluetoothsdk/utils/BinaryMessageChunkerTest.java +84 -0
  255. package/android/src/test/java/com/glassly/bluetoothsdk/utils/BleJsonCompactTest.java +319 -0
  256. package/android/src/test/java/com/glassly/bluetoothsdk/utils/BlePhotoUploadServiceTest.java +107 -0
  257. package/android/src/test/java/com/glassly/bluetoothsdk/utils/K900ProtocolUtilsEndiannessTest.java +172 -0
  258. package/android/src/test/java/com/glassly/bluetoothsdk/utils/K900ProtocolUtilsTest.java +24 -0
  259. package/android/src/test/java/com/glassly/bluetoothsdk/utils/PhoneAudioMonitorTest.kt +45 -0
  260. package/android/src/test/resources/avif_with_exif.avif +0 -0
  261. package/app.plugin.js +3 -0
  262. package/build/BluetoothSdk.types.d.ts +1354 -0
  263. package/build/BluetoothSdk.types.d.ts.map +1 -0
  264. package/build/BluetoothSdk.types.js +41 -0
  265. package/build/BluetoothSdk.types.js.map +1 -0
  266. package/build/_internal.d.ts +17 -0
  267. package/build/_internal.d.ts.map +1 -0
  268. package/build/_internal.js +16 -0
  269. package/build/_internal.js.map +1 -0
  270. package/build/_private/BluetoothSdkModule.d.ts +172 -0
  271. package/build/_private/BluetoothSdkModule.d.ts.map +1 -0
  272. package/build/_private/BluetoothSdkModule.js +300 -0
  273. package/build/_private/BluetoothSdkModule.js.map +1 -0
  274. package/build/_private/LocalNetworkModule.d.ts +38 -0
  275. package/build/_private/LocalNetworkModule.d.ts.map +1 -0
  276. package/build/_private/LocalNetworkModule.js +3 -0
  277. package/build/_private/LocalNetworkModule.js.map +1 -0
  278. package/build/_private/cameraRequestPayload.d.ts +4 -0
  279. package/build/_private/cameraRequestPayload.d.ts.map +1 -0
  280. package/build/_private/cameraRequestPayload.js +32 -0
  281. package/build/_private/cameraRequestPayload.js.map +1 -0
  282. package/build/_private/photoRequestPayload.d.ts +6 -0
  283. package/build/_private/photoRequestPayload.d.ts.map +1 -0
  284. package/build/_private/photoRequestPayload.js +86 -0
  285. package/build/_private/photoRequestPayload.js.map +1 -0
  286. package/build/_private/sdkOtaManifest.d.ts +11 -0
  287. package/build/_private/sdkOtaManifest.d.ts.map +1 -0
  288. package/build/_private/sdkOtaManifest.js +15 -0
  289. package/build/_private/sdkOtaManifest.js.map +1 -0
  290. package/build/changelogs.d.ts +7 -0
  291. package/build/changelogs.d.ts.map +1 -0
  292. package/build/changelogs.js +46 -0
  293. package/build/changelogs.js.map +1 -0
  294. package/build/debug.d.ts +3 -0
  295. package/build/debug.d.ts.map +1 -0
  296. package/build/debug.js +8 -0
  297. package/build/debug.js.map +1 -0
  298. package/build/generated/changelogCatalog.d.ts +9 -0
  299. package/build/generated/changelogCatalog.d.ts.map +1 -0
  300. package/build/generated/changelogCatalog.js +12 -0
  301. package/build/generated/changelogCatalog.js.map +1 -0
  302. package/build/generated/releaseMetadata.d.ts +12 -0
  303. package/build/generated/releaseMetadata.d.ts.map +1 -0
  304. package/build/generated/releaseMetadata.js +10 -0
  305. package/build/generated/releaseMetadata.js.map +1 -0
  306. package/build/index.d.ts +6 -0
  307. package/build/index.d.ts.map +1 -0
  308. package/build/index.js +171 -0
  309. package/build/index.js.map +1 -0
  310. package/build/ota-server/OtaServer.types.d.ts +14 -0
  311. package/build/ota-server/OtaServer.types.d.ts.map +1 -0
  312. package/build/ota-server/OtaServer.types.js +2 -0
  313. package/build/ota-server/OtaServer.types.js.map +1 -0
  314. package/build/ota-server/OtaServerModule.d.ts +21 -0
  315. package/build/ota-server/OtaServerModule.d.ts.map +1 -0
  316. package/build/ota-server/OtaServerModule.js +3 -0
  317. package/build/ota-server/OtaServerModule.js.map +1 -0
  318. package/build/ota-server/OtaServerModule.web.d.ts +10 -0
  319. package/build/ota-server/OtaServerModule.web.d.ts.map +1 -0
  320. package/build/ota-server/OtaServerModule.web.js +12 -0
  321. package/build/ota-server/OtaServerModule.web.js.map +1 -0
  322. package/build/ota-server/index.d.ts +3 -0
  323. package/build/ota-server/index.d.ts.map +1 -0
  324. package/build/ota-server/index.js +3 -0
  325. package/build/ota-server/index.js.map +1 -0
  326. package/build/ota-transport/index.d.ts +67 -0
  327. package/build/ota-transport/index.d.ts.map +1 -0
  328. package/build/ota-transport/index.js +58 -0
  329. package/build/ota-transport/index.js.map +1 -0
  330. package/build/photo-receiver/PhotoReceiver.types.d.ts +18 -0
  331. package/build/photo-receiver/PhotoReceiver.types.d.ts.map +1 -0
  332. package/build/photo-receiver/PhotoReceiver.types.js +2 -0
  333. package/build/photo-receiver/PhotoReceiver.types.js.map +1 -0
  334. package/build/photo-receiver/PhotoReceiverModule.d.ts +10 -0
  335. package/build/photo-receiver/PhotoReceiverModule.d.ts.map +1 -0
  336. package/build/photo-receiver/PhotoReceiverModule.js +3 -0
  337. package/build/photo-receiver/PhotoReceiverModule.js.map +1 -0
  338. package/build/photo-receiver/PhotoReceiverModule.web.d.ts +10 -0
  339. package/build/photo-receiver/PhotoReceiverModule.web.d.ts.map +1 -0
  340. package/build/photo-receiver/PhotoReceiverModule.web.js +12 -0
  341. package/build/photo-receiver/PhotoReceiverModule.web.js.map +1 -0
  342. package/build/photo-receiver/index.d.ts +3 -0
  343. package/build/photo-receiver/index.d.ts.map +1 -0
  344. package/build/photo-receiver/index.js +3 -0
  345. package/build/photo-receiver/index.js.map +1 -0
  346. package/build/react/index.d.ts +5 -0
  347. package/build/react/index.d.ts.map +1 -0
  348. package/build/react/index.js +4 -0
  349. package/build/react/index.js.map +1 -0
  350. package/build/react/useBluetooth.d.ts +100 -0
  351. package/build/react/useBluetooth.d.ts.map +1 -0
  352. package/build/react/useBluetooth.js +167 -0
  353. package/build/react/useBluetooth.js.map +1 -0
  354. package/build/react/useBluetoothEvent.d.ts +6 -0
  355. package/build/react/useBluetoothEvent.d.ts.map +1 -0
  356. package/build/react/useBluetoothEvent.js +21 -0
  357. package/build/react/useBluetoothEvent.js.map +1 -0
  358. package/build/react/useBluetoothScan.d.ts +22 -0
  359. package/build/react/useBluetoothScan.d.ts.map +1 -0
  360. package/build/react/useBluetoothScan.js +135 -0
  361. package/build/react/useBluetoothScan.js.map +1 -0
  362. package/build/react/useBluetoothStatus.d.ts +16 -0
  363. package/build/react/useBluetoothStatus.d.ts.map +1 -0
  364. package/build/react/useBluetoothStatus.js +137 -0
  365. package/build/react/useBluetoothStatus.js.map +1 -0
  366. package/build/react/useGlassesConnection.d.ts +29 -0
  367. package/build/react/useGlassesConnection.d.ts.map +1 -0
  368. package/build/react/useGlassesConnection.js +153 -0
  369. package/build/react/useGlassesConnection.js.map +1 -0
  370. package/build/types/index.d.ts +3 -0
  371. package/build/types/index.d.ts.map +1 -0
  372. package/build/types/index.js +2 -0
  373. package/build/types/index.js.map +1 -0
  374. package/expo-module.config.json +14 -0
  375. package/ios/BackgroundOtaArtifactDownloader.swift +125 -0
  376. package/ios/BluetoothSdkModule.swift +1034 -0
  377. package/ios/GlasslyBluetoothSDK.podspec +106 -0
  378. package/ios/LocalIPv4.swift +150 -0
  379. package/ios/LocalOtaServer.swift +309 -0
  380. package/ios/LocalPhotoUploadServer.swift +754 -0
  381. package/ios/OtaServerModule.swift +147 -0
  382. package/ios/Packages/CoreObjC/CoreObjC.xcodeproj/project.pbxproj +213 -0
  383. package/ios/Packages/CoreObjC/PcmConverter.h +22 -0
  384. package/ios/Packages/CoreObjC/PcmConverter.m +266 -0
  385. package/ios/Packages/CoreObjC/attdet.c +92 -0
  386. package/ios/Packages/CoreObjC/attdet.h +44 -0
  387. package/ios/Packages/CoreObjC/bits.c +375 -0
  388. package/ios/Packages/CoreObjC/bits.h +315 -0
  389. package/ios/Packages/CoreObjC/bwdet.c +129 -0
  390. package/ios/Packages/CoreObjC/bwdet.h +69 -0
  391. package/ios/Packages/CoreObjC/common.h +151 -0
  392. package/ios/Packages/CoreObjC/energy.c +70 -0
  393. package/ios/Packages/CoreObjC/energy.h +43 -0
  394. package/ios/Packages/CoreObjC/fastmath.h +158 -0
  395. package/ios/Packages/CoreObjC/include/PcmConverter.h +22 -0
  396. package/ios/Packages/CoreObjC/lc3.c +704 -0
  397. package/ios/Packages/CoreObjC/lc3.h +313 -0
  398. package/ios/Packages/CoreObjC/lc3_cpp.h +283 -0
  399. package/ios/Packages/CoreObjC/lc3_private.h +163 -0
  400. package/ios/Packages/CoreObjC/ltpf.c +905 -0
  401. package/ios/Packages/CoreObjC/ltpf.h +111 -0
  402. package/ios/Packages/CoreObjC/ltpf_arm.h +506 -0
  403. package/ios/Packages/CoreObjC/ltpf_neon.h +281 -0
  404. package/ios/Packages/CoreObjC/makefile.mk +35 -0
  405. package/ios/Packages/CoreObjC/mdct.c +469 -0
  406. package/ios/Packages/CoreObjC/mdct.h +57 -0
  407. package/ios/Packages/CoreObjC/mdct_neon.h +296 -0
  408. package/ios/Packages/CoreObjC/meson.build +61 -0
  409. package/ios/Packages/CoreObjC/plc.c +61 -0
  410. package/ios/Packages/CoreObjC/plc.h +57 -0
  411. package/ios/Packages/CoreObjC/rnnoise.h +114 -0
  412. package/ios/Packages/CoreObjC/sns.c +880 -0
  413. package/ios/Packages/CoreObjC/sns.h +103 -0
  414. package/ios/Packages/CoreObjC/spec.c +907 -0
  415. package/ios/Packages/CoreObjC/spec.h +119 -0
  416. package/ios/Packages/CoreObjC/tables.c +3457 -0
  417. package/ios/Packages/CoreObjC/tables.h +94 -0
  418. package/ios/Packages/CoreObjC/tns.c +457 -0
  419. package/ios/Packages/CoreObjC/tns.h +99 -0
  420. package/ios/Packages/SherpaOnnx/Model/joiner.onnx +0 -0
  421. package/ios/Packages/SherpaOnnx/Model/tokens.txt +502 -0
  422. package/ios/Packages/SherpaOnnx/SherpaOnnx.swift +2383 -0
  423. package/ios/Packages/SherpaOnnx/sherpa-onnx.xcframework/Info.plist +48 -0
  424. package/ios/Packages/SherpaOnnx/sherpa-onnx.xcframework/ios-arm64/Headers/sherpa-onnx/c-api/c-api.h +4689 -0
  425. package/ios/Packages/SherpaOnnx/sherpa-onnx.xcframework/ios-arm64/Headers/sherpa-onnx/c-api/cxx-api.h +2036 -0
  426. package/ios/Packages/SherpaOnnx/sherpa-onnx.xcframework/ios-arm64/libsherpa-onnx.a +0 -0
  427. package/ios/Packages/SherpaOnnx/sherpa-onnx.xcframework/ios-arm64_x86_64-simulator/Headers/sherpa-onnx/c-api/c-api.h +4689 -0
  428. package/ios/Packages/SherpaOnnx/sherpa-onnx.xcframework/ios-arm64_x86_64-simulator/Headers/sherpa-onnx/c-api/cxx-api.h +2036 -0
  429. package/ios/Packages/SherpaOnnx/sherpa-onnx.xcframework/ios-arm64_x86_64-simulator/libsherpa-onnx.a +0 -0
  430. package/ios/Packages/libbz2/module.modulemap +5 -0
  431. package/ios/Packages/libbz2/shim.h +1 -0
  432. package/ios/PhotoReceiverModule.swift +129 -0
  433. package/ios/Source/BluetoothSDK.swift +2303 -0
  434. package/ios/Source/BluetoothSDKDebug.swift +12 -0
  435. package/ios/Source/BluetoothSdkDefaults.swift +29 -0
  436. package/ios/Source/Bridge.swift +708 -0
  437. package/ios/Source/Bridging-Header.h +16 -0
  438. package/ios/Source/DeviceManager.swift +2109 -0
  439. package/ios/Source/DeviceStore.swift +336 -0
  440. package/ios/Source/GeneratedChangelogCatalog.swift +7 -0
  441. package/ios/Source/GeneratedReleaseMetadata.swift +11 -0
  442. package/ios/Source/ObservableStore.swift +118 -0
  443. package/ios/Source/OtaManifest.swift +211 -0
  444. package/ios/Source/PrivacyInfo.xcprivacy +23 -0
  445. package/ios/Source/ReleaseChangelog.swift +65 -0
  446. package/ios/Source/Resources/G2Firmware/README.md +10 -0
  447. package/ios/Source/audio/AudioModels.swift +178 -0
  448. package/ios/Source/audio/PcmStreamPlayer.swift +410 -0
  449. package/ios/Source/camera/CameraModels.swift +866 -0
  450. package/ios/Source/connection/ScanSession.swift +27 -0
  451. package/ios/Source/controllers/ControllerManager.swift +184 -0
  452. package/ios/Source/controllers/R1.swift +829 -0
  453. package/ios/Source/errors/BluetoothSdkError.swift +19 -0
  454. package/ios/Source/events/BluetoothEvents.swift +342 -0
  455. package/ios/Source/internal/BleTraceLogger.swift +192 -0
  456. package/ios/Source/internal/BluetoothAvailability.swift +78 -0
  457. package/ios/Source/internal/BluetoothSdkAnalytics.swift +199 -0
  458. package/ios/Source/internal/ValueParsing.swift +99 -0
  459. package/ios/Source/requests/DisplayRequests.swift +82 -0
  460. package/ios/Source/services/PhoneMic.swift +662 -0
  461. package/ios/Source/sgcs/Ar99.swift +2451 -0
  462. package/ios/Source/sgcs/Frame.swift +649 -0
  463. package/ios/Source/sgcs/G1.swift +2554 -0
  464. package/ios/Source/sgcs/G2.swift +6887 -0
  465. package/ios/Source/sgcs/G2CfwClassification.swift +43 -0
  466. package/ios/Source/sgcs/G2CfwRenderer.swift +1279 -0
  467. package/ios/Source/sgcs/G2CfwTextureCache.swift +233 -0
  468. package/ios/Source/sgcs/G2FlashProtocol.swift +312 -0
  469. package/ios/Source/sgcs/G2Flasher.swift +773 -0
  470. package/ios/Source/sgcs/Mach1.swift +541 -0
  471. package/ios/Source/sgcs/MentraLive.swift +7011 -0
  472. package/ios/Source/sgcs/MentraLiveL2capChannel.swift +183 -0
  473. package/ios/Source/sgcs/MentraLivePairingAdvertisement.swift +64 -0
  474. package/ios/Source/sgcs/MentraNex.swift +3221 -0
  475. package/ios/Source/sgcs/Nimo.swift +1886 -0
  476. package/ios/Source/sgcs/SGCManager.swift +608 -0
  477. package/ios/Source/sgcs/Simulated.swift +274 -0
  478. package/ios/Source/sgcs/ar99/ota/Ar99OtaManager.swift +637 -0
  479. package/ios/Source/sgcs/glassly_ble.pb.swift +4354 -0
  480. package/ios/Source/speakerid/SpeakerIdEngine.swift +573 -0
  481. package/ios/Source/status/DeviceStatus.swift +981 -0
  482. package/ios/Source/status/RuntimeState.swift +359 -0
  483. package/ios/Source/status/WifiHotspotStatus.swift +345 -0
  484. package/ios/Source/streaming/StreamModels.swift +693 -0
  485. package/ios/Source/stt/STTTools.swift +191 -0
  486. package/ios/Source/stt/SherpaOnnxTranscriber.swift +466 -0
  487. package/ios/Source/tts/TTSTools.swift +171 -0
  488. package/ios/Source/types/DeviceModels.swift +177 -0
  489. package/ios/Source/utils/AudioSessionMonitor.swift +283 -0
  490. package/ios/Source/utils/BinaryCodec.swift +61 -0
  491. package/ios/Source/utils/BleJsonCompact.swift +405 -0
  492. package/ios/Source/utils/BleWireProtocol.swift +92 -0
  493. package/ios/Source/utils/Constants.swift +78 -0
  494. package/ios/Source/utils/Enums.swift +95 -0
  495. package/ios/Source/utils/G1Text.swift +2096 -0
  496. package/ios/Source/utils/JSCExperiment.swift +241 -0
  497. package/ios/Source/utils/MemoryMonitor.swift +44 -0
  498. package/ios/Source/utils/MessageChunkReassembler.swift +190 -0
  499. package/ios/Source/utils/MessageChunker.swift +294 -0
  500. package/ios/Source/utils/Models.swift +135 -0
  501. package/ios/Source/utils/PhoneAudioMonitor.swift +230 -0
  502. package/ios/Source/utils/TarBz2Extractor.swift +257 -0
  503. package/ios/Tests/BluetoothSDKTests/G2CfwClassificationTests.swift +78 -0
  504. package/ios/Tests/BluetoothSDKTests/G2CfwRendererTests.swift +372 -0
  505. package/ios/Tests/BluetoothSDKTests/G2CfwTextureCacheTests.swift +162 -0
  506. package/ios/Tests/BluetoothSDKTests/G2FlashProtocolTests.swift +182 -0
  507. package/ios/Tests/MentraLivePairingAdvertisementTests.swift +160 -0
  508. package/ios/Tests/ReleaseChangelogTests.swift +13 -0
  509. package/package.json +129 -0
  510. package/plugin/build/index.d.ts +10 -0
  511. package/plugin/build/index.js +12 -0
  512. package/plugin/build/withAndroid.d.ts +3 -0
  513. package/plugin/build/withAndroid.js +190 -0
  514. package/plugin/build/withIos.d.ts +5 -0
  515. package/plugin/build/withIos.js +108 -0
  516. package/scripts/inject-ios-sdk-version.mjs +65 -0
  517. package/scripts/public-ota-api.test.mjs +37 -0
  518. package/scripts/verify-release-package.mjs +45 -0
  519. package/scripts/write-release-metadata.mjs +152 -0
  520. package/scripts/write-release-metadata.test.mjs +37 -0
  521. package/src/BluetoothSdk.types.ts +1623 -0
  522. package/src/_internal.ts +16 -0
  523. package/src/_private/BluetoothSdkModule.ts +684 -0
  524. package/src/_private/LocalNetworkModule.ts +50 -0
  525. package/src/_private/cameraRequestPayload.ts +34 -0
  526. package/src/_private/photoRequestPayload.ts +90 -0
  527. package/src/_private/sdkOtaManifest.ts +18 -0
  528. package/src/changelogs.ts +46 -0
  529. package/src/debug.ts +9 -0
  530. package/src/generated/changelogCatalog.ts +13 -0
  531. package/src/generated/releaseMetadata.ts +20 -0
  532. package/src/index.ts +321 -0
  533. package/src/ota-server/OtaServer.types.ts +10 -0
  534. package/src/ota-server/OtaServerModule.ts +23 -0
  535. package/src/ota-server/OtaServerModule.web.ts +17 -0
  536. package/src/ota-server/index.ts +2 -0
  537. package/src/ota-transport/index.ts +116 -0
  538. package/src/photo-receiver/PhotoReceiver.types.ts +20 -0
  539. package/src/photo-receiver/PhotoReceiverModule.ts +11 -0
  540. package/src/photo-receiver/PhotoReceiverModule.web.ts +17 -0
  541. package/src/photo-receiver/index.ts +2 -0
  542. package/src/react/index.ts +21 -0
  543. package/src/react/useBluetooth.ts +309 -0
  544. package/src/react/useBluetoothEvent.ts +35 -0
  545. package/src/react/useBluetoothScan.ts +173 -0
  546. package/src/react/useBluetoothStatus.ts +180 -0
  547. package/src/react/useGlassesConnection.ts +202 -0
  548. package/src/types/index.ts +12 -0
@@ -0,0 +1,19 @@
1
+ import Foundation
2
+
3
+ public struct BluetoothSdkError: Error, LocalizedError, CustomStringConvertible {
4
+ public let code: String
5
+ public let message: String
6
+
7
+ public init(code: String, message: String) {
8
+ self.code = code
9
+ self.message = message
10
+ }
11
+
12
+ public var errorDescription: String? {
13
+ message
14
+ }
15
+
16
+ public var description: String {
17
+ "\(code): \(message)"
18
+ }
19
+ }
@@ -0,0 +1,342 @@
1
+ import Foundation
2
+
3
+ public struct ButtonPressEvent: CustomStringConvertible {
4
+ public let buttonId: String
5
+ public let pressType: String
6
+ public let timestamp: Int?
7
+
8
+ public init(buttonId: String, pressType: String, timestamp: Int? = nil) {
9
+ self.buttonId = buttonId
10
+ self.pressType = pressType
11
+ self.timestamp = timestamp
12
+ }
13
+
14
+ public var description: String {
15
+ "ButtonPressEvent(buttonId: \(buttonId), pressType: \(pressType))"
16
+ }
17
+ }
18
+
19
+ public struct TouchEvent: CustomStringConvertible {
20
+ public let values: [String: Any]
21
+
22
+ public init(values: [String: Any]) {
23
+ self.values = values
24
+ }
25
+
26
+ public var deviceModel: String? {
27
+ stringValue(values, "deviceModel")
28
+ }
29
+
30
+ public var gestureName: String? {
31
+ stringValue(values, "gestureName")
32
+ }
33
+
34
+ public var timestamp: Int? {
35
+ intValue(values["timestamp"])
36
+ }
37
+
38
+ public var isSwipe: Bool {
39
+ gestureName?.localizedCaseInsensitiveContains("swipe") == true
40
+ }
41
+
42
+ public var description: String {
43
+ "TouchEvent(gestureName: \(gestureName ?? "unknown"))"
44
+ }
45
+ }
46
+
47
+ public struct VoiceActivityDetectionStatusEvent: CustomStringConvertible {
48
+ public let voiceActivityDetectionEnabled: Bool
49
+ public let values: [String: Any]
50
+
51
+ public init(values: [String: Any]) {
52
+ voiceActivityDetectionEnabled =
53
+ boolValue(values, "voiceActivityDetectionEnabled") ?? BluetoothSdkDefaults.voiceActivityDetectionEnabled
54
+ self.values = values
55
+ }
56
+
57
+ public var description: String {
58
+ "VoiceActivityDetectionStatusEvent(voiceActivityDetectionEnabled: \(voiceActivityDetectionEnabled))"
59
+ }
60
+ }
61
+
62
+ public struct SpeakingStatusEvent: CustomStringConvertible {
63
+ public let speaking: Bool
64
+ public let values: [String: Any]
65
+
66
+ public init(values: [String: Any]) {
67
+ speaking = boolValue(values, "speaking") ?? false
68
+ self.values = values
69
+ }
70
+
71
+ public var description: String {
72
+ "SpeakingStatusEvent(speaking: \(speaking))"
73
+ }
74
+ }
75
+
76
+ public struct MicHealthEvent: CustomStringConvertible {
77
+ public let reason: String
78
+ public let sequenceGapEvents: Int
79
+ public let decodeFailures: Int
80
+ public let lastLc3ReceivedAt: Int?
81
+ public let lastPcmProducedAt: Int?
82
+ public let timestamp: Int
83
+ public let values: [String: Any]
84
+
85
+ public init(values: [String: Any]) {
86
+ reason = stringValue(values, "reason") ?? ""
87
+ sequenceGapEvents = intValue(values["sequenceGapEvents"]) ?? 0
88
+ decodeFailures = intValue(values["decodeFailures"]) ?? 0
89
+ lastLc3ReceivedAt = intValue(values["lastLc3ReceivedAt"])
90
+ lastPcmProducedAt = intValue(values["lastPcmProducedAt"])
91
+ timestamp = intValue(values["timestamp"]) ?? Int(Date().timeIntervalSince1970 * 1000)
92
+ self.values = values
93
+ }
94
+
95
+ public var description: String {
96
+ "MicHealthEvent(reason: \(reason), sequenceGapEvents: \(sequenceGapEvents), decodeFailures: \(decodeFailures))"
97
+ }
98
+ }
99
+
100
+ public struct OtaStartAckEvent: CustomStringConvertible {
101
+ public let timestamp: Int?
102
+ public let values: [String: Any]
103
+
104
+ public init(values: [String: Any]) {
105
+ timestamp = intValue(values["timestamp"])
106
+ self.values = values
107
+ }
108
+
109
+ public var description: String {
110
+ "OtaStartAckEvent(timestamp: \(timestamp.map(String.init) ?? "unknown"))"
111
+ }
112
+ }
113
+
114
+ public struct OtaStatusEvent: CustomStringConvertible {
115
+ public let sessionId: String
116
+ public let totalSteps: Int
117
+ public let currentStep: Int
118
+ public let stepType: String
119
+ public let phase: String
120
+ public let stepPercent: Int
121
+ public let overallPercent: Int
122
+ public let status: String
123
+ public let errorMessage: String?
124
+ public let glassesTimeMs: Int?
125
+ public let values: [String: Any]
126
+
127
+ public init(values: [String: Any]) {
128
+ sessionId = stringValue(values, "session_id") ?? ""
129
+ totalSteps = intValue(values["total_steps"]) ?? 0
130
+ currentStep = intValue(values["current_step"]) ?? 0
131
+ stepType = stringValue(values, "step_type") ?? ""
132
+ phase = stringValue(values, "phase") ?? ""
133
+ stepPercent = intValue(values["step_percent"]) ?? 0
134
+ overallPercent = intValue(values["overall_percent"]) ?? 0
135
+ status = stringValue(values, "status") ?? ""
136
+ errorMessage = stringValue(values, "error_message")
137
+ glassesTimeMs = intValue(values["glasses_time_ms"])
138
+ self.values = values
139
+ }
140
+
141
+ public var description: String {
142
+ "OtaStatusEvent(status: \(status), overallPercent: \(overallPercent))"
143
+ }
144
+ }
145
+
146
+ public struct OtaQueryResult: CustomStringConvertible {
147
+ public let values: [String: Any]
148
+
149
+ public init(values: [String: Any]) {
150
+ self.values = values
151
+ }
152
+
153
+ public var type: String {
154
+ stringValue(values, "type") ?? ""
155
+ }
156
+
157
+ public var status: String? {
158
+ stringValue(values, "status")
159
+ }
160
+
161
+ public var description: String {
162
+ "OtaQueryResult(type: \(type), status: \(status ?? "unknown"))"
163
+ }
164
+ }
165
+
166
+ public struct SettingsAckEvent: CustomStringConvertible {
167
+ public let values: [String: Any]
168
+
169
+ public init(values: [String: Any]) {
170
+ self.values = values
171
+ }
172
+
173
+ public var requestId: String {
174
+ stringValue(values, "requestId") ?? ""
175
+ }
176
+
177
+ public var setting: String {
178
+ stringValue(values, "setting") ?? ""
179
+ }
180
+
181
+ public var status: String {
182
+ stringValue(values, "status") ?? "applied"
183
+ }
184
+
185
+ public var timestamp: Int {
186
+ intValue(values["timestamp"]) ?? Int(Date().timeIntervalSince1970 * 1000)
187
+ }
188
+
189
+ public var fov: Int? {
190
+ intValue(values["fov"])
191
+ }
192
+
193
+ public var roiPosition: Int? {
194
+ intValue(values["roiPosition"]) ?? intValue(values["roi_position"])
195
+ }
196
+
197
+ public var hardwareApplied: Bool {
198
+ boolValue(values, "hardwareApplied") ?? boolValue(values, "hardware_applied") ?? false
199
+ }
200
+
201
+ public var errorCode: String? {
202
+ stringValue(values, "errorCode")
203
+ }
204
+
205
+ public var errorMessage: String? {
206
+ stringValue(values, "errorMessage")
207
+ }
208
+
209
+ public var description: String {
210
+ "SettingsAckEvent(setting: \(setting), status: \(status))"
211
+ }
212
+ }
213
+
214
+ public struct RgbLedControlResponseEvent: CustomStringConvertible {
215
+ public let values: [String: Any]
216
+
217
+ public init(values: [String: Any]) {
218
+ self.values = values
219
+ }
220
+
221
+ public var requestId: String {
222
+ stringValue(values, "requestId") ?? ""
223
+ }
224
+
225
+ public var state: String {
226
+ stringValue(values, "state") ?? "error"
227
+ }
228
+
229
+ public var errorCode: String? {
230
+ stringValue(values, "errorCode")
231
+ }
232
+
233
+ public var description: String {
234
+ "RgbLedControlResponseEvent(requestId: \(requestId), state: \(state))"
235
+ }
236
+ }
237
+
238
+ public enum BluetoothEvent: CustomStringConvertible {
239
+ case buttonPress(ButtonPressEvent)
240
+ case touch(TouchEvent)
241
+ case voiceActivityDetectionStatus(VoiceActivityDetectionStatusEvent)
242
+ case speakingStatus(SpeakingStatusEvent)
243
+ case micHealth(MicHealthEvent)
244
+ case wifiStatus(WifiStatusEvent)
245
+ case hotspotStatus(HotspotStatusEvent)
246
+ case hotspotError(HotspotErrorEvent)
247
+ case photoResponse(PhotoResponseEvent)
248
+ case photoStatus(PhotoStatusEvent)
249
+ case cameraStatus(CameraStatusEvent)
250
+ case videoRecordingStatus(VideoRecordingStatusEvent)
251
+ case mediaUpload(MediaUploadEvent)
252
+ case rgbLedControlResponse(RgbLedControlResponseEvent)
253
+ case streamStatus(StreamStatusEvent)
254
+ case keepAliveAck(KeepAliveAckEvent)
255
+ case otaStartAck(OtaStartAckEvent)
256
+ case otaStatus(OtaStatusEvent)
257
+ case settingsAck(SettingsAckEvent)
258
+ case versionInfo(VersionInfoResult)
259
+ case localTranscription(LocalTranscriptionEvent)
260
+ case raw(name: String, values: [String: Any])
261
+
262
+ public var description: String {
263
+ switch self {
264
+ case let .buttonPress(event):
265
+ event.description
266
+ case let .touch(event):
267
+ event.description
268
+ case let .voiceActivityDetectionStatus(event):
269
+ event.description
270
+ case let .speakingStatus(event):
271
+ event.description
272
+ case let .micHealth(event):
273
+ event.description
274
+ case let .wifiStatus(event):
275
+ event.description
276
+ case let .hotspotStatus(event):
277
+ event.description
278
+ case let .hotspotError(event):
279
+ event.description
280
+ case let .photoResponse(event):
281
+ event.description
282
+ case let .photoStatus(event):
283
+ event.description
284
+ case let .cameraStatus(event):
285
+ event.description
286
+ case let .videoRecordingStatus(event):
287
+ event.description
288
+ case let .mediaUpload(event):
289
+ event.description
290
+ case let .rgbLedControlResponse(event):
291
+ event.description
292
+ case let .streamStatus(event):
293
+ event.description
294
+ case let .keepAliveAck(event):
295
+ event.description
296
+ case let .otaStartAck(event):
297
+ event.description
298
+ case let .otaStatus(event):
299
+ event.description
300
+ case let .settingsAck(event):
301
+ event.description
302
+ case let .versionInfo(event):
303
+ event.description
304
+ case let .localTranscription(event):
305
+ event.description
306
+ case let .raw(name, values):
307
+ "\(name): \(values)"
308
+ }
309
+ }
310
+ }
311
+
312
+ @MainActor
313
+ public protocol BluetoothSDKDelegate: AnyObject {
314
+ func bluetoothSDK(_ sdk: BluetoothSDK, didUpdate state: BluetoothState)
315
+ func bluetoothSDK(_ sdk: BluetoothSDK, didUpdateGlasses glasses: GlassesRuntimeState)
316
+ func bluetoothSDK(_ sdk: BluetoothSDK, didUpdateSdkState sdkState: PhoneSdkRuntimeState)
317
+ func bluetoothSDK(_ sdk: BluetoothSDK, didUpdateScan scan: BluetoothScanState)
318
+ func bluetoothSDK(_ sdk: BluetoothSDK, didDiscover device: Device)
319
+ func bluetoothSDK(_ sdk: BluetoothSDK, didStopScan reason: ScanStopReason)
320
+ func bluetoothSDK(_ sdk: BluetoothSDK, didReceive event: BluetoothEvent)
321
+ func bluetoothSDK(_ sdk: BluetoothSDK, didReceiveMicPcm event: MicPcmEvent)
322
+ func bluetoothSDK(_ sdk: BluetoothSDK, didReceiveMicLc3 event: MicLc3Event)
323
+ func bluetoothSDK(_ sdk: BluetoothSDK, didChangeDefaultDevice device: Device?)
324
+ func bluetoothSDK(_ sdk: BluetoothSDK, didLog message: String)
325
+ func bluetoothSDK(_ sdk: BluetoothSDK, didFail error: BluetoothSdkError)
326
+ }
327
+
328
+ @MainActor
329
+ public extension BluetoothSDKDelegate {
330
+ func bluetoothSDK(_: BluetoothSDK, didUpdate _: BluetoothState) {}
331
+ func bluetoothSDK(_: BluetoothSDK, didUpdateGlasses _: GlassesRuntimeState) {}
332
+ func bluetoothSDK(_: BluetoothSDK, didUpdateSdkState _: PhoneSdkRuntimeState) {}
333
+ func bluetoothSDK(_: BluetoothSDK, didUpdateScan _: BluetoothScanState) {}
334
+ func bluetoothSDK(_: BluetoothSDK, didDiscover _: Device) {}
335
+ func bluetoothSDK(_: BluetoothSDK, didStopScan _: ScanStopReason) {}
336
+ func bluetoothSDK(_: BluetoothSDK, didReceive _: BluetoothEvent) {}
337
+ func bluetoothSDK(_: BluetoothSDK, didReceiveMicPcm _: MicPcmEvent) {}
338
+ func bluetoothSDK(_: BluetoothSDK, didReceiveMicLc3 _: MicLc3Event) {}
339
+ func bluetoothSDK(_: BluetoothSDK, didChangeDefaultDevice _: Device?) {}
340
+ func bluetoothSDK(_: BluetoothSDK, didLog _: String) {}
341
+ func bluetoothSDK(_: BluetoothSDK, didFail _: BluetoothSdkError) {}
342
+ }
@@ -0,0 +1,192 @@
1
+ import Foundation
2
+ import os.log
3
+ import UIKit
4
+
5
+ enum BleTraceLogger {
6
+ private static let log = OSLog(subsystem: "com.glassly.bluetoothsdk", category: "GlasslyBleTrace")
7
+ private static let maxPayloadChars = 3000
8
+ private static let k900Type = "k900"
9
+ private static let sensitiveKeyParts = ["password", "pass", "token", "secret", "authorization", "auth", "email", "serial"]
10
+
11
+ static func logJson(
12
+ direction: String,
13
+ layer: String,
14
+ payload: [String: Any]?,
15
+ bytes: Int? = nil,
16
+ sourceFile: String = #fileID,
17
+ sourceFunction: String = #function,
18
+ sourceLine: Int = #line
19
+ ) {
20
+ guard let payload else {
21
+ emit(format(
22
+ direction: direction,
23
+ layer: layer,
24
+ source: source(file: sourceFile, function: sourceFunction, line: sourceLine),
25
+ type: "null",
26
+ bytes: bytes,
27
+ payload: "null"
28
+ ))
29
+ return
30
+ }
31
+
32
+ let sanitized = sanitizeDictionary(payload)
33
+ emit(format(
34
+ direction: direction,
35
+ layer: layer,
36
+ source: source(file: sourceFile, function: sourceFunction, line: sourceLine),
37
+ type: extractType(from: payload),
38
+ bytes: bytes,
39
+ payload: jsonString(sanitized)
40
+ ))
41
+ }
42
+
43
+ static func logMap(
44
+ direction: String,
45
+ layer: String,
46
+ type: String?,
47
+ payload: [String: Any],
48
+ bytes: Int? = nil,
49
+ sourceFile: String = #fileID,
50
+ sourceFunction: String = #function,
51
+ sourceLine: Int = #line
52
+ ) {
53
+ let sanitized = sanitizeDictionary(payload)
54
+ emit(format(
55
+ direction: direction,
56
+ layer: layer,
57
+ source: source(file: sourceFile, function: sourceFunction, line: sourceLine),
58
+ type: type ?? extractType(from: sanitized),
59
+ bytes: bytes,
60
+ payload: jsonString(sanitized)
61
+ ))
62
+ }
63
+
64
+ static func logLifecycle(component: String, event: String, extra: [String: Any] = [:]) {
65
+ var payload: [String: Any] = [
66
+ "event": event,
67
+ "component": component,
68
+ "pid": ProcessInfo.processInfo.processIdentifier,
69
+ "model": UIDevice.current.model,
70
+ "systemVersion": UIDevice.current.systemVersion,
71
+ ]
72
+ for (key, value) in extra {
73
+ payload[key] = value
74
+ }
75
+ logMap(direction: "phone_app", layer: "app_lifecycle", type: event, payload: payload)
76
+ }
77
+
78
+ private static func emit(_ line: String) {
79
+ os_log("%{public}@", log: log, type: .info, line)
80
+ }
81
+
82
+ private static func format(
83
+ direction: String,
84
+ layer: String,
85
+ source: String,
86
+ type: String,
87
+ bytes: Int?,
88
+ payload: String
89
+ ) -> String {
90
+ let bytesText = bytes.map { " bytes=\($0)" } ?? ""
91
+ return "BLE_TRACE direction=\(direction) layer=\(layer) source=\(source) type=\(type)\(bytesText) payload=\(truncate(payload))"
92
+ }
93
+
94
+ private static func extractType(from payload: [String: Any]) -> String {
95
+ if let type = payload["type"] as? String, !type.isEmpty {
96
+ return type
97
+ }
98
+ if let cValue = payload["C"] as? String, !cValue.isEmpty {
99
+ if let data = cValue.data(using: .utf8),
100
+ let inner = try? JSONSerialization.jsonObject(with: data) as? [String: Any],
101
+ let type = inner["type"] as? String,
102
+ !type.isEmpty
103
+ {
104
+ return type
105
+ }
106
+ return extractK900Type(cValue)
107
+ }
108
+ return "unknown"
109
+ }
110
+
111
+ private static func extractK900Type(_ value: String) -> String {
112
+ value == "sr_log" ? "\(k900Type):sr_log" : k900Type
113
+ }
114
+
115
+ private static func sanitizeDictionary(_ value: [String: Any]) -> [String: Any] {
116
+ var output: [String: Any] = [:]
117
+ for (key, child) in value {
118
+ output[key] = sanitizeValue(key: key, value: child)
119
+ }
120
+ return output
121
+ }
122
+
123
+ private static func sanitizeArray(_ value: [Any]) -> [Any] {
124
+ value.map { sanitizeValue(key: nil, value: $0) }
125
+ }
126
+
127
+ private static func sanitizeValue(key: String?, value: Any) -> Any {
128
+ if let key, sensitiveKeyParts.contains(where: { key.localizedCaseInsensitiveContains($0) }) {
129
+ return "<redacted>"
130
+ }
131
+
132
+ if key == "C", let stringValue = value as? String {
133
+ if let data = stringValue.data(using: .utf8),
134
+ let parsed = try? JSONSerialization.jsonObject(with: data)
135
+ {
136
+ return jsonString(sanitizeJsonValue(parsed))
137
+ }
138
+ return sanitizeK900Command(stringValue)
139
+ }
140
+
141
+ return sanitizeJsonValue(value)
142
+ }
143
+
144
+ private static func sanitizeJsonValue(_ value: Any) -> Any {
145
+ switch value {
146
+ case let dictionary as [String: Any]:
147
+ return sanitizeDictionary(dictionary)
148
+ case let array as [Any]:
149
+ return sanitizeArray(array)
150
+ case let data as Data:
151
+ return "<data \(data.count) bytes>"
152
+ case let url as URL:
153
+ return url.absoluteString
154
+ case let bool as Bool:
155
+ return bool
156
+ case let number as NSNumber:
157
+ return number
158
+ case let string as String:
159
+ return string
160
+ case _ as NSNull:
161
+ return NSNull()
162
+ default:
163
+ return String(describing: value)
164
+ }
165
+ }
166
+
167
+ private static func sanitizeK900Command(_ value: String) -> String {
168
+ value == "sr_log" ? value : "<non-json C payload>"
169
+ }
170
+
171
+ private static func jsonString(_ value: Any) -> String {
172
+ guard JSONSerialization.isValidJSONObject(value),
173
+ let data = try? JSONSerialization.data(withJSONObject: value),
174
+ let string = String(data: data, encoding: .utf8)
175
+ else {
176
+ return String(describing: value)
177
+ }
178
+ return string
179
+ }
180
+
181
+ private static func source(file: String, function: String, line: Int) -> String {
182
+ "\(function)(\(file):\(line))"
183
+ }
184
+
185
+ private static func truncate(_ value: String) -> String {
186
+ guard value.count > maxPayloadChars else {
187
+ return value
188
+ }
189
+ let endIndex = value.index(value.startIndex, offsetBy: maxPayloadChars)
190
+ return "\(value[..<endIndex])...(truncated \(value.count - maxPayloadChars) chars)"
191
+ }
192
+ }
@@ -0,0 +1,78 @@
1
+ import CoreBluetooth
2
+ import Foundation
3
+
4
+ final class BluetoothAvailability: NSObject, CBCentralManagerDelegate {
5
+ static let shared = BluetoothAvailability()
6
+
7
+ private var centralManager: CBCentralManager?
8
+ private var state: CBManagerState = .unknown
9
+ private var listeners: [UUID: (CBManagerState) -> Void] = [:]
10
+
11
+ override private init() {
12
+ super.init()
13
+ centralManager = CBCentralManager(
14
+ delegate: self,
15
+ queue: .main,
16
+ options: [CBCentralManagerOptionShowPowerAlertKey: false]
17
+ )
18
+ state = centralManager?.state ?? .unknown
19
+ }
20
+
21
+ func centralManagerDidUpdateState(_ central: CBCentralManager) {
22
+ state = central.state
23
+ for listener in Array(listeners.values) {
24
+ listener(state)
25
+ }
26
+ }
27
+
28
+ @discardableResult
29
+ func addStateListener(_ listener: @escaping (CBManagerState) -> Void) -> UUID {
30
+ // `listeners` is unsynchronized; it is only safe because the central
31
+ // manager queue is `.main` and all callers are main-thread bound.
32
+ dispatchPrecondition(condition: .onQueue(.main))
33
+ let id = UUID()
34
+ listeners[id] = listener
35
+ listener(state)
36
+ return id
37
+ }
38
+
39
+ func removeStateListener(_ id: UUID) {
40
+ dispatchPrecondition(condition: .onQueue(.main))
41
+ listeners[id] = nil
42
+ }
43
+
44
+ func requirePoweredOn(operation: String) throws {
45
+ if let current = centralManager?.state {
46
+ state = current
47
+ }
48
+ switch state {
49
+ case .poweredOn:
50
+ return
51
+ case .poweredOff:
52
+ throw BluetoothSdkError(
53
+ code: "bluetooth_powered_off",
54
+ message: "Turn on phone Bluetooth to \(operation)."
55
+ )
56
+ case .unauthorized:
57
+ throw BluetoothSdkError(
58
+ code: "bluetooth_unauthorized",
59
+ message: "Allow Bluetooth access to \(operation)."
60
+ )
61
+ case .unsupported:
62
+ throw BluetoothSdkError(
63
+ code: "bluetooth_unsupported",
64
+ message: "This phone does not support Bluetooth."
65
+ )
66
+ case .resetting, .unknown:
67
+ throw BluetoothSdkError(
68
+ code: "bluetooth_not_ready",
69
+ message: "Bluetooth is not ready yet. Try again."
70
+ )
71
+ @unknown default:
72
+ throw BluetoothSdkError(
73
+ code: "bluetooth_unavailable",
74
+ message: "Bluetooth is unavailable. Try again."
75
+ )
76
+ }
77
+ }
78
+ }