jooby-codec 3.7.0 → 3.8.0
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/analog/CommandBinaryBuffer.d.ts +9 -0
- package/dist/analog/CommandBinaryBuffer.js +19 -0
- package/dist/analog/CommandBinaryBuffer.js.map +1 -1
- package/dist/analog/DataSegmentsCollector.d.ts +7 -0
- package/dist/analog/DataSegmentsCollector.js +61 -0
- package/dist/analog/DataSegmentsCollector.js.map +1 -0
- package/dist/analog/commands/DataSegmentBase.d.ts +11 -0
- package/dist/analog/commands/DataSegmentBase.js +41 -0
- package/dist/analog/commands/DataSegmentBase.js.map +1 -0
- package/dist/analog/commands/downlink/DataSegment.d.ts +4 -0
- package/dist/analog/commands/downlink/DataSegment.js +7 -0
- package/dist/analog/commands/downlink/DataSegment.js.map +1 -0
- package/dist/analog/commands/downlink/index.d.ts +1 -0
- package/dist/analog/commands/downlink/index.js +1 -0
- package/dist/analog/commands/downlink/index.js.map +1 -1
- package/dist/analog/commands/uplink/DataSegment.d.ts +4 -0
- package/dist/analog/commands/uplink/DataSegment.js +7 -0
- package/dist/analog/commands/uplink/DataSegment.js.map +1 -0
- package/dist/analog/commands/uplink/index.d.ts +1 -0
- package/dist/analog/commands/uplink/index.js +1 -0
- package/dist/analog/commands/uplink/index.js.map +1 -1
- package/dist/analog/constants/commandRelations.d.ts +2 -2
- package/dist/analog/constants/commandRelations.js +1 -0
- package/dist/analog/constants/commandRelations.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/mtx/message.d.ts +2 -1
- package/dist/mtx/message.js +8 -6
- package/dist/mtx/message.js.map +1 -1
- package/dist/mtxLora/Command.d.ts +1 -1
- package/dist/mtxLora/Command.js +0 -3
- package/dist/mtxLora/Command.js.map +1 -1
- package/dist/mtxLora/CommandBinaryBuffer.d.ts +44 -8
- package/dist/mtxLora/CommandBinaryBuffer.js +260 -16
- package/dist/mtxLora/CommandBinaryBuffer.js.map +1 -1
- package/dist/mtxLora/UnknownCommand.d.ts +12 -0
- package/dist/mtxLora/UnknownCommand.js +17 -0
- package/dist/mtxLora/UnknownCommand.js.map +1 -0
- package/dist/mtxLora/commands/downlink/GetHalfhoursEnergies.d.ts +20 -0
- package/dist/mtxLora/commands/downlink/GetHalfhoursEnergies.js +61 -0
- package/dist/mtxLora/commands/downlink/GetHalfhoursEnergies.js.map +1 -0
- package/dist/mtxLora/commands/downlink/index.d.ts +1 -1
- package/dist/mtxLora/commands/downlink/index.js +1 -1
- package/dist/mtxLora/commands/downlink/index.js.map +1 -1
- package/dist/mtxLora/commands/uplink/GetDayEnergies.d.ts +17 -0
- package/dist/mtxLora/commands/uplink/GetDayEnergies.js +59 -0
- package/dist/mtxLora/commands/uplink/GetDayEnergies.js.map +1 -0
- package/dist/mtxLora/commands/uplink/GetDayMaxPower.d.ts +17 -0
- package/dist/mtxLora/commands/uplink/GetDayMaxPower.js +67 -0
- package/dist/mtxLora/commands/uplink/GetDayMaxPower.js.map +1 -0
- package/dist/mtxLora/commands/uplink/GetHalfhoursEnergies.d.ts +19 -0
- package/dist/mtxLora/commands/uplink/GetHalfhoursEnergies.js +68 -0
- package/dist/mtxLora/commands/uplink/GetHalfhoursEnergies.js.map +1 -0
- package/dist/mtxLora/commands/uplink/index.d.ts +3 -1
- package/dist/mtxLora/commands/uplink/index.js +3 -1
- package/dist/mtxLora/commands/uplink/index.js.map +1 -1
- package/dist/mtxLora/constants/commandRelations.d.ts +2 -2
- package/dist/mtxLora/constants/commandRelations.js +1 -1
- package/dist/mtxLora/constants/commandRelations.js.map +1 -1
- package/dist/mtxLora/index.d.ts +1 -0
- package/dist/mtxLora/index.js +1 -0
- package/dist/mtxLora/index.js.map +1 -1
- package/dist/mtxLora/message.d.ts +24 -0
- package/dist/mtxLora/message.js +81 -0
- package/dist/mtxLora/message.js.map +1 -0
- package/dist/utils/permutations.d.ts +2 -0
- package/dist/utils/permutations.js +15 -0
- package/dist/utils/permutations.js.map +1 -0
- package/package.json +1 -1
- package/dist/mtxLora/commands/MtxCommandBase.d.ts +0 -11
- package/dist/mtxLora/commands/MtxCommandBase.js +0 -44
- package/dist/mtxLora/commands/MtxCommandBase.js.map +0 -1
- package/dist/mtxLora/commands/downlink/MtxCommand.d.ts +0 -4
- package/dist/mtxLora/commands/downlink/MtxCommand.js +0 -7
- package/dist/mtxLora/commands/downlink/MtxCommand.js.map +0 -1
- package/dist/mtxLora/commands/uplink/MtxCommand.d.ts +0 -4
- package/dist/mtxLora/commands/uplink/MtxCommand.js +0 -7
- package/dist/mtxLora/commands/uplink/MtxCommand.js.map +0 -1
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import Command, { COMMAND_HEADER_SIZE } from '../../Command.js';
|
|
2
|
+
import CommandBinaryBuffer from '../../CommandBinaryBuffer.js';
|
|
3
|
+
import { UPLINK } from '../../../constants/directions.js';
|
|
4
|
+
const COMMAND_ID = 0x79;
|
|
5
|
+
const DATE_SIZE = 3;
|
|
6
|
+
const MAX_TARIFFS_ENERGIES_SIZE = 5 * 4 * (1 + 1 + 4);
|
|
7
|
+
const COMMAND_MAX_SIZE = DATE_SIZE + MAX_TARIFFS_ENERGIES_SIZE;
|
|
8
|
+
const examples = [
|
|
9
|
+
{
|
|
10
|
+
name: 'get day max power',
|
|
11
|
+
parameters: {
|
|
12
|
+
date: {
|
|
13
|
+
year: 21,
|
|
14
|
+
month: 2,
|
|
15
|
+
day: 3
|
|
16
|
+
},
|
|
17
|
+
tariffs: [
|
|
18
|
+
{
|
|
19
|
+
aPlus: {
|
|
20
|
+
hours: 2,
|
|
21
|
+
minutes: 3,
|
|
22
|
+
power: 0x1000
|
|
23
|
+
},
|
|
24
|
+
aMinusRPlus: {
|
|
25
|
+
hours: 4,
|
|
26
|
+
minutes: 5,
|
|
27
|
+
power: 0x2000
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
]
|
|
31
|
+
},
|
|
32
|
+
hex: {
|
|
33
|
+
header: '79 10',
|
|
34
|
+
body: '2a 43 11 11 02 03 00 00 10 00 04 05 00 00 20 00'
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
];
|
|
38
|
+
class GetDayMaxPower extends Command {
|
|
39
|
+
constructor(parameters) {
|
|
40
|
+
super();
|
|
41
|
+
this.parameters = parameters;
|
|
42
|
+
}
|
|
43
|
+
static fromBytes(data) {
|
|
44
|
+
const buffer = new CommandBinaryBuffer(data);
|
|
45
|
+
return new GetDayMaxPower({
|
|
46
|
+
date: buffer.getDate(),
|
|
47
|
+
tariffs: buffer.getTariffsPowerMax()
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
toBytes() {
|
|
51
|
+
const { parameters: { date, tariffs: powers } } = this;
|
|
52
|
+
const buffer = new CommandBinaryBuffer(COMMAND_HEADER_SIZE + COMMAND_MAX_SIZE);
|
|
53
|
+
buffer.setDate(date);
|
|
54
|
+
buffer.setTariffsPowerMax(powers);
|
|
55
|
+
return new Uint8Array([
|
|
56
|
+
COMMAND_ID,
|
|
57
|
+
buffer.position,
|
|
58
|
+
...buffer.getBytesToOffset()
|
|
59
|
+
]);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
GetDayMaxPower.id = COMMAND_ID;
|
|
63
|
+
GetDayMaxPower.directionType = UPLINK;
|
|
64
|
+
GetDayMaxPower.examples = examples;
|
|
65
|
+
GetDayMaxPower.hasParameters = true;
|
|
66
|
+
export default GetDayMaxPower;
|
|
67
|
+
//# sourceMappingURL=GetDayMaxPower.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GetDayMaxPower.js","sourceRoot":"","sources":["../../../../src/mtxLora/commands/uplink/GetDayMaxPower.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,EAAE,EAAsB,mBAAmB,EAAC,MAAM,kBAAkB,CAAC;AACnF,OAAO,mBAA8C,MAAM,8BAA8B,CAAC;AAC1F,OAAO,EAAC,MA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D,MAAM,MAAM,GAAG,IAAI,mBAAmB,CAAC,mBAAmB,GAAG,gBAAgB,CAAC,CAAC;QAG/E,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QACrB,MAAM,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC;QAElC,OAAO,IAAI,UAAU,CAAC;YAClB,UAAU;YACV,MAAM,CAAC,QAAQ;YACf,GAAG,MAAM,CAAC,gBAAgB,EAAE;SAC/B,CAAC,CAAC;IACP,CAAC;;AAjCe,iBAAE,GAAG,UAAU,CAAC;AAEhB,4BAAa,GAAG,MAAM,CAAC;AAEvB,uBAAQ,GAAG,QAAQ,CAAC;AAEpB,4BAAa,GAAG,IAAI,CAAC;AA8BzC,eAAe,cAAc,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import Command, { TCommandExampleList } from '../../Command.js';
|
|
2
|
+
import { IDate, THalfhoursEnergies } from '../../CommandBinaryBuffer.js';
|
|
3
|
+
interface IGetHalfhoursEnergies {
|
|
4
|
+
date: IDate;
|
|
5
|
+
firstHalfhour: number;
|
|
6
|
+
halfhoursNumber: number;
|
|
7
|
+
energies: THalfhoursEnergies;
|
|
8
|
+
}
|
|
9
|
+
declare class GetHalfhoursEnergies extends Command {
|
|
10
|
+
parameters: IGetHalfhoursEnergies;
|
|
11
|
+
constructor(parameters: IGetHalfhoursEnergies);
|
|
12
|
+
static readonly id = 105;
|
|
13
|
+
static readonly directionType = 2;
|
|
14
|
+
static readonly examples: TCommandExampleList;
|
|
15
|
+
static readonly hasParameters = true;
|
|
16
|
+
static fromBytes(data: Uint8Array): GetHalfhoursEnergies;
|
|
17
|
+
toBytes(): Uint8Array;
|
|
18
|
+
}
|
|
19
|
+
export default GetHalfhoursEnergies;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import Command, { COMMAND_HEADER_SIZE } from '../../Command.js';
|
|
2
|
+
import CommandBinaryBuffer from '../../CommandBinaryBuffer.js';
|
|
3
|
+
import { UPLINK } from '../../../constants/directions.js';
|
|
4
|
+
const COMMAND_ID = 0x69;
|
|
5
|
+
const DATE_SIZE = 3;
|
|
6
|
+
const MAX_HALFHOURS_ENERGY_SIZE = 5 * 3 * 4;
|
|
7
|
+
const COMMAND_MAX_SIZE = DATE_SIZE + MAX_HALFHOURS_ENERGY_SIZE;
|
|
8
|
+
const examples = [
|
|
9
|
+
{
|
|
10
|
+
name: 'get halfhours energies',
|
|
11
|
+
parameters: {
|
|
12
|
+
date: {
|
|
13
|
+
year: 21,
|
|
14
|
+
month: 2,
|
|
15
|
+
day: 3
|
|
16
|
+
},
|
|
17
|
+
firstHalfhour: 1,
|
|
18
|
+
halfhoursNumber: 2,
|
|
19
|
+
energies: {
|
|
20
|
+
aPlus: [0x1000, 0x2000],
|
|
21
|
+
aMinusRPlus: [0x3000, 0x4000]
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
hex: {
|
|
25
|
+
header: '69 15',
|
|
26
|
+
body: '2a 43 11 01 02 00 00 10 00 00 00 20 00 00 00 30 00 00 00 40 00'
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
];
|
|
30
|
+
class GetHalfhoursEnergies extends Command {
|
|
31
|
+
constructor(parameters) {
|
|
32
|
+
super();
|
|
33
|
+
this.parameters = parameters;
|
|
34
|
+
}
|
|
35
|
+
static fromBytes(data) {
|
|
36
|
+
const buffer = new CommandBinaryBuffer(data);
|
|
37
|
+
const date = buffer.getDate();
|
|
38
|
+
const energiesFlags = buffer.getEnergiesFlags();
|
|
39
|
+
const firstHalfhour = buffer.getUint8();
|
|
40
|
+
const halfhoursNumber = buffer.getUint8();
|
|
41
|
+
return new GetHalfhoursEnergies({
|
|
42
|
+
date,
|
|
43
|
+
firstHalfhour,
|
|
44
|
+
halfhoursNumber,
|
|
45
|
+
energies: buffer.getHalfhoursEnergies(energiesFlags, halfhoursNumber)
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
toBytes() {
|
|
49
|
+
const { parameters: { date, firstHalfhour, halfhoursNumber, energies } } = this;
|
|
50
|
+
const buffer = new CommandBinaryBuffer(COMMAND_HEADER_SIZE + COMMAND_MAX_SIZE);
|
|
51
|
+
buffer.setDate(date);
|
|
52
|
+
buffer.setEnergiesFlags(energies);
|
|
53
|
+
buffer.setUint8(firstHalfhour);
|
|
54
|
+
buffer.setUint8(halfhoursNumber);
|
|
55
|
+
buffer.setHalfhoursEnergies(energies);
|
|
56
|
+
return new Uint8Array([
|
|
57
|
+
COMMAND_ID,
|
|
58
|
+
buffer.position,
|
|
59
|
+
...buffer.getBytesToOffset()
|
|
60
|
+
]);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
GetHalfhoursEnergies.id = COMMAND_ID;
|
|
64
|
+
GetHalfhoursEnergies.directionType = UPLINK;
|
|
65
|
+
GetHalfhoursEnergies.examples = examples;
|
|
66
|
+
GetHalfhoursEnergies.hasParameters = true;
|
|
67
|
+
export default GetHalfhoursEnergies;
|
|
68
|
+
//# sourceMappingURL=GetHalfhoursEnergies.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GetHalfhoursEnergies.js","sourceRoot":"","sources":["../../../../src/mtxLora/commands/uplink/GetHalfhoursEnergies.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,EAAE,EAAsB,mBAAmB,EAAC,MAAM,kBAAkB,CAAC;AACnF,OAAO,mBAAgD,MAAM,8BAA8B,CAAC;AAC5F,OAAO,EAAC,MAAM,EAAC,MAAM,kCAAkC,CAAC;AAWxD,MAAM,UAAU,GAAG,IAAI,CAAC;AACxB,MAAM,SAAS,GAAG,CAAC,CAAC;AACpB,MAAM,yBAAyB,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAC5C,MAAM,gBAAgB,GAAG,SAAS,GAAG,yBAAyB,CAAC;AAE/D,MAAM,QAAQ,GAAwB;IAClC;QACI,IAAI,EAAE,wBAAwB;QAC9B,UAAU,EAAE;YACR,IAAI,EAAE;gB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AAC,QAAQ,CAAC,CAAC;QAClC,MAAM,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC;QAC/B,MAAM,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC;QACjC,MAAM,CAAC,oBAAoB,CAAC,QAAQ,CAAC,CAAC;QAEtC,OAAO,IAAI,UAAU,CAAC;YAClB,UAAU;YACV,MAAM,CAAC,QAAQ;YACf,GAAG,MAAM,CAAC,gBAAgB,EAAE;SAC/B,CAAC,CAAC;IACP,CAAC;;AA1Ce,uBAAE,GAAG,UAAU,CAAC;AAEhB,kCAAa,GAAG,MAAM,CAAC;AAEvB,6BAAQ,GAAG,QAAQ,CAAC;AAEpB,kCAAa,GAAG,IAAI,CAAC;AAwCzC,eAAe,oBAAoB,CAAC"}
|
|
@@ -1,2 +1,4 @@
|
|
|
1
|
-
export { default as
|
|
1
|
+
export { default as GetHalfhoursEnergies } from './GetHalfhoursEnergies.js';
|
|
2
|
+
export { default as GetDayEnergies } from './GetDayEnergies.js';
|
|
3
|
+
export { default as GetDayMaxPower } from './GetDayMaxPower.js';
|
|
2
4
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/mtxLora/commands/uplink/index.ts"],"names":[],"mappings":"AAMA,OAAO,EAAC,OAAO,IAAI,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/mtxLora/commands/uplink/index.ts"],"names":[],"mappings":"AAMA,OAAO,EAAC,OAAO,IAAI,oBAAoB,EAAC,MAAM,2BAA2B,CAAC;AAC1E,OAAO,EAAC,OAAO,IAAI,cAAc,EAAC,MAAM,qBAAqB,CAAC;AAC9D,OAAO,EAAC,OAAO,IAAI,cAAc,EAAC,MAAM,qBAAqB,CAAC"}
|
|
@@ -2,5 +2,5 @@ import * as downlinkCommands from '../commands/downlink/index.js';
|
|
|
2
2
|
import * as uplinkCommands from '../commands/uplink/index.js';
|
|
3
3
|
export declare const requestByResponse: Map<any, any>;
|
|
4
4
|
export declare const responseByRequest: Map<any, any>;
|
|
5
|
-
export declare const requestById: Map<number, typeof downlinkCommands.
|
|
6
|
-
export declare const responseById: Map<number, typeof uplinkCommands.
|
|
5
|
+
export declare const requestById: Map<number, typeof downlinkCommands.GetHalfhoursEnergies>;
|
|
6
|
+
export declare const responseById: Map<number, typeof uplinkCommands.GetHalfhoursEnergies | typeof uplinkCommands.GetDayEnergies | typeof uplinkCommands.GetDayMaxPower>;
|
|
@@ -4,7 +4,7 @@ export const requestByResponse = new Map();
|
|
|
4
4
|
export const responseByRequest = new Map();
|
|
5
5
|
export const requestById = new Map(Object.values(downlinkCommands).map(command => [command.id, command]));
|
|
6
6
|
export const responseById = new Map(Object.values(uplinkCommands).map(command => [command.id, command]));
|
|
7
|
-
requestByResponse.set(uplinkCommands.
|
|
7
|
+
requestByResponse.set(uplinkCommands.GetHalfhoursEnergies, downlinkCommands.GetHalfhoursEnergies);
|
|
8
8
|
for (const [response, request] of requestByResponse.entries()) {
|
|
9
9
|
responseByRequest.set(request, response);
|
|
10
10
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commandRelations.js","sourceRoot":"","sources":["../../../src/mtxLora/constants/commandRelations.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,gBAAgB,MAAM,+BAA+B,CAAC;AAClE,OAAO,KAAK,cAAc,MAAM,6BAA6B,CAAC;AAI9D,MAAM,CAAC,MAAM,iBAAiB,GAAG,IAAI,GAAG,EAAE,CAAC;AAC3C,MAAM,CAAC,MAAM,iBAAiB,GAAG,IAAI,GAAG,EAAE,CAAC;AAG3C,MAAM,CAAC,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;AAC1G,MAAM,CAAC,MAAM,YAAY,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;AAGzG,iBAAiB,CAAC,GAAG,CAAC,cAAc,CAAC,
|
|
1
|
+
{"version":3,"file":"commandRelations.js","sourceRoot":"","sources":["../../../src/mtxLora/constants/commandRelations.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,gBAAgB,MAAM,+BAA+B,CAAC;AAClE,OAAO,KAAK,cAAc,MAAM,6BAA6B,CAAC;AAI9D,MAAM,CAAC,MAAM,iBAAiB,GAAG,IAAI,GAAG,EAAE,CAAC;AAC3C,MAAM,CAAC,MAAM,iBAAiB,GAAG,IAAI,GAAG,EAAE,CAAC;AAG3C,MAAM,CAAC,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;AAC1G,MAAM,CAAC,MAAM,YAAY,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;AAGzG,iBAAiB,CAAC,GAAG,CAAC,cAAc,CAAC,oBAAoB,EAAE,gBAAgB,CAAC,oBAAoB,CAAC,CAAC;AAElG,KAAM,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,IAAI,iBAAiB,CAAC,OAAO,EAAE,EAAG,CAAC;IAE9D,iBAAiB,CAAC,GAAG,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;AAC7C,CAAC"}
|
package/dist/mtxLora/index.d.ts
CHANGED
package/dist/mtxLora/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/mtxLora/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,QAAQ,MAAM,qBAAqB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/mtxLora/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,QAAQ,MAAM,qBAAqB,CAAC;AAChD,OAAO,KAAK,OAAO,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import Command from './Command.js';
|
|
2
|
+
import { IHexFormatOptions } from '../config.js';
|
|
3
|
+
interface IMessageCommand {
|
|
4
|
+
data: {
|
|
5
|
+
header: Uint8Array;
|
|
6
|
+
body: Uint8Array;
|
|
7
|
+
};
|
|
8
|
+
command: Command;
|
|
9
|
+
}
|
|
10
|
+
export interface IMessage {
|
|
11
|
+
messageId: number;
|
|
12
|
+
accessLevel: number;
|
|
13
|
+
commands?: Array<IMessageCommand>;
|
|
14
|
+
}
|
|
15
|
+
export interface IMessageConfig {
|
|
16
|
+
direction?: number;
|
|
17
|
+
}
|
|
18
|
+
export declare const fromBytes: (bytes: Uint8Array, config?: IMessageConfig) => IMessage;
|
|
19
|
+
export declare const fromHex: (data: string, config?: IMessageConfig) => IMessage;
|
|
20
|
+
export declare const fromBase64: (data: string) => IMessage;
|
|
21
|
+
export declare const toBytes: (messageId: number, accessLevel: number, commands: Array<Command>) => Uint8Array;
|
|
22
|
+
export declare const toHex: (messageId: number, accessLevel: number, commands: Array<Command>, hexOptions?: IHexFormatOptions) => string;
|
|
23
|
+
export declare const toBase64: (messageId: number, accessLevel: number, commands: Array<Command>) => string;
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import UnknownCommand from './UnknownCommand.js';
|
|
2
|
+
import { requestById, responseById } from './constants/commandRelations.js';
|
|
3
|
+
import { accessLevels } from '../mtx/constants/index.js';
|
|
4
|
+
import getBytesFromHex from '../utils/getBytesFromHex.js';
|
|
5
|
+
import getBytesFromBase64 from '../utils/getBytesFromBase64.js';
|
|
6
|
+
import getHexFromBytes from '../utils/getHexFromBytes.js';
|
|
7
|
+
import getBase64FromBytes from '../utils/getBase64FromBytes.js';
|
|
8
|
+
import mergeUint8Arrays from '../utils/mergeUint8Arrays.js';
|
|
9
|
+
import * as directionTypes from '../constants/directions.js';
|
|
10
|
+
import { AUTO, DOWNLINK, UPLINK } from '../constants/directions.js';
|
|
11
|
+
const MESSAGE_HEADER_SIZE = 3;
|
|
12
|
+
const COMMAND_HEADER_SIZE = 2;
|
|
13
|
+
const PROTOCOL_VERSION = 0x10;
|
|
14
|
+
const directionTypeIds = new Set(Object.values(directionTypes));
|
|
15
|
+
const getCommand = (id, data, direction = AUTO) => {
|
|
16
|
+
if (!directionTypeIds.has(direction)) {
|
|
17
|
+
throw new Error('wrong direction type');
|
|
18
|
+
}
|
|
19
|
+
const downlinkCommand = requestById.get(id);
|
|
20
|
+
const uplinkCommand = responseById.get(id);
|
|
21
|
+
if ((!downlinkCommand && !uplinkCommand)
|
|
22
|
+
|| (direction === DOWNLINK && !downlinkCommand)
|
|
23
|
+
|| (direction === UPLINK && !uplinkCommand)) {
|
|
24
|
+
return UnknownCommand.fromBytes(id, data);
|
|
25
|
+
}
|
|
26
|
+
if (direction === DOWNLINK || direction === UPLINK) {
|
|
27
|
+
const command = direction === UPLINK ? uplinkCommand : downlinkCommand;
|
|
28
|
+
return command.fromBytes(data);
|
|
29
|
+
}
|
|
30
|
+
try {
|
|
31
|
+
return uplinkCommand.fromBytes(data);
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
return downlinkCommand.fromBytes(data);
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
export const fromBytes = (bytes, config) => {
|
|
38
|
+
const direction = config?.direction ?? AUTO;
|
|
39
|
+
const commands = [];
|
|
40
|
+
const [messageId, accessLevel1, accessLevel2] = bytes;
|
|
41
|
+
const result = {
|
|
42
|
+
messageId,
|
|
43
|
+
accessLevel: (accessLevel1 & accessLevels.MASK)
|
|
44
|
+
};
|
|
45
|
+
if (result.accessLevel !== accessLevels.UNENCRYPTED) {
|
|
46
|
+
return result;
|
|
47
|
+
}
|
|
48
|
+
if (accessLevel1 !== accessLevel2) {
|
|
49
|
+
throw new Error('wrong access level');
|
|
50
|
+
}
|
|
51
|
+
result.commands = commands;
|
|
52
|
+
const messageBody = bytes.slice(MESSAGE_HEADER_SIZE);
|
|
53
|
+
let position = 0;
|
|
54
|
+
do {
|
|
55
|
+
const commandId = messageBody[position];
|
|
56
|
+
const commandBodySize = messageBody[position + 1];
|
|
57
|
+
const commandSize = COMMAND_HEADER_SIZE + commandBodySize;
|
|
58
|
+
const commandBody = messageBody.slice(position + COMMAND_HEADER_SIZE, position + commandSize);
|
|
59
|
+
if (!commandId) {
|
|
60
|
+
break;
|
|
61
|
+
}
|
|
62
|
+
const command = getCommand(commandId, commandBody, direction);
|
|
63
|
+
commands.push({
|
|
64
|
+
data: { header: new Uint8Array([commandId]), body: commandBody },
|
|
65
|
+
command
|
|
66
|
+
});
|
|
67
|
+
position += commandSize;
|
|
68
|
+
} while (position <= messageBody.length);
|
|
69
|
+
return result;
|
|
70
|
+
};
|
|
71
|
+
export const fromHex = (data, config) => (fromBytes(getBytesFromHex(data), config));
|
|
72
|
+
export const fromBase64 = (data) => (fromBytes(getBytesFromBase64(data)));
|
|
73
|
+
export const toBytes = (messageId, accessLevel, commands) => {
|
|
74
|
+
const commandBytes = commands.map(command => command.toBytes());
|
|
75
|
+
const maskedAccessLevel = accessLevel | PROTOCOL_VERSION;
|
|
76
|
+
const header = new Uint8Array([messageId, maskedAccessLevel, maskedAccessLevel]);
|
|
77
|
+
return mergeUint8Arrays(header, ...commandBytes);
|
|
78
|
+
};
|
|
79
|
+
export const toHex = (messageId, accessLevel, commands, hexOptions = {}) => (getHexFromBytes(toBytes(messageId, accessLevel, commands), hexOptions));
|
|
80
|
+
export const toBase64 = (messageId, accessLevel, commands) => (getBase64FromBytes(toBytes(messageId, accessLevel, commands)));
|
|
81
|
+
//# sourceMappingURL=message.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"message.js","sourceRoot":"","sources":["../../src/mtxLora/message.ts"],"names":[],"mappings":"AAGA,OAAO,cAAc,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAC,WAAW,EAAE,YAAY,EAAC,MAAM,iCAAiC,CAAC;AAC1E,OAAO,EAAC,YAAY,EAAC,MAAM,2BAA2B,CAAC;AAEvD,OAAO,eAAe,MAAM,6BAA6B,CAAC;AAC1D,OAAO,kBAAkB,MAAM,gCAAgC,CAAC;AAChE,OAAO,eAAe,MAAM,6BAA6B,CAAC;AAC1D,OAAO,kBAAkB,MAAM,gCAAgC,CAAC;AAChE,OAAO,gBAAgB,MAAM,8BAA8B,CAAC;AAE5D,OAAO,KAAK,cAAc,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAC,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAC,MAAM,4BAA4B,CAAC;AAyBlE,MAAM,mBAAmB,GAAG,CAAC,CAAC;AAC9B,MAAM,mBAAmB,GAAG,CAAC,CAAC;AAC9B,MAAM,gBAAgB,GAAG,IAAI,CAAC;AAI9B,MAAM,gBAAgB,GAAgB,IAAI,GAAG,CAAS,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,CAAC;AAErF,MAAM,UAAU,GAAG,CAAE,EAAU,EAAE,IAAgB,EAAE,SAAS,GAAG,IAAI,EAAY,EAAE;IAC7E,IAAK,CAAC,gBAAgB,CAAC,GAAG,CAAC,SAAS,CAAC,EAAG,CAAC;QACrC,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;IAC5C,CAAC;IAED,MAAM,eAAe,GAAG,WAAW,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAC5C,MAAM,aAAa,GAAG,YAAY,CAAC,G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GAAG,CAAE,SAAiB,EAAE,WAAmB,EAAE,QAAwB,EAAe,EAAE;IACtG,MAAM,YAAY,GAAG,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;IAChE,MAAM,iBAAiB,GAAG,WAAW,GAAG,gBAAgB,CAAC;IACzD,MAAM,MAAM,GAAG,IAAI,UAAU,CAAC,CAAC,SAAS,EAAE,iBAAiB,EAAE,iBAAiB,CAAC,CAAC,CAAC;IAEjF,OAAO,gBAAgB,CAAC,MAAM,EAAE,GAAG,YAAY,CAAC,CAAC;AACrD,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,KAAK,GAAG,CAAE,SAAiB,EAAE,WAAmB,EAAE,QAAwB,EAAE,aAAgC,EAAE,EAAW,EAAE,CAAC,CACrI,eAAe,CAAC,OAAO,CAAC,SAAS,EAAE,WAAW,EAAE,QAAQ,CAAC,EAAE,UAAU,CAAC,CACzE,CAAC;AAEF,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAE,SAAiB,EAAE,WAAmB,EAAE,QAAwB,EAAW,EAAE,CAAC,CACpG,kBAAkB,CAAC,OAAO,CAAC,SAAS,EAAE,WAAW,EAAE,QAAQ,CAAC,CAAC,CAChE,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const permutations = (sequence) => {
|
|
2
|
+
const result = new Array();
|
|
3
|
+
for (let i = 0; i < sequence.length; i++) {
|
|
4
|
+
if (sequence.length === 1) {
|
|
5
|
+
return [[sequence[i]]];
|
|
6
|
+
}
|
|
7
|
+
const remaining = permutations(sequence.filter((_value, index) => i !== index));
|
|
8
|
+
for (const rest of remaining) {
|
|
9
|
+
result.push([sequence[i], ...rest]);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
return result;
|
|
13
|
+
};
|
|
14
|
+
export default permutations;
|
|
15
|
+
//# sourceMappingURL=permutations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"permutations.js","sourceRoot":"","sources":["../../src/utils/permutations.ts"],"names":[],"mappings":"AAsBA,MAAM,YAAY,GAAG,CAAK,QAAkB,EAAoB,EAAE;IAC9D,MAAM,MAAM,GAAG,IAAI,KAAK,EAAY,CAAC;IAErC,KAAM,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,EAAG,CAAC;QACzC,IAAK,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAG,CAAC;YAC1B,OAAO,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC3B,CAAC;QAED,MAAM,SAAS,GAAG,YAAY,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,KAAK,CAAC,CAAC,CAAC;QAEhF,KAAM,MAAM,IAAI,IAAI,SAAS,EAAG,CAAC;YAC7B,MAAM,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC;QACxC,CAAC;IACL,CAAC;IAED,OAAO,MAAM,CAAC;AAClB,CAAC,CAAC;AAEF,eAAe,YAAY,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import Command, { TCommandExampleList } from '../Command.js';
|
|
2
|
-
import { IMtxCommand } from '../CommandBinaryBuffer.js';
|
|
3
|
-
export default class MtxCommandBase extends Command {
|
|
4
|
-
parameters: IMtxCommand;
|
|
5
|
-
constructor(parameters: IMtxCommand);
|
|
6
|
-
static readonly id = 30;
|
|
7
|
-
static readonly examples: TCommandExampleList;
|
|
8
|
-
static readonly hasParameters = true;
|
|
9
|
-
toBytes(): Uint8Array;
|
|
10
|
-
static fromBytes(data: Uint8Array): MtxCommandBase;
|
|
11
|
-
}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import Command, { COMMAND_HEADER_SIZE } from '../Command.js';
|
|
2
|
-
import CommandBinaryBuffer from '../CommandBinaryBuffer.js';
|
|
3
|
-
import getBytesFromHex from '../../utils/getBytesFromHex.js';
|
|
4
|
-
const COMMAND_ID = 0x1e;
|
|
5
|
-
const examples = [
|
|
6
|
-
{
|
|
7
|
-
name: 'MtxCommand request',
|
|
8
|
-
parameters: {
|
|
9
|
-
sequence: 2,
|
|
10
|
-
last: false,
|
|
11
|
-
fragmentsNumber: 5,
|
|
12
|
-
fragmentIndex: 3,
|
|
13
|
-
data: getBytesFromHex('00 01 02 03 04')
|
|
14
|
-
},
|
|
15
|
-
hex: {
|
|
16
|
-
header: '1e 07',
|
|
17
|
-
body: '02 53 00 01 02 03 04'
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
];
|
|
21
|
-
class MtxCommandBase extends Command {
|
|
22
|
-
constructor(parameters) {
|
|
23
|
-
super();
|
|
24
|
-
this.parameters = parameters;
|
|
25
|
-
this.size = 2 + parameters.data.length;
|
|
26
|
-
}
|
|
27
|
-
toBytes() {
|
|
28
|
-
const { size, parameters } = this;
|
|
29
|
-
const buffer = new CommandBinaryBuffer(COMMAND_HEADER_SIZE + size);
|
|
30
|
-
buffer.setUint8(COMMAND_ID);
|
|
31
|
-
buffer.setUint8(size);
|
|
32
|
-
buffer.setMtxCommand(parameters);
|
|
33
|
-
return buffer.toUint8Array();
|
|
34
|
-
}
|
|
35
|
-
static fromBytes(data) {
|
|
36
|
-
const buffer = new CommandBinaryBuffer(data);
|
|
37
|
-
return new this(buffer.getMtxCommand());
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
MtxCommandBase.id = COMMAND_ID;
|
|
41
|
-
MtxCommandBase.examples = examples;
|
|
42
|
-
MtxCommandBase.hasParameters = true;
|
|
43
|
-
export default MtxCommandBase;
|
|
44
|
-
//# sourceMappingURL=MtxCommandBase.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"MtxCommandBase.js","sour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,CAAC,MAAM,CAAC,aAAa,EAAE,CAAC,CAAC;IAC5C,CAAC;;AA1Be,iBAAE,GAAG,UAAU,CAAC;AAEhB,uBAAQ,GAAG,QAAQ,CAAC;AAEpB,4BAAa,GAAG,IAAI,CAAC;eAXpB,cAAc"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import MtxCommandBase from '../MtxCommandBase.js';
|
|
2
|
-
import { DOWNLINK } from '../../../constants/directions.js';
|
|
3
|
-
class MtxCommand extends MtxCommandBase {
|
|
4
|
-
}
|
|
5
|
-
MtxCommand.directionType = DOWNLINK;
|
|
6
|
-
export default MtxCommand;
|
|
7
|
-
//# sourceMappingURL=MtxCommand.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"MtxCommand.js","sourceRoot":"","sources":["../../../../src/mtxLora/commands/downlink/MtxCommand.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,MAAM,sBAAsB,CAAC;AAElD,OAAO,EAAC,QAAQ,EAAC,MAAM,kCAAkC,CAAC;AAuB1D,MAAqB,UAAW,SAAQ,cAAc;;AAClC,wBAAa,GAAG,QAAQ,CAAC;eADxB,UAAU"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"MtxCommand.js","sourceRoot":"","sources":["../../../../src/mtxLora/commands/uplink/MtxCommand.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAC,MAAM,EAAC,MAAM,kCAAkC,CAAC;AA0BxD,MAAqB,UAAW,SAAQ,cAAc;;AAClC,wBAAa,GAAG,MAAM,CAAC;eADtB,UAAU"}
|