@neurodevs/ndx-native 1.1.0 → 2.0.1
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/.vscode/launch.json +3 -1
- package/.vscode/settings.json +1 -2
- package/.vscode/tasks.json +6 -31
- package/build/__tests__/impl/LibndxAdapter.test.d.ts +14 -11
- package/build/__tests__/impl/LibndxAdapter.test.js +92 -99
- package/build/__tests__/impl/LibndxAdapter.test.js.map +1 -1
- package/build/impl/LibndxAdapter.d.ts +13 -9
- package/build/impl/LibndxAdapter.js +31 -69
- package/build/impl/LibndxAdapter.js.map +1 -1
- package/build/testDoubles/Libndx/FakeLibndx.d.ts +5 -2
- package/build/testDoubles/Libndx/FakeLibndx.js +19 -12
- package/build/testDoubles/Libndx/FakeLibndx.js.map +1 -1
- package/package.json +8 -17
- package/src/__tests__/impl/LibndxAdapter.test.ts +114 -108
- package/src/impl/LibndxAdapter.ts +68 -75
- package/src/testDoubles/Libndx/FakeLibndx.ts +23 -13
- package/tsconfig.json +1 -1
- package/.regressionproof.json +0 -7
- package/build/.spruce/settings.json +0 -11
- package/src/.spruce/settings.json +0 -11
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import koffi from 'koffi';
|
|
2
2
|
export default class LibndxAdapter {
|
|
3
3
|
static Class;
|
|
4
|
-
static
|
|
5
|
-
static ffiRsDefine = define;
|
|
4
|
+
static koffiLoad = koffi.load.bind(koffi);
|
|
6
5
|
static instance;
|
|
7
6
|
libndxPath;
|
|
8
7
|
bindings;
|
|
@@ -25,72 +24,33 @@ export default class LibndxAdapter {
|
|
|
25
24
|
}
|
|
26
25
|
tryToLoadBindings() {
|
|
27
26
|
try {
|
|
28
|
-
this.openLibndx();
|
|
29
27
|
this.defineBindings();
|
|
30
28
|
}
|
|
31
29
|
catch (err) {
|
|
32
30
|
this.throwFailedToLoadLibndx(err);
|
|
33
31
|
}
|
|
34
32
|
}
|
|
35
|
-
openLibndx() {
|
|
36
|
-
this.ffiRsOpen({
|
|
37
|
-
library: 'ndx',
|
|
38
|
-
path: this.libndxPath,
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
33
|
defineBindings() {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
},
|
|
58
|
-
get_rssi_ble_backend: {
|
|
59
|
-
library: 'ndx',
|
|
60
|
-
retType: DataType.String,
|
|
61
|
-
paramsType: [DataType.String],
|
|
62
|
-
},
|
|
63
|
-
destroy_ble_backend: {
|
|
64
|
-
library: 'ndx',
|
|
65
|
-
retType: DataType.String,
|
|
66
|
-
paramsType: [DataType.String],
|
|
67
|
-
},
|
|
68
|
-
create_ftdi_backend: {
|
|
69
|
-
library: 'ndx',
|
|
70
|
-
retType: DataType.String,
|
|
71
|
-
paramsType: [DataType.String],
|
|
72
|
-
},
|
|
73
|
-
start_ftdi_backend: {
|
|
74
|
-
library: 'ndx',
|
|
75
|
-
retType: DataType.String,
|
|
76
|
-
paramsType: [DataType.String],
|
|
77
|
-
},
|
|
78
|
-
stop_ftdi_backend: {
|
|
79
|
-
library: 'ndx',
|
|
80
|
-
retType: DataType.String,
|
|
81
|
-
paramsType: [DataType.String],
|
|
82
|
-
},
|
|
83
|
-
destroy_ftdi_backend: {
|
|
84
|
-
library: 'ndx',
|
|
85
|
-
retType: DataType.String,
|
|
86
|
-
paramsType: [DataType.String],
|
|
87
|
-
},
|
|
88
|
-
});
|
|
34
|
+
const lib = LibndxAdapter.koffiLoad(this.libndxPath);
|
|
35
|
+
const wrap1 = (f) => (args) => f(args[0]);
|
|
36
|
+
const wrap3 = (f) => (args) => f(args[0], args[1], args[2]);
|
|
37
|
+
this.bindings = {
|
|
38
|
+
create_ble_backend: wrap1(lib.func('str create_ble_backend(str config)')),
|
|
39
|
+
start_ble_backend: wrap1(lib.func('str start_ble_backend(str uuid)')),
|
|
40
|
+
write_ble_characteristic: wrap3(lib.func('str write_ble_characteristic(str uuid, str charUuid, str value)')),
|
|
41
|
+
read_ble_rssi: wrap1(lib.func('str read_ble_rssi(str uuid)')),
|
|
42
|
+
stop_ble_backend: wrap1(lib.func('str stop_ble_backend(str uuid)')),
|
|
43
|
+
destroy_ble_backend: wrap1(lib.func('str destroy_ble_backend(str uuid)')),
|
|
44
|
+
create_ftdi_backend: wrap1(lib.func('str create_ftdi_backend(str config)')),
|
|
45
|
+
start_ftdi_backend: wrap1(lib.func('str start_ftdi_backend(str serial)')),
|
|
46
|
+
stop_ftdi_backend: wrap1(lib.func('str stop_ftdi_backend(str serial)')),
|
|
47
|
+
destroy_ftdi_backend: wrap1(lib.func('str destroy_ftdi_backend(str serial)')),
|
|
48
|
+
};
|
|
89
49
|
}
|
|
90
50
|
throwFailedToLoadLibndx(err) {
|
|
91
51
|
throw new Error(`
|
|
92
52
|
\n -----------------------------------
|
|
93
|
-
\n Failed to load libndx! Tried to load from:
|
|
53
|
+
\n Failed to load libndx! Tried to load from:
|
|
94
54
|
\n ${this.libndxPath}
|
|
95
55
|
\n Instructions to save your day (on MacOS):
|
|
96
56
|
\n 1. git clone https://github.com/neurodevs/libndx.git
|
|
@@ -98,7 +58,7 @@ export default class LibndxAdapter {
|
|
|
98
58
|
\n 3. sudo cp build/libndx.dylib /opt/local/lib/
|
|
99
59
|
\n 4. Try whatever you were doing again!
|
|
100
60
|
\n Modify step 3 for your OS if you are not on MacOS.
|
|
101
|
-
\n If you're still unsure, ask an LLM with this error and your OS.
|
|
61
|
+
\n If you're still unsure, ask an LLM with this error and your OS.
|
|
102
62
|
\n You could also post an issue on the repo:
|
|
103
63
|
\n https://github.com/neurodevs/ndx-native/issues
|
|
104
64
|
\n Good luck!
|
|
@@ -117,6 +77,18 @@ export default class LibndxAdapter {
|
|
|
117
77
|
const { deviceUuid } = options;
|
|
118
78
|
return this.bindings.start_ble_backend([deviceUuid]);
|
|
119
79
|
}
|
|
80
|
+
writeBleCharacteristic(options) {
|
|
81
|
+
const { deviceUuid, characteristicUuid, value } = options;
|
|
82
|
+
return this.bindings.write_ble_characteristic([
|
|
83
|
+
deviceUuid,
|
|
84
|
+
characteristicUuid,
|
|
85
|
+
value,
|
|
86
|
+
]);
|
|
87
|
+
}
|
|
88
|
+
readBleRssi(options) {
|
|
89
|
+
const { deviceUuid } = options;
|
|
90
|
+
return this.bindings.read_ble_rssi([deviceUuid]);
|
|
91
|
+
}
|
|
120
92
|
stopBleBackend(options) {
|
|
121
93
|
const { deviceUuid } = options;
|
|
122
94
|
return this.bindings.stop_ble_backend([deviceUuid]);
|
|
@@ -125,10 +97,6 @@ export default class LibndxAdapter {
|
|
|
125
97
|
const { deviceUuid } = options;
|
|
126
98
|
return this.bindings.destroy_ble_backend([deviceUuid]);
|
|
127
99
|
}
|
|
128
|
-
getRssiBleBackend(options) {
|
|
129
|
-
const { deviceUuid } = options;
|
|
130
|
-
return this.bindings.get_rssi_ble_backend([deviceUuid]);
|
|
131
|
-
}
|
|
132
100
|
createFtdiBackend(options) {
|
|
133
101
|
const { serialNumber } = options;
|
|
134
102
|
const configJson = JSON.stringify({ serialNumber });
|
|
@@ -146,11 +114,5 @@ export default class LibndxAdapter {
|
|
|
146
114
|
const { serialNumber } = options;
|
|
147
115
|
return this.bindings.destroy_ftdi_backend([serialNumber]);
|
|
148
116
|
}
|
|
149
|
-
get ffiRsOpen() {
|
|
150
|
-
return LibndxAdapter.ffiRsOpen;
|
|
151
|
-
}
|
|
152
|
-
get ffiRsDefine() {
|
|
153
|
-
return LibndxAdapter.ffiRsDefine;
|
|
154
|
-
}
|
|
155
117
|
}
|
|
156
118
|
//# sourceMappingURL=LibndxAdapter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LibndxAdapter.js","sourceRoot":"","sources":["../../src/impl/LibndxAdapter.ts"],"names":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,UAAU,CAAC,CAAC,CAAA;IAC1D,CAAC;IAEM,iBAAiB,CAAC,OAA2B;QAChD,MAAM,EAAE,YAAY,EAAE,GAAG,OAAO,CAAA;QAChC,MAAM,UAAU,GAAG,IAAI,CAAC,SAAS,CAAC,EAAE,YAAY,EAAE,CAAC,CAAA;QACnD,OAAO,IAAI,CAAC,QAAQ,CAAC,mBAAmB,CAAC,CAAC,UAAU,CAAC,CAAC,CAAA;IAC1D,CAAC;IAEM,gBAAgB,CAAC,OAA2B;QAC/C,MAAM,EAAE,YAAY,EAAE,GAAG,OAAO,CAAA;QAChC,OAAO,IAAI,CAAC,QAAQ,CAAC,kBAAkB,CAAC,CAAC,YAAY,CAAC,CAAC,CAAA;IAC3D,CAAC;IAEM,eAAe,CAAC,OAA2B;QAC9C,MAAM,EAAE,YAAY,EAAE,GAAG,OAAO,CAAA;QAChC,OAAO,IAAI,CAAC,QAAQ,CAAC,iBAAiB,CAAC,CAAC,YAAY,CAAC,CAAC,CAAA;IAC1D,CAAC;IAEM,kBAAkB,CAAC,OAA2B;QACjD,MAAM,EAAE,YAAY,EAAE,GAAG,OAAO,CAAA;QAChC,OAAO,IAAI,CAAC,QAAQ,CAAC,oBAAoB,CAAC,CAAC,YAAY,CAAC,CAAC,CAAA;IAC7D,CAAC"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { BleBackendOptions, FtdiBackendOptions, Libndx, LibndxAdapterOptions } from '../../impl/LibndxAdapter.js';
|
|
1
|
+
import { BleBackendOptions, BleWriteOptions, FtdiBackendOptions, Libndx, LibndxAdapterOptions } from '../../impl/LibndxAdapter.js';
|
|
2
2
|
export default class FakeLibndx implements Libndx {
|
|
3
3
|
static callsToConstructor: (LibndxAdapterOptions | undefined)[];
|
|
4
4
|
static callsToCreateBleBackend: BleBackendOptions[];
|
|
5
5
|
static callsToStartBleBackend: BleBackendOptions[];
|
|
6
|
+
static callsToWriteBle: BleWriteOptions[];
|
|
6
7
|
static callsToStopBleBacked: BleBackendOptions[];
|
|
7
8
|
static callsToDestroyBleBackend: BleBackendOptions[];
|
|
8
9
|
static callsToGetRssiBleBackend: BleBackendOptions[];
|
|
@@ -10,12 +11,14 @@ export default class FakeLibndx implements Libndx {
|
|
|
10
11
|
static callsToStartFtdiBackend: FtdiBackendOptions[];
|
|
11
12
|
static callsToStopFtdiBackend: FtdiBackendOptions[];
|
|
12
13
|
static callsToDestroyFtdiBackend: FtdiBackendOptions[];
|
|
14
|
+
static fakeResult: string;
|
|
13
15
|
constructor(options?: LibndxAdapterOptions);
|
|
14
16
|
createBleBackend(options: BleBackendOptions): string;
|
|
15
17
|
startBleBackend(options: BleBackendOptions): string;
|
|
18
|
+
writeBleCharacteristic(options: BleWriteOptions): string;
|
|
19
|
+
readBleRssi(options: BleBackendOptions): string;
|
|
16
20
|
stopBleBackend(options: BleBackendOptions): string;
|
|
17
21
|
destroyBleBackend(options: BleBackendOptions): string;
|
|
18
|
-
getRssiBleBackend(options: BleBackendOptions): string;
|
|
19
22
|
createFtdiBackend(options: FtdiBackendOptions): string;
|
|
20
23
|
startFtdiBackend(options: FtdiBackendOptions): string;
|
|
21
24
|
stopFtdiBackend(options: FtdiBackendOptions): string;
|
|
@@ -2,6 +2,7 @@ export default class FakeLibndx {
|
|
|
2
2
|
static callsToConstructor = [];
|
|
3
3
|
static callsToCreateBleBackend = [];
|
|
4
4
|
static callsToStartBleBackend = [];
|
|
5
|
+
static callsToWriteBle = [];
|
|
5
6
|
static callsToStopBleBacked = [];
|
|
6
7
|
static callsToDestroyBleBackend = [];
|
|
7
8
|
static callsToGetRssiBleBackend = [];
|
|
@@ -9,49 +10,55 @@ export default class FakeLibndx {
|
|
|
9
10
|
static callsToStartFtdiBackend = [];
|
|
10
11
|
static callsToStopFtdiBackend = [];
|
|
11
12
|
static callsToDestroyFtdiBackend = [];
|
|
13
|
+
static fakeResult = '';
|
|
12
14
|
constructor(options) {
|
|
13
15
|
FakeLibndx.callsToConstructor.push(options);
|
|
14
16
|
}
|
|
15
17
|
createBleBackend(options) {
|
|
16
18
|
FakeLibndx.callsToCreateBleBackend.push(options);
|
|
17
|
-
return
|
|
19
|
+
return FakeLibndx.fakeResult;
|
|
18
20
|
}
|
|
19
21
|
startBleBackend(options) {
|
|
20
22
|
FakeLibndx.callsToStartBleBackend.push(options);
|
|
21
|
-
return
|
|
23
|
+
return FakeLibndx.fakeResult;
|
|
24
|
+
}
|
|
25
|
+
writeBleCharacteristic(options) {
|
|
26
|
+
FakeLibndx.callsToWriteBle.push(options);
|
|
27
|
+
return FakeLibndx.fakeResult;
|
|
28
|
+
}
|
|
29
|
+
readBleRssi(options) {
|
|
30
|
+
FakeLibndx.callsToGetRssiBleBackend.push(options);
|
|
31
|
+
return FakeLibndx.fakeResult;
|
|
22
32
|
}
|
|
23
33
|
stopBleBackend(options) {
|
|
24
34
|
FakeLibndx.callsToStopBleBacked.push(options);
|
|
25
|
-
return
|
|
35
|
+
return FakeLibndx.fakeResult;
|
|
26
36
|
}
|
|
27
37
|
destroyBleBackend(options) {
|
|
28
38
|
FakeLibndx.callsToDestroyBleBackend.push(options);
|
|
29
|
-
return
|
|
30
|
-
}
|
|
31
|
-
getRssiBleBackend(options) {
|
|
32
|
-
FakeLibndx.callsToGetRssiBleBackend.push(options);
|
|
33
|
-
return '';
|
|
39
|
+
return FakeLibndx.fakeResult;
|
|
34
40
|
}
|
|
35
41
|
createFtdiBackend(options) {
|
|
36
42
|
FakeLibndx.callsToCreateFtdiBackend.push(options);
|
|
37
|
-
return
|
|
43
|
+
return FakeLibndx.fakeResult;
|
|
38
44
|
}
|
|
39
45
|
startFtdiBackend(options) {
|
|
40
46
|
FakeLibndx.callsToStartFtdiBackend.push(options);
|
|
41
|
-
return
|
|
47
|
+
return FakeLibndx.fakeResult;
|
|
42
48
|
}
|
|
43
49
|
stopFtdiBackend(options) {
|
|
44
50
|
FakeLibndx.callsToStopFtdiBackend.push(options);
|
|
45
|
-
return
|
|
51
|
+
return FakeLibndx.fakeResult;
|
|
46
52
|
}
|
|
47
53
|
destroyFtdiBackend(options) {
|
|
48
54
|
FakeLibndx.callsToDestroyFtdiBackend.push(options);
|
|
49
|
-
return
|
|
55
|
+
return FakeLibndx.fakeResult;
|
|
50
56
|
}
|
|
51
57
|
static resetTestDouble() {
|
|
52
58
|
FakeLibndx.callsToConstructor = [];
|
|
53
59
|
FakeLibndx.callsToCreateBleBackend = [];
|
|
54
60
|
FakeLibndx.callsToStartBleBackend = [];
|
|
61
|
+
FakeLibndx.callsToWriteBle = [];
|
|
55
62
|
FakeLibndx.callsToStopBleBacked = [];
|
|
56
63
|
FakeLibndx.callsToGetRssiBleBackend = [];
|
|
57
64
|
FakeLibndx.callsToDestroyBleBackend = [];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FakeLibndx.js","sourceRoot":"","sources":["../../../src/testDoubles/Libndx/FakeLibndx.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"FakeLibndx.js","sourceRoot":"","sources":["../../../src/testDoubles/Libndx/FakeLibndx.ts"],"names":[],"mappings":"AAQA,MAAM,CAAC,OAAO,OAAO,UAAU;IACpB,MAAM,CAAC,kBAAkB,GAAyC,EAAE,CAAA;IACpE,MAAM,CAAC,uBAAuB,GAAwB,EAAE,CAAA;IACxD,MAAM,CAAC,sBAAsB,GAAwB,EAAE,CAAA;IACvD,MAAM,CAAC,eAAe,GAAsB,EAAE,CAAA;IAC9C,MAAM,CAAC,oBAAoB,GAAwB,EAAE,CAAA;IACrD,MAAM,CAAC,wBAAwB,GAAwB,EAAE,CAAA;IACzD,MAAM,CAAC,wBAAwB,GAAwB,EAAE,CAAA;IACzD,MAAM,CAAC,wBAAwB,GAAyB,EAAE,CAAA;IAC1D,MAAM,CAAC,uBAAuB,GAAyB,EAAE,CAAA;IACzD,MAAM,CAAC,sBAAsB,GAAyB,EAAE,CAAA;IACxD,MAAM,CAAC,yBAAyB,GAAyB,EAAE,CAAA;IAE3D,MAAM,CAAC,UAAU,GAAG,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C,OAA2B;QAC9C,UAAU,CAAC,sBAAsB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;QAC/C,OAAO,UAAU,CAAC,UAAU,CAAA;IAChC,CAAC;IAEM,kBAAkB,CAAC,OAA2B;QACjD,UAAU,CAAC,yBAAyB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;QAClD,OAAO,UAAU,CAAC,UAAU,CAAA;IAChC,CAAC;IAEM,MAAM,CAAC,eAAe;QACzB,UAAU,CAAC,kBAAkB,GAAG,EAAE,CAAA;QAClC,UAAU,CAAC,uBAAuB,GAAG,EAAE,CAAA;QACvC,UAAU,CAAC,sBAAsB,GAAG,EAAE,CAAA;QACtC,UAAU,CAAC,eAAe,GAAG,EAAE,CAAA;QAC/B,UAAU,CAAC,oBAAoB,GAAG,EAAE,CAAA;QACpC,UAAU,CAAC,wBAAwB,GAAG,EAAE,CAAA;QACxC,UAAU,CAAC,wBAAwB,GAAG,EAAE,CAAA;QACxC,UAAU,CAAC,wBAAwB,GAAG,EAAE,CAAA;QACxC,UAAU,CAAC,uBAAuB,GAAG,EAAE,CAAA;QACvC,UAAU,CAAC,sBAAsB,GAAG,EAAE,CAAA;QACtC,UAAU,CAAC,yBAAyB,GAAG,EAAE,CAAA;IAC7C,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@neurodevs/ndx-native",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"description": "Native Node.js adapters for LSL, XDF, and LabRecorder",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"main": "build/index.js",
|
|
22
22
|
"scripts": {
|
|
23
23
|
"build.ci": "yarn run build.tsc && yarn run lint",
|
|
24
|
-
"build.dev": "yarn run build.tsc --sourceMap ; yarn run fix.lint ; prettier --write .",
|
|
24
|
+
"build.dev": "yarn run build.tsc --sourceMap ; yarn run fix.lint ; prettier --write . --log-level warn",
|
|
25
25
|
"build.copy-files": "mkdir -p build && rsync -avzq --exclude='*.ts' ./src/ ./build/",
|
|
26
26
|
"build.tsc": "yarn run build.copy-files && tsc",
|
|
27
27
|
"clean": "yarn run clean.build",
|
|
@@ -37,32 +37,23 @@
|
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@neurodevs/node-mangled-names": "^1.0.1",
|
|
40
|
-
"ffi-rs": "^1.3.
|
|
40
|
+
"ffi-rs": "^1.3.2",
|
|
41
|
+
"koffi": "^3.0.1"
|
|
41
42
|
},
|
|
42
43
|
"devDependencies": {
|
|
43
44
|
"@neurodevs/eslint-config-ndx": "^1.0.1",
|
|
44
45
|
"@neurodevs/generate-id": "^1.1.2",
|
|
45
|
-
"@neurodevs/node-tdd": "^
|
|
46
|
+
"@neurodevs/node-tdd": "^1.1.2",
|
|
46
47
|
"@neurodevs/prettier-config-ndx": "^1.0.2",
|
|
47
|
-
"@regressionproof/cli": "^0.9.4",
|
|
48
|
-
"@regressionproof/jest-reporter": "^0.9.4",
|
|
49
|
-
"jest": "^30.2.0",
|
|
50
|
-
"jest-circus": "^30.2.0",
|
|
51
|
-
"prettier": "^3.8.1",
|
|
52
|
-
"tsc-watch": "^7.2.0",
|
|
53
48
|
"typescript": "^5.9.3"
|
|
54
49
|
},
|
|
55
50
|
"jest": {
|
|
56
|
-
"testRunner": "jest-circus/runner",
|
|
57
|
-
"maxWorkers": 4,
|
|
58
|
-
"testTimeout": 5000,
|
|
59
51
|
"testEnvironment": "node",
|
|
52
|
+
"testRunner": "jest-circus/runner",
|
|
60
53
|
"testMatch": [
|
|
61
54
|
"<rootDir>/build/__tests__/**/*.test.js?(x)"
|
|
62
55
|
],
|
|
63
|
-
"
|
|
64
|
-
|
|
65
|
-
"@regressionproof/jest-reporter"
|
|
66
|
-
]
|
|
56
|
+
"testTimeout": 5000,
|
|
57
|
+
"maxWorkers": 4
|
|
67
58
|
}
|
|
68
59
|
}
|
|
@@ -5,29 +5,29 @@ import LibndxAdapter, {
|
|
|
5
5
|
LibndxBindings,
|
|
6
6
|
} from '../../impl/LibndxAdapter.js'
|
|
7
7
|
import AbstractPackageTest from '../AbstractPackageTest.js'
|
|
8
|
-
import { DataType, define, OpenParams } from 'ffi-rs'
|
|
9
|
-
import { FfiRsDefineOptions } from '../../types.js'
|
|
10
8
|
import FakeLibndx from '../../testDoubles/Libndx/FakeLibndx.js'
|
|
11
9
|
|
|
12
10
|
export default class LibndxAdapterTest extends AbstractPackageTest {
|
|
13
|
-
public static ffiRsDefine = define
|
|
14
|
-
|
|
15
11
|
private static instance: Libndx
|
|
16
12
|
private static libndxPath = '/opt/local/lib/libndx.dylib'
|
|
17
13
|
private static shouldThrowWhenLoadingBindings: boolean
|
|
18
14
|
private static fakeBindings: LibndxBindings
|
|
19
15
|
|
|
20
|
-
private static
|
|
21
|
-
private static
|
|
16
|
+
private static koffiLoadPath?: string
|
|
17
|
+
private static koffiFuncSignatures?: string[]
|
|
22
18
|
|
|
23
19
|
private static readonly bleDeviceUuid = this.generateId()
|
|
20
|
+
private static readonly bleCharacteristicUuid = this.generateId()
|
|
21
|
+
private static readonly bleValueToWrite = this.generateId()
|
|
22
|
+
|
|
24
23
|
private static readonly ftdiSerialNumber = this.generateId()
|
|
25
24
|
|
|
26
25
|
private static readonly callsToCreateBle: string[][] = []
|
|
27
26
|
private static readonly callsToStartBle: string[][] = []
|
|
27
|
+
private static readonly callsToWriteBle: string[][] = []
|
|
28
|
+
private static readonly callsToReadRssi: string[][] = []
|
|
28
29
|
private static readonly callsToStopBle: string[][] = []
|
|
29
30
|
private static readonly callsToDestroyBle: string[][] = []
|
|
30
|
-
private static readonly callsToGetRssi: string[][] = []
|
|
31
31
|
private static readonly callsToCreateFtdi: string[][] = []
|
|
32
32
|
private static readonly callsToStartFtdi: string[][] = []
|
|
33
33
|
private static readonly callsToStopFtdi: string[][] = []
|
|
@@ -66,65 +66,31 @@ export default class LibndxAdapterTest extends AbstractPackageTest {
|
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
@test()
|
|
69
|
-
protected static async
|
|
70
|
-
assert.
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
69
|
+
protected static async callsKoffiLoadWithLibndxPath() {
|
|
70
|
+
assert.isEqual(
|
|
71
|
+
this.koffiLoadPath,
|
|
72
|
+
this.libndxPath,
|
|
73
|
+
'Did not call koffiLoad with the expected library path!'
|
|
74
|
+
)
|
|
74
75
|
}
|
|
75
76
|
|
|
76
77
|
@test()
|
|
77
|
-
protected static async
|
|
78
|
+
protected static async registersExpectedKoffiFuncSignatures() {
|
|
78
79
|
assert.isEqualDeep(
|
|
79
|
-
this.
|
|
80
|
-
|
|
81
|
-
create_ble_backend
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
retType: DataType.String,
|
|
94
|
-
paramsType: [DataType.String],
|
|
95
|
-
},
|
|
96
|
-
destroy_ble_backend: {
|
|
97
|
-
library: 'ndx',
|
|
98
|
-
retType: DataType.String,
|
|
99
|
-
paramsType: [DataType.String],
|
|
100
|
-
},
|
|
101
|
-
get_rssi_ble_backend: {
|
|
102
|
-
library: 'ndx',
|
|
103
|
-
retType: DataType.String,
|
|
104
|
-
paramsType: [DataType.String],
|
|
105
|
-
},
|
|
106
|
-
create_ftdi_backend: {
|
|
107
|
-
library: 'ndx',
|
|
108
|
-
retType: DataType.String,
|
|
109
|
-
paramsType: [DataType.String],
|
|
110
|
-
},
|
|
111
|
-
start_ftdi_backend: {
|
|
112
|
-
library: 'ndx',
|
|
113
|
-
retType: DataType.String,
|
|
114
|
-
paramsType: [DataType.String],
|
|
115
|
-
},
|
|
116
|
-
stop_ftdi_backend: {
|
|
117
|
-
library: 'ndx',
|
|
118
|
-
retType: DataType.String,
|
|
119
|
-
paramsType: [DataType.String],
|
|
120
|
-
},
|
|
121
|
-
destroy_ftdi_backend: {
|
|
122
|
-
library: 'ndx',
|
|
123
|
-
retType: DataType.String,
|
|
124
|
-
paramsType: [DataType.String],
|
|
125
|
-
},
|
|
126
|
-
},
|
|
127
|
-
'Did not pass valid options to ffiRsDefine!'
|
|
80
|
+
this.koffiFuncSignatures,
|
|
81
|
+
[
|
|
82
|
+
'str create_ble_backend(str config)',
|
|
83
|
+
'str start_ble_backend(str uuid)',
|
|
84
|
+
'str write_ble_characteristic(str uuid, str charUuid, str value)',
|
|
85
|
+
'str read_ble_rssi(str uuid)',
|
|
86
|
+
'str stop_ble_backend(str uuid)',
|
|
87
|
+
'str destroy_ble_backend(str uuid)',
|
|
88
|
+
'str create_ftdi_backend(str config)',
|
|
89
|
+
'str start_ftdi_backend(str serial)',
|
|
90
|
+
'str stop_ftdi_backend(str serial)',
|
|
91
|
+
'str destroy_ftdi_backend(str serial)',
|
|
92
|
+
],
|
|
93
|
+
'Did not register expected koffi func signatures!'
|
|
128
94
|
)
|
|
129
95
|
}
|
|
130
96
|
|
|
@@ -178,6 +144,51 @@ export default class LibndxAdapterTest extends AbstractPackageTest {
|
|
|
178
144
|
assert.isTruthy(json, 'startBleBackend did not return a JSON string!')
|
|
179
145
|
}
|
|
180
146
|
|
|
147
|
+
@test()
|
|
148
|
+
protected static async writeBleCharacteristicCallsBindingWithExpectedArgs() {
|
|
149
|
+
this.writeBleCharacteristic()
|
|
150
|
+
|
|
151
|
+
assert.isEqualDeep(
|
|
152
|
+
this.callsToWriteBle[0],
|
|
153
|
+
[
|
|
154
|
+
this.bleDeviceUuid,
|
|
155
|
+
this.bleCharacteristicUuid,
|
|
156
|
+
this.bleValueToWrite,
|
|
157
|
+
],
|
|
158
|
+
'writeBleCharacteristic did not call binding with expected args!'
|
|
159
|
+
)
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
@test()
|
|
163
|
+
protected static async writeBleCharacteristicReturnsJsonString() {
|
|
164
|
+
const raw = this.writeBleCharacteristic()
|
|
165
|
+
const json = JSON.parse(raw)
|
|
166
|
+
|
|
167
|
+
assert.isTruthy(
|
|
168
|
+
json,
|
|
169
|
+
'writeBleCharacteristic did not return a JSON string!'
|
|
170
|
+
)
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
@test()
|
|
174
|
+
protected static async getRssiBleBackendCallsBindingWithExpectedArgs() {
|
|
175
|
+
this.getRssiBleBackend()
|
|
176
|
+
|
|
177
|
+
assert.isEqual(
|
|
178
|
+
this.callsToReadRssi[0][0],
|
|
179
|
+
this.bleDeviceUuid,
|
|
180
|
+
'getRssiBleBackend did not call binding with expected args!'
|
|
181
|
+
)
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
@test()
|
|
185
|
+
protected static async getRssiBleBackendReturnsJson() {
|
|
186
|
+
const raw = this.getRssiBleBackend()
|
|
187
|
+
const json = JSON.parse(raw)
|
|
188
|
+
|
|
189
|
+
assert.isTruthy(json, 'getRssiBleBackend did not return a JSON string!')
|
|
190
|
+
}
|
|
191
|
+
|
|
181
192
|
@test()
|
|
182
193
|
protected static async stopBleBackendCallsBindingWithExpectedArgs() {
|
|
183
194
|
this.stopBleBackend()
|
|
@@ -216,25 +227,6 @@ export default class LibndxAdapterTest extends AbstractPackageTest {
|
|
|
216
227
|
assert.isTruthy(json, 'destroyBleBackend did not return a JSON string!')
|
|
217
228
|
}
|
|
218
229
|
|
|
219
|
-
@test()
|
|
220
|
-
protected static async getRssiBleBackendCallsBindingWithExpectedArgs() {
|
|
221
|
-
this.getRssiBleBackend()
|
|
222
|
-
|
|
223
|
-
assert.isEqual(
|
|
224
|
-
this.callsToGetRssi[0][0],
|
|
225
|
-
this.bleDeviceUuid,
|
|
226
|
-
'getRssiBleBackend did not call binding with expected args!'
|
|
227
|
-
)
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
@test()
|
|
231
|
-
protected static async getRssiBleBackendReturnsJson() {
|
|
232
|
-
const raw = this.getRssiBleBackend()
|
|
233
|
-
const json = JSON.parse(raw)
|
|
234
|
-
|
|
235
|
-
assert.isTruthy(json, 'getRssiBleBackend did not return a JSON string!')
|
|
236
|
-
}
|
|
237
|
-
|
|
238
230
|
@test()
|
|
239
231
|
protected static async createFtdiBackendCallsBindingWithExpectedArgs() {
|
|
240
232
|
this.createFtdiBackend()
|
|
@@ -326,6 +318,14 @@ export default class LibndxAdapterTest extends AbstractPackageTest {
|
|
|
326
318
|
})
|
|
327
319
|
}
|
|
328
320
|
|
|
321
|
+
private static writeBleCharacteristic() {
|
|
322
|
+
return this.instance.writeBleCharacteristic({
|
|
323
|
+
deviceUuid: this.bleDeviceUuid,
|
|
324
|
+
characteristicUuid: this.bleCharacteristicUuid,
|
|
325
|
+
value: this.bleValueToWrite,
|
|
326
|
+
})
|
|
327
|
+
}
|
|
328
|
+
|
|
329
329
|
private static stopBleBackend() {
|
|
330
330
|
return this.instance.stopBleBackend({
|
|
331
331
|
deviceUuid: this.bleDeviceUuid,
|
|
@@ -339,7 +339,7 @@ export default class LibndxAdapterTest extends AbstractPackageTest {
|
|
|
339
339
|
}
|
|
340
340
|
|
|
341
341
|
private static getRssiBleBackend() {
|
|
342
|
-
return this.instance.
|
|
342
|
+
return this.instance.readBleRssi({
|
|
343
343
|
deviceUuid: this.bleDeviceUuid,
|
|
344
344
|
})
|
|
345
345
|
}
|
|
@@ -378,6 +378,14 @@ export default class LibndxAdapterTest extends AbstractPackageTest {
|
|
|
378
378
|
this.callsToStartBle.push(args)
|
|
379
379
|
return JSON.stringify({})
|
|
380
380
|
},
|
|
381
|
+
write_ble_characteristic: (args) => {
|
|
382
|
+
this.callsToWriteBle.push(args)
|
|
383
|
+
return JSON.stringify({})
|
|
384
|
+
},
|
|
385
|
+
read_ble_rssi: (args) => {
|
|
386
|
+
this.callsToReadRssi.push(args)
|
|
387
|
+
return JSON.stringify({})
|
|
388
|
+
},
|
|
381
389
|
stop_ble_backend: (args) => {
|
|
382
390
|
this.callsToStopBle.push(args)
|
|
383
391
|
return JSON.stringify({})
|
|
@@ -386,10 +394,6 @@ export default class LibndxAdapterTest extends AbstractPackageTest {
|
|
|
386
394
|
this.callsToDestroyBle.push(args)
|
|
387
395
|
return JSON.stringify({})
|
|
388
396
|
},
|
|
389
|
-
get_rssi_ble_backend: (args) => {
|
|
390
|
-
this.callsToGetRssi.push(args)
|
|
391
|
-
return JSON.stringify({})
|
|
392
|
-
},
|
|
393
397
|
create_ftdi_backend: (args) => {
|
|
394
398
|
this.callsToCreateFtdi.push(args)
|
|
395
399
|
return JSON.stringify({})
|
|
@@ -414,7 +418,7 @@ export default class LibndxAdapterTest extends AbstractPackageTest {
|
|
|
414
418
|
this.callsToStartBle.length = 0
|
|
415
419
|
this.callsToStopBle.length = 0
|
|
416
420
|
this.callsToDestroyBle.length = 0
|
|
417
|
-
this.
|
|
421
|
+
this.callsToReadRssi.length = 0
|
|
418
422
|
this.callsToCreateFtdi.length = 0
|
|
419
423
|
this.callsToStartFtdi.length = 0
|
|
420
424
|
this.callsToStopFtdi.length = 0
|
|
@@ -422,30 +426,32 @@ export default class LibndxAdapterTest extends AbstractPackageTest {
|
|
|
422
426
|
}
|
|
423
427
|
|
|
424
428
|
private static clearAndFakeFfi() {
|
|
425
|
-
delete this.
|
|
426
|
-
|
|
427
|
-
this.
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
429
|
+
delete this.koffiLoadPath
|
|
430
|
+
this.koffiFuncSignatures = []
|
|
431
|
+
this.fakeKoffiLoad()
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
private static fakeKoffiLoad() {
|
|
435
|
+
LibndxAdapter.koffiLoad = (path) => {
|
|
436
|
+
this.koffiLoadPath = path as string
|
|
437
|
+
return {
|
|
438
|
+
func: (sig: string) => {
|
|
439
|
+
this.koffiFuncSignatures!.push(sig)
|
|
440
|
+
|
|
441
|
+
if (this.shouldThrowWhenLoadingBindings) {
|
|
442
|
+
throw new Error(this.fakeErrorMessage)
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
const name = sig.match(
|
|
446
|
+
/\w+\s+(\w+)\s*\(/
|
|
447
|
+
)![1] as keyof LibndxBindings
|
|
448
|
+
return (...args: string[]) =>
|
|
449
|
+
this.fakeBindings[name](args as any)
|
|
450
|
+
},
|
|
451
|
+
} as any
|
|
434
452
|
}
|
|
435
453
|
}
|
|
436
454
|
|
|
437
|
-
private static fakeFfiRsDefine() {
|
|
438
|
-
LibndxAdapter.ffiRsDefine = ((options) => {
|
|
439
|
-
this.ffiRsDefineOptions = options
|
|
440
|
-
|
|
441
|
-
if (this.shouldThrowWhenLoadingBindings) {
|
|
442
|
-
throw new Error(this.fakeErrorMessage)
|
|
443
|
-
}
|
|
444
|
-
|
|
445
|
-
return this.fakeBindings as any
|
|
446
|
-
}) as typeof define
|
|
447
|
-
}
|
|
448
|
-
|
|
449
455
|
private static get failedToLoadError() {
|
|
450
456
|
return `
|
|
451
457
|
\n -----------------------------------
|