@mentra/bluetooth-sdk 0.1.5 → 0.1.6
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 +29 -13
- package/android/src/main/java/com/mentra/bluetoothsdk/BluetoothSdkModule.kt +15 -7
- package/android/src/main/java/com/mentra/bluetoothsdk/DeviceStore.kt +1 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/MentraBluetoothSdk.kt +34 -46
- package/android/src/main/java/com/mentra/bluetoothsdk/audio/AudioModels.kt +125 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/camera/CameraModels.kt +187 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/connection/ConnectionModels.kt +78 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/events/BluetoothEvents.kt +60 -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/status/DeviceStatus.kt +605 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/status/RuntimeState.kt +199 -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/types/DeviceModels.kt +75 -0
- package/build/BluetoothSdk.types.d.ts +4 -0
- package/build/BluetoothSdk.types.d.ts.map +1 -1
- package/build/BluetoothSdk.types.js.map +1 -1
- package/build/_private/BluetoothSdkModule.d.ts.map +1 -1
- package/build/_private/BluetoothSdkModule.js +3 -0
- package/build/_private/BluetoothSdkModule.js.map +1 -1
- package/ios/BluetoothSdkModule.swift +4 -4
- package/ios/Source/Audio/AudioModels.swift +159 -0
- package/ios/Source/Camera/CameraModels.swift +246 -0
- package/ios/Source/Connection/ScanSession.swift +27 -0
- package/ios/Source/DeviceStore.swift +1 -0
- package/ios/Source/Errors/BluetoothError.swift +19 -0
- package/ios/Source/Events/BluetoothEvents.swift +115 -0
- package/ios/Source/Internal/BluetoothAvailability.swift +58 -0
- package/ios/Source/Internal/ValueParsing.swift +90 -0
- package/ios/Source/MentraBluetoothSDK.swift +25 -2140
- package/ios/Source/Requests/DisplayRequests.swift +58 -0
- package/ios/Source/Status/DeviceStatus.swift +463 -0
- package/ios/Source/Status/RuntimeState.swift +350 -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/sgcs/G2.swift +97 -36
- package/package.json +1 -1
- package/src/BluetoothSdk.types.ts +4 -0
- package/src/_private/BluetoothSdkModule.ts +3 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/MentraBluetoothModels.kt +0 -1810
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
package com.mentra.bluetoothsdk
|
|
2
|
+
|
|
3
|
+
data class ButtonPressEvent(
|
|
4
|
+
val buttonId: String,
|
|
5
|
+
val pressType: String,
|
|
6
|
+
val timestamp: Long? = null,
|
|
7
|
+
)
|
|
8
|
+
|
|
9
|
+
data class TouchEvent(
|
|
10
|
+
val values: Map<String, Any>,
|
|
11
|
+
) {
|
|
12
|
+
val deviceModel: String? get() = stringValue(values, "deviceModel")
|
|
13
|
+
val gestureName: String? get() = stringValue(values, "gestureName")
|
|
14
|
+
val timestamp: Long? get() = longValue(values, "timestamp")
|
|
15
|
+
val isSwipe: Boolean get() = gestureName?.contains("swipe", ignoreCase = true) == true
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
data class SwipeEvent(
|
|
19
|
+
val values: Map<String, Any>,
|
|
20
|
+
) {
|
|
21
|
+
val deviceModel: String? get() = stringValue(values, "deviceModel")
|
|
22
|
+
val gestureName: String? get() = stringValue(values, "gestureName")
|
|
23
|
+
val timestamp: Long? get() = longValue(values, "timestamp")
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
data class BatteryStatusEvent(
|
|
27
|
+
val level: Int?,
|
|
28
|
+
val charging: Boolean?,
|
|
29
|
+
val values: Map<String, Any>,
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
interface MentraBluetoothSdkListener {
|
|
33
|
+
fun onStateChanged(state: MentraBluetoothState) {}
|
|
34
|
+
fun onGlassesChanged(glasses: GlassesRuntimeState) {}
|
|
35
|
+
fun onSdkStateChanged(sdk: PhoneSdkRuntimeState) {}
|
|
36
|
+
fun onScanChanged(scan: BluetoothScanState) {}
|
|
37
|
+
fun onDeviceDiscovered(device: Device) {}
|
|
38
|
+
fun onScanStopped(reason: ScanStopReason) {}
|
|
39
|
+
fun onButtonPress(event: ButtonPressEvent) {}
|
|
40
|
+
fun onTouch(event: TouchEvent) {}
|
|
41
|
+
fun onSwipe(event: SwipeEvent) {}
|
|
42
|
+
fun onHeadUpChanged(headUp: Boolean) {}
|
|
43
|
+
fun onBatteryStatus(event: BatteryStatusEvent) {}
|
|
44
|
+
fun onWifiStatusChanged(event: WifiStatusEvent) {}
|
|
45
|
+
fun onHotspotStatusChanged(event: HotspotStatusEvent) {}
|
|
46
|
+
fun onHotspotError(event: HotspotErrorEvent) {}
|
|
47
|
+
fun onGalleryStatus(event: GalleryStatusEvent) {}
|
|
48
|
+
fun onPhotoResponse(event: PhotoResponseEvent) {}
|
|
49
|
+
fun onStreamStatus(event: StreamStatusEvent) {}
|
|
50
|
+
fun onKeepAliveAck(event: KeepAliveAckEvent) {}
|
|
51
|
+
fun onMicPcm(event: MicPcmEvent) {}
|
|
52
|
+
fun onMicLc3(event: MicLc3Event) {}
|
|
53
|
+
fun onLocalTranscription(event: LocalTranscriptionEvent) {}
|
|
54
|
+
fun onDefaultDeviceChanged(device: Device?) {}
|
|
55
|
+
fun onLog(message: String) {}
|
|
56
|
+
fun onError(error: BluetoothError) {}
|
|
57
|
+
fun onRawEvent(eventName: String, values: Map<String, Any>) {}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
abstract class MentraBluetoothSdkCallback : MentraBluetoothSdkListener
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
package com.mentra.bluetoothsdk
|
|
2
|
+
|
|
3
|
+
internal fun numberValue(
|
|
4
|
+
values: Map<String, Any>,
|
|
5
|
+
vararg keys: String,
|
|
6
|
+
): Int? =
|
|
7
|
+
keys.firstNotNullOfOrNull { key ->
|
|
8
|
+
(values[key] as? Number)?.toInt()
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
internal fun stringValue(
|
|
12
|
+
values: Map<String, Any>,
|
|
13
|
+
vararg keys: String,
|
|
14
|
+
): String? =
|
|
15
|
+
keys.firstNotNullOfOrNull { key ->
|
|
16
|
+
values[key]?.let { it as? String }
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
internal fun boolValue(
|
|
20
|
+
values: Map<String, Any>,
|
|
21
|
+
vararg keys: String,
|
|
22
|
+
): Boolean? =
|
|
23
|
+
keys.firstNotNullOfOrNull { key ->
|
|
24
|
+
values[key] as? Boolean
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
internal fun longValue(
|
|
28
|
+
values: Map<String, Any>,
|
|
29
|
+
vararg keys: String,
|
|
30
|
+
): Long? =
|
|
31
|
+
keys.firstNotNullOfOrNull { key ->
|
|
32
|
+
(values[key] as? Number)?.toLong()
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
internal fun hasAnyKey(
|
|
36
|
+
values: Map<String, Any>,
|
|
37
|
+
vararg keys: String,
|
|
38
|
+
): Boolean = keys.any(values::containsKey)
|
|
39
|
+
|
|
40
|
+
internal fun Map<*, *>.stringKeyedMap(): Map<String, Any> =
|
|
41
|
+
entries.mapNotNull { (key, value) ->
|
|
42
|
+
val stringKey = key as? String ?: return@mapNotNull null
|
|
43
|
+
val anyValue = value ?: return@mapNotNull null
|
|
44
|
+
stringKey to anyValue
|
|
45
|
+
}.toMap()
|
|
46
|
+
|
|
47
|
+
internal fun optionalNumberValue(
|
|
48
|
+
values: Map<String, Any>,
|
|
49
|
+
vararg keys: String,
|
|
50
|
+
): Int? =
|
|
51
|
+
if (hasAnyKey(values, *keys)) {
|
|
52
|
+
numberValue(values, *keys)
|
|
53
|
+
} else {
|
|
54
|
+
null
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
internal fun optionalLongValue(
|
|
58
|
+
values: Map<String, Any>,
|
|
59
|
+
vararg keys: String,
|
|
60
|
+
): Long? =
|
|
61
|
+
if (hasAnyKey(values, *keys)) {
|
|
62
|
+
longValue(values, *keys)
|
|
63
|
+
} else {
|
|
64
|
+
null
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
internal fun optionalStringValue(
|
|
68
|
+
values: Map<String, Any>,
|
|
69
|
+
vararg keys: String,
|
|
70
|
+
): String? =
|
|
71
|
+
if (hasAnyKey(values, *keys)) {
|
|
72
|
+
stringValue(values, *keys)
|
|
73
|
+
} else {
|
|
74
|
+
null
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
internal fun optionalBoolValue(
|
|
78
|
+
values: Map<String, Any>,
|
|
79
|
+
vararg keys: String,
|
|
80
|
+
): Boolean? =
|
|
81
|
+
if (hasAnyKey(values, *keys)) {
|
|
82
|
+
boolValue(values, *keys)
|
|
83
|
+
} else {
|
|
84
|
+
null
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
internal fun stringListValue(
|
|
88
|
+
values: Map<String, Any>,
|
|
89
|
+
key: String,
|
|
90
|
+
): List<String> = (values[key] as? List<*>)?.mapNotNull { it as? String } ?: emptyList()
|
|
91
|
+
|
|
92
|
+
internal fun optionalStringListValue(
|
|
93
|
+
values: Map<String, Any>,
|
|
94
|
+
key: String,
|
|
95
|
+
): List<String>? =
|
|
96
|
+
if (values.containsKey(key)) {
|
|
97
|
+
stringListValue(values, key)
|
|
98
|
+
} else {
|
|
99
|
+
null
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
internal fun mapListValue(
|
|
103
|
+
values: Map<String, Any>,
|
|
104
|
+
key: String,
|
|
105
|
+
): List<Map<String, Any>> =
|
|
106
|
+
(values[key] as? List<*>)?.mapNotNull(::stringMapValue) ?: emptyList()
|
|
107
|
+
|
|
108
|
+
internal fun optionalMapListValue(
|
|
109
|
+
values: Map<String, Any>,
|
|
110
|
+
key: String,
|
|
111
|
+
): List<Map<String, Any>>? =
|
|
112
|
+
if (values.containsKey(key)) {
|
|
113
|
+
mapListValue(values, key)
|
|
114
|
+
} else {
|
|
115
|
+
null
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
internal fun stringMapValue(value: Any?): Map<String, Any>? =
|
|
119
|
+
(value as? Map<*, *>)?.entries?.mapNotNull { (key, mapValue) ->
|
|
120
|
+
val stringKey = key as? String ?: return@mapNotNull null
|
|
121
|
+
val nonNullValue = mapValue ?: return@mapNotNull null
|
|
122
|
+
stringKey to nonNullValue
|
|
123
|
+
}?.toMap()
|
|
124
|
+
|
|
125
|
+
internal fun MutableMap<String, Any>.putIfNotNull(
|
|
126
|
+
key: String,
|
|
127
|
+
value: Any?,
|
|
128
|
+
) {
|
|
129
|
+
if (value != null) {
|
|
130
|
+
put(key, value)
|
|
131
|
+
}
|
|
132
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
package com.mentra.bluetoothsdk
|
|
2
|
+
|
|
3
|
+
data class DisplayTextRequest(
|
|
4
|
+
val text: String,
|
|
5
|
+
val x: Int = 0,
|
|
6
|
+
val y: Int = 0,
|
|
7
|
+
val size: Int = 24,
|
|
8
|
+
) {
|
|
9
|
+
fun toMap(): Map<String, Any> =
|
|
10
|
+
mapOf(
|
|
11
|
+
"text" to text,
|
|
12
|
+
"x" to x,
|
|
13
|
+
"y" to y,
|
|
14
|
+
"size" to size,
|
|
15
|
+
)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
internal data class DisplayEventRequest(
|
|
19
|
+
val values: Map<String, Any>,
|
|
20
|
+
) {
|
|
21
|
+
fun toMap(): Map<String, Any> = values
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
data class DashboardPositionRequest(
|
|
25
|
+
val height: Int,
|
|
26
|
+
val depth: Int,
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
internal data class DashboardMenuItem(
|
|
30
|
+
val title: String,
|
|
31
|
+
val packageName: String,
|
|
32
|
+
val values: Map<String, Any> = emptyMap(),
|
|
33
|
+
) {
|
|
34
|
+
fun toMap(): Map<String, Any> =
|
|
35
|
+
values + mapOf(
|
|
36
|
+
"title" to title,
|
|
37
|
+
"packageName" to packageName,
|
|
38
|
+
)
|
|
39
|
+
}
|