@mentra/bluetooth-sdk 3.4.0-dev.1208 → 3.4.0-dev.1209
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/android/src/main/java/com/mentra/bluetoothsdk/DeviceManager.kt +2 -16
- package/android/src/main/java/com/mentra/bluetoothsdk/GeneratedReleaseMetadata.kt +5 -5
- package/android/src/main/java/com/mentra/bluetoothsdk/MentraBluetoothSdk.kt +2 -9
- package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/Nimo.kt +13 -316
- package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/NimoCanvasCoordinator.kt +0 -35
- package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/NimoCanvasSession.kt +2 -10
- package/android/src/test/java/com/mentra/bluetoothsdk/sgcs/NimoCanvasCoordinatorTest.kt +1 -56
- package/android/src/test/java/com/mentra/bluetoothsdk/sgcs/NimoCanvasSessionTest.kt +0 -22
- package/build/_private/BluetoothSdkModule.d.ts +0 -3
- package/build/_private/BluetoothSdkModule.d.ts.map +1 -1
- package/build/_private/BluetoothSdkModule.js.map +1 -1
- package/build/generated/releaseMetadata.js +5 -5
- package/build/generated/releaseMetadata.js.map +1 -1
- package/ios/BluetoothSdkModule.swift +0 -6
- package/ios/Source/BluetoothSdkDefaults.swift +1 -1
- package/ios/Source/DeviceManager.swift +1 -10
- package/ios/Source/GeneratedReleaseMetadata.swift +5 -5
- package/ios/Source/MentraBluetoothSDK.swift +2 -15
- package/ios/Source/sgcs/Nimo.swift +39 -272
- package/ios/Source/sgcs/NimoCanvasCoordinator.swift +9 -38
- package/ios/Source/sgcs/NimoCanvasSession.swift +0 -1
- package/ios/Tests/DeviceManagerReconnectTests.swift +0 -71
- package/ios/Tests/NimoCanvasTransportTests.swift +0 -89
- package/package.json +2 -2
- package/src/_private/BluetoothSdkModule.ts +0 -3
- package/src/generated/releaseMetadata.ts +5 -5
- package/android/src/debug/java/com/mentra/bluetoothsdk/sgcs/NimoDiagnostics.kt +0 -368
- package/android/src/debug/java/com/mentra/bluetoothsdk/sgcs/NimoFramebufferProtocol.kt +0 -156
- package/android/src/debug/java/com/mentra/bluetoothsdk/sgcs/NimoResourceDiagnostics.kt +0 -274
- package/android/src/release/java/com/mentra/bluetoothsdk/sgcs/NimoDiagnostics.kt +0 -20
- package/android/src/release/java/com/mentra/bluetoothsdk/sgcs/NimoResourceDiagnostics.kt +0 -16
- package/android/src/testDebug/java/com/mentra/bluetoothsdk/sgcs/NimoDiagnosticsTest.kt +0 -287
- package/android/src/testDebug/java/com/mentra/bluetoothsdk/sgcs/NimoFramebufferProtocolTest.kt +0 -127
- package/android/src/testDebug/java/com/mentra/bluetoothsdk/sgcs/NimoLifecycleTest.kt +0 -851
- package/ios/Source/sgcs/NimoMacResourceTransport.swift +0 -217
- package/ios/Source/sgcs/NimoResourceFixture.swift +0 -384
- package/ios/Source/sgcs/NimoResourceSession.swift +0 -406
- package/ios/Tests/NimoResourceSessionTests.swift +0 -476
package/android/src/testDebug/java/com/mentra/bluetoothsdk/sgcs/NimoFramebufferProtocolTest.kt
DELETED
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
package com.mentra.bluetoothsdk.sgcs
|
|
2
|
-
|
|
3
|
-
import org.junit.Assert.*
|
|
4
|
-
import org.junit.Test
|
|
5
|
-
|
|
6
|
-
class NimoFramebufferProtocolTest {
|
|
7
|
-
@Test fun hexPreservesEveryByteAndEmptyEvidence() {
|
|
8
|
-
val bytes = ByteArray(256) { it.toByte() }
|
|
9
|
-
assertEquals(bytes.joinToString("") { "%02x".format(it.toInt() and 255) }, NimoFramebufferProtocol.hex(bytes))
|
|
10
|
-
assertEquals("", NimoFramebufferProtocol.hex(byteArrayOf()))
|
|
11
|
-
}
|
|
12
|
-
private val pingRequest = NimoFramebufferProtocol.Request(0x01020304L, 0, 0, 0)
|
|
13
|
-
// Fixed vectors produced independently by the existing Python FBP1 codec.
|
|
14
|
-
private val ping = hex("bf0023008234000002151f0000464250310403020100000000000100000001000008003533376366317031")
|
|
15
|
-
private val page = hex("bf000b0175e500000215070100464250310403020101013a010001000000010000f000") +
|
|
16
|
-
ByteArray(240) { it.toByte() }
|
|
17
|
-
|
|
18
|
-
@Test fun requestAndReplyMatchIndependentGoldenVectors() {
|
|
19
|
-
assertArrayEquals(hex("bf001000227a000002150c00464250310403020100000000"),
|
|
20
|
-
NimoFramebufferProtocol.requestFrame(pingRequest))
|
|
21
|
-
val reply = NimoFramebufferProtocol.reply(ping, pingRequest)
|
|
22
|
-
assertArrayEquals("537cf1p1".toByteArray(), reply.data)
|
|
23
|
-
assertEquals(NimoFramebufferProtocol.State(0, 1, 0, 0), reply.before)
|
|
24
|
-
val expectedPage = NimoFramebufferProtocol.Request(0x01020304L, 1, 1, 314)
|
|
25
|
-
assertArrayEquals(ByteArray(240) { it.toByte() }, NimoFramebufferProtocol.reply(page, expectedPage).data)
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
@Test fun rejectsCrcLengthsDirectionIndexAndCommand() {
|
|
29
|
-
for (offset in listOf(0, 1, 2, 4, 6, 8, 9, 10)) {
|
|
30
|
-
val invalid = ping.copyOf().also { it[offset] = (it[offset].toInt() xor 1).toByte() }
|
|
31
|
-
rejects { NimoFramebufferProtocol.reply(invalid, pingRequest) }
|
|
32
|
-
}
|
|
33
|
-
rejects { NimoFramebufferProtocol.reply(ping + 0, pingRequest) }
|
|
34
|
-
rejects { NimoFramebufferProtocol.reply(ping.copyOf(ping.size - 1), pingRequest) }
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
@Test fun rejectsWrongTagMagicNonceOperationBankAndPage() {
|
|
38
|
-
for (offset in listOf(13, 17, 21, 22, 23, 33, 35)) {
|
|
39
|
-
val invalid = changeAndRecrc(ping, offset, ping[offset].toInt() xor 1)
|
|
40
|
-
rejects { NimoFramebufferProtocol.reply(invalid, pingRequest) }
|
|
41
|
-
}
|
|
42
|
-
rejects { NimoFramebufferProtocol.reply(ping, pingRequest.copy(nonce = 9)) }
|
|
43
|
-
rejects { NimoFramebufferProtocol.reply(ping, pingRequest.copy(op = 1)) }
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
@Test fun rejectsStatusErrorsEvenWithValidCorrelation() {
|
|
47
|
-
for (status in listOf(1, 6, 7, 255)) {
|
|
48
|
-
val payload = ping.copyOfRange(12, 35).also { it[0] = status.toByte(); it[21] = 0; it[22] = 0 }
|
|
49
|
-
rejects { NimoFramebufferProtocol.reply(frame(0x15, payload), pingRequest) }
|
|
50
|
-
}
|
|
51
|
-
rejects { NimoFramebufferProtocol.reply(changeAndRecrc(ping, 12, 6), pingRequest) }
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
@Test fun rejectsMetadataChangedWithinAndAcrossPagesAndOutOfOrder() {
|
|
55
|
-
val request = NimoFramebufferProtocol.Request(0x01020304L, 1, 1, 0)
|
|
56
|
-
val first = NimoFramebufferProtocol.reply(pageAt(0), request)
|
|
57
|
-
val read = NimoFramebufferProtocol.BankRead(request.nonce, request.bank)
|
|
58
|
-
read.add(first)
|
|
59
|
-
rejects { read.add(first) }
|
|
60
|
-
rejects { NimoFramebufferProtocol.BankRead(request.nonce, request.bank).add(first.copy(page = 1)) }
|
|
61
|
-
rejects { NimoFramebufferProtocol.reply(changeAndRecrc(pageAt(0), 29, 1), request) }
|
|
62
|
-
val changed = first.copy(page = 1, before = first.before.copy(dirty = 1), after = first.after.copy(dirty = 1))
|
|
63
|
-
val changedRead = NimoFramebufferProtocol.BankRead(request.nonce, request.bank)
|
|
64
|
-
changedRead.add(first)
|
|
65
|
-
rejects { changedRead.add(changed) }
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
@Test fun bankRequiresEveryPageAndIndependentEqualSecondPass() {
|
|
69
|
-
val first = completeBank(10)
|
|
70
|
-
val second = completeBank(11)
|
|
71
|
-
NimoFramebufferProtocol.verifyPair(first, second)
|
|
72
|
-
assertEquals(75600, first.bytes().size)
|
|
73
|
-
rejects { NimoFramebufferProtocol.verifyPair(first, first) }
|
|
74
|
-
rejects { NimoFramebufferProtocol.verifyPair(first, completeBank(12, changedLastPixel = true)) }
|
|
75
|
-
rejects { NimoFramebufferProtocol.BankRead(20, 1).bytes() }
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
@Test fun requestLimitsPreventArbitraryCommandsOrAddresses() {
|
|
79
|
-
for (request in listOf(pingRequest.copy(nonce = -1), pingRequest.copy(nonce = 0x100000000L),
|
|
80
|
-
pingRequest.copy(op = 2), pingRequest.copy(bank = 2), pingRequest.copy(page = 1),
|
|
81
|
-
pingRequest.copy(op = 1, page = 315))) {
|
|
82
|
-
rejects { NimoFramebufferProtocol.requestFrame(request) }
|
|
83
|
-
}
|
|
84
|
-
rejects { NimoFramebufferProtocol.queryFrame(0x0A) }
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
@Test fun basicResponsesRequireExactVersionAndReadinessShape() {
|
|
88
|
-
val version = byteArrayOf(0) + NimoFramebufferProtocol.EXPECTED_VERSION.toByteArray()
|
|
89
|
-
assertEquals(NimoFramebufferProtocol.EXPECTED_VERSION,
|
|
90
|
-
NimoFramebufferProtocol.version(frame(0x0B, version)))
|
|
91
|
-
rejects { NimoFramebufferProtocol.version(frame(0x0B, version + 0)) }
|
|
92
|
-
rejects { NimoFramebufferProtocol.version(frame(0x0B, version.copyOf().also { it[0] = 7 })) }
|
|
93
|
-
assertEquals(listOf(0, 0, 1, 0), NimoFramebufferProtocol.readiness(frame(0x19, byteArrayOf(0, 0, 1, 0))))
|
|
94
|
-
rejects { NimoFramebufferProtocol.readiness(frame(0x19, byteArrayOf(0, 1, 1))) }
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
private fun completeBank(nonce: Long, changedLastPixel: Boolean = false): NimoFramebufferProtocol.BankRead {
|
|
98
|
-
val read = NimoFramebufferProtocol.BankRead(nonce, 1)
|
|
99
|
-
repeat(315) { index ->
|
|
100
|
-
val original = NimoFramebufferProtocol.reply(pageAt(index),
|
|
101
|
-
NimoFramebufferProtocol.Request(0x01020304L, 1, 1, index))
|
|
102
|
-
val data = original.data.copyOf()
|
|
103
|
-
if (changedLastPixel && index == 314) data[239] = 0
|
|
104
|
-
read.add(original.copy(nonce = nonce, data = data))
|
|
105
|
-
}
|
|
106
|
-
return read
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
private fun pageAt(index: Int): ByteArray {
|
|
110
|
-
val result = page.copyOf()
|
|
111
|
-
result[23] = index.toByte(); result[24] = (index shr 8).toByte()
|
|
112
|
-
return recrc(result)
|
|
113
|
-
}
|
|
114
|
-
private fun changeAndRecrc(value: ByteArray, index: Int, byte: Int) =
|
|
115
|
-
recrc(value.copyOf().also { it[index] = byte.toByte() })
|
|
116
|
-
private fun recrc(value: ByteArray): ByteArray {
|
|
117
|
-
val crc = NimoCanvasCodec.crc16(value.copyOfRange(8, value.size))
|
|
118
|
-
value[4] = crc.toByte(); value[5] = (crc shr 8).toByte()
|
|
119
|
-
return value
|
|
120
|
-
}
|
|
121
|
-
private fun frame(key: Int, payload: ByteArray): ByteArray {
|
|
122
|
-
val body = byteArrayOf(2, key.toByte(), payload.size.toByte(), (payload.size shr 8).toByte()) + payload
|
|
123
|
-
return recrc(byteArrayOf(0xBF.toByte(), 0, body.size.toByte(), (body.size shr 8).toByte(), 0, 0, 0, 0) + body)
|
|
124
|
-
}
|
|
125
|
-
private fun rejects(block: () -> Unit) { assertThrows(IllegalArgumentException::class.java, block) }
|
|
126
|
-
private fun hex(value: String) = value.chunked(2).map { it.toInt(16).toByte() }.toByteArray()
|
|
127
|
-
}
|