@robotical/raftjs 1.4.7 → 2.0.4
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/dist/react-native/RaftAttributeHandler.d.ts +2 -0
- package/dist/react-native/RaftAttributeHandler.js +136 -10
- package/dist/react-native/RaftAttributeHandler.js.map +1 -1
- package/dist/react-native/RaftChannel.d.ts +2 -0
- package/dist/react-native/RaftChannelBLE.native.d.ts +2 -0
- package/dist/react-native/RaftChannelBLE.native.js +14 -7
- package/dist/react-native/RaftChannelBLE.native.js.map +1 -1
- package/dist/react-native/RaftChannelBLE.web.d.ts +2 -0
- package/dist/react-native/RaftChannelBLE.web.js +24 -15
- package/dist/react-native/RaftChannelBLE.web.js.map +1 -1
- package/dist/react-native/RaftChannelSimulated.d.ts +32 -0
- package/dist/react-native/RaftChannelSimulated.js +418 -0
- package/dist/react-native/RaftChannelSimulated.js.map +1 -0
- package/dist/react-native/RaftChannelWebSerial.d.ts +2 -0
- package/dist/react-native/RaftChannelWebSerial.js +18 -9
- package/dist/react-native/RaftChannelWebSerial.js.map +1 -1
- package/dist/react-native/RaftChannelWebSocket.d.ts +2 -0
- package/dist/react-native/RaftChannelWebSocket.js +10 -0
- package/dist/react-native/RaftChannelWebSocket.js.map +1 -1
- package/dist/react-native/RaftConnector.js +13 -6
- package/dist/react-native/RaftConnector.js.map +1 -1
- package/dist/react-native/RaftCustomAttrHandler.js +15 -0
- package/dist/react-native/RaftCustomAttrHandler.js.map +1 -1
- package/dist/react-native/RaftDeviceInfo.d.ts +8 -1
- package/dist/react-native/RaftDeviceInfo.js +17 -3
- package/dist/react-native/RaftDeviceInfo.js.map +1 -1
- package/dist/react-native/RaftDeviceManager.d.ts +3 -0
- package/dist/react-native/RaftDeviceManager.js +123 -43
- package/dist/react-native/RaftDeviceManager.js.map +1 -1
- package/dist/react-native/RaftFileHandler.js +8 -8
- package/dist/react-native/RaftFileHandler.js.map +1 -1
- package/dist/react-native/RaftLog.js +1 -1
- package/dist/react-native/RaftLog.js.map +1 -1
- package/dist/react-native/RaftMsgHandler.d.ts +5 -0
- package/dist/react-native/RaftMsgHandler.js +32 -0
- package/dist/react-native/RaftMsgHandler.js.map +1 -1
- package/dist/react-native/RaftStreamHandler.js +6 -5
- package/dist/react-native/RaftStreamHandler.js.map +1 -1
- package/dist/react-native/RaftStruct.js +197 -147
- package/dist/react-native/RaftStruct.js.map +1 -1
- package/dist/react-native/RaftSysTypeManager.d.ts +2 -0
- package/dist/react-native/RaftSysTypeManager.js +25 -0
- package/dist/react-native/RaftSysTypeManager.js.map +1 -1
- package/dist/react-native/RaftSystemType.d.ts +9 -7
- package/dist/react-native/RaftSystemUtils.js +3 -1
- package/dist/react-native/RaftSystemUtils.js.map +1 -1
- package/dist/react-native/RaftUpdateManager.js +2 -2
- package/dist/react-native/RaftUpdateManager.js.map +1 -1
- package/dist/react-native/RaftUtils.d.ts +2 -0
- package/dist/react-native/RaftUtils.js +22 -2
- package/dist/react-native/RaftUtils.js.map +1 -1
- package/dist/react-native/main.d.ts +2 -0
- package/dist/react-native/main.js +4 -1
- package/dist/react-native/main.js.map +1 -1
- package/dist/web/RaftAttributeHandler.d.ts +2 -0
- package/dist/web/RaftAttributeHandler.js +136 -10
- package/dist/web/RaftAttributeHandler.js.map +1 -1
- package/dist/web/RaftChannel.d.ts +2 -0
- package/dist/web/RaftChannelBLE.web.d.ts +2 -0
- package/dist/web/RaftChannelBLE.web.js +24 -15
- package/dist/web/RaftChannelBLE.web.js.map +1 -1
- package/dist/web/RaftChannelSimulated.d.ts +32 -0
- package/dist/web/RaftChannelSimulated.js +418 -0
- package/dist/web/RaftChannelSimulated.js.map +1 -0
- package/dist/web/RaftChannelWebSerial.d.ts +2 -0
- package/dist/web/RaftChannelWebSerial.js +18 -9
- package/dist/web/RaftChannelWebSerial.js.map +1 -1
- package/dist/web/RaftChannelWebSocket.d.ts +2 -0
- package/dist/web/RaftChannelWebSocket.js +10 -0
- package/dist/web/RaftChannelWebSocket.js.map +1 -1
- package/dist/web/RaftConnector.js +13 -6
- package/dist/web/RaftConnector.js.map +1 -1
- package/dist/web/RaftCustomAttrHandler.js +15 -0
- package/dist/web/RaftCustomAttrHandler.js.map +1 -1
- package/dist/web/RaftDeviceInfo.d.ts +8 -1
- package/dist/web/RaftDeviceInfo.js +17 -3
- package/dist/web/RaftDeviceInfo.js.map +1 -1
- package/dist/web/RaftDeviceManager.d.ts +3 -0
- package/dist/web/RaftDeviceManager.js +123 -43
- package/dist/web/RaftDeviceManager.js.map +1 -1
- package/dist/web/RaftFileHandler.js +8 -8
- package/dist/web/RaftFileHandler.js.map +1 -1
- package/dist/web/RaftLog.js +1 -1
- package/dist/web/RaftLog.js.map +1 -1
- package/dist/web/RaftMsgHandler.d.ts +5 -0
- package/dist/web/RaftMsgHandler.js +32 -0
- package/dist/web/RaftMsgHandler.js.map +1 -1
- package/dist/web/RaftStreamHandler.js +6 -5
- package/dist/web/RaftStreamHandler.js.map +1 -1
- package/dist/web/RaftStruct.js +197 -147
- package/dist/web/RaftStruct.js.map +1 -1
- package/dist/web/RaftSysTypeManager.d.ts +2 -0
- package/dist/web/RaftSysTypeManager.js +25 -0
- package/dist/web/RaftSysTypeManager.js.map +1 -1
- package/dist/web/RaftSystemType.d.ts +9 -7
- package/dist/web/RaftSystemUtils.js +3 -1
- package/dist/web/RaftSystemUtils.js.map +1 -1
- package/dist/web/RaftUpdateManager.js +2 -2
- package/dist/web/RaftUpdateManager.js.map +1 -1
- package/dist/web/RaftUtils.d.ts +2 -0
- package/dist/web/RaftUtils.js +22 -2
- package/dist/web/RaftUtils.js.map +1 -1
- package/dist/web/main.d.ts +2 -0
- package/dist/web/main.js +4 -1
- package/dist/web/main.js.map +1 -1
- package/examples/dashboard/package.json +1 -1
- package/examples/dashboard/src/CommandPanel.tsx +3 -3
- package/examples/dashboard/src/ConnManager.ts +83 -6
- package/examples/dashboard/src/DeviceActionsForm.tsx +2 -2
- package/examples/dashboard/src/DevicePanel.tsx +2 -2
- package/examples/dashboard/src/Main.tsx +14 -4
- package/examples/dashboard/src/SystemTypeMarty/RICSystemUtils.ts +4 -4
- package/examples/dashboard/src/styles.css +8 -0
- package/examples/dashboard/tsconfig.json +1 -1
- package/package.json +10 -11
- package/src/RaftAttributeHandler.ts +163 -11
- package/src/RaftChannel.ts +2 -0
- package/src/RaftChannelBLE.native.ts +17 -8
- package/src/RaftChannelBLE.web.ts +28 -16
- package/src/RaftChannelSimulated.ts +482 -0
- package/src/RaftChannelWebSerial.ts +18 -7
- package/src/RaftChannelWebSocket.ts +13 -0
- package/src/RaftConnector.ts +13 -7
- package/src/RaftCustomAttrHandler.ts +17 -0
- package/src/RaftDeviceInfo.ts +27 -5
- package/src/RaftDeviceManager.ts +155 -47
- package/src/RaftFileHandler.ts +8 -8
- package/src/RaftLog.ts +1 -1
- package/src/RaftMsgHandler.ts +36 -0
- package/src/RaftStreamHandler.ts +48 -47
- package/src/RaftStruct.ts +220 -147
- package/src/RaftSysTypeManager.ts +27 -0
- package/src/RaftSystemType.ts +9 -7
- package/src/RaftSystemUtils.ts +3 -1
- package/src/RaftUpdateManager.ts +2 -2
- package/src/RaftUtils.ts +25 -5
- package/src/main.ts +2 -0
package/src/RaftSystemType.ts
CHANGED
|
@@ -15,18 +15,20 @@ export interface ConnectorOptions {
|
|
|
15
15
|
|
|
16
16
|
export interface RaftSystemType {
|
|
17
17
|
nameForDialogs: string;
|
|
18
|
-
defaultWiFiHostname
|
|
19
|
-
BLEServiceUUIDs
|
|
20
|
-
BLECmdUUID
|
|
21
|
-
BLERespUUID
|
|
22
|
-
|
|
23
|
-
|
|
18
|
+
defaultWiFiHostname?: string;
|
|
19
|
+
BLEServiceUUIDs?: string[];
|
|
20
|
+
BLECmdUUID?: string;
|
|
21
|
+
BLERespUUID?: string;
|
|
22
|
+
BLEDeviceNames?: string[];
|
|
23
|
+
firmwareDestName?: string;
|
|
24
|
+
normalFileDestName?: string;
|
|
24
25
|
connectorOptions: ConnectorOptions;
|
|
25
26
|
setup: (systemUtils: RaftSystemUtils, onEvent: RaftEventFn | null) => void;
|
|
26
27
|
subscribeForUpdates: RaftSubscribeForUpdatesCBType | null;
|
|
27
28
|
stateIsInvalid: RaftStateIsInvalidCBType | null;
|
|
28
29
|
rxOtherMsgType: RaftRxOtherMsgType | null;
|
|
29
|
-
deviceMgrIF
|
|
30
|
+
deviceMgrIF?: RaftDeviceMgrIF;
|
|
31
|
+
nonRaftTypeCode?: string;
|
|
30
32
|
}
|
|
31
33
|
|
|
32
34
|
export type RaftGetSystemTypeCBType = (systemUtils: RaftSystemUtils) => Promise<RaftSystemType | null>;
|
package/src/RaftSystemUtils.ts
CHANGED
|
@@ -61,7 +61,9 @@ export default class RaftSystemUtils {
|
|
|
61
61
|
* @param defaultWiFiHostname
|
|
62
62
|
*/
|
|
63
63
|
setDefaultWiFiHostname(defaultWiFiHostname: string) {
|
|
64
|
-
|
|
64
|
+
if (defaultWiFiHostname) {
|
|
65
|
+
this._defaultWiFiHostname = defaultWiFiHostname;
|
|
66
|
+
}
|
|
65
67
|
}
|
|
66
68
|
|
|
67
69
|
/**
|
package/src/RaftUpdateManager.ts
CHANGED
|
@@ -762,9 +762,9 @@ export default class RICUpdateManager {
|
|
|
762
762
|
): Promise<boolean> {
|
|
763
763
|
|
|
764
764
|
// Get the destination
|
|
765
|
-
let fileDest = this._systemType ? this._systemType.normalFileDestName : "fs";
|
|
765
|
+
let fileDest = this._systemType && this._systemType.normalFileDestName ? this._systemType.normalFileDestName : "fs";
|
|
766
766
|
if (fileType === RaftFileSendType.FIRMWARE_UPDATE) {
|
|
767
|
-
fileDest = this._systemType ? this._systemType.firmwareDestName : "fw";
|
|
767
|
+
fileDest = this._systemType && this._systemType.firmwareDestName ? this._systemType.firmwareDestName : "fw";
|
|
768
768
|
}
|
|
769
769
|
return await this._raftFileHandler.fileSend(
|
|
770
770
|
fileName,
|
package/src/RaftUtils.ts
CHANGED
|
@@ -29,7 +29,7 @@ export default class RaftUtils {
|
|
|
29
29
|
): void {
|
|
30
30
|
// Check valid
|
|
31
31
|
if (buffer.length < startPos + strToAdd.length + 1) {
|
|
32
|
-
RaftLog.
|
|
32
|
+
RaftLog.warn("addStringToBuffer buffer too short");
|
|
33
33
|
return;
|
|
34
34
|
}
|
|
35
35
|
let curPos = startPos;
|
|
@@ -471,7 +471,7 @@ export default class RaftUtils {
|
|
|
471
471
|
return v1 === v2;
|
|
472
472
|
} catch (e) {
|
|
473
473
|
// one of the two versions is invalid, return false
|
|
474
|
-
RaftLog.
|
|
474
|
+
RaftLog.warn(`isVersionEqual - invalid version ${v1} or ${v2} ${e}`);
|
|
475
475
|
return false;
|
|
476
476
|
}
|
|
477
477
|
}
|
|
@@ -481,14 +481,34 @@ export default class RaftUtils {
|
|
|
481
481
|
const timeout = new Promise((_, reject) => {
|
|
482
482
|
id = setTimeout(() => {
|
|
483
483
|
clearTimeout(id);
|
|
484
|
-
reject('Timed out in '+ ms + 'ms.')
|
|
484
|
+
reject('Timed out in ' + ms + 'ms.')
|
|
485
485
|
}, ms)
|
|
486
486
|
})
|
|
487
|
-
|
|
487
|
+
|
|
488
488
|
return Promise.race([
|
|
489
489
|
promise,
|
|
490
490
|
timeout
|
|
491
491
|
])
|
|
492
492
|
}
|
|
493
|
-
|
|
493
|
+
|
|
494
|
+
static toBufferSource(u8: Uint8Array<ArrayBufferLike>): BufferSource {
|
|
495
|
+
if (u8.buffer instanceof ArrayBuffer) {
|
|
496
|
+
// Respect byteOffset/byteLength
|
|
497
|
+
return u8.buffer.slice(u8.byteOffset, u8.byteOffset + u8.byteLength);
|
|
498
|
+
}
|
|
499
|
+
// e.g., SharedArrayBuffer -> copy into a real ArrayBuffer
|
|
500
|
+
const ab = new ArrayBuffer(u8.byteLength);
|
|
501
|
+
new Uint8Array(ab).set(u8);
|
|
502
|
+
return ab;
|
|
503
|
+
}
|
|
504
|
+
static toArrayBufferView(u8: Uint8Array<ArrayBufferLike>): Uint8Array<ArrayBuffer> {
|
|
505
|
+
if (u8.buffer instanceof ArrayBuffer) {
|
|
506
|
+
// keep the same bytes/offset/length, but the return type is now locked to ArrayBuffer
|
|
507
|
+
return new Uint8Array(u8.buffer, u8.byteOffset, u8.byteLength);
|
|
508
|
+
}
|
|
509
|
+
// e.g., SharedArrayBuffer → copy into a real ArrayBuffer
|
|
510
|
+
const ab = new ArrayBuffer(u8.byteLength);
|
|
511
|
+
new Uint8Array(ab).set(u8);
|
|
512
|
+
return new Uint8Array(ab);
|
|
513
|
+
}
|
|
494
514
|
}
|
package/src/main.ts
CHANGED
|
@@ -16,6 +16,7 @@ export { default as RaftCommsStats } from './RaftCommsStats';
|
|
|
16
16
|
export { default as RaftConnector } from './RaftConnector';
|
|
17
17
|
export { default as RaftChannel } from './RaftChannel';
|
|
18
18
|
export { default as RaftChannelWebSocket } from './RaftChannelWebSocket';
|
|
19
|
+
export { default as RaftChannelSimulated } from './RaftChannelSimulated';
|
|
19
20
|
export { default as RaftFileHandler } from './RaftFileHandler';
|
|
20
21
|
export { default as RaftLog } from './RaftLog';
|
|
21
22
|
export { default as RaftMiniHDLC } from './RaftMiniHDLC';
|
|
@@ -34,3 +35,4 @@ export * from './RaftConnEvents';
|
|
|
34
35
|
export * from './RaftUpdateEvents';
|
|
35
36
|
export * from "./RaftProtocolDefs";
|
|
36
37
|
export * from "./RaftDeviceStates";
|
|
38
|
+
export * from "./RaftDeviceInfo";
|