iobroker.lorawan 0.2.0 → 0.2.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/README.md +3 -0
- package/admin/blockly.js +242 -0
- package/io-package.json +15 -14
- package/lib/modules/deviceProfiles/Dragino LT22222.json +3 -1
- package/lib/modules/deviceProfiles/Dragino.json +3 -1
- package/lib/modules/deviceProfiles/Vicki.json +3 -1
- package/lib/modules/directorieshandler.js +2 -0
- package/lib/modules/messagehandler.js +1 -1
- package/main.js +29 -18
- 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.2.1 (2024-02-13)
|
|
26
|
+
* (BenAhrdt) check types of messaging values and implements more blockly blocks
|
|
27
|
+
|
|
25
28
|
### 0.2.0 (2024-02-12)
|
|
26
29
|
* (BenAhrdt) more functionality in messageing
|
|
27
30
|
|
package/admin/blockly.js
ADDED
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
/* eslint-disable prefer-const */
|
|
2
|
+
/* eslint-disable no-undef */
|
|
3
|
+
// @ts-nocheck
|
|
4
|
+
"use strict";
|
|
5
|
+
|
|
6
|
+
// @ts-ignore
|
|
7
|
+
if (typeof goog !== "undefined") {
|
|
8
|
+
// @ts-ignore
|
|
9
|
+
// eslint-disable-next-line no-undef
|
|
10
|
+
goog.provide("Blockly.JavaScript.Sendto");
|
|
11
|
+
// @ts-ignore
|
|
12
|
+
// eslint-disable-next-line no-undef
|
|
13
|
+
goog.require("Blockly.JavaScript");
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
// --- general translations --------------------------------------------------
|
|
18
|
+
Blockly.Words["anyInstance"] = {"en": "all instances","pt": "todas as instâncias","pl": "wszystkie przypadki","nl": "alle instanties","it": "tutte le istanze","es": "todas las instancias","fr": "toutes les instances","de": "Alle Instanzen","ru": "На все драйвера"};
|
|
19
|
+
Blockly.Words["lorawanDeviceEUI"] = {"en": "device EUI","de": "Geräte EUI","ru": "устройство EUI","pt": "dispositivo EUI","nl": "apparaat EUI","fr": "dispositif IUE","it": "dispositivo EUI","es": "dispositivo EUI","pl": "urządzenie EUI","uk": "пристрій EUI","zh-cn": "设备 EUI"};
|
|
20
|
+
|
|
21
|
+
/**************************************************************************
|
|
22
|
+
******************************Get Device Info******************************
|
|
23
|
+
**************************************************************************/
|
|
24
|
+
|
|
25
|
+
// --- Get DeviceInfo translations --------------------------------------------------
|
|
26
|
+
Blockly.Words["lorawanGetDeviceInfo"] = {"en": "lorawan Device Info", "de": "lorawan Geräteinfo", "ru": "lorawan Device Info", "pt": "lorawan Informações do dispositivo", "nl": "lorawan Apparaatinformatie", "fr": "lorawan Informations sur le périphérique", "it": "lorawan Dispositivi Info", "es": "lorawan Device Info", "pl": "informacje o urządzeniu Lorawan", "uk": "інформація про пристрій lorawan", "zh-cn": "lorawan 设备信息"};
|
|
27
|
+
Blockly.Words["lorawanGetDeviceInfotooltip"] = {"en": "get Informations about the device with the given device EUI", "de": "informationen über das Gerät mit der angegebenen Geräte EUI", "ru": "получить информацию об устройстве с данным устройством EUI", "pt": "obter informações sobre o dispositivo com o dispositivo dado EUI", "nl": "informatie over het apparaat met het gegeven apparaat opvragen EUI", "fr": "obtenir des informations sur l'appareil avec l'appareil donné IUE", "it": "ottenere informazioni sul dispositivo con il dispositivo fornito EUI", "es": "obtener Información sobre el dispositivo con el dispositivo dado EUI", "pl": "pobierz informacje o urządzeniu z podanym urządzeniem EUI", "uk": "отримувати інформацію про пристрій з заданим пристроєм EUI", "zh-cn": "用指定的设备获取设备信息 EUI"};
|
|
28
|
+
|
|
29
|
+
// eslint-disable-next-line no-undef
|
|
30
|
+
Blockly.Sendto.blocks["lorawanGetDeviceInfo"] =
|
|
31
|
+
"<block type='lorawanGetDeviceInfo'>"
|
|
32
|
+
+ " <value name='INSTANCE'>"
|
|
33
|
+
+ " </value>"
|
|
34
|
+
+ " <value name='deviceEUI'>"
|
|
35
|
+
+ " <shadow type='text'>"
|
|
36
|
+
+ " <field name='TEXT'>text</field>"
|
|
37
|
+
+ " </shadow>"
|
|
38
|
+
+ " </value>"
|
|
39
|
+
+ "</block>";
|
|
40
|
+
|
|
41
|
+
// eslint-disable-next-line no-undef
|
|
42
|
+
Blockly.Blocks["lorawanGetDeviceInfo"] = {
|
|
43
|
+
init: function() {
|
|
44
|
+
const options = [[Blockly.Translate("anyInstance"), ""]];
|
|
45
|
+
if (typeof main !== "undefined" && main.instances) {
|
|
46
|
+
for (let i = 0; i < main.instances.length; i++) {
|
|
47
|
+
// eslint-disable-next-line prefer-const
|
|
48
|
+
let m = main.instances[i].match(/^system.adapter.lorawan.(\d+)$/);
|
|
49
|
+
if (m) {
|
|
50
|
+
// eslint-disable-next-line prefer-const
|
|
51
|
+
let k = parseInt(m[1], 10);
|
|
52
|
+
options.push(["lorawan." + k, "." + k]);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
if (options.length === 0) {
|
|
56
|
+
for (let u = 0; u <= 4; u++) {
|
|
57
|
+
options.push(["lorawan." + u, "." + u]);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
} else {
|
|
61
|
+
for (let n = 0; n <= 4; n++) {
|
|
62
|
+
options.push(["lorawan." + n, "." + n]);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
this.appendDummyInput("INSTANCE")
|
|
67
|
+
.appendField(Blockly.Translate("lorawanGetDeviceInfo"))
|
|
68
|
+
.appendField(new Blockly.FieldDropdown(options), "INSTANCE");
|
|
69
|
+
|
|
70
|
+
this.appendValueInput("deviceEUI")
|
|
71
|
+
.appendField(Blockly.Translate("lorawanDeviceEUI"));
|
|
72
|
+
|
|
73
|
+
this.setColour(Blockly.Sendto.HUE);
|
|
74
|
+
this.setTooltip(Blockly.Translate("lorawanGetDeviceInfotooltip"));
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
Blockly.JavaScript["lorawanGetDeviceInfo"] = function(block){
|
|
79
|
+
const dropdown_instance = block.getFieldValue("INSTANCE");
|
|
80
|
+
const value_devEUI = Blockly.JavaScript.valueToCode(block, "deviceEUI", Blockly.JavaScript.ORDER_ATOMIC);
|
|
81
|
+
return 'sendTo("lorawan' + dropdown_instance + '", "getDeviceInfo", {deviceEUI: ' + value_devEUI + "}, async (result) => {console.log(result);});";
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
/**************************************************************************
|
|
85
|
+
*********************************Get uplink********************************
|
|
86
|
+
**************************************************************************/
|
|
87
|
+
|
|
88
|
+
// --- Get DeviceInfo translations --------------------------------------------------
|
|
89
|
+
Blockly.Words["lorawanGetUplink"] = {"en": "lorawan uplinkinfo", "de": "lorawan uplinkinfo", "ru": "lorawan uplinkinfo", "pt": "o que fazer", "nl": "lorawan uplinkinfo", "fr": "lorawan uplinkinfo", "it": "condividi su google", "es": "lorawan uplinkinfo", "pl": "lorawan uplinkinfo", "uk": "український", "zh-cn": "lorawan 上行链接信息"};
|
|
90
|
+
Blockly.Words["lorawanGetUplinktooltip"] = {"en": "get information about the given uplink", "de": "informationen zum angegebenen uplink", "ru": "получить информацию об отказе от ссылки", "pt": "obter informações sobre o link fornecido", "nl": "informatie krijgen over de opgegeven uplink", "fr": "obtenir des informations sur le lien ascendant donné", "it": "ottenere informazioni su il link up", "es": "obtener información sobre el enlace dado", "pl": "uzyskać informacje o danym łączniku", "uk": "отримувати інформацію про задану посилання", "zh-cn": "获取上行链路的信息"};
|
|
91
|
+
Blockly.Words["lorawanUplink"] = {"en": "uplink","de": "uplink","ru": "uplink", "pt": "o que é","nl": "uplink","fr": "lien ascendant","it": "uplink","es": "subtítulos","pl": "link","uk": "посилання","zh-cn": "上行链接"};
|
|
92
|
+
Blockly.Words["lorawanSubfolder"] = {"en": "subfolder", "de": "unterordner", "ru": "subfolder", "pt": "subpastas", "nl": "submap", "fr": "sous-dossier", "it": "sottocartella", "es": "subcarpeta", "pl": "podfolder", "uk": "підпалювач", "zh-cn": "子文件夹"};
|
|
93
|
+
|
|
94
|
+
// eslint-disable-next-line no-undef
|
|
95
|
+
Blockly.Sendto.blocks["lorawanGetUplink"] =
|
|
96
|
+
"<block type='lorawanGetUplink'>"
|
|
97
|
+
+ " <value name='INSTANCE'>"
|
|
98
|
+
+ " </value>"
|
|
99
|
+
+ " <value name='deviceEUI'>"
|
|
100
|
+
+ " <shadow type='text'>"
|
|
101
|
+
+ " <field name='TEXT'>text</field>"
|
|
102
|
+
+ " </shadow>"
|
|
103
|
+
+ " </value>"
|
|
104
|
+
+ " <value name='uplink'>"
|
|
105
|
+
+ " <shadow type='text'>"
|
|
106
|
+
+ " <field name='TEXT'>text</field>"
|
|
107
|
+
+ " </shadow>"
|
|
108
|
+
+ " </value>"
|
|
109
|
+
+ " <value name='subfolder'>"
|
|
110
|
+
+ " <shadow type='text'>"
|
|
111
|
+
+ " <field name='TEXT'>decoded</field>"
|
|
112
|
+
+ " </shadow>"
|
|
113
|
+
+ " </value>"
|
|
114
|
+
+ "</block>";
|
|
115
|
+
|
|
116
|
+
// eslint-disable-next-line no-undef
|
|
117
|
+
Blockly.Blocks["lorawanGetUplink"] = {
|
|
118
|
+
init: function() {
|
|
119
|
+
const options = [[Blockly.Translate("anyInstance"), ""]];
|
|
120
|
+
if (typeof main !== "undefined" && main.instances) {
|
|
121
|
+
for (let i = 0; i < main.instances.length; i++) {
|
|
122
|
+
// eslint-disable-next-line prefer-const
|
|
123
|
+
let m = main.instances[i].match(/^system.adapter.lorawan.(\d+)$/);
|
|
124
|
+
if (m) {
|
|
125
|
+
// eslint-disable-next-line prefer-const
|
|
126
|
+
let k = parseInt(m[1], 10);
|
|
127
|
+
options.push(["lorawan." + k, "." + k]);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
if (options.length === 0) {
|
|
131
|
+
for (let u = 0; u <= 4; u++) {
|
|
132
|
+
options.push(["lorawan." + u, "." + u]);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
} else {
|
|
136
|
+
for (let n = 0; n <= 4; n++) {
|
|
137
|
+
options.push(["lorawan." + n, "." + n]);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
this.appendDummyInput("INSTANCE")
|
|
142
|
+
.appendField(Blockly.Translate("lorawanGetUplink"))
|
|
143
|
+
.appendField(new Blockly.FieldDropdown(options), "INSTANCE");
|
|
144
|
+
|
|
145
|
+
this.appendValueInput("deviceEUI")
|
|
146
|
+
.appendField(Blockly.Translate("lorawanDeviceEUI"));
|
|
147
|
+
|
|
148
|
+
this.appendValueInput("uplink")
|
|
149
|
+
.appendField(Blockly.Translate("lorawanUplink"));
|
|
150
|
+
|
|
151
|
+
this.appendValueInput("subfolder")
|
|
152
|
+
.appendField(Blockly.Translate("lorawanSubfolder"));
|
|
153
|
+
|
|
154
|
+
this.setColour(Blockly.Sendto.HUE);
|
|
155
|
+
this.setTooltip(Blockly.Translate("lorawanGetUplinktooltip"));
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
Blockly.JavaScript["lorawanGetUplink"] = function(block){
|
|
160
|
+
const dropdown_instance = block.getFieldValue("INSTANCE");
|
|
161
|
+
const value_devEUI = Blockly.JavaScript.valueToCode(block, "deviceEUI", Blockly.JavaScript.ORDER_ATOMIC);
|
|
162
|
+
const value_uplink = Blockly.JavaScript.valueToCode(block, "uplink", Blockly.JavaScript.ORDER_ATOMIC);
|
|
163
|
+
const value_subfolder = Blockly.JavaScript.valueToCode(block, "subfolder", Blockly.JavaScript.ORDER_ATOMIC);
|
|
164
|
+
return 'sendTo("lorawan' + dropdown_instance + '", "getUplink", {deviceEUI: ' + value_devEUI + ", uplink: " + value_uplink + ", subfolder: " + value_subfolder +"}, async (result) => {console.log(result);});";
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
/**************************************************************************
|
|
168
|
+
*******************************Set downlink********************************
|
|
169
|
+
**************************************************************************/
|
|
170
|
+
|
|
171
|
+
// --- Get DeviceInfo translations --------------------------------------------------
|
|
172
|
+
Blockly.Words["lorawanSetDownlink"] = {"en": "lorawan downlink", "de": "lorawan downlink", "ru": "lorawan downlink", "pt": "para baixo", "nl": "lorawan downlink", "fr": "lorawan lien descendant", "it": "lorawan downlink", "es": "lorawan downlink", "pl": "lorawan downlink", "uk": "логін", "zh-cn": "龙卷风下行链路"};
|
|
173
|
+
Blockly.Words["lorawanSetDownlinktooltip"] = {"en": "set downlink", "de": "downlink zur lorawan instanz absetzen", "ru": "set downlink", "pt": "definir link", "nl": "downlink instellen", "fr": "définir la liaison descendante", "it": "impostare il collegamento", "es": "desplazamiento", "pl": "set downlink", "uk": "увійти", "zh-cn": "设置下行链路"};
|
|
174
|
+
Blockly.Words["lorawanDownlink"] = {"en": "downlink","de": "downlink","ru": "downlink", "pt": "o que é","nl": "downlink","fr": "lien ascendant","it": "downlink","es": "subtítulos","pl": "link","uk": "посилання","zh-cn": "上行链接"};
|
|
175
|
+
|
|
176
|
+
// eslint-disable-next-line no-undef
|
|
177
|
+
Blockly.Sendto.blocks["lorawanSetDownlink"] =
|
|
178
|
+
"<block type='lorawanSetDownlink'>"
|
|
179
|
+
+ " <value name='INSTANCE'>"
|
|
180
|
+
+ " </value>"
|
|
181
|
+
+ " <value name='deviceEUI'>"
|
|
182
|
+
+ " <shadow type='text'>"
|
|
183
|
+
+ " <field name='TEXT'>text</field>"
|
|
184
|
+
+ " </shadow>"
|
|
185
|
+
+ " </value>"
|
|
186
|
+
+ " <value name='downlink'>"
|
|
187
|
+
+ " <shadow type='text'>"
|
|
188
|
+
+ " <field name='TEXT'>text</field>"
|
|
189
|
+
+ " </shadow>"
|
|
190
|
+
+ " </value>"
|
|
191
|
+
+ " <value name='xxxx'>"
|
|
192
|
+
+ " <shadow type='text'>"
|
|
193
|
+
+ " <field name='xx'>cc</field>"
|
|
194
|
+
+ " </shadow>"
|
|
195
|
+
+ " </value>"
|
|
196
|
+
+ "</block>";
|
|
197
|
+
|
|
198
|
+
// eslint-disable-next-line no-undef
|
|
199
|
+
Blockly.Blocks["lorawanSetDownlink"] = {
|
|
200
|
+
init: function() {
|
|
201
|
+
const options = [[Blockly.Translate("anyInstance"), ""]];
|
|
202
|
+
if (typeof main !== "undefined" && main.instances) {
|
|
203
|
+
for (let i = 0; i < main.instances.length; i++) {
|
|
204
|
+
let m = main.instances[i].match(/^system.adapter.lorawan.(\d+)$/);
|
|
205
|
+
if (m) {
|
|
206
|
+
// eslint-disable-next-line prefer-const
|
|
207
|
+
let k = parseInt(m[1], 10);
|
|
208
|
+
options.push(["lorawan." + k, "." + k]);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
if (options.length === 0) {
|
|
212
|
+
for (let u = 0; u <= 4; u++) {
|
|
213
|
+
options.push(["lorawan." + u, "." + u]);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
} else {
|
|
217
|
+
for (let n = 0; n <= 4; n++) {
|
|
218
|
+
options.push(["lorawan." + n, "." + n]);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
this.appendDummyInput("INSTANCE")
|
|
223
|
+
.appendField(Blockly.Translate("lorawanSetDownlink"))
|
|
224
|
+
.appendField(new Blockly.FieldDropdown(options), "INSTANCE");
|
|
225
|
+
|
|
226
|
+
this.appendValueInput("deviceEUI")
|
|
227
|
+
.appendField(Blockly.Translate("lorawanDeviceEUI"));
|
|
228
|
+
|
|
229
|
+
this.appendValueInput("downlink")
|
|
230
|
+
.appendField(Blockly.Translate("lorawanDownlink"));
|
|
231
|
+
|
|
232
|
+
this.setColour(Blockly.Sendto.HUE);
|
|
233
|
+
this.setTooltip(Blockly.Translate("lorawanSetDownlinktooltip"));
|
|
234
|
+
}
|
|
235
|
+
};
|
|
236
|
+
|
|
237
|
+
Blockly.JavaScript["lorawanSetDownlink"] = function(block){
|
|
238
|
+
const dropdown_instance = block.getFieldValue("INSTANCE");
|
|
239
|
+
const value_devEUI = Blockly.JavaScript.valueToCode(block, "deviceEUI", Blockly.JavaScript.ORDER_ATOMIC);
|
|
240
|
+
const value_downlink = Blockly.JavaScript.valueToCode(block, "downlink", Blockly.JavaScript.ORDER_ATOMIC);
|
|
241
|
+
return 'sendTo("lorawan' + dropdown_instance + '", "setDownlink", {deviceEUI: ' + value_devEUI + ", downlink: " + value_downlink +"}, async (result) => {console.log(result);});";
|
|
242
|
+
};
|
package/io-package.json
CHANGED
|
@@ -1,8 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"common": {
|
|
3
3
|
"name": "lorawan",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.1",
|
|
5
5
|
"news": {
|
|
6
|
+
"0.2.1": {
|
|
7
|
+
"en": "check types of messaging values and implements more blockly blocks",
|
|
8
|
+
"de": "überprüfen sie die arten der messaging-werte und implementiert mehr blockweise blöcke",
|
|
9
|
+
"ru": "проверить типы значений обмена сообщениями и реализовать более блоков",
|
|
10
|
+
"pt": "verificar os tipos de valores de mensagens e implementa blocos mais bloqueados",
|
|
11
|
+
"nl": "controleer soorten messaging waarden en implementeert meer blokken",
|
|
12
|
+
"fr": "vérifier les types de valeurs de messagerie et implémente des blocs plus bloc",
|
|
13
|
+
"it": "controllare i tipi di valori di messaggistica e implementa più blocchi bloccati",
|
|
14
|
+
"es": "comprobar tipos de valores de mensajería e implementar bloques más bloque",
|
|
15
|
+
"pl": "sprawdzają typy wartości wiadomości i wdrażają blokowane bloki",
|
|
16
|
+
"uk": "перевіряти типи значень обміну повідомленнями та реалізовувати більше блоків",
|
|
17
|
+
"zh-cn": "检查消息值的类型, 执行更多块"
|
|
18
|
+
},
|
|
6
19
|
"0.2.0": {
|
|
7
20
|
"en": "more functionality in messageing",
|
|
8
21
|
"de": "mehr funktionalität in der meldung",
|
|
@@ -80,19 +93,6 @@
|
|
|
80
93
|
"pl": "crc obliczenia improuved",
|
|
81
94
|
"uk": "розрахунок обертів",
|
|
82
95
|
"zh-cn": "crc 计算未启动"
|
|
83
|
-
},
|
|
84
|
-
"0.1.8": {
|
|
85
|
-
"en": "implement crc calculation",
|
|
86
|
-
"de": "ck-berechnung implementieren",
|
|
87
|
-
"ru": "целевые вычисления",
|
|
88
|
-
"pt": "cálculo de crc de implementação",
|
|
89
|
-
"nl": "crc berekening uitvoeren",
|
|
90
|
-
"fr": "mettre en œuvre le calcul crc",
|
|
91
|
-
"it": "implementare il calcolo crc",
|
|
92
|
-
"es": "cálculo de crc",
|
|
93
|
-
"pl": "implementation crc calculation",
|
|
94
|
-
"uk": "реалізація розрахунку кришки",
|
|
95
|
-
"zh-cn": "执行计算"
|
|
96
96
|
}
|
|
97
97
|
},
|
|
98
98
|
"title": "LoRaWAN",
|
|
@@ -143,6 +143,7 @@
|
|
|
143
143
|
"connectionType": "cloud",
|
|
144
144
|
"messagebox": true,
|
|
145
145
|
"dataSource": "push",
|
|
146
|
+
"blockly": true,
|
|
146
147
|
"adminUI": {
|
|
147
148
|
"config": "json"
|
|
148
149
|
},
|
|
@@ -13,9 +13,11 @@ class directorieshandlerClass {
|
|
|
13
13
|
|
|
14
14
|
this.reachableSubfolders = {
|
|
15
15
|
configuration: "configuration",
|
|
16
|
+
uplink: "uplink",
|
|
16
17
|
uplinkDecoded: "uplink.decoded",
|
|
17
18
|
uplinkRaw: "uplink.raw",
|
|
18
19
|
uplinkRemaining: "uplink.remaining",
|
|
20
|
+
downlink: "downlink",
|
|
19
21
|
downlinkRaw: "downlink.raw",
|
|
20
22
|
downlinkControl: "downlink.control",
|
|
21
23
|
downlinkRemaining: "downlink.remaining",
|
|
@@ -113,7 +113,7 @@ class messagehandlerClass {
|
|
|
113
113
|
else if(stateCommonType === "number"){
|
|
114
114
|
stateCommonMax = 1000000;
|
|
115
115
|
}
|
|
116
|
-
await this.adapter.extendObjectAsync(`${deviceStartdirectory}.
|
|
116
|
+
await this.adapter.extendObjectAsync(`${deviceStartdirectory}.${this.directoryhandler.reachableSubfolders.downlinkControl}.${downlinkParameter.name}`,{
|
|
117
117
|
type: "state",
|
|
118
118
|
common: {
|
|
119
119
|
name: "",
|
package/main.js
CHANGED
|
@@ -375,7 +375,7 @@ class Lorawan extends utils.Adapter {
|
|
|
375
375
|
return id;
|
|
376
376
|
}
|
|
377
377
|
|
|
378
|
-
// Get
|
|
378
|
+
// Get Changeinfo in case of device EUI (used more times in onMessage)
|
|
379
379
|
async getChangeInfoFromDeviceEUI(deviceUI,subId){
|
|
380
380
|
let changeInfo = undefined;
|
|
381
381
|
const adapterObjects = await this.getAdapterObjectsAsync();
|
|
@@ -396,8 +396,10 @@ class Lorawan extends utils.Adapter {
|
|
|
396
396
|
// * Using this method requires "common.messagebox" property to be set to true in io-package.json
|
|
397
397
|
// * @param {ioBroker.Message} obj
|
|
398
398
|
// */
|
|
399
|
+
|
|
399
400
|
async onMessage(obj){
|
|
400
401
|
const activeFunction = "onMessage";
|
|
402
|
+
this.log.debug(`message recieved: command = ${obj.command} - message = ${JSON.stringify(obj.message)}`);
|
|
401
403
|
try{
|
|
402
404
|
if (typeof obj === "object" && obj.message){
|
|
403
405
|
let result = {};
|
|
@@ -417,29 +419,37 @@ class Lorawan extends utils.Adapter {
|
|
|
417
419
|
// Send response
|
|
418
420
|
if (obj.callback) this.sendTo(obj.from, obj.command, result, obj.callback);
|
|
419
421
|
}
|
|
420
|
-
else if (obj.command === "
|
|
422
|
+
else if (obj.command === "setDownlink"){
|
|
421
423
|
if(obj.message.deviceEUI && obj.message.downlink && (obj.message.value || obj.message.value === false)){
|
|
422
424
|
const changeInfo = await this.getChangeInfoFromDeviceEUI(obj.message.deviceEUI,`${this.messagehandler?.directoryhandler.reachableSubfolders.downlinkControl}.${obj.message.downlink}`);
|
|
423
425
|
if(changeInfo){
|
|
424
426
|
const downlinkId = changeInfo.id;
|
|
425
427
|
if(await this.objectExists(downlinkId)){
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
if(
|
|
429
|
-
//
|
|
430
|
-
if(
|
|
431
|
-
|
|
432
|
-
|
|
428
|
+
// get Object to decide min and max value
|
|
429
|
+
const downlinkObject = await this.getObjectAsync(downlinkId);
|
|
430
|
+
if(downlinkObject){
|
|
431
|
+
// check typ number
|
|
432
|
+
if(downlinkObject.common.type === "number"){
|
|
433
|
+
if(typeof obj.message.value === "number"){
|
|
434
|
+
// Check limit
|
|
435
|
+
if((!downlinkObject.common.min || obj.message.value >= downlinkObject.common.min) && (!downlinkObject.common.max || obj.message.value <= downlinkObject.common.max)){
|
|
436
|
+
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};
|
|
438
|
+
}
|
|
439
|
+
else{
|
|
440
|
+
result = {error:true, message:"value is not in valid range"};
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
else{
|
|
444
|
+
result = {error:true, message: `downlink is type number, but recieved ${typeof obj.message.value}`};
|
|
445
|
+
}
|
|
433
446
|
}
|
|
447
|
+
// downlinkobject is not a number
|
|
434
448
|
else{
|
|
435
|
-
|
|
449
|
+
await this.setStateAsync(downlinkId,obj.message.value);
|
|
450
|
+
result = {applicationId: changeInfo.applicationId, deviceEUI: changeInfo.deviceEUI, deviceId: changeInfo.deviceId, deviceType: changeInfo.deviceType, downlink: obj.message.downlink, value: obj.message.value};
|
|
436
451
|
}
|
|
437
452
|
}
|
|
438
|
-
// downlinkvalue not a number
|
|
439
|
-
else{
|
|
440
|
-
await this.setStateAsync(downlinkId,obj.message.value);
|
|
441
|
-
result = {applicationId: changeInfo.applicationId, deviceEUI: changeInfo.deviceEUI, deviceId: changeInfo.deviceId, deviceType: changeInfo.deviceType, downlink: obj.message.downlink, value: obj.message.value};
|
|
442
|
-
}
|
|
443
453
|
}
|
|
444
454
|
else{
|
|
445
455
|
result = {error:true, message:"No downlink matches"};
|
|
@@ -455,9 +465,10 @@ class Lorawan extends utils.Adapter {
|
|
|
455
465
|
// Send response
|
|
456
466
|
if (obj.callback) this.sendTo(obj.from, obj.command, result, obj.callback);
|
|
457
467
|
}
|
|
458
|
-
else if (obj.command === "
|
|
468
|
+
else if (obj.command === "getUplink"){
|
|
459
469
|
if(obj.message.deviceEUI && obj.message.uplink){
|
|
460
|
-
const
|
|
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);
|
|
461
472
|
if(changeInfo){
|
|
462
473
|
const uplinkId = changeInfo.id;
|
|
463
474
|
if(await this.objectExists(uplinkId)){
|
|
@@ -467,7 +478,7 @@ class Lorawan extends utils.Adapter {
|
|
|
467
478
|
}
|
|
468
479
|
}
|
|
469
480
|
else{
|
|
470
|
-
result = {error:true, message:"No uplink matches"};
|
|
481
|
+
result = {error:true, message:"No uplink matches", changeInfo: changeInfo};
|
|
471
482
|
}
|
|
472
483
|
}
|
|
473
484
|
else{
|