@robdobsn/raftjs 1.7.8 → 1.10.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/.editorconfig +14 -0
- package/.gitattributes +11 -0
- package/.nvmrc +1 -0
- package/TODO.md +1 -0
- package/dist/react-native/RaftAttributeHandler.d.ts +14 -0
- package/dist/react-native/RaftAttributeHandler.js +375 -0
- package/dist/react-native/RaftAttributeHandler.js.map +1 -0
- package/dist/react-native/RaftChannel.d.ts +20 -0
- package/dist/react-native/RaftChannel.js +12 -0
- package/dist/react-native/RaftChannel.js.map +1 -0
- package/dist/react-native/RaftChannelBLE.native.d.ts +95 -0
- package/dist/react-native/RaftChannelBLE.native.js +483 -0
- package/dist/react-native/RaftChannelBLE.native.js.map +1 -0
- package/dist/react-native/RaftChannelBLE.web.d.ts +40 -0
- package/dist/react-native/RaftChannelBLE.web.js +302 -0
- package/dist/react-native/RaftChannelBLE.web.js.map +1 -0
- package/dist/react-native/RaftChannelBLEFactory.d.ts +10 -0
- package/dist/react-native/RaftChannelBLEFactory.js +17 -0
- package/dist/react-native/RaftChannelBLEFactory.js.map +1 -0
- package/dist/react-native/RaftChannelBLEScanner.native.d.ts +18 -0
- package/dist/react-native/RaftChannelBLEScanner.native.js +138 -0
- package/dist/react-native/RaftChannelBLEScanner.native.js.map +1 -0
- package/dist/react-native/RaftChannelSimulated.d.ts +42 -0
- package/dist/react-native/RaftChannelSimulated.js +1000 -0
- package/dist/react-native/RaftChannelSimulated.js.map +1 -0
- package/dist/react-native/RaftChannelWebSerial.d.ts +39 -0
- package/dist/react-native/RaftChannelWebSerial.js +329 -0
- package/dist/react-native/RaftChannelWebSerial.js.map +1 -0
- package/dist/react-native/RaftChannelWebSocket.d.ts +30 -0
- package/dist/react-native/RaftChannelWebSocket.js +222 -0
- package/dist/react-native/RaftChannelWebSocket.js.map +1 -0
- package/dist/react-native/RaftCommsStats.d.ts +39 -0
- package/dist/react-native/RaftCommsStats.js +128 -0
- package/dist/react-native/RaftCommsStats.js.map +1 -0
- package/dist/react-native/RaftConnEvents.d.ts +39 -0
- package/dist/react-native/RaftConnEvents.js +54 -0
- package/dist/react-native/RaftConnEvents.js.map +1 -0
- package/dist/react-native/RaftConnector.d.ts +248 -0
- package/dist/react-native/RaftConnector.js +658 -0
- package/dist/react-native/RaftConnector.js.map +1 -0
- package/dist/react-native/RaftCustomAttrHandler.d.ts +6 -0
- package/dist/react-native/RaftCustomAttrHandler.js +93 -0
- package/dist/react-native/RaftCustomAttrHandler.js.map +1 -0
- package/dist/react-native/RaftDeviceInfo.d.ts +71 -0
- package/dist/react-native/RaftDeviceInfo.js +50 -0
- package/dist/react-native/RaftDeviceInfo.js.map +1 -0
- package/dist/react-native/RaftDeviceManager.d.ts +61 -0
- package/dist/react-native/RaftDeviceManager.js +665 -0
- package/dist/react-native/RaftDeviceManager.js.map +1 -0
- package/dist/react-native/RaftDeviceMgrIF.d.ts +15 -0
- package/dist/react-native/RaftDeviceMgrIF.js +11 -0
- package/dist/react-native/RaftDeviceMgrIF.js.map +1 -0
- package/dist/react-native/RaftDeviceMsg.d.ts +9 -0
- package/dist/react-native/RaftDeviceMsg.js +11 -0
- package/dist/react-native/RaftDeviceMsg.js.map +1 -0
- package/dist/react-native/RaftDeviceStates.d.ts +37 -0
- package/dist/react-native/RaftDeviceStates.js +60 -0
- package/dist/react-native/RaftDeviceStates.js.map +1 -0
- package/dist/react-native/RaftFileHandler.d.ts +52 -0
- package/dist/react-native/RaftFileHandler.js +502 -0
- package/dist/react-native/RaftFileHandler.js.map +1 -0
- package/dist/react-native/RaftLog.d.ts +22 -0
- package/dist/react-native/RaftLog.js +63 -0
- package/dist/react-native/RaftLog.js.map +1 -0
- package/dist/react-native/RaftMiniHDLC.d.ts +18 -0
- package/dist/react-native/RaftMiniHDLC.js +383 -0
- package/dist/react-native/RaftMiniHDLC.js.map +1 -0
- package/dist/react-native/RaftMsgHandler.d.ts +62 -0
- package/dist/react-native/RaftMsgHandler.js +511 -0
- package/dist/react-native/RaftMsgHandler.js.map +1 -0
- package/dist/react-native/RaftMsgTrackInfo.d.ts +17 -0
- package/dist/react-native/RaftMsgTrackInfo.js +42 -0
- package/dist/react-native/RaftMsgTrackInfo.js.map +1 -0
- package/dist/react-native/RaftProtocolDefs.d.ts +30 -0
- package/dist/react-native/RaftProtocolDefs.js +48 -0
- package/dist/react-native/RaftProtocolDefs.js.map +1 -0
- package/dist/react-native/RaftStreamHandler.d.ts +38 -0
- package/dist/react-native/RaftStreamHandler.js +258 -0
- package/dist/react-native/RaftStreamHandler.js.map +1 -0
- package/dist/react-native/RaftStruct.d.ts +3 -0
- package/dist/react-native/RaftStruct.js +258 -0
- package/dist/react-native/RaftStruct.js.map +1 -0
- package/dist/react-native/RaftSysTypeManager.d.ts +16 -0
- package/dist/react-native/RaftSysTypeManager.js +78 -0
- package/dist/react-native/RaftSysTypeManager.js.map +1 -0
- package/dist/react-native/RaftSystemType.d.ts +30 -0
- package/dist/react-native/RaftSystemType.js +3 -0
- package/dist/react-native/RaftSystemType.js.map +1 -0
- package/dist/react-native/RaftSystemUtils.d.ts +136 -0
- package/dist/react-native/RaftSystemUtils.js +412 -0
- package/dist/react-native/RaftSystemUtils.js.map +1 -0
- package/dist/react-native/RaftTypes.d.ts +195 -0
- package/dist/react-native/RaftTypes.js +153 -0
- package/dist/react-native/RaftTypes.js.map +1 -0
- package/dist/react-native/RaftUpdateEvents.d.ts +33 -0
- package/dist/react-native/RaftUpdateEvents.js +46 -0
- package/dist/react-native/RaftUpdateEvents.js.map +1 -0
- package/dist/react-native/RaftUpdateManager.d.ts +61 -0
- package/dist/react-native/RaftUpdateManager.js +621 -0
- package/dist/react-native/RaftUpdateManager.js.map +1 -0
- package/dist/react-native/RaftUtils.d.ts +128 -0
- package/dist/react-native/RaftUtils.js +487 -0
- package/dist/react-native/RaftUtils.js.map +1 -0
- package/dist/react-native/RaftWifiTypes.d.ts +23 -0
- package/dist/react-native/RaftWifiTypes.js +43 -0
- package/dist/react-native/RaftWifiTypes.js.map +1 -0
- package/dist/react-native/main.d.ts +26 -0
- package/dist/react-native/main.js +51 -0
- package/dist/react-native/main.js.map +1 -0
- package/dist/web/RaftAttributeHandler.js +9 -6
- package/dist/web/RaftAttributeHandler.js.map +1 -1
- package/dist/web/RaftChannelBLE.web.js +8 -6
- package/dist/web/RaftChannelBLE.web.js.map +1 -1
- package/dist/web/RaftChannelSimulated.d.ts +10 -0
- package/dist/web/RaftChannelSimulated.js +662 -80
- package/dist/web/RaftChannelSimulated.js.map +1 -1
- package/dist/web/RaftChannelWebSerial.js +2 -2
- package/dist/web/RaftChannelWebSerial.js.map +1 -1
- package/dist/web/RaftChannelWebSocket.js +16 -1
- package/dist/web/RaftChannelWebSocket.js.map +1 -1
- package/dist/web/RaftConnector.d.ts +2 -0
- package/dist/web/RaftConnector.js +38 -15
- package/dist/web/RaftConnector.js.map +1 -1
- package/dist/web/RaftCustomAttrHandler.d.ts +2 -0
- package/dist/web/RaftCustomAttrHandler.js +54 -26
- package/dist/web/RaftCustomAttrHandler.js.map +1 -1
- package/dist/web/RaftDeviceInfo.d.ts +3 -1
- package/dist/web/RaftDeviceInfo.js +17 -3
- package/dist/web/RaftDeviceInfo.js.map +1 -1
- package/dist/web/RaftDeviceManager.d.ts +22 -1
- package/dist/web/RaftDeviceManager.js +210 -44
- package/dist/web/RaftDeviceManager.js.map +1 -1
- package/dist/web/RaftDeviceStates.d.ts +1 -1
- package/dist/web/RaftDeviceStates.js +2 -2
- package/dist/web/RaftDeviceStates.js.map +1 -1
- package/dist/web/RaftMsgHandler.js.map +1 -1
- package/dist/web/RaftStreamHandler.js +2 -1
- 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/RaftUpdateManager.js +1 -1
- package/dist/web/RaftUpdateManager.js.map +1 -1
- package/dist/web/RaftUtils.d.ts +2 -0
- package/dist/web/RaftUtils.js +20 -0
- package/dist/web/RaftUtils.js.map +1 -1
- package/dist/web/main.d.ts +1 -0
- package/dist/web/main.js.map +1 -1
- package/eslint.config.mjs +33 -0
- package/examples/dashboard/package.json +36 -0
- package/examples/dashboard/src/CommandPanel.tsx +147 -0
- package/examples/dashboard/src/ConnManager.ts +166 -0
- package/examples/dashboard/src/DeviceActionsForm.tsx +133 -0
- package/examples/dashboard/src/DeviceAttrsForm.tsx +49 -0
- package/examples/dashboard/src/DeviceLineChart.tsx +163 -0
- package/examples/dashboard/src/DevicePanel.tsx +171 -0
- package/examples/dashboard/src/DevicesPanel.tsx +58 -0
- package/examples/dashboard/src/DispLedGrid.tsx +110 -0
- package/examples/dashboard/src/DispOneLed.tsx +20 -0
- package/examples/dashboard/src/LatencyTest.ts +130 -0
- package/examples/dashboard/src/LatencyTestPanel.tsx +92 -0
- package/examples/dashboard/src/Main.tsx +234 -0
- package/examples/dashboard/src/SettingsManager.ts +67 -0
- package/examples/dashboard/src/SettingsScreen.tsx +174 -0
- package/examples/dashboard/src/StatusPanel.tsx +71 -0
- package/examples/dashboard/src/SystemTypeCog/CogStateInfo.ts +162 -0
- package/examples/dashboard/src/SystemTypeCog/SystemTypeCog.ts +91 -0
- package/examples/dashboard/src/SystemTypeGeneric/StateInfoGeneric.ts +30 -0
- package/examples/dashboard/src/SystemTypeGeneric/SystemTypeGeneric.ts +91 -0
- package/examples/dashboard/src/SystemTypeMarty/RICAddOn.ts +70 -0
- package/examples/dashboard/src/SystemTypeMarty/RICAddOnBase.ts +33 -0
- package/examples/dashboard/src/SystemTypeMarty/RICAddOnManager.ts +342 -0
- package/examples/dashboard/src/SystemTypeMarty/RICCommsStats.ts +170 -0
- package/examples/dashboard/src/SystemTypeMarty/RICHWElem.ts +123 -0
- package/examples/dashboard/src/SystemTypeMarty/RICLEDPatternChecker.ts +207 -0
- package/examples/dashboard/src/SystemTypeMarty/RICROSSerial.ts +464 -0
- package/examples/dashboard/src/SystemTypeMarty/RICServoFaultDetector.ts +146 -0
- package/examples/dashboard/src/SystemTypeMarty/RICStateInfo.ts +97 -0
- package/examples/dashboard/src/SystemTypeMarty/RICSystemUtils.ts +371 -0
- package/examples/dashboard/src/SystemTypeMarty/RICTypes.ts +20 -0
- package/examples/dashboard/src/SystemTypeMarty/SystemTypeMarty.ts +119 -0
- package/examples/dashboard/src/index.html +15 -0
- package/examples/dashboard/src/index.tsx +13 -0
- package/examples/dashboard/src/styles.css +408 -0
- package/examples/dashboard/tsconfig.json +18 -0
- package/jest.config.js +11 -0
- package/package.json +4 -7
- package/src/RaftAttributeHandler.ts +450 -0
- package/src/RaftChannel.ts +32 -0
- package/src/RaftChannelBLE.native.ts +617 -0
- package/src/RaftChannelBLE.web.ts +374 -0
- package/src/RaftChannelBLEFactory.ts +13 -0
- package/src/RaftChannelBLEScanner.native.ts +184 -0
- package/src/RaftChannelSimulated.ts +1176 -0
- package/src/RaftChannelWebSerial.ts +420 -0
- package/src/RaftChannelWebSocket.ts +272 -0
- package/src/RaftCommsStats.ts +142 -0
- package/src/RaftConnEvents.ts +58 -0
- package/src/RaftConnector.ts +785 -0
- package/src/RaftCustomAttrHandler.ts +117 -0
- package/src/RaftDeviceInfo.ts +125 -0
- package/src/RaftDeviceManager.ts +844 -0
- package/src/RaftDeviceMgrIF.ts +33 -0
- package/src/RaftDeviceMsg.ts +20 -0
- package/src/RaftDeviceStates.ts +92 -0
- package/src/RaftFileHandler.ts +668 -0
- package/src/RaftLog.ts +70 -0
- package/src/RaftMiniHDLC.ts +396 -0
- package/src/RaftMsgHandler.ts +812 -0
- package/src/RaftMsgTrackInfo.ts +51 -0
- package/src/RaftProtocolDefs.ts +46 -0
- package/src/RaftStreamHandler.ts +329 -0
- package/src/RaftStruct.ts +282 -0
- package/src/RaftSysTypeManager.ts +87 -0
- package/src/RaftSystemType.ts +34 -0
- package/src/RaftSystemUtils.ts +489 -0
- package/src/RaftTypes.ts +279 -0
- package/src/RaftUpdateEvents.ts +48 -0
- package/src/RaftUpdateManager.ts +781 -0
- package/src/RaftUtils.ts +514 -0
- package/src/RaftWifiTypes.ts +36 -0
- package/src/main.ts +39 -0
- package/testdata/TestDeviceTypeRecs.json +492 -0
- package/tsconfig.json +30 -0
- package/tsconfig.react-native.json +29 -0
package/.editorconfig
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# http://editorconfig.org
|
|
2
|
+
root = true
|
|
3
|
+
|
|
4
|
+
[*]
|
|
5
|
+
charset = utf-8
|
|
6
|
+
end_of_line = lf
|
|
7
|
+
indent_size = 2
|
|
8
|
+
indent_style = space
|
|
9
|
+
insert_final_newline = true
|
|
10
|
+
trim_trailing_whitespace = true
|
|
11
|
+
|
|
12
|
+
[*.md]
|
|
13
|
+
max_line_length = 0
|
|
14
|
+
trim_trailing_whitespace = true
|
package/.gitattributes
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Set the default behavior, in case users don't have core.autocrlf set.
|
|
2
|
+
* text=auto
|
|
3
|
+
|
|
4
|
+
# Declare files that will always have LF line endings on checkout.
|
|
5
|
+
* text eol=lf
|
|
6
|
+
|
|
7
|
+
# Denote all files that are truly binary and should not be modified.
|
|
8
|
+
*.png binary
|
|
9
|
+
*.jpg binary
|
|
10
|
+
*.gif binary
|
|
11
|
+
*.pdf binary
|
package/.nvmrc
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
20.11.0
|
package/TODO.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
[] Previously there was a function called retrieveMartySystemInfo() on RICConnector - this is removed - it used to call RICSystem (now RaftSystemUtils).retrieve info and that used to ge to getHWElems() etc as the code to do that was in RICSystem. This now needs to be split out and getHWElems(), etc handled directly in the target library and not RaftJS
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { DeviceTypePollRespMetadata } from "./RaftDeviceInfo";
|
|
2
|
+
import { DeviceAttributesState, DeviceTimeline } from "./RaftDeviceStates";
|
|
3
|
+
export default class AttributeHandler {
|
|
4
|
+
private _customAttrHandler;
|
|
5
|
+
private POLL_RESULT_TIMESTAMP_SIZE;
|
|
6
|
+
private POLL_RESULT_WRAP_VALUE;
|
|
7
|
+
private POLL_RESULT_RESOLUTION_US;
|
|
8
|
+
processMsgAttrGroup(msgBuffer: Uint8Array, msgBufIdx: number, deviceTimeline: DeviceTimeline, pollRespMetadata: DeviceTypePollRespMetadata, devAttrsState: DeviceAttributesState, maxDataPoints: number): number;
|
|
9
|
+
private validateAttributes;
|
|
10
|
+
private processMsgAttribute;
|
|
11
|
+
private signExtend;
|
|
12
|
+
private extractTimestampAndAdvanceIdx;
|
|
13
|
+
private isValueInRangeString;
|
|
14
|
+
}
|
|
@@ -0,0 +1,375 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
3
|
+
//
|
|
4
|
+
// RaftAttributeHandler
|
|
5
|
+
// Attribute handler for Raft devices
|
|
6
|
+
//
|
|
7
|
+
// Rob Dobson (C) 2024
|
|
8
|
+
//
|
|
9
|
+
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
const tslib_1 = require("tslib");
|
|
12
|
+
const RaftCustomAttrHandler_1 = tslib_1.__importDefault(require("./RaftCustomAttrHandler"));
|
|
13
|
+
const RaftDeviceInfo_1 = require("./RaftDeviceInfo");
|
|
14
|
+
const RaftStruct_1 = require("./RaftStruct");
|
|
15
|
+
class AttributeHandler {
|
|
16
|
+
constructor() {
|
|
17
|
+
// Custom attribute handler
|
|
18
|
+
this._customAttrHandler = new RaftCustomAttrHandler_1.default();
|
|
19
|
+
// Message timestamp size
|
|
20
|
+
this.POLL_RESULT_TIMESTAMP_SIZE = 2;
|
|
21
|
+
this.POLL_RESULT_WRAP_VALUE = this.POLL_RESULT_TIMESTAMP_SIZE === 2 ? 65536 : 4294967296;
|
|
22
|
+
this.POLL_RESULT_RESOLUTION_US = 1000;
|
|
23
|
+
}
|
|
24
|
+
processMsgAttrGroup(msgBuffer, msgBufIdx, deviceTimeline, pollRespMetadata, devAttrsState, maxDataPoints) {
|
|
25
|
+
// console.log(`processMsgAttrGroup msg ${msgHexStr} timestamp ${timestamp} origTimestamp ${origTimestamp} msgBufIdx ${msgBufIdx}`)
|
|
26
|
+
// Extract msg timestamp
|
|
27
|
+
const { newBufIdx, timestampUs } = this.extractTimestampAndAdvanceIdx(msgBuffer, msgBufIdx, deviceTimeline);
|
|
28
|
+
if (newBufIdx < 0)
|
|
29
|
+
return -1;
|
|
30
|
+
msgBufIdx = newBufIdx;
|
|
31
|
+
// Start of message data
|
|
32
|
+
const msgDataStartIdx = msgBufIdx;
|
|
33
|
+
// New attribute values (in order as they appear in the attributes JSON)
|
|
34
|
+
let newAttrValues = [];
|
|
35
|
+
if ("c" in pollRespMetadata) {
|
|
36
|
+
// Extract attribute values using custom handler
|
|
37
|
+
newAttrValues = this._customAttrHandler.handleAttr(pollRespMetadata, msgBuffer, msgBufIdx);
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
// console.log(`RaftAttrHdlr.processMsgAttrGroup ${JSON.stringify(pollRespMetadata)} msgBufIdx ${msgBufIdx} timestampUs ${timestampUs}`);
|
|
41
|
+
// Iterate over attributes
|
|
42
|
+
for (let attrIdx = 0; attrIdx < pollRespMetadata.a.length; attrIdx++) {
|
|
43
|
+
// Get the attribute definition
|
|
44
|
+
const attrDef = pollRespMetadata.a[attrIdx];
|
|
45
|
+
if (!("t" in attrDef)) {
|
|
46
|
+
console.warn(`DeviceManager msg unknown msgBuffer ${msgBuffer} tsUs ${timestampUs} attrDef ${JSON.stringify(attrDef)}`);
|
|
47
|
+
newAttrValues.push([]);
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
// console.log(`RaftAttrHdlr.processMsgAttrGroup attr ${attrDef.n} msgBufIdx ${msgBufIdx} timestampUs ${timestampUs} attrDef ${JSON.stringify(attrDef)}`);
|
|
51
|
+
// Process the attribute
|
|
52
|
+
const { values, newMsgBufIdx } = this.processMsgAttribute(attrDef, msgBuffer, msgBufIdx, msgDataStartIdx);
|
|
53
|
+
if (newMsgBufIdx < 0) {
|
|
54
|
+
newAttrValues.push([]);
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
msgBufIdx = newMsgBufIdx;
|
|
58
|
+
newAttrValues.push(values);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
// Number of bytes in group
|
|
62
|
+
let pollRespSizeBytes = msgBufIdx - msgDataStartIdx;
|
|
63
|
+
if (pollRespSizeBytes < pollRespMetadata.b) {
|
|
64
|
+
pollRespSizeBytes = pollRespMetadata.b;
|
|
65
|
+
}
|
|
66
|
+
// Check if any attributes were added (in addition to timestamp)
|
|
67
|
+
if (newAttrValues.length === 0) {
|
|
68
|
+
console.warn(`DeviceManager msg attrGroup ${JSON.stringify(pollRespMetadata)} newAttrValues ${newAttrValues} is empty`);
|
|
69
|
+
return msgDataStartIdx + pollRespSizeBytes;
|
|
70
|
+
}
|
|
71
|
+
// All attributes must have the same number of new values
|
|
72
|
+
const numNewDataPoints = newAttrValues[0].length;
|
|
73
|
+
for (let i = 1; i < newAttrValues.length; i++) {
|
|
74
|
+
if (newAttrValues[i].length !== numNewDataPoints) {
|
|
75
|
+
console.warn(`DeviceManager msg attrGroup ${pollRespMetadata} attrName ${pollRespMetadata.a[i].n} newAttrValues ${newAttrValues} do not have the same length`);
|
|
76
|
+
return msgDataStartIdx + pollRespSizeBytes;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
// All attributes in the schema should have values
|
|
80
|
+
if (newAttrValues.length !== pollRespMetadata.a.length) {
|
|
81
|
+
console.warn(`DeviceManager msg attrGroup ${pollRespMetadata} newAttrValues ${newAttrValues} length does not match attrGroup.a length`);
|
|
82
|
+
return msgDataStartIdx + pollRespSizeBytes;
|
|
83
|
+
}
|
|
84
|
+
// Add the new attribute values to the device state
|
|
85
|
+
for (let attrIdx = 0; attrIdx < pollRespMetadata.a.length; attrIdx++) {
|
|
86
|
+
// Check if attribute already exists in the device state
|
|
87
|
+
const attrDef = pollRespMetadata.a[attrIdx];
|
|
88
|
+
if (!(attrDef.n in devAttrsState)) {
|
|
89
|
+
devAttrsState[attrDef.n] = {
|
|
90
|
+
name: attrDef.n,
|
|
91
|
+
newAttribute: true,
|
|
92
|
+
newData: false,
|
|
93
|
+
numNewValues: 0,
|
|
94
|
+
values: [],
|
|
95
|
+
units: (0, RaftDeviceInfo_1.decodeAttrUnitsEncoding)(attrDef.u || ""),
|
|
96
|
+
range: attrDef.r || [0, 0],
|
|
97
|
+
format: ("f" in attrDef && typeof attrDef.f == "string") ? attrDef.f : "",
|
|
98
|
+
visibleSeries: "v" in attrDef ? attrDef.v === 0 || attrDef.v === false : ("vs" in attrDef ? (attrDef.vs === 0 || attrDef.vs === false ? false : !!attrDef.vs) : true),
|
|
99
|
+
visibleForm: "v" in attrDef ? attrDef.v === 0 || attrDef.v === false : ("vf" in attrDef ? (attrDef.vf === 0 || attrDef.vf === false ? false : !!attrDef.vf) : true),
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
// Check if any data points need to be discarded
|
|
103
|
+
const discardCount = Math.max(0, devAttrsState[attrDef.n].values.length + newAttrValues[attrIdx].length - maxDataPoints);
|
|
104
|
+
if (discardCount > 0) {
|
|
105
|
+
devAttrsState[attrDef.n].values.splice(0, discardCount);
|
|
106
|
+
}
|
|
107
|
+
// Add the new values
|
|
108
|
+
devAttrsState[attrDef.n].values.push(...newAttrValues[attrIdx]);
|
|
109
|
+
devAttrsState[attrDef.n].newData = newAttrValues[attrIdx].length > 0;
|
|
110
|
+
devAttrsState[attrDef.n].numNewValues = newAttrValues[attrIdx].length;
|
|
111
|
+
}
|
|
112
|
+
// Handle the timestamps with increments if specified
|
|
113
|
+
const timeIncUs = pollRespMetadata.us ? pollRespMetadata.us : 1000;
|
|
114
|
+
const timestampsUs = Array(numNewDataPoints).fill(0);
|
|
115
|
+
for (let i = 0; i < numNewDataPoints; i++) {
|
|
116
|
+
timestampsUs[i] = timestampUs + i * timeIncUs;
|
|
117
|
+
}
|
|
118
|
+
// Check if timeline points need to be discarded
|
|
119
|
+
const discardCount = Math.max(0, deviceTimeline.timestampsUs.length + timestampsUs.length - maxDataPoints);
|
|
120
|
+
if (discardCount > 0) {
|
|
121
|
+
deviceTimeline.timestampsUs.splice(0, discardCount);
|
|
122
|
+
}
|
|
123
|
+
// Add the new timestamps
|
|
124
|
+
deviceTimeline.timestampsUs.push(...timestampsUs);
|
|
125
|
+
// Validate attributes based on the vft field
|
|
126
|
+
this.validateAttributes(pollRespMetadata, devAttrsState, numNewDataPoints);
|
|
127
|
+
// Return the next message buffer index
|
|
128
|
+
return msgDataStartIdx + pollRespSizeBytes;
|
|
129
|
+
}
|
|
130
|
+
validateAttributes(pollRespMetadata, devAttrsState, numNewDataPoints) {
|
|
131
|
+
// Iterate through all attributes to find those with a vft field
|
|
132
|
+
for (let attrIdx = 0; attrIdx < pollRespMetadata.a.length; attrIdx++) {
|
|
133
|
+
const attrDef = pollRespMetadata.a[attrIdx];
|
|
134
|
+
// Check if this attribute has a vft field
|
|
135
|
+
if (!("vft" in attrDef) || !attrDef.vft) {
|
|
136
|
+
continue;
|
|
137
|
+
}
|
|
138
|
+
// Get the name of the validating attribute
|
|
139
|
+
const validatingAttrName = attrDef.vft;
|
|
140
|
+
// Check if the validating attribute exists in the state
|
|
141
|
+
if (!(validatingAttrName in devAttrsState)) {
|
|
142
|
+
console.debug(`Cannot validate attribute ${attrDef.n} as validating attribute ${validatingAttrName} doesn't exist`);
|
|
143
|
+
continue;
|
|
144
|
+
}
|
|
145
|
+
// Get the current attribute state
|
|
146
|
+
const currentAttr = devAttrsState[attrDef.n];
|
|
147
|
+
const validatingAttr = devAttrsState[validatingAttrName];
|
|
148
|
+
// Check if both attributes have values
|
|
149
|
+
if (!currentAttr.values.length || !validatingAttr.values.length) {
|
|
150
|
+
continue;
|
|
151
|
+
}
|
|
152
|
+
// Get the most recent values from both attributes
|
|
153
|
+
const numValues = currentAttr.values.length;
|
|
154
|
+
const startIdx = numValues - numNewDataPoints;
|
|
155
|
+
// Process each of the new values
|
|
156
|
+
for (let i = 0; i < numNewDataPoints; i++) {
|
|
157
|
+
const valueIdx = startIdx + i;
|
|
158
|
+
if (valueIdx >= 0 && valueIdx < numValues) {
|
|
159
|
+
// Check if the validating attribute's value is 0/false at the same index
|
|
160
|
+
const validatingValueIdx = validatingAttr.values.length - numNewDataPoints + i;
|
|
161
|
+
if (validatingValueIdx >= 0 && validatingValueIdx < validatingAttr.values.length) {
|
|
162
|
+
// If the validating attribute's value is 0 or false, mark the current value as invalid
|
|
163
|
+
if (!validatingAttr.values[validatingValueIdx]) {
|
|
164
|
+
currentAttr.values[valueIdx] = NaN; // Using NaN to represent invalid values
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
processMsgAttribute(attrDef, msgBuffer, msgBufIdx, msgDataStartIdx) {
|
|
172
|
+
// Current field message string index
|
|
173
|
+
let curFieldBufIdx = msgBufIdx;
|
|
174
|
+
let attrUsesAbsPos = false;
|
|
175
|
+
// Check for "at" field which means absolute position in the buffer
|
|
176
|
+
if (attrDef.at !== undefined) {
|
|
177
|
+
// Handle both single value and array of byte positions
|
|
178
|
+
if (Array.isArray(attrDef.at)) {
|
|
179
|
+
// Create a new buffer for non-contiguous data extraction
|
|
180
|
+
const elemSize = (0, RaftStruct_1.structSizeOf)(attrDef.t);
|
|
181
|
+
const bytesForType = new Uint8Array(elemSize);
|
|
182
|
+
// Zero out the buffer
|
|
183
|
+
bytesForType.fill(0);
|
|
184
|
+
// Copy bytes from the specified positions
|
|
185
|
+
for (let i = 0; i < attrDef.at.length && i < elemSize; i++) {
|
|
186
|
+
const sourceIdx = msgDataStartIdx + attrDef.at[i];
|
|
187
|
+
if (sourceIdx < msgBuffer.length) {
|
|
188
|
+
bytesForType[i] = msgBuffer[sourceIdx];
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
// Use this buffer for attribute extraction
|
|
192
|
+
msgBuffer = bytesForType;
|
|
193
|
+
curFieldBufIdx = 0;
|
|
194
|
+
}
|
|
195
|
+
else {
|
|
196
|
+
// Standard absolute position in the buffer
|
|
197
|
+
curFieldBufIdx = msgDataStartIdx + attrDef.at;
|
|
198
|
+
}
|
|
199
|
+
attrUsesAbsPos = true;
|
|
200
|
+
}
|
|
201
|
+
// Check if outside bounds of message
|
|
202
|
+
if (curFieldBufIdx >= msgBuffer.length) {
|
|
203
|
+
// console.warn(`DeviceManager msg outside bounds msgBuffer ${msgBuffer} attrName ${attrDef.n}`);
|
|
204
|
+
return { values: [], newMsgBufIdx: -1 };
|
|
205
|
+
}
|
|
206
|
+
// Attribute type
|
|
207
|
+
const attrTypesOnly = attrDef.t;
|
|
208
|
+
// Slice into buffer
|
|
209
|
+
const attrBuf = msgBuffer.slice(curFieldBufIdx);
|
|
210
|
+
// Check if a mask is used and the value is signed
|
|
211
|
+
const maskOnSignedValue = "m" in attrDef && (0, RaftDeviceInfo_1.isAttrTypeSigned)(attrTypesOnly);
|
|
212
|
+
// Extract the value using python-struct
|
|
213
|
+
const unpackValues = (0, RaftStruct_1.structUnpack)(maskOnSignedValue ? attrTypesOnly.toUpperCase() : attrTypesOnly, attrBuf);
|
|
214
|
+
let attrValues = unpackValues;
|
|
215
|
+
// Get number of bytes consumed
|
|
216
|
+
const numBytesConsumed = (0, RaftStruct_1.structSizeOf)(attrTypesOnly);
|
|
217
|
+
// // Check if sign extendable mask specified on signed value
|
|
218
|
+
// if (mmSpecifiedOnSignedValue) {
|
|
219
|
+
// const signBitMask = 1 << (signExtendableMaskSignPos - 1);
|
|
220
|
+
// const valueOnlyMask = signBitMask - 1;
|
|
221
|
+
// if (value & signBitMask) {
|
|
222
|
+
// value = (value & valueOnlyMask) - signBitMask;
|
|
223
|
+
// } else {
|
|
224
|
+
// value = value & valueOnlyMask;
|
|
225
|
+
// }
|
|
226
|
+
// }
|
|
227
|
+
// Check for XOR mask
|
|
228
|
+
if ("x" in attrDef) {
|
|
229
|
+
const mask = typeof attrDef.x === "string" ? parseInt(attrDef.x, 16) : attrDef.x;
|
|
230
|
+
attrValues = attrValues.map((value) => (value >>> 0) ^ mask);
|
|
231
|
+
}
|
|
232
|
+
// Check for AND mask
|
|
233
|
+
if ("m" in attrDef) {
|
|
234
|
+
const mask = typeof attrDef.m === "string" ? parseInt(attrDef.m, 16) : attrDef.m;
|
|
235
|
+
attrValues = attrValues.map((value) => (maskOnSignedValue ? this.signExtend(value, mask) : (value >>> 0) & mask));
|
|
236
|
+
}
|
|
237
|
+
// Check for a sign-bit
|
|
238
|
+
if ("sb" in attrDef) {
|
|
239
|
+
const signBitPos = attrDef.sb;
|
|
240
|
+
const signBitMask = 1 << signBitPos;
|
|
241
|
+
if ("ss" in attrDef) {
|
|
242
|
+
const signBitSubtract = attrDef.ss;
|
|
243
|
+
attrValues = attrValues.map((value) => (value & signBitMask) ? signBitSubtract - value : value);
|
|
244
|
+
}
|
|
245
|
+
else {
|
|
246
|
+
attrValues = attrValues.map((value) => (value & signBitMask) ? value - (signBitMask << 1) : value);
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
// Check for bit shift required
|
|
250
|
+
if ("s" in attrDef && attrDef.s) {
|
|
251
|
+
const bitshift = attrDef.s;
|
|
252
|
+
if (bitshift > 0) {
|
|
253
|
+
attrValues = attrValues.map((value) => (value >>> 0) >>> bitshift);
|
|
254
|
+
}
|
|
255
|
+
else if (bitshift < 0) {
|
|
256
|
+
attrValues = attrValues.map((value) => (value >>> 0) << -bitshift);
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
// Check for divisor
|
|
260
|
+
if ("d" in attrDef && attrDef.d) {
|
|
261
|
+
const divisor = attrDef.d;
|
|
262
|
+
attrValues = attrValues.map((value) => (value) / divisor);
|
|
263
|
+
}
|
|
264
|
+
// Check for value to add
|
|
265
|
+
if ("a" in attrDef && attrDef.a !== undefined) {
|
|
266
|
+
const addValue = attrDef.a;
|
|
267
|
+
attrValues = attrValues.map((value) => (value) + addValue);
|
|
268
|
+
}
|
|
269
|
+
// Apply lookup table if defined
|
|
270
|
+
if ("lut" in attrDef && attrDef.lut !== undefined) {
|
|
271
|
+
attrValues = attrValues.map((value) => {
|
|
272
|
+
// Skip NaN values
|
|
273
|
+
if (isNaN(value)) {
|
|
274
|
+
return value;
|
|
275
|
+
}
|
|
276
|
+
// Search through the lookup table rows for a match
|
|
277
|
+
let defaultValue = null;
|
|
278
|
+
for (const row of attrDef.lut || []) {
|
|
279
|
+
// Empty string means default for unmatched values
|
|
280
|
+
if (row.r === "") {
|
|
281
|
+
defaultValue = row.v;
|
|
282
|
+
continue;
|
|
283
|
+
}
|
|
284
|
+
// Parse the range string
|
|
285
|
+
if (this.isValueInRangeString(value, row.r)) {
|
|
286
|
+
return row.v;
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
// If no match found but we have a default, use it
|
|
290
|
+
if (defaultValue !== null) {
|
|
291
|
+
return defaultValue;
|
|
292
|
+
}
|
|
293
|
+
// Otherwise keep the original value
|
|
294
|
+
return value;
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
// const msgBufIdxIn = msgBufIdx;
|
|
298
|
+
// Move buffer position if using relative positioning
|
|
299
|
+
msgBufIdx += attrUsesAbsPos ? 0 : numBytesConsumed;
|
|
300
|
+
// console.log(`RaftAttrHdlr.processMsgAttr attr ${attrDef.n} msgBufIdx ${msgBufIdxIn} msgBufIdx ${msgBufIdx} attrUsesAbsPos ${attrUsesAbsPos} numBytesConsumed ${numBytesConsumed} attrValues ${attrValues}`);
|
|
301
|
+
// if (attrDef.n === "amb0") {
|
|
302
|
+
// console.log(`${new Date().toISOString()} ${attrDef.n} ${attrValues}`);
|
|
303
|
+
// }
|
|
304
|
+
// Return the value
|
|
305
|
+
return { values: attrValues, newMsgBufIdx: msgBufIdx };
|
|
306
|
+
}
|
|
307
|
+
signExtend(value, mask) {
|
|
308
|
+
const signBitMask = (mask + 1) >> 1;
|
|
309
|
+
const signBit = value & signBitMask;
|
|
310
|
+
if (signBit !== 0) { // If sign bit is set
|
|
311
|
+
const highBitsMask = ~mask & ~((mask + 1) >> 1);
|
|
312
|
+
value |= highBitsMask; // Apply the sign extension
|
|
313
|
+
}
|
|
314
|
+
return value;
|
|
315
|
+
}
|
|
316
|
+
extractTimestampAndAdvanceIdx(msgBuffer, msgBufIdx, timestampWrapHandler) {
|
|
317
|
+
// Check there are enough bytes for the timestamp
|
|
318
|
+
if (msgBufIdx + this.POLL_RESULT_TIMESTAMP_SIZE > msgBuffer.length) {
|
|
319
|
+
return { newBufIdx: -1, timestampUs: 0 };
|
|
320
|
+
}
|
|
321
|
+
// Use struct to extract the timestamp
|
|
322
|
+
const tsBuffer = msgBuffer.slice(msgBufIdx, msgBufIdx + this.POLL_RESULT_TIMESTAMP_SIZE);
|
|
323
|
+
let timestampUs;
|
|
324
|
+
if (this.POLL_RESULT_TIMESTAMP_SIZE === 2) {
|
|
325
|
+
timestampUs = (0, RaftStruct_1.structUnpack)(">H", tsBuffer)[0] * this.POLL_RESULT_RESOLUTION_US;
|
|
326
|
+
}
|
|
327
|
+
else {
|
|
328
|
+
timestampUs = (0, RaftStruct_1.structUnpack)(">I", tsBuffer)[0] * this.POLL_RESULT_RESOLUTION_US;
|
|
329
|
+
}
|
|
330
|
+
// Check if time is before lastReportTimeMs by more than 100ms - in which case a wrap around occurred to add on the max value
|
|
331
|
+
if (timestampUs + 100000 < timestampWrapHandler.lastReportTimestampUs) {
|
|
332
|
+
timestampWrapHandler.reportTimestampOffsetUs += this.POLL_RESULT_WRAP_VALUE * this.POLL_RESULT_RESOLUTION_US;
|
|
333
|
+
}
|
|
334
|
+
timestampWrapHandler.lastReportTimestampUs = timestampUs;
|
|
335
|
+
// Offset timestamp
|
|
336
|
+
timestampUs += timestampWrapHandler.reportTimestampOffsetUs;
|
|
337
|
+
// Advance the index
|
|
338
|
+
msgBufIdx += this.POLL_RESULT_TIMESTAMP_SIZE;
|
|
339
|
+
// Return the timestamp
|
|
340
|
+
return { newBufIdx: msgBufIdx, timestampUs: timestampUs };
|
|
341
|
+
}
|
|
342
|
+
// Helper method to check if a value is in a range string like "42,43,44-45,47"
|
|
343
|
+
isValueInRangeString(value, rangeStr) {
|
|
344
|
+
// Round to integer for comparison
|
|
345
|
+
const roundedValue = Math.round(value);
|
|
346
|
+
// Split the range string by commas
|
|
347
|
+
const parts = rangeStr.split(',');
|
|
348
|
+
for (const part of parts) {
|
|
349
|
+
// Check if it's a range (contains a hyphen)
|
|
350
|
+
if (part.includes('-')) {
|
|
351
|
+
const [startStr, endStr] = part.split('-');
|
|
352
|
+
// Handle hex values
|
|
353
|
+
const start = startStr.toLowerCase().startsWith('0x') ?
|
|
354
|
+
parseInt(startStr, 16) : parseInt(startStr, 10);
|
|
355
|
+
const end = endStr.toLowerCase().startsWith('0x') ?
|
|
356
|
+
parseInt(endStr, 16) : parseInt(endStr, 10);
|
|
357
|
+
if (!isNaN(start) && !isNaN(end) && roundedValue >= start && roundedValue <= end) {
|
|
358
|
+
return true;
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
// Check if it's a single value
|
|
362
|
+
else {
|
|
363
|
+
// Handle hex values
|
|
364
|
+
const partValue = part.toLowerCase().startsWith('0x') ?
|
|
365
|
+
parseInt(part, 16) : parseInt(part, 10);
|
|
366
|
+
if (!isNaN(partValue) && roundedValue === partValue) {
|
|
367
|
+
return true;
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
return false;
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
exports.default = AttributeHandler;
|
|
375
|
+
//# sourceMappingURL=RaftAttributeHandler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RaftAttributeHandler.js","sourceRoot":"","sources":["../../src/RaftAttributeHandler.ts"],"names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EAAE,EAAE,CAAC,CAAC;gBAEhD,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,YAAY,IAAI,KAAK,IAAI,YAAY,IAAI,GAAG,EAAE,CAAC;oBAC/E,OAAO,IAAI,CAAC;gBAChB,CAAC;YACL,CAAC;YACD,+BAA+B;iBAC1B,CAAC;gBACF,oBAAoB;gBACpB,MAAM,SAAS,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC;oBACnD,QAAQ,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;gBAE5C,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,IAAI,YAAY,KAAK,SAAS,EAAE,CAAC;oBAClD,OAAO,IAAI,CAAC;gBAChB,CAAC;YACL,CAAC;QACL,CAAC;QAED,OAAO,KAAK,CAAC;IACjB,CAAC;CAEJ;AAnbD,mCAmbC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { RaftConnEventFn } from "./RaftConnEvents";
|
|
2
|
+
import RaftMsgHandler from "./RaftMsgHandler";
|
|
3
|
+
import { ConnectorOptions } from "./RaftSystemType";
|
|
4
|
+
export default interface RaftChannel {
|
|
5
|
+
isConnected(): boolean;
|
|
6
|
+
connect(locator: string | object, connectorOptions: ConnectorOptions): Promise<boolean>;
|
|
7
|
+
disconnect(): Promise<void>;
|
|
8
|
+
getConnectedLocator(): string | object;
|
|
9
|
+
setOnConnEvent(connEventFn: RaftConnEventFn): void;
|
|
10
|
+
setMsgHandler(raftMsgHandler: RaftMsgHandler): void;
|
|
11
|
+
sendTxMsg(msg: Uint8Array, sendWithResponse: boolean): Promise<boolean>;
|
|
12
|
+
sendTxMsgNoAwait(msg: Uint8Array, sendWithResponse: boolean): Promise<boolean>;
|
|
13
|
+
sendTxMsgRaw(msg: string): boolean;
|
|
14
|
+
sendTxMsgRawAndWaitForReply<T>(msgPayload: Uint8Array): T;
|
|
15
|
+
requiresSubscription(): boolean;
|
|
16
|
+
ricRestCmdBeforeDisconnect(): string | null;
|
|
17
|
+
fhBatchAckSize(): number;
|
|
18
|
+
fhFileBlockSize(): number;
|
|
19
|
+
pauseConnection(pause: boolean): void;
|
|
20
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
3
|
+
//
|
|
4
|
+
// RaftChannel
|
|
5
|
+
// Part of RaftJS
|
|
6
|
+
//
|
|
7
|
+
// Rob Dobson & Chris Greening 2020-2024
|
|
8
|
+
// (C) 2020-2024 All rights reserved
|
|
9
|
+
//
|
|
10
|
+
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
//# sourceMappingURL=RaftChannel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RaftChannel.js","sourceRoot":"","sources":["../../src/RaftChannel.ts"],"names":[],"mappings":";AAAA,iHAAiH;AACjH,EAAE;AACF,cAAc;AACd,iBAAiB;AACjB,EAAE;AACF,wCAAwC;AACxC,oCAAoC;AACpC,EAAE;AACF,iHAAiH"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { BleError, BleManager, Characteristic, Device, State, Subscription } from "react-native-ble-plx";
|
|
2
|
+
import RaftChannel from "./RaftChannel";
|
|
3
|
+
import { RaftConnEvent, RaftConnEventFn } from "./RaftConnEvents";
|
|
4
|
+
import RaftMsgHandler from "./RaftMsgHandler";
|
|
5
|
+
import RaftChannelBLEScanner from "./RaftChannelBLEScanner.native";
|
|
6
|
+
import { DiscoveredDevice } from "./RaftTypes";
|
|
7
|
+
export default class RaftChannelPhoneBLE implements RaftChannel {
|
|
8
|
+
private _onConnEvent;
|
|
9
|
+
_cmdUUID: string;
|
|
10
|
+
_respUUID: string;
|
|
11
|
+
_serviceUUIDs: string[];
|
|
12
|
+
_bleScanner: RaftChannelBLEScanner;
|
|
13
|
+
_deviceToConnectTo: DiscoveredDevice | null;
|
|
14
|
+
_retryConnectionIfLost: boolean;
|
|
15
|
+
RECONNECT_ATTEMPTS_AFTER_CONN_LOST: number;
|
|
16
|
+
_bleSubscrOnRx: Subscription | null;
|
|
17
|
+
_bleSubscrOnDisconnect: Subscription | null;
|
|
18
|
+
_bleSubscrOnStateChange: Subscription | null;
|
|
19
|
+
_bleDevice: Device | null;
|
|
20
|
+
MTU_SIZE_TO_REQUEST: number;
|
|
21
|
+
_raftMsgHandler: RaftMsgHandler | null;
|
|
22
|
+
private _msgTxTimeLast;
|
|
23
|
+
private _msgTxMinTimeBetweenMs;
|
|
24
|
+
private readonly maxRetries;
|
|
25
|
+
private _requestedBatchAckSize;
|
|
26
|
+
private _requestedFileBlockSize;
|
|
27
|
+
private _connectedDeviceServiceUUID?;
|
|
28
|
+
constructor();
|
|
29
|
+
setConnectedDeviceUUID(serviceUUID: string): void;
|
|
30
|
+
getBleManager(): BleManager;
|
|
31
|
+
fhBatchAckSize(): number;
|
|
32
|
+
fhFileBlockSize(): number;
|
|
33
|
+
pauseConnection(pause: boolean): void;
|
|
34
|
+
isConnected(): boolean;
|
|
35
|
+
setOnConnEvent(connEventFn: RaftConnEventFn): void;
|
|
36
|
+
requiresSubscription(): boolean;
|
|
37
|
+
isEnabled(): boolean;
|
|
38
|
+
setMsgHandler(raftMsgHandler: RaftMsgHandler): void;
|
|
39
|
+
setRetryConnectionIfLost(retry: boolean): void;
|
|
40
|
+
discoveryStart(uuids: string[], tries?: number): Promise<boolean>;
|
|
41
|
+
discoveryCancel(): void;
|
|
42
|
+
_onBLEStateChange(state: State): void;
|
|
43
|
+
getConnectedLocator(): string | Device;
|
|
44
|
+
/**
|
|
45
|
+
* Get RIC connection status
|
|
46
|
+
*
|
|
47
|
+
* @returns boolean (true if connected)
|
|
48
|
+
*
|
|
49
|
+
*/
|
|
50
|
+
getIsConnected(forceCheck?: boolean): Promise<boolean>;
|
|
51
|
+
/**
|
|
52
|
+
* Get the RSSI of the currently connected device
|
|
53
|
+
*
|
|
54
|
+
* @return number (or null if not connected)
|
|
55
|
+
*
|
|
56
|
+
*/
|
|
57
|
+
readRSSI(): Promise<number>;
|
|
58
|
+
/**
|
|
59
|
+
* Connect to a RIC
|
|
60
|
+
*
|
|
61
|
+
* @returns boolean (true if connected)
|
|
62
|
+
*
|
|
63
|
+
*/
|
|
64
|
+
connect(discoveredDevice: DiscoveredDevice): Promise<boolean>;
|
|
65
|
+
/**
|
|
66
|
+
* Disconnect from RIC
|
|
67
|
+
*
|
|
68
|
+
* @returns None
|
|
69
|
+
*
|
|
70
|
+
*/
|
|
71
|
+
disconnect(): Promise<void>;
|
|
72
|
+
/**
|
|
73
|
+
* Configure device connection
|
|
74
|
+
*
|
|
75
|
+
* @returns None
|
|
76
|
+
*
|
|
77
|
+
*/
|
|
78
|
+
_configDeviceConnection(): Promise<boolean>;
|
|
79
|
+
/**
|
|
80
|
+
* Handle lost connections
|
|
81
|
+
*
|
|
82
|
+
* @returns None
|
|
83
|
+
*
|
|
84
|
+
*/
|
|
85
|
+
_handleLostConnections(): void;
|
|
86
|
+
getMTU(): number | undefined;
|
|
87
|
+
emit(event: RaftConnEvent, data?: any): void;
|
|
88
|
+
_onMsgRx(error: BleError | null, characteristic: Characteristic | null): void;
|
|
89
|
+
scanningEvent(event: RaftConnEvent, data?: any): Promise<void>;
|
|
90
|
+
sendTxMsg(msg: Uint8Array): Promise<boolean>;
|
|
91
|
+
sendTxMsgNoAwait(msg: Uint8Array): Promise<boolean>;
|
|
92
|
+
ricRestCmdBeforeDisconnect(): string | null;
|
|
93
|
+
sendTxMsgRaw(): boolean;
|
|
94
|
+
sendTxMsgRawAndWaitForReply<T>(): T;
|
|
95
|
+
}
|