@mentra/bluetooth-sdk 0.1.5 → 0.1.7
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 +45 -27
- package/android/build.gradle +2 -9
- package/android/src/main/java/com/mentra/bluetoothsdk/BluetoothSdkModule.kt +53 -36
- package/android/src/main/java/com/mentra/bluetoothsdk/Bridge.kt +22 -9
- package/android/src/main/java/com/mentra/bluetoothsdk/DeviceManager.kt +25 -36
- package/android/src/main/java/com/mentra/bluetoothsdk/DeviceStore.kt +9 -4
- package/android/src/main/java/com/mentra/bluetoothsdk/MentraBluetoothSdk.kt +68 -56
- package/android/src/main/java/com/mentra/bluetoothsdk/audio/AudioModels.kt +125 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/camera/CameraModels.kt +209 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/connection/ConnectionModels.kt +78 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/controllers/ControllerManager.kt +4 -3
- package/android/src/main/java/com/mentra/bluetoothsdk/controllers/R1.kt +2 -1
- package/android/src/main/java/com/mentra/bluetoothsdk/events/BluetoothEvents.kt +72 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/internal/MapParsing.kt +132 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/requests/DisplayRequests.kt +39 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/G1.java +1 -1
- package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/G2.kt +2 -1
- package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/Mach1.java +1 -1
- package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/MentraLive.java +168 -10
- package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/MentraNex.kt +1 -1
- package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/SGCManager.kt +7 -3
- package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/Simulated.kt +3 -1
- package/android/src/main/java/com/mentra/bluetoothsdk/status/DeviceStatus.kt +607 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/status/RuntimeState.kt +201 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/status/WifiHotspotStatus.kt +173 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/streaming/StreamModels.kt +348 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/stt/SherpaOnnxTranscriber.kt +1 -3
- package/android/src/main/java/com/mentra/bluetoothsdk/types/DeviceModels.kt +75 -0
- package/build/BluetoothSdk.types.d.ts +46 -20
- package/build/BluetoothSdk.types.d.ts.map +1 -1
- package/build/BluetoothSdk.types.js +1 -0
- package/build/BluetoothSdk.types.js.map +1 -1
- package/build/_private/BluetoothSdkModule.d.ts +6 -5
- package/build/_private/BluetoothSdkModule.d.ts.map +1 -1
- package/build/_private/BluetoothSdkModule.js +40 -5
- package/build/_private/BluetoothSdkModule.js.map +1 -1
- package/build/index.d.ts +1 -1
- package/build/index.d.ts.map +1 -1
- package/build/index.js +4 -2
- package/build/index.js.map +1 -1
- package/build/react/useMentraBluetooth.d.ts +5 -3
- package/build/react/useMentraBluetooth.d.ts.map +1 -1
- package/build/react/useMentraBluetooth.js +15 -4
- package/build/react/useMentraBluetooth.js.map +1 -1
- package/ios/BluetoothSdkModule.swift +45 -28
- package/ios/MentraBluetoothSDK.podspec +0 -3
- package/ios/Source/Audio/AudioModels.swift +159 -0
- package/ios/Source/Bridge.swift +22 -11
- package/ios/Source/Camera/CameraModels.swift +248 -0
- package/ios/Source/Connection/ScanSession.swift +27 -0
- package/ios/Source/DeviceManager.swift +20 -97
- package/ios/Source/DeviceStore.swift +13 -4
- package/ios/Source/Errors/BluetoothError.swift +19 -0
- package/ios/Source/Events/BluetoothEvents.swift +149 -0
- package/ios/Source/Internal/BluetoothAvailability.swift +58 -0
- package/ios/Source/Internal/ValueParsing.swift +90 -0
- package/ios/Source/MentraBluetoothSDK.swift +50 -2150
- package/ios/Source/Requests/DisplayRequests.swift +58 -0
- package/ios/Source/Status/DeviceStatus.swift +471 -0
- package/ios/Source/Status/RuntimeState.swift +359 -0
- package/ios/Source/Status/WifiHotspotStatus.swift +326 -0
- package/ios/Source/Streaming/StreamModels.swift +436 -0
- package/ios/Source/Types/DeviceModels.swift +134 -0
- package/ios/Source/controllers/ControllerManager.swift +3 -3
- package/ios/Source/controllers/R1.swift +1 -1
- package/ios/Source/sgcs/G1.swift +1 -1
- package/ios/Source/sgcs/G2.swift +99 -39
- package/ios/Source/sgcs/Mach1.swift +1 -1
- package/ios/Source/sgcs/MentraLive.swift +109 -12
- package/ios/Source/sgcs/MentraNex.swift +1 -1
- package/ios/Source/sgcs/SGCManager.swift +11 -3
- package/ios/Source/sgcs/Simulated.swift +2 -2
- package/ios/Source/stt/SherpaOnnxTranscriber.swift +1 -4
- package/package.json +1 -1
- package/src/BluetoothSdk.types.ts +48 -28
- package/src/_private/BluetoothSdkModule.ts +47 -21
- package/src/index.ts +6 -4
- package/src/react/useMentraBluetooth.ts +19 -7
- package/android/src/main/java/com/mentra/bluetoothsdk/MentraBluetoothModels.kt +0 -1810
- package/android/src/main/java/com/mentra/bluetoothsdk/stt/VadGateSpeechPolicy.kt +0 -221
- package/ios/Packages/VAD/Common/VAD/VADQuality.swift +0 -41
- package/ios/Packages/VAD/Common/VAD/VADState.swift +0 -26
- package/ios/Packages/VAD/Common/VAD/VADStrategy.swift +0 -29
- package/ios/Packages/VAD/Common/VAD/VADType.swift +0 -14
- package/ios/Packages/VAD/Data/Configuration.swift +0 -68
- package/ios/Packages/VAD/Data/FrameSize.swift +0 -39
- package/ios/Packages/VAD/Data/Record.swift +0 -13
- package/ios/Packages/VAD/Data/Result.swift +0 -22
- package/ios/Packages/VAD/Data/SampleRate.swift +0 -48
- package/ios/Packages/VAD/Silero/Model/silero_vad.onnx +0 -0
- package/ios/Packages/VAD/Silero/SileroVAD.swift +0 -284
- package/ios/Packages/VAD/Silero/SileroVADStrategy.swift +0 -64
|
@@ -0,0 +1,58 @@
|
|
|
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
|
+
|
|
10
|
+
override private init() {
|
|
11
|
+
super.init()
|
|
12
|
+
centralManager = CBCentralManager(
|
|
13
|
+
delegate: self,
|
|
14
|
+
queue: .main,
|
|
15
|
+
options: [CBCentralManagerOptionShowPowerAlertKey: false]
|
|
16
|
+
)
|
|
17
|
+
state = centralManager?.state ?? .unknown
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
func centralManagerDidUpdateState(_ central: CBCentralManager) {
|
|
21
|
+
state = central.state
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
func requirePoweredOn(operation: String) throws {
|
|
25
|
+
if let current = centralManager?.state {
|
|
26
|
+
state = current
|
|
27
|
+
}
|
|
28
|
+
switch state {
|
|
29
|
+
case .poweredOn:
|
|
30
|
+
return
|
|
31
|
+
case .poweredOff:
|
|
32
|
+
throw BluetoothError(
|
|
33
|
+
code: "bluetooth_powered_off",
|
|
34
|
+
message: "Turn on phone Bluetooth to \(operation)."
|
|
35
|
+
)
|
|
36
|
+
case .unauthorized:
|
|
37
|
+
throw BluetoothError(
|
|
38
|
+
code: "bluetooth_unauthorized",
|
|
39
|
+
message: "Allow Bluetooth access to \(operation)."
|
|
40
|
+
)
|
|
41
|
+
case .unsupported:
|
|
42
|
+
throw BluetoothError(
|
|
43
|
+
code: "bluetooth_unsupported",
|
|
44
|
+
message: "This phone does not support Bluetooth."
|
|
45
|
+
)
|
|
46
|
+
case .resetting, .unknown:
|
|
47
|
+
throw BluetoothError(
|
|
48
|
+
code: "bluetooth_not_ready",
|
|
49
|
+
message: "Bluetooth is not ready yet. Try again."
|
|
50
|
+
)
|
|
51
|
+
@unknown default:
|
|
52
|
+
throw BluetoothError(
|
|
53
|
+
code: "bluetooth_unavailable",
|
|
54
|
+
message: "Bluetooth is unavailable. Try again."
|
|
55
|
+
)
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
|
|
3
|
+
func intValue(_ value: Any?) -> Int? {
|
|
4
|
+
if let int = value as? Int { return int }
|
|
5
|
+
if let double = value as? Double { return Int(double) }
|
|
6
|
+
if let number = value as? NSNumber { return number.intValue }
|
|
7
|
+
return nil
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
func stringValue(_ values: [String: Any], _ keys: String...) -> String? {
|
|
11
|
+
stringValue(values, keys)
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
func stringValue(_ values: [String: Any], _ keys: [String]) -> String? {
|
|
15
|
+
for key in keys {
|
|
16
|
+
if let value = values[key] as? String {
|
|
17
|
+
return value
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return nil
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
func boolValue(_ values: [String: Any], _ keys: String...) -> Bool? {
|
|
24
|
+
boolValue(values, keys)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
func boolValue(_ values: [String: Any], _ keys: [String]) -> Bool? {
|
|
28
|
+
for key in keys {
|
|
29
|
+
if let value = values[key] as? Bool { return value }
|
|
30
|
+
if let value = values[key] as? NSNumber { return value.boolValue }
|
|
31
|
+
}
|
|
32
|
+
return nil
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
func hasAnyKey(_ values: [String: Any], _ keys: String...) -> Bool {
|
|
36
|
+
hasAnyKey(values, keys)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
func hasAnyKey(_ values: [String: Any], _ keys: [String]) -> Bool {
|
|
40
|
+
keys.contains { values.keys.contains($0) }
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
func optionalStringValue(_ values: [String: Any], _ keys: String...) -> String? {
|
|
44
|
+
hasAnyKey(values, keys) ? stringValue(values, keys) : nil
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
func nonEmptyStringValue(_ values: [String: Any], _ keys: String...) -> String? {
|
|
48
|
+
for key in keys {
|
|
49
|
+
guard let value = values[key] as? String else { continue }
|
|
50
|
+
let trimmed = value.trimmingCharacters(in: .whitespacesAndNewlines)
|
|
51
|
+
if !trimmed.isEmpty {
|
|
52
|
+
return value
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return nil
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
func optionalIntValue(_ values: [String: Any], _ keys: String...) -> Int? {
|
|
59
|
+
guard hasAnyKey(values, keys) else { return nil }
|
|
60
|
+
for key in keys {
|
|
61
|
+
if let value = intValue(values[key]) { return value }
|
|
62
|
+
}
|
|
63
|
+
return nil
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
func optionalBoolValue(_ values: [String: Any], _ keys: String...) -> Bool? {
|
|
67
|
+
hasAnyKey(values, keys) ? boolValue(values, keys) : nil
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
func stringListValue(_ values: [String: Any], _ key: String) -> [String] {
|
|
71
|
+
values[key] as? [String] ?? []
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
func optionalStringListValue(_ values: [String: Any], _ key: String) -> [String]? {
|
|
75
|
+
values.keys.contains(key) ? stringListValue(values, key) : nil
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
func dictionaryListValue(_ values: [String: Any], _ key: String) -> [[String: Any]] {
|
|
79
|
+
values[key] as? [[String: Any]] ?? []
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
func optionalDictionaryListValue(_ values: [String: Any], _ key: String) -> [[String: Any]]? {
|
|
83
|
+
values.keys.contains(key) ? dictionaryListValue(values, key) : nil
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
func putIfNotNil(_ map: inout [String: Any], _ key: String, _ value: Any?) {
|
|
87
|
+
if let value {
|
|
88
|
+
map[key] = value
|
|
89
|
+
}
|
|
90
|
+
}
|