brilliantsole 0.0.27 → 0.0.28
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/assets/3d/anchor.glb +0 -0
- package/assets/3d/coin.glb +0 -0
- package/assets/3d/glasses.glb +0 -0
- package/assets/audio/bounceMedium.wav +0 -0
- package/assets/audio/bounceStrong.wav +0 -0
- package/assets/audio/bounceWeak.wav +0 -0
- package/assets/audio/coin.wav +0 -0
- package/assets/audio/getUp.wav +0 -0
- package/assets/audio/grab.wav +0 -0
- package/assets/audio/kick.wav +0 -0
- package/assets/audio/platterFadeIn old.wav +0 -0
- package/assets/audio/platterFadeIn.wav +0 -0
- package/assets/audio/platterFadeOut.wav +0 -0
- package/assets/audio/punch.wav +0 -0
- package/assets/audio/punchSqueak.wav +0 -0
- package/assets/audio/purr.wav +0 -0
- package/assets/audio/purrFadeOut.wav +0 -0
- package/assets/audio/release.wav +0 -0
- package/assets/audio/splat.wav +0 -0
- package/assets/audio/stomp.wav +0 -0
- package/build/brilliantsole.cjs +2627 -775
- package/build/brilliantsole.cjs.map +1 -1
- package/build/brilliantsole.js +2273 -721
- package/build/brilliantsole.js.map +1 -1
- package/build/brilliantsole.ls.js +2096 -535
- package/build/brilliantsole.ls.js.map +1 -1
- package/build/brilliantsole.min.js +1 -1
- package/build/brilliantsole.min.js.map +1 -1
- package/build/brilliantsole.module.d.ts +235 -65
- package/build/brilliantsole.module.js +2266 -722
- package/build/brilliantsole.module.js.map +1 -1
- package/build/brilliantsole.module.min.d.ts +235 -65
- package/build/brilliantsole.module.min.js +1 -1
- package/build/brilliantsole.module.min.js.map +1 -1
- package/build/brilliantsole.node.module.d.ts +229 -62
- package/build/brilliantsole.node.module.js +2619 -776
- package/build/brilliantsole.node.module.js.map +1 -1
- package/build/dts/BS-output.d.ts +10 -0
- package/build/dts/BS.d.ts +20 -8
- package/build/dts/CameraManager.d.ts +72 -0
- package/build/dts/Device.d.ts +46 -13
- package/build/dts/DeviceInformationManager.d.ts +4 -4
- package/build/dts/DeviceManager.d.ts +2 -0
- package/build/dts/FileTransferManager.d.ts +18 -8
- package/build/dts/InformationManager.d.ts +2 -0
- package/build/dts/TfliteManager.d.ts +22 -2
- package/build/dts/WifiManager.d.ts +61 -0
- package/build/dts/connection/BaseConnectionManager.d.ts +35 -3
- package/build/dts/connection/ClientConnectionManager.d.ts +7 -2
- package/build/dts/connection/bluetooth/NobleConnectionManager.d.ts +2 -1
- package/build/dts/connection/bluetooth/WebBluetoothConnectionManager.d.ts +1 -0
- package/build/dts/connection/bluetooth/bluetoothUUIDs.d.ts +2 -2
- package/build/dts/connection/udp/UDPConnectionManager.d.ts +28 -0
- package/build/dts/connection/webSocket/WebSocketConnectionManager.d.ts +25 -0
- package/build/dts/devicePair/DevicePair.d.ts +5 -5
- package/build/dts/scanner/BaseScanner.d.ts +4 -1
- package/build/dts/scanner/NobleScanner.d.ts +2 -1
- package/build/dts/sensor/MotionSensorDataManager.d.ts +5 -2
- package/build/dts/sensor/SensorDataManager.d.ts +5 -4
- package/build/dts/server/BaseClient.d.ts +5 -3
- package/build/dts/server/ServerUtils.d.ts +1 -1
- package/build/dts/server/websocket/WebSocketUtils.d.ts +1 -1
- package/build/dts/utils/Console.d.ts +2 -0
- package/build/dts/utils/ThrottleUtils.d.ts +2 -0
- package/build/dts/vibration/VibrationManager.d.ts +19 -2
- package/build/index.d.ts +232 -62
- package/build/index.node.d.ts +226 -59
- package/examples/3d/scene.html +19 -5
- package/examples/3d-generic/index.html +144 -0
- package/examples/3d-generic/script.js +266 -0
- package/examples/basic/index.html +211 -16
- package/examples/basic/script.js +731 -105
- package/examples/edge-impulse/script.js +135 -44
- package/examples/edge-impulse-test/README.md +11 -0
- package/examples/edge-impulse-test/edge-impulse-standalone.js +7228 -0
- package/examples/edge-impulse-test/edge-impulse-standalone.wasm +0 -0
- package/examples/edge-impulse-test/index.html +75 -0
- package/examples/edge-impulse-test/run-impulse.js +135 -0
- package/examples/edge-impulse-test/script.js +200 -0
- package/examples/gloves/edge-impulse-standalone.js +7228 -0
- package/examples/gloves/edge-impulse-standalone.wasm +0 -0
- package/examples/gloves/index.html +4 -1
- package/examples/gloves/run-impulse.js +135 -0
- package/examples/gloves/script.js +367 -51
- package/examples/graph/script.js +94 -37
- package/examples/punch/index.html +135 -0
- package/examples/punch/punch.tflite +0 -0
- package/examples/punch/script.js +169 -0
- package/examples/server/index.html +98 -22
- package/examples/server/script.js +317 -109
- package/examples/ukaton-firmware-update/merged-firmware.bin +0 -0
- package/examples/utils/aframe/aframe-master.min.js +2 -0
- package/examples/utils/aframe/bs-vibration.js +150 -0
- package/examples/utils/aframe/force-pushable.js +80 -0
- package/examples/utils/aframe/grabbable-anchor.js +46 -0
- package/examples/utils/aframe/grabbable-listener.js +31 -0
- package/examples/utils/aframe/grabbable-physics-body.js +190 -0
- package/examples/utils/aframe/grow-shrink.js +25 -0
- package/examples/utils/aframe/hand-punch.js +119 -0
- package/examples/utils/aframe/my-obb-collider.js +293 -0
- package/examples/utils/aframe/occlude-hand-tracking-controls.js +47 -0
- package/examples/utils/aframe/occlude-mesh.js +42 -0
- package/examples/utils/aframe/palm-up-detector.js +47 -0
- package/examples/utils/aframe/shadow-material.js +20 -0
- package/examples/utils/aframe/soft-shadow-light.js +9 -0
- package/examples/webxr-2/assets/3d/soccerBall.glb +0 -0
- package/examples/webxr-2/assets/audio/shellBounce.wav +0 -0
- package/examples/webxr-2/assets/audio/shellHit.wav +0 -0
- package/examples/webxr-2/assets/audio/shellKick.wav +0 -0
- package/examples/webxr-2/assets/audio/soccerBounce.wav +0 -0
- package/examples/webxr-2/assets/audio/soccerKick.mp3 +0 -0
- package/examples/webxr-2/assets/images/shellTexture.png +0 -0
- package/examples/webxr-2/components/bs-ankle.js +337 -0
- package/examples/webxr-2/components/coin.js +84 -0
- package/examples/webxr-2/components/custom-wrap.js +17 -0
- package/examples/webxr-2/components/goomba.js +3250 -0
- package/examples/webxr-2/components/init-shell-material.js +215 -0
- package/examples/webxr-2/components/platter.js +172 -0
- package/examples/webxr-2/components/shell.js +374 -0
- package/examples/webxr-2/components/soccer-ball.js +250 -0
- package/examples/webxr-2/components/squashed-goomba.js +249 -0
- package/examples/webxr-2/edge-impulse-standalone.js +7228 -0
- package/examples/webxr-2/edge-impulse-standalone.wasm +0 -0
- package/examples/webxr-2/index.html +996 -0
- package/examples/webxr-2/kick.tflite +0 -0
- package/examples/webxr-2/kick2.tflite +0 -0
- package/examples/webxr-2/run-impulse.js +135 -0
- package/examples/webxr-2/script.js +384 -0
- package/package.json +2 -1
- package/src/.prettierrc +4 -0
- package/src/BS.ts +70 -8
- package/src/CameraManager.ts +499 -0
- package/src/Device.ts +581 -86
- package/src/DeviceInformationManager.ts +19 -10
- package/src/DeviceManager.ts +85 -25
- package/src/FileTransferManager.ts +145 -20
- package/src/InformationManager.ts +40 -15
- package/src/TfliteManager.ts +171 -25
- package/src/WifiManager.ts +323 -0
- package/src/connection/BaseConnectionManager.ts +128 -30
- package/src/connection/ClientConnectionManager.ts +34 -10
- package/src/connection/bluetooth/BluetoothConnectionManager.ts +8 -2
- package/src/connection/bluetooth/NobleConnectionManager.ts +147 -41
- package/src/connection/bluetooth/WebBluetoothConnectionManager.ts +99 -34
- package/src/connection/bluetooth/bluetoothUUIDs.ts +40 -13
- package/src/connection/udp/UDPConnectionManager.ts +356 -0
- package/src/connection/websocket/WebSocketConnectionManager.ts +282 -0
- package/src/devicePair/DevicePair.ts +95 -25
- package/src/devicePair/DevicePairPressureSensorDataManager.ts +27 -7
- package/src/scanner/BaseScanner.ts +49 -11
- package/src/scanner/NobleScanner.ts +76 -14
- package/src/sensor/MotionSensorDataManager.ts +21 -6
- package/src/sensor/PressureSensorDataManager.ts +37 -8
- package/src/sensor/SensorConfigurationManager.ts +73 -22
- package/src/sensor/SensorDataManager.ts +104 -23
- package/src/server/BaseClient.ts +150 -36
- package/src/server/BaseServer.ts +50 -2
- package/src/server/ServerUtils.ts +39 -9
- package/src/server/udp/UDPServer.ts +73 -22
- package/src/server/udp/UDPUtils.ts +9 -2
- package/src/server/websocket/WebSocketClient.ts +27 -7
- package/src/server/websocket/WebSocketUtils.ts +4 -2
- package/src/utils/Console.ts +62 -9
- package/src/utils/ParseUtils.ts +24 -5
- package/src/utils/ThrottleUtils.ts +62 -0
- package/src/utils/Timer.ts +1 -1
- package/src/vibration/VibrationManager.ts +166 -40
|
@@ -14,7 +14,9 @@ window.device = device;
|
|
|
14
14
|
// GET DEVICES
|
|
15
15
|
|
|
16
16
|
/** @type {HTMLTemplateElement} */
|
|
17
|
-
const availableDeviceTemplate = document.getElementById(
|
|
17
|
+
const availableDeviceTemplate = document.getElementById(
|
|
18
|
+
"availableDeviceTemplate"
|
|
19
|
+
);
|
|
18
20
|
const availableDevicesContainer = document.getElementById("availableDevices");
|
|
19
21
|
/** @param {BS.Device[]} availableDevices */
|
|
20
22
|
function onAvailableDevices(availableDevices) {
|
|
@@ -26,19 +28,24 @@ function onAvailableDevices(availableDevices) {
|
|
|
26
28
|
const availableDeviceContainer = availableDeviceTemplate.content
|
|
27
29
|
.cloneNode(true)
|
|
28
30
|
.querySelector(".availableDevice");
|
|
29
|
-
availableDeviceContainer.querySelector(".name").innerText =
|
|
30
|
-
|
|
31
|
+
availableDeviceContainer.querySelector(".name").innerText =
|
|
32
|
+
availableDevice.name;
|
|
33
|
+
availableDeviceContainer.querySelector(".type").innerText =
|
|
34
|
+
availableDevice.type;
|
|
31
35
|
|
|
32
36
|
/** @type {HTMLButtonElement} */
|
|
33
|
-
const toggleConnectionButton =
|
|
37
|
+
const toggleConnectionButton =
|
|
38
|
+
availableDeviceContainer.querySelector(".toggleConnection");
|
|
34
39
|
toggleConnectionButton.addEventListener("click", () => {
|
|
35
40
|
device.connectionManager = availableDevice.connectionManager;
|
|
36
41
|
device.reconnect();
|
|
37
42
|
});
|
|
38
43
|
device.addEventListener("connectionStatus", () => {
|
|
39
|
-
toggleConnectionButton.disabled =
|
|
44
|
+
toggleConnectionButton.disabled =
|
|
45
|
+
device.connectionStatus != "notConnected";
|
|
40
46
|
});
|
|
41
|
-
toggleConnectionButton.disabled =
|
|
47
|
+
toggleConnectionButton.disabled =
|
|
48
|
+
device.connectionStatus != "notConnected";
|
|
42
49
|
|
|
43
50
|
availableDevicesContainer.appendChild(availableDeviceContainer);
|
|
44
51
|
});
|
|
@@ -87,7 +94,9 @@ device.addEventListener("connectionStatus", () => {
|
|
|
87
94
|
case "connected":
|
|
88
95
|
case "notConnected":
|
|
89
96
|
toggleConnectionButton.disabled = false;
|
|
90
|
-
toggleConnectionButton.innerText = device.isConnected
|
|
97
|
+
toggleConnectionButton.innerText = device.isConnected
|
|
98
|
+
? "disconnect"
|
|
99
|
+
: "connect";
|
|
91
100
|
break;
|
|
92
101
|
case "connecting":
|
|
93
102
|
case "disconnecting":
|
|
@@ -98,7 +107,9 @@ device.addEventListener("connectionStatus", () => {
|
|
|
98
107
|
});
|
|
99
108
|
|
|
100
109
|
/** @type {HTMLInputElement} */
|
|
101
|
-
const reconnectOnDisconnectionCheckbox = document.getElementById(
|
|
110
|
+
const reconnectOnDisconnectionCheckbox = document.getElementById(
|
|
111
|
+
"reconnectOnDisconnection"
|
|
112
|
+
);
|
|
102
113
|
reconnectOnDisconnectionCheckbox.addEventListener("input", () => {
|
|
103
114
|
device.reconnectOnDisconnection = reconnectOnDisconnectionCheckbox.checked;
|
|
104
115
|
});
|
|
@@ -108,13 +119,23 @@ reconnectOnDisconnectionCheckbox.addEventListener("input", () => {
|
|
|
108
119
|
/** @type {HTMLPreElement} */
|
|
109
120
|
const deviceInformationPre = document.getElementById("deviceInformationPre");
|
|
110
121
|
device.addEventListener("deviceInformation", () => {
|
|
111
|
-
deviceInformationPre.textContent = JSON.stringify(
|
|
122
|
+
deviceInformationPre.textContent = JSON.stringify(
|
|
123
|
+
device.deviceInformation,
|
|
124
|
+
null,
|
|
125
|
+
2
|
|
126
|
+
);
|
|
112
127
|
});
|
|
113
128
|
|
|
114
129
|
/** @type {HTMLPreElement} */
|
|
115
|
-
const sensorConfigurationPre = document.getElementById(
|
|
130
|
+
const sensorConfigurationPre = document.getElementById(
|
|
131
|
+
"sensorConfigurationPre"
|
|
132
|
+
);
|
|
116
133
|
device.addEventListener("getSensorConfiguration", () => {
|
|
117
|
-
sensorConfigurationPre.textContent = JSON.stringify(
|
|
134
|
+
sensorConfigurationPre.textContent = JSON.stringify(
|
|
135
|
+
device.sensorConfiguration,
|
|
136
|
+
null,
|
|
137
|
+
2
|
|
138
|
+
);
|
|
118
139
|
});
|
|
119
140
|
|
|
120
141
|
/** @type {HTMLSpanElement} */
|
|
@@ -148,7 +169,12 @@ function setUrlParam(key, value) {
|
|
|
148
169
|
searchParams.delete(key);
|
|
149
170
|
}
|
|
150
171
|
let newUrl =
|
|
151
|
-
window.location.protocol +
|
|
172
|
+
window.location.protocol +
|
|
173
|
+
"//" +
|
|
174
|
+
window.location.host +
|
|
175
|
+
window.location.pathname +
|
|
176
|
+
"?" +
|
|
177
|
+
searchParams.toString();
|
|
152
178
|
window.history.pushState({ path: newUrl }, "", newUrl);
|
|
153
179
|
}
|
|
154
180
|
}
|
|
@@ -268,7 +294,9 @@ const sensorTypeTemplate = document.getElementById("sensorTypeTemplate");
|
|
|
268
294
|
const sensorTypeContainers = {};
|
|
269
295
|
|
|
270
296
|
BS.TfliteSensorTypes.forEach((sensorType) => {
|
|
271
|
-
const sensorTypeContainer = sensorTypeTemplate.content
|
|
297
|
+
const sensorTypeContainer = sensorTypeTemplate.content
|
|
298
|
+
.cloneNode(true)
|
|
299
|
+
.querySelector(".sensorType");
|
|
272
300
|
sensorTypeContainer.querySelector(".name").innerText = sensorType;
|
|
273
301
|
|
|
274
302
|
/** @type {HTMLInputElement} */
|
|
@@ -403,16 +431,24 @@ toggleSamplingButton.addEventListener("click", () => {
|
|
|
403
431
|
|
|
404
432
|
function updateToggleSamplingButton() {
|
|
405
433
|
const enabled =
|
|
406
|
-
device.isConnected &&
|
|
434
|
+
device.isConnected &&
|
|
435
|
+
isRemoteManagementConnected() &&
|
|
436
|
+
sensorTypes.length > 0 &&
|
|
437
|
+
label.length > 0 &&
|
|
438
|
+
!isSampling;
|
|
407
439
|
toggleSamplingButton.disabled = !enabled;
|
|
408
|
-
toggleSamplingButton.innerText = isSampling
|
|
440
|
+
toggleSamplingButton.innerText = isSampling
|
|
441
|
+
? "sampling..."
|
|
442
|
+
: "start sampling";
|
|
409
443
|
}
|
|
410
444
|
|
|
411
|
-
["isSampling", "remoteManagementConnection", "sensortypes", "label"].forEach(
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
});
|
|
445
|
+
["isSampling", "remoteManagementConnection", "sensortypes", "label"].forEach(
|
|
446
|
+
(eventType) => {
|
|
447
|
+
window.addEventListener(eventType, () => {
|
|
448
|
+
updateToggleSamplingButton();
|
|
449
|
+
});
|
|
450
|
+
}
|
|
451
|
+
);
|
|
416
452
|
device.addEventListener("isConnected", () => {
|
|
417
453
|
updateToggleSamplingButton();
|
|
418
454
|
});
|
|
@@ -451,7 +487,9 @@ async function getProjects() {
|
|
|
451
487
|
x.open("GET", `${studioEndpoint}/v1/api/projects`);
|
|
452
488
|
x.onload = () => {
|
|
453
489
|
if (x.status !== 200) {
|
|
454
|
-
reject(
|
|
490
|
+
reject(
|
|
491
|
+
"No projects found: " + x.status + " - " + JSON.stringify(x.response)
|
|
492
|
+
);
|
|
455
493
|
} else {
|
|
456
494
|
if (!x.response.success) {
|
|
457
495
|
reject(x.response.error);
|
|
@@ -459,7 +497,9 @@ async function getProjects() {
|
|
|
459
497
|
const projects = x.response.projects;
|
|
460
498
|
console.log("projects", projects);
|
|
461
499
|
resolve(projects);
|
|
462
|
-
window.dispatchEvent(
|
|
500
|
+
window.dispatchEvent(
|
|
501
|
+
new CustomEvent("edgeImpulseProjects", { detail: { projects } })
|
|
502
|
+
);
|
|
463
503
|
}
|
|
464
504
|
}
|
|
465
505
|
};
|
|
@@ -476,7 +516,9 @@ async function getProject() {
|
|
|
476
516
|
x.open("GET", `${studioEndpoint}/v1/api/${projectId}/public-info`);
|
|
477
517
|
x.onload = () => {
|
|
478
518
|
if (x.status !== 200) {
|
|
479
|
-
reject(
|
|
519
|
+
reject(
|
|
520
|
+
"No projects found: " + x.status + " - " + JSON.stringify(x.response)
|
|
521
|
+
);
|
|
480
522
|
} else {
|
|
481
523
|
if (!x.response.success) {
|
|
482
524
|
reject(x.response.error);
|
|
@@ -484,7 +526,9 @@ async function getProject() {
|
|
|
484
526
|
const project = x.response;
|
|
485
527
|
console.log("project", project);
|
|
486
528
|
resolve(project);
|
|
487
|
-
window.dispatchEvent(
|
|
529
|
+
window.dispatchEvent(
|
|
530
|
+
new CustomEvent("edgeImpulseProject", { detail: { project } })
|
|
531
|
+
);
|
|
488
532
|
}
|
|
489
533
|
}
|
|
490
534
|
};
|
|
@@ -503,7 +547,12 @@ async function getHmacKey() {
|
|
|
503
547
|
x.open("GET", `${studioEndpoint}/v1/api/${projectId}/devkeys`);
|
|
504
548
|
x.onload = () => {
|
|
505
549
|
if (x.status !== 200) {
|
|
506
|
-
reject(
|
|
550
|
+
reject(
|
|
551
|
+
"No development keys found: " +
|
|
552
|
+
x.status +
|
|
553
|
+
" - " +
|
|
554
|
+
JSON.stringify(x.response)
|
|
555
|
+
);
|
|
507
556
|
} else {
|
|
508
557
|
if (!x.response.success) {
|
|
509
558
|
reject(x.response.error);
|
|
@@ -609,10 +658,14 @@ async function connectToRemoteManagement() {
|
|
|
609
658
|
console.log("samplingDetails", samplingDetails);
|
|
610
659
|
|
|
611
660
|
/** @type {BS.ContinuousSensorType[]} */
|
|
612
|
-
const sensorTypes = samplingDetails.sensor.split(
|
|
661
|
+
const sensorTypes = samplingDetails.sensor.split(
|
|
662
|
+
sensorCombinationSeparator
|
|
663
|
+
);
|
|
613
664
|
console.log("sensorTypes", sensorTypes);
|
|
614
665
|
|
|
615
|
-
const invalidSensors = sensorTypes.filter(
|
|
666
|
+
const invalidSensors = sensorTypes.filter(
|
|
667
|
+
(sensorType) => !device.allowedTfliteSensorTypes.includes(sensorType)
|
|
668
|
+
);
|
|
616
669
|
if (invalidSensors.length > 0) {
|
|
617
670
|
console.error("invalid sensorTypes", invalidSensors);
|
|
618
671
|
return;
|
|
@@ -707,7 +760,7 @@ function remoteManagementHelloMessage() {
|
|
|
707
760
|
return {
|
|
708
761
|
name: sensorCombination,
|
|
709
762
|
maxSampleLengthS: 1 * 60,
|
|
710
|
-
frequencies: [50.0, 25.0, 12.5], // 20ms, 40ms, 80ms
|
|
763
|
+
frequencies: [100.0, 50.0, 25.0, 12.5], // 10ms, 20ms, 40ms, 80ms
|
|
711
764
|
};
|
|
712
765
|
}),
|
|
713
766
|
supportsSnapshotStreaming: false,
|
|
@@ -716,11 +769,16 @@ function remoteManagementHelloMessage() {
|
|
|
716
769
|
}
|
|
717
770
|
|
|
718
771
|
function isRemoteManagementConnected() {
|
|
719
|
-
return
|
|
772
|
+
return (
|
|
773
|
+
remoteManagementWebSocket?.readyState == WebSocket.OPEN &&
|
|
774
|
+
remoteManagementWebSocket?._isConnected
|
|
775
|
+
);
|
|
720
776
|
}
|
|
721
777
|
|
|
722
778
|
/** @type {HTMLButtonElement} */
|
|
723
|
-
const toggleRemoteManagementConnectionButton = document.getElementById(
|
|
779
|
+
const toggleRemoteManagementConnectionButton = document.getElementById(
|
|
780
|
+
"toggleRemoteManagementConnection"
|
|
781
|
+
);
|
|
724
782
|
toggleRemoteManagementConnectionButton.addEventListener("click", () => {
|
|
725
783
|
if (isRemoteManagementConnected()) {
|
|
726
784
|
remoteManagementWebSocket.dontReconnect = true;
|
|
@@ -756,13 +814,20 @@ let reconnectRemoteManagementOnDisconnection = false;
|
|
|
756
814
|
const reconnectRemoteManagementOnDisconnectionInput = document.getElementById(
|
|
757
815
|
"reconnectRemoteManagementOnDisconnection"
|
|
758
816
|
);
|
|
759
|
-
reconnectRemoteManagementOnDisconnectionInput.addEventListener(
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
817
|
+
reconnectRemoteManagementOnDisconnectionInput.addEventListener(
|
|
818
|
+
"input",
|
|
819
|
+
(event) => {
|
|
820
|
+
setReconnectRemoteManagementOnDisconnection(event.target.checked);
|
|
821
|
+
}
|
|
822
|
+
);
|
|
823
|
+
reconnectRemoteManagementOnDisconnectionInput.checked =
|
|
824
|
+
reconnectRemoteManagementOnDisconnection;
|
|
763
825
|
/** @param {boolean} newReconnectRemoteManagementOnDisconnection */
|
|
764
|
-
function setReconnectRemoteManagementOnDisconnection(
|
|
765
|
-
|
|
826
|
+
function setReconnectRemoteManagementOnDisconnection(
|
|
827
|
+
newReconnectRemoteManagementOnDisconnection
|
|
828
|
+
) {
|
|
829
|
+
reconnectRemoteManagementOnDisconnection =
|
|
830
|
+
newReconnectRemoteManagementOnDisconnection;
|
|
766
831
|
console.log({ reconnectRemoteManagementOnDisconnection });
|
|
767
832
|
dispatchEvent(new Event("reconnectRemoteManagementOnDisconnection"));
|
|
768
833
|
}
|
|
@@ -843,7 +908,9 @@ async function uploadData(sensorTypes, deviceData) {
|
|
|
843
908
|
case "linearAcceleration":
|
|
844
909
|
case "gyroscope":
|
|
845
910
|
case "magnetometer":
|
|
846
|
-
names = ["x", "y", "z"].map(
|
|
911
|
+
names = ["x", "y", "z"].map(
|
|
912
|
+
(component) => `${sensorType}.${component}`
|
|
913
|
+
);
|
|
847
914
|
switch (sensorType) {
|
|
848
915
|
case "linearAcceleration":
|
|
849
916
|
units = "g/s";
|
|
@@ -891,8 +958,15 @@ async function uploadData(sensorTypes, deviceData) {
|
|
|
891
958
|
});
|
|
892
959
|
break;
|
|
893
960
|
case "pressure":
|
|
894
|
-
for (
|
|
895
|
-
|
|
961
|
+
for (
|
|
962
|
+
let pressureIndex = 0;
|
|
963
|
+
pressureIndex < device.numberOfPressureSensors;
|
|
964
|
+
pressureIndex++
|
|
965
|
+
) {
|
|
966
|
+
value.push(
|
|
967
|
+
sensorSamples[sampleIndex].sensors[pressureIndex].rawValue *
|
|
968
|
+
scalar
|
|
969
|
+
);
|
|
896
970
|
}
|
|
897
971
|
break;
|
|
898
972
|
default:
|
|
@@ -928,7 +1002,11 @@ async function uploadData(sensorTypes, deviceData) {
|
|
|
928
1002
|
console.log("signature", data.signature);
|
|
929
1003
|
|
|
930
1004
|
const formData = new FormData();
|
|
931
|
-
formData.append(
|
|
1005
|
+
formData.append(
|
|
1006
|
+
"message",
|
|
1007
|
+
new Blob([JSON.stringify(data)], { type: "application/json" }),
|
|
1008
|
+
"message.json"
|
|
1009
|
+
);
|
|
932
1010
|
|
|
933
1011
|
return new Promise((resolve, reject) => {
|
|
934
1012
|
let xml = new XMLHttpRequest();
|
|
@@ -936,7 +1014,12 @@ async function uploadData(sensorTypes, deviceData) {
|
|
|
936
1014
|
if (xml.status === 200) {
|
|
937
1015
|
resolve(xml.responseText);
|
|
938
1016
|
} else {
|
|
939
|
-
reject(
|
|
1017
|
+
reject(
|
|
1018
|
+
"Failed to upload (status code " +
|
|
1019
|
+
xml.status +
|
|
1020
|
+
"): " +
|
|
1021
|
+
xml.responseText
|
|
1022
|
+
);
|
|
940
1023
|
}
|
|
941
1024
|
};
|
|
942
1025
|
xml.onerror = () => reject(undefined);
|
|
@@ -980,10 +1063,16 @@ async function createSignature(hmacKey, data) {
|
|
|
980
1063
|
["sign", "verify"] // what this key can do
|
|
981
1064
|
);
|
|
982
1065
|
// Create signature for encoded input data
|
|
983
|
-
const signature = await crypto.subtle.sign(
|
|
1066
|
+
const signature = await crypto.subtle.sign(
|
|
1067
|
+
"HMAC",
|
|
1068
|
+
key,
|
|
1069
|
+
textEncoder.encode(JSON.stringify(data))
|
|
1070
|
+
);
|
|
984
1071
|
// Convert back to Hex
|
|
985
1072
|
const b = new Uint8Array(signature);
|
|
986
|
-
return Array.prototype.map
|
|
1073
|
+
return Array.prototype.map
|
|
1074
|
+
.call(b, (x) => ("00" + x.toString(16)).slice(-2))
|
|
1075
|
+
.join("");
|
|
987
1076
|
}
|
|
988
1077
|
|
|
989
1078
|
// EDGE IMPULSE CONFIG
|
|
@@ -1012,7 +1101,9 @@ function loadConfigFromLocalStorage() {
|
|
|
1012
1101
|
loadConfigFromLocalStorage();
|
|
1013
1102
|
|
|
1014
1103
|
function saveConfigToLocalStorage() {
|
|
1015
|
-
const isConfigDifferent =
|
|
1104
|
+
const isConfigDifferent =
|
|
1105
|
+
!loadedConfig ||
|
|
1106
|
+
Object.entries(loadedConfig).some(([key, value]) => config[key] != value);
|
|
1016
1107
|
if (!isConfigDifferent) {
|
|
1017
1108
|
return;
|
|
1018
1109
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Running your impulse using WebAssembly in the browser
|
|
2
|
+
|
|
3
|
+
For more information see the documentation at https://docs.edgeimpulse.com/docs/through-webassembly-browser
|
|
4
|
+
|
|
5
|
+
To start, open a terminal or command prompt and run:
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
$ python3 server.py
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Then open http://localhost:8082 in a browser to see the application.
|