iobroker.lorawan 0.2.1 → 0.3.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/README.md +9 -1
- package/admin/blockly.js +221 -23
- package/io-package.json +14 -14
- package/lib/modules/directorieshandler.js +1 -1
- package/main.js +40 -35
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -22,6 +22,9 @@ For now there is documentation in English here: http://www.hafenmeister.com/Lora
|
|
|
22
22
|
Placeholder for the next version (at the beginning of the line):
|
|
23
23
|
### **WORK IN PROGRESS**
|
|
24
24
|
-->
|
|
25
|
+
### 0.3.0 (2024-02-15)
|
|
26
|
+
* (BenAhrdt) define user friendly Blockly Blocks with result
|
|
27
|
+
|
|
25
28
|
### 0.2.1 (2024-02-13)
|
|
26
29
|
* (BenAhrdt) check types of messaging values and implements more blockly blocks
|
|
27
30
|
|
|
@@ -149,4 +152,9 @@ SOFTWARE.
|
|
|
149
152
|
The rights of the trademarks and company names,
|
|
150
153
|
remain with their owners and have no relation to this adapter.
|
|
151
154
|
The fairuse policy must continue to be adhered to by the operator of the adapter.
|
|
152
|
-
If this repository is forked, it must be cited as the source.
|
|
155
|
+
If this repository is forked, it must be cited as the source.
|
|
156
|
+
|
|
157
|
+
LoRa® is a registered trademark or service
|
|
158
|
+
mark of Semtech Corporation or its affilantes.
|
|
159
|
+
|
|
160
|
+
LoRaWAN® is a licensed mark.
|
package/admin/blockly.js
CHANGED
|
@@ -5,26 +5,68 @@
|
|
|
5
5
|
|
|
6
6
|
// @ts-ignore
|
|
7
7
|
if (typeof goog !== "undefined") {
|
|
8
|
-
// @ts-ignore
|
|
9
|
-
// eslint-disable-next-line no-undef
|
|
10
8
|
goog.provide("Blockly.JavaScript.Sendto");
|
|
11
|
-
// @ts-ignore
|
|
12
|
-
// eslint-disable-next-line no-undef
|
|
13
9
|
goog.require("Blockly.JavaScript");
|
|
14
10
|
}
|
|
15
11
|
|
|
16
12
|
|
|
17
13
|
// --- general translations --------------------------------------------------
|
|
18
|
-
Blockly.Words["anyInstance"] = {
|
|
19
|
-
|
|
14
|
+
Blockly.Words["anyInstance"] = {
|
|
15
|
+
"en": "all instances",
|
|
16
|
+
"pt": "todas as instâncias",
|
|
17
|
+
"pl": "wszystkie przypadki",
|
|
18
|
+
"nl": "alle instanties",
|
|
19
|
+
"it": "tutte le istanze",
|
|
20
|
+
"es": "todas las instancias",
|
|
21
|
+
"fr": "toutes les instances",
|
|
22
|
+
"de": "Alle Instanzen",
|
|
23
|
+
"ru": "На все драйвера"
|
|
24
|
+
};
|
|
25
|
+
Blockly.Words["lorawanDeviceEUI"] = {
|
|
26
|
+
"en": "device EUI",
|
|
27
|
+
"de": "Device EUI",
|
|
28
|
+
"ru": "устройство EUI",
|
|
29
|
+
"pt": "dispositivo EUI",
|
|
30
|
+
"nl": "apparaat EUI",
|
|
31
|
+
"fr": "dispositif IUE",
|
|
32
|
+
"it": "dispositivo EUI",
|
|
33
|
+
"es": "dispositivo EUI",
|
|
34
|
+
"pl": "urządzenie EUI",
|
|
35
|
+
"uk": "пристрій EUI",
|
|
36
|
+
"zh-cn": "设备 EUI"
|
|
37
|
+
};
|
|
20
38
|
|
|
21
39
|
/**************************************************************************
|
|
22
40
|
******************************Get Device Info******************************
|
|
23
41
|
**************************************************************************/
|
|
24
42
|
|
|
25
43
|
// --- Get DeviceInfo translations --------------------------------------------------
|
|
26
|
-
Blockly.Words["lorawanGetDeviceInfo"] = {
|
|
27
|
-
|
|
44
|
+
Blockly.Words["lorawanGetDeviceInfo"] = {
|
|
45
|
+
"en": "lorawan Device Info",
|
|
46
|
+
"de": "lorawan Geräteinfo",
|
|
47
|
+
"ru": "lorawan Device Info",
|
|
48
|
+
"pt": "lorawan Informações do dispositivo",
|
|
49
|
+
"nl": "lorawan Apparaatinformatie",
|
|
50
|
+
"fr": "lorawan Informations sur le périphérique",
|
|
51
|
+
"it": "lorawan Dispositivi Info",
|
|
52
|
+
"es": "lorawan Device Info",
|
|
53
|
+
"pl": "informacje o urządzeniu Lorawan",
|
|
54
|
+
"uk": "інформація про пристрій lorawan",
|
|
55
|
+
"zh-cn": "lorawan 设备信息"
|
|
56
|
+
};
|
|
57
|
+
Blockly.Words["lorawanGetDeviceInfotooltip"] = {
|
|
58
|
+
"en": "get Informations about the device with the given device EUI",
|
|
59
|
+
"de": "Informationen über das Gerät mit der angegebenen Geräte EUI",
|
|
60
|
+
"ru": "получить информацию об устройстве с данным устройством EUI",
|
|
61
|
+
"pt": "obter informações sobre o dispositivo com o dispositivo dado EUI",
|
|
62
|
+
"nl": "informatie over het apparaat met het gegeven apparaat opvragen EUI",
|
|
63
|
+
"fr": "obtenir des informations sur l'appareil avec l'appareil donné IUE",
|
|
64
|
+
"it": "ottenere informazioni sul dispositivo con il dispositivo fornito EUI",
|
|
65
|
+
"es": "obtener Información sobre el dispositivo con el dispositivo dado EUI",
|
|
66
|
+
"pl": "pobierz informacje o urządzeniu z podanym urządzeniem EUI",
|
|
67
|
+
"uk": "отримувати інформацію про пристрій з заданим пристроєм EUI",
|
|
68
|
+
"zh-cn": "用指定的设备获取设备信息 EUI"
|
|
69
|
+
};
|
|
28
70
|
|
|
29
71
|
// eslint-disable-next-line no-undef
|
|
30
72
|
Blockly.Sendto.blocks["lorawanGetDeviceInfo"] =
|
|
@@ -70,15 +112,32 @@ Blockly.Blocks["lorawanGetDeviceInfo"] = {
|
|
|
70
112
|
this.appendValueInput("deviceEUI")
|
|
71
113
|
.appendField(Blockly.Translate("lorawanDeviceEUI"));
|
|
72
114
|
|
|
115
|
+
this.appendStatementInput("result");
|
|
116
|
+
|
|
117
|
+
this.setInputsInline(false);
|
|
118
|
+
this.setPreviousStatement(true, null);
|
|
119
|
+
this.setNextStatement(true, null);
|
|
120
|
+
|
|
73
121
|
this.setColour(Blockly.Sendto.HUE);
|
|
74
122
|
this.setTooltip(Blockly.Translate("lorawanGetDeviceInfotooltip"));
|
|
75
123
|
}
|
|
76
124
|
};
|
|
77
125
|
|
|
78
126
|
Blockly.JavaScript["lorawanGetDeviceInfo"] = function(block){
|
|
79
|
-
const dropdown_instance = block.getFieldValue("INSTANCE");
|
|
80
127
|
const value_devEUI = Blockly.JavaScript.valueToCode(block, "deviceEUI", Blockly.JavaScript.ORDER_ATOMIC);
|
|
81
|
-
|
|
128
|
+
const code_result = Blockly.JavaScript.statementToCode(block, "result");
|
|
129
|
+
|
|
130
|
+
// build code
|
|
131
|
+
const objParameter = [];
|
|
132
|
+
objParameter.push("deviceEUI:" + value_devEUI);
|
|
133
|
+
const objEnd = [];
|
|
134
|
+
if(code_result){
|
|
135
|
+
objEnd.push(`, async (result) => {${code_result}});`);
|
|
136
|
+
}
|
|
137
|
+
else{
|
|
138
|
+
objEnd.push(`);`);
|
|
139
|
+
}
|
|
140
|
+
return `sendTo("lorawan${block.getFieldValue("INSTANCE")}", "getDeviceInfo", {${objParameter.join(",")}}${objEnd}`;
|
|
82
141
|
};
|
|
83
142
|
|
|
84
143
|
/**************************************************************************
|
|
@@ -86,10 +145,58 @@ Blockly.JavaScript["lorawanGetDeviceInfo"] = function(block){
|
|
|
86
145
|
**************************************************************************/
|
|
87
146
|
|
|
88
147
|
// --- Get DeviceInfo translations --------------------------------------------------
|
|
89
|
-
Blockly.Words["lorawanGetUplink"] = {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
148
|
+
Blockly.Words["lorawanGetUplink"] = {
|
|
149
|
+
"en": "lorawan uplinkinfo",
|
|
150
|
+
"de": "lorawan uplinkinfo",
|
|
151
|
+
"ru": "lorawan uplinkinfo",
|
|
152
|
+
"pt": "o que fazer",
|
|
153
|
+
"nl": "lorawan uplinkinfo",
|
|
154
|
+
"fr": "lorawan uplinkinfo",
|
|
155
|
+
"it": "condividi su google",
|
|
156
|
+
"es": "lorawan uplinkinfo",
|
|
157
|
+
"pl": "lorawan uplinkinfo",
|
|
158
|
+
"uk": "український",
|
|
159
|
+
"zh-cn": "lorawan 上行链接信息"
|
|
160
|
+
};
|
|
161
|
+
Blockly.Words["lorawanGetUplinktooltip"] = {
|
|
162
|
+
"en": "get information about the given uplink",
|
|
163
|
+
"de": "Informationen zum angegebenen uplink",
|
|
164
|
+
"ru": "получить информацию об отказе от ссылки",
|
|
165
|
+
"pt": "obter informações sobre o link fornecido",
|
|
166
|
+
"nl": "informatie krijgen over de opgegeven uplink",
|
|
167
|
+
"fr": "obtenir des informations sur le lien ascendant donné",
|
|
168
|
+
"it": "ottenere informazioni su il link up",
|
|
169
|
+
"es": "obtener información sobre el enlace dado",
|
|
170
|
+
"pl": "uzyskać informacje o danym łączniku",
|
|
171
|
+
"uk": "отримувати інформацію про задану посилання",
|
|
172
|
+
"zh-cn": "获取上行链路的信息"
|
|
173
|
+
};
|
|
174
|
+
Blockly.Words["lorawanUplink"] = {
|
|
175
|
+
"en": "uplink",
|
|
176
|
+
"de": "Uplink",
|
|
177
|
+
"ru": "uplink",
|
|
178
|
+
"pt": "o que é",
|
|
179
|
+
"nl": "uplink",
|
|
180
|
+
"fr": "lien ascendant",
|
|
181
|
+
"it": "uplink",
|
|
182
|
+
"es": "subtítulos",
|
|
183
|
+
"pl": "link",
|
|
184
|
+
"uk": "посилання",
|
|
185
|
+
"zh-cn": "上行链接"
|
|
186
|
+
};
|
|
187
|
+
Blockly.Words["lorawanSubfolder"] = {
|
|
188
|
+
"en": "subfolder",
|
|
189
|
+
"de": "Unterordner",
|
|
190
|
+
"ru": "subfolder",
|
|
191
|
+
"pt": "subpastas",
|
|
192
|
+
"nl": "submap",
|
|
193
|
+
"fr": "sous-dossier",
|
|
194
|
+
"it": "sottocartella",
|
|
195
|
+
"es": "subcarpeta",
|
|
196
|
+
"pl": "podfolder",
|
|
197
|
+
"uk": "підпалювач",
|
|
198
|
+
"zh-cn": "子文件夹"
|
|
199
|
+
};
|
|
93
200
|
|
|
94
201
|
// eslint-disable-next-line no-undef
|
|
95
202
|
Blockly.Sendto.blocks["lorawanGetUplink"] =
|
|
@@ -151,17 +258,36 @@ Blockly.Blocks["lorawanGetUplink"] = {
|
|
|
151
258
|
this.appendValueInput("subfolder")
|
|
152
259
|
.appendField(Blockly.Translate("lorawanSubfolder"));
|
|
153
260
|
|
|
261
|
+
this.appendStatementInput("result");
|
|
262
|
+
|
|
263
|
+
this.setInputsInline(false);
|
|
264
|
+
this.setPreviousStatement(true, null);
|
|
265
|
+
this.setNextStatement(true, null);
|
|
266
|
+
|
|
154
267
|
this.setColour(Blockly.Sendto.HUE);
|
|
155
268
|
this.setTooltip(Blockly.Translate("lorawanGetUplinktooltip"));
|
|
156
269
|
}
|
|
157
270
|
};
|
|
158
271
|
|
|
159
272
|
Blockly.JavaScript["lorawanGetUplink"] = function(block){
|
|
160
|
-
const dropdown_instance = block.getFieldValue("INSTANCE");
|
|
161
273
|
const value_devEUI = Blockly.JavaScript.valueToCode(block, "deviceEUI", Blockly.JavaScript.ORDER_ATOMIC);
|
|
162
274
|
const value_uplink = Blockly.JavaScript.valueToCode(block, "uplink", Blockly.JavaScript.ORDER_ATOMIC);
|
|
163
275
|
const value_subfolder = Blockly.JavaScript.valueToCode(block, "subfolder", Blockly.JavaScript.ORDER_ATOMIC);
|
|
164
|
-
|
|
276
|
+
const code_result = Blockly.JavaScript.statementToCode(block, "result");
|
|
277
|
+
|
|
278
|
+
// build code
|
|
279
|
+
const objParameter = [];
|
|
280
|
+
objParameter.push("deviceEUI:" + value_devEUI);
|
|
281
|
+
objParameter.push("uplink:" + value_uplink);
|
|
282
|
+
objParameter.push("subfolder:" + value_subfolder);
|
|
283
|
+
const objEnd = [];
|
|
284
|
+
if(code_result){
|
|
285
|
+
objEnd.push(`, async (result) => {${code_result}});`);
|
|
286
|
+
}
|
|
287
|
+
else{
|
|
288
|
+
objEnd.push(`);`);
|
|
289
|
+
}
|
|
290
|
+
return `sendTo("lorawan${block.getFieldValue("INSTANCE")}", "getUplink", {${objParameter.join(",")}}${objEnd}`;
|
|
165
291
|
};
|
|
166
292
|
|
|
167
293
|
/**************************************************************************
|
|
@@ -169,9 +295,58 @@ Blockly.JavaScript["lorawanGetUplink"] = function(block){
|
|
|
169
295
|
**************************************************************************/
|
|
170
296
|
|
|
171
297
|
// --- Get DeviceInfo translations --------------------------------------------------
|
|
172
|
-
Blockly.Words["lorawanSetDownlink"] = {
|
|
173
|
-
|
|
174
|
-
|
|
298
|
+
Blockly.Words["lorawanSetDownlink"] = {
|
|
299
|
+
"en": "lorawan downlink",
|
|
300
|
+
"de": "lorawan downlink",
|
|
301
|
+
"ru": "lorawan downlink",
|
|
302
|
+
"pt": "para baixo",
|
|
303
|
+
"nl": "lorawan downlink",
|
|
304
|
+
"fr": "lorawan lien descendant",
|
|
305
|
+
"it": "lorawan downlink",
|
|
306
|
+
"es": "lorawan downlink",
|
|
307
|
+
"pl": "lorawan downlink",
|
|
308
|
+
"uk": "логін",
|
|
309
|
+
"zh-cn": "龙卷风下行链路"
|
|
310
|
+
};
|
|
311
|
+
Blockly.Words["lorawanSetDownlinktooltip"] = {
|
|
312
|
+
"en": "set downlink",
|
|
313
|
+
"de": "Downlink zur lorawan instanz absetzen",
|
|
314
|
+
"ru": "set downlink",
|
|
315
|
+
"pt": "definir link",
|
|
316
|
+
"nl": "downlink instellen",
|
|
317
|
+
"fr": "définir la liaison descendante",
|
|
318
|
+
"it": "impostare il collegamento",
|
|
319
|
+
"es": "desplazamiento",
|
|
320
|
+
"pl": "set downlink",
|
|
321
|
+
"uk": "увійти",
|
|
322
|
+
"zh-cn": "设置下行链路"
|
|
323
|
+
};
|
|
324
|
+
Blockly.Words["lorawanDownlink"] = {
|
|
325
|
+
"en": "downlink",
|
|
326
|
+
"de": "Downlink",
|
|
327
|
+
"ru": "downlink",
|
|
328
|
+
"pt": "o que é",
|
|
329
|
+
"nl": "downlink",
|
|
330
|
+
"fr": "lien ascendant",
|
|
331
|
+
"it": "downlink",
|
|
332
|
+
"es": "subtítulos",
|
|
333
|
+
"pl": "link",
|
|
334
|
+
"uk": "посилання",
|
|
335
|
+
"zh-cn": "上行链接"
|
|
336
|
+
};
|
|
337
|
+
Blockly.Words["lorawanValue"] = {
|
|
338
|
+
"en": "value",
|
|
339
|
+
"de": "Wert",
|
|
340
|
+
"ru": "стоимость",
|
|
341
|
+
"pt": "valor",
|
|
342
|
+
"nl": "waarde",
|
|
343
|
+
"fr": "valeur",
|
|
344
|
+
"it": "valore",
|
|
345
|
+
"es": "valor",
|
|
346
|
+
"pl": "wartość",
|
|
347
|
+
"uk": "значення",
|
|
348
|
+
"zh-cn": "价值"
|
|
349
|
+
};
|
|
175
350
|
|
|
176
351
|
// eslint-disable-next-line no-undef
|
|
177
352
|
Blockly.Sendto.blocks["lorawanSetDownlink"] =
|
|
@@ -188,9 +363,9 @@ Blockly.Sendto.blocks["lorawanSetDownlink"] =
|
|
|
188
363
|
+ " <field name='TEXT'>text</field>"
|
|
189
364
|
+ " </shadow>"
|
|
190
365
|
+ " </value>"
|
|
191
|
-
+ " <value name='
|
|
366
|
+
+ " <value name='value'>"
|
|
192
367
|
+ " <shadow type='text'>"
|
|
193
|
-
+ " <field name='
|
|
368
|
+
+ " <field name='text'></field>"
|
|
194
369
|
+ " </shadow>"
|
|
195
370
|
+ " </value>"
|
|
196
371
|
+ "</block>";
|
|
@@ -229,14 +404,37 @@ Blockly.Blocks["lorawanSetDownlink"] = {
|
|
|
229
404
|
this.appendValueInput("downlink")
|
|
230
405
|
.appendField(Blockly.Translate("lorawanDownlink"));
|
|
231
406
|
|
|
407
|
+
this.appendValueInput("value")
|
|
408
|
+
.appendField(Blockly.Translate("lorawanValue"));
|
|
409
|
+
|
|
410
|
+
this.appendStatementInput("result");
|
|
411
|
+
|
|
412
|
+
this.setInputsInline(false);
|
|
413
|
+
this.setPreviousStatement(true, null);
|
|
414
|
+
this.setNextStatement(true, null);
|
|
415
|
+
|
|
232
416
|
this.setColour(Blockly.Sendto.HUE);
|
|
233
417
|
this.setTooltip(Blockly.Translate("lorawanSetDownlinktooltip"));
|
|
234
418
|
}
|
|
235
419
|
};
|
|
236
420
|
|
|
237
421
|
Blockly.JavaScript["lorawanSetDownlink"] = function(block){
|
|
238
|
-
const dropdown_instance = block.getFieldValue("INSTANCE");
|
|
239
422
|
const value_devEUI = Blockly.JavaScript.valueToCode(block, "deviceEUI", Blockly.JavaScript.ORDER_ATOMIC);
|
|
240
423
|
const value_downlink = Blockly.JavaScript.valueToCode(block, "downlink", Blockly.JavaScript.ORDER_ATOMIC);
|
|
241
|
-
|
|
424
|
+
const value_value = Blockly.JavaScript.valueToCode(block, "value", Blockly.JavaScript.ORDER_ATOMIC);
|
|
425
|
+
const code_result = Blockly.JavaScript.statementToCode(block, "result");
|
|
426
|
+
|
|
427
|
+
// build code
|
|
428
|
+
const objParameter = [];
|
|
429
|
+
objParameter.push("deviceEUI:" + value_devEUI);
|
|
430
|
+
objParameter.push("downlink:" + value_downlink);
|
|
431
|
+
objParameter.push("value:" + value_value);
|
|
432
|
+
const objEnd = [];
|
|
433
|
+
if(code_result){
|
|
434
|
+
objEnd.push(`, async (result) => {${code_result}});`);
|
|
435
|
+
}
|
|
436
|
+
else{
|
|
437
|
+
objEnd.push(`);`);
|
|
438
|
+
}
|
|
439
|
+
return `sendTo("lorawan${block.getFieldValue("INSTANCE")}", "setDownlink", {${objParameter.join(",")}}${objEnd}`;
|
|
242
440
|
};
|
package/io-package.json
CHANGED
|
@@ -1,8 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"common": {
|
|
3
3
|
"name": "lorawan",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.3.0",
|
|
5
5
|
"news": {
|
|
6
|
+
"0.3.0": {
|
|
7
|
+
"en": "define user friendly Blockly Blocks with result",
|
|
8
|
+
"de": "benutzerfreundlich definieren Blockly Blocks mit Ergebnis",
|
|
9
|
+
"ru": "определение пользователя Блоки с результатом",
|
|
10
|
+
"pt": "definir amigável Blocos com resultado",
|
|
11
|
+
"nl": "gebruikersvriendelijk definiëren Blokkeren met resultaat",
|
|
12
|
+
"fr": "définir une utilisation conviviale Blocs avec résultat",
|
|
13
|
+
"it": "definire l'utente amichevole Blocchi Blockly con risultato",
|
|
14
|
+
"es": "definir fácil de usar Bloqueo bloques con resultado",
|
|
15
|
+
"pl": "zdefiniować przyjazny dla użytkownika Blokady z wynikiem",
|
|
16
|
+
"uk": "визначення дружності користувача Блокнотні блоки з результатом",
|
|
17
|
+
"zh-cn": "定义用户友好 块状块及结果"
|
|
18
|
+
},
|
|
6
19
|
"0.2.1": {
|
|
7
20
|
"en": "check types of messaging values and implements more blockly blocks",
|
|
8
21
|
"de": "überprüfen sie die arten der messaging-werte und implementiert mehr blockweise blöcke",
|
|
@@ -80,19 +93,6 @@
|
|
|
80
93
|
"pl": "domyślna zmiana crc",
|
|
81
94
|
"uk": "за замовчуванням змінного струму",
|
|
82
95
|
"zh-cn": "默认 crc 已更改"
|
|
83
|
-
},
|
|
84
|
-
"0.1.9": {
|
|
85
|
-
"en": "crc calculation improoved",
|
|
86
|
-
"de": "cc berechnung improoviert",
|
|
87
|
-
"ru": "crccalc improov",
|
|
88
|
-
"pt": "cálculo de crc improoved",
|
|
89
|
-
"nl": "crc berekening geïmproviseerd",
|
|
90
|
-
"fr": "calcul crc réalisé",
|
|
91
|
-
"it": "crc calcolo improvato",
|
|
92
|
-
"es": "crc cálculo improvido",
|
|
93
|
-
"pl": "crc obliczenia improuved",
|
|
94
|
-
"uk": "розрахунок обертів",
|
|
95
|
-
"zh-cn": "crc 计算未启动"
|
|
96
96
|
}
|
|
97
97
|
},
|
|
98
98
|
"title": "LoRaWAN",
|
|
@@ -202,7 +202,7 @@ class directorieshandlerClass {
|
|
|
202
202
|
role: stateCommonRole,
|
|
203
203
|
read: stateCommonRole !== "button",
|
|
204
204
|
unit: obj[elementName]? obj[elementName].CommonStateUnit? obj[elementName].CommonStateUnit : "" : "",
|
|
205
|
-
def: obj[elementName]? obj[elementName].stateCommonDef? obj[elementName].stateCommonDef: stateCommonType === "boolean"? false : stateCommonType === "number"? 0: "": stateCommonType === "number"? 0: "",
|
|
205
|
+
def: obj[elementName] || typeof obj[elementName] === "boolean" ? obj[elementName].stateCommonDef? obj[elementName].stateCommonDef: stateCommonType === "boolean"? false : stateCommonType === "number"? 0: "": stateCommonType === "number"? 0: "",
|
|
206
206
|
write: stateCommonWrite
|
|
207
207
|
},
|
|
208
208
|
native: {},
|
package/main.js
CHANGED
|
@@ -419,6 +419,32 @@ class Lorawan extends utils.Adapter {
|
|
|
419
419
|
// Send response
|
|
420
420
|
if (obj.callback) this.sendTo(obj.from, obj.command, result, obj.callback);
|
|
421
421
|
}
|
|
422
|
+
else if (obj.command === "getUplink"){
|
|
423
|
+
if(obj.message.deviceEUI && obj.message.uplink){
|
|
424
|
+
const folderAndUplinkId = obj.message.subfolder? `${this.messagehandler?.directoryhandler.reachableSubfolders.uplink}.${obj.message.subfolder}.${obj.message.uplink}`: obj.message.uplink;
|
|
425
|
+
const changeInfo = await this.getChangeInfoFromDeviceEUI(obj.message.deviceEUI,folderAndUplinkId);
|
|
426
|
+
if(changeInfo){
|
|
427
|
+
const uplinkId = changeInfo.id;
|
|
428
|
+
if(await this.objectExists(uplinkId)){
|
|
429
|
+
const stateResult = await this.getStateAsync(changeInfo.id);
|
|
430
|
+
if(stateResult){
|
|
431
|
+
result = {applicationId: changeInfo.applicationId, deviceEUI: changeInfo.deviceEUI, deviceId: changeInfo.deviceId, deviceType: changeInfo.deviceType, value: stateResult.val, recieved:obj.message};
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
else{
|
|
435
|
+
result = {error:true, message:"No uplink matches", recieved:obj.message};
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
else{
|
|
439
|
+
result = {error:true, message:"No device found", recieved:obj.message};
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
else{
|
|
443
|
+
result = {error:true, message:"No deviceEUI & uplink found", recieved:obj.message};
|
|
444
|
+
}
|
|
445
|
+
// Send response
|
|
446
|
+
if (obj.callback) this.sendTo(obj.from, obj.command, result, obj.callback);
|
|
447
|
+
}
|
|
422
448
|
else if (obj.command === "setDownlink"){
|
|
423
449
|
if(obj.message.deviceEUI && obj.message.downlink && (obj.message.value || obj.message.value === false)){
|
|
424
450
|
const changeInfo = await this.getChangeInfoFromDeviceEUI(obj.message.deviceEUI,`${this.messagehandler?.directoryhandler.reachableSubfolders.downlinkControl}.${obj.message.downlink}`);
|
|
@@ -434,66 +460,45 @@ class Lorawan extends utils.Adapter {
|
|
|
434
460
|
// Check limit
|
|
435
461
|
if((!downlinkObject.common.min || obj.message.value >= downlinkObject.common.min) && (!downlinkObject.common.max || obj.message.value <= downlinkObject.common.max)){
|
|
436
462
|
await this.setStateAsync(downlinkId,obj.message.value);
|
|
437
|
-
result = {applicationId: changeInfo.applicationId, deviceEUI: changeInfo.deviceEUI, deviceId: changeInfo.deviceId, deviceType: changeInfo.deviceType,downlink: obj.message.downlink, value: obj.message.value};
|
|
463
|
+
result = {applicationId: changeInfo.applicationId, deviceEUI: changeInfo.deviceEUI, deviceId: changeInfo.deviceId, deviceType: changeInfo.deviceType,downlink: obj.message.downlink, value: obj.message.value, recieved:obj.message};
|
|
438
464
|
}
|
|
439
465
|
else{
|
|
440
|
-
result = {error:true, message:"value is not in valid range"};
|
|
466
|
+
result = {error:true, message:"value is not in valid range", recieved:obj.message};
|
|
441
467
|
}
|
|
442
468
|
}
|
|
443
469
|
else{
|
|
444
|
-
result = {error:true, message: `downlink is type number, but recieved ${typeof obj.message.value}
|
|
470
|
+
result = {error:true, message: `downlink is type number, but recieved ${typeof obj.message.value}`, recieved:obj.message};
|
|
445
471
|
}
|
|
446
472
|
}
|
|
447
473
|
// downlinkobject is not a number
|
|
448
474
|
else{
|
|
449
|
-
|
|
450
|
-
|
|
475
|
+
if(downlinkObject.common.type !== typeof obj.message.value){
|
|
476
|
+
result = {error:true, message: `downlink is type ${downlinkObject.common.type}, but recieved ${typeof obj.message.value}`, recieved:obj.message};
|
|
477
|
+
}
|
|
478
|
+
else{
|
|
479
|
+
await this.setStateAsync(downlinkId,obj.message.value);
|
|
480
|
+
result = {applicationId: changeInfo.applicationId, deviceEUI: changeInfo.deviceEUI, deviceId: changeInfo.deviceId, deviceType: changeInfo.deviceType, downlink: obj.message.downlink, value: obj.message.value, recieved:obj.message};
|
|
481
|
+
}
|
|
451
482
|
}
|
|
452
483
|
}
|
|
453
484
|
}
|
|
454
485
|
else{
|
|
455
|
-
result = {error:true, message:"No downlink matches"};
|
|
486
|
+
result = {error:true, message:"No downlink matches", recieved:obj.message};
|
|
456
487
|
}
|
|
457
488
|
}
|
|
458
489
|
else{
|
|
459
|
-
result = {error:true, message:"No device found"};
|
|
460
|
-
}
|
|
461
|
-
}
|
|
462
|
-
else{
|
|
463
|
-
result = {error:true, message:"No deviceEUI, downlink & value found"};
|
|
464
|
-
}
|
|
465
|
-
// Send response
|
|
466
|
-
if (obj.callback) this.sendTo(obj.from, obj.command, result, obj.callback);
|
|
467
|
-
}
|
|
468
|
-
else if (obj.command === "getUplink"){
|
|
469
|
-
if(obj.message.deviceEUI && obj.message.uplink){
|
|
470
|
-
const folderAndUplinkId = obj.message.subfolder? `${this.messagehandler?.directoryhandler.reachableSubfolders.uplink}.${obj.message.subfolder}.${obj.message.uplink}`: obj.message.uplink;
|
|
471
|
-
const changeInfo = await this.getChangeInfoFromDeviceEUI(obj.message.deviceEUI,folderAndUplinkId);
|
|
472
|
-
if(changeInfo){
|
|
473
|
-
const uplinkId = changeInfo.id;
|
|
474
|
-
if(await this.objectExists(uplinkId)){
|
|
475
|
-
const stateResult = await this.getStateAsync(changeInfo.id);
|
|
476
|
-
if(stateResult){
|
|
477
|
-
result = {applicationId: changeInfo.applicationId, deviceEUI: changeInfo.deviceEUI, deviceId: changeInfo.deviceId, deviceType: changeInfo.deviceType, value: stateResult.val};
|
|
478
|
-
}
|
|
479
|
-
}
|
|
480
|
-
else{
|
|
481
|
-
result = {error:true, message:"No uplink matches", changeInfo: changeInfo};
|
|
482
|
-
}
|
|
483
|
-
}
|
|
484
|
-
else{
|
|
485
|
-
result = {error:true, message:"No device found"};
|
|
490
|
+
result = {error:true, message:"No device found", recieved:obj.message};
|
|
486
491
|
}
|
|
487
492
|
}
|
|
488
493
|
else{
|
|
489
|
-
result = {error:true, message:"No deviceEUI &
|
|
494
|
+
result = {error:true, message:"No deviceEUI, downlink & value found", recieved:obj.message};
|
|
490
495
|
}
|
|
491
496
|
// Send response
|
|
492
497
|
if (obj.callback) this.sendTo(obj.from, obj.command, result, obj.callback);
|
|
493
498
|
}
|
|
494
499
|
else
|
|
495
500
|
{
|
|
496
|
-
const result = {error:true, message: "No message matched"};
|
|
501
|
+
const result = {error:true, message: "No message matched", recieved:obj.message};
|
|
497
502
|
if (obj.callback) this.sendTo(obj.from, obj.command, result, obj.callback);
|
|
498
503
|
}
|
|
499
504
|
}
|