iobroker.lorawan 0.0.13 → 0.0.14
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/io-package.json +14 -14
- package/lib/modules/directorieshandler.js +184 -122
- package/lib/modules/messagehandler.js +3 -8
- package/main.js +11 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -19,6 +19,9 @@ Adapter was created in collaboration with Joerg Froehner LoraWan@hafenmeister.co
|
|
|
19
19
|
Placeholder for the next version (at the beginning of the line):
|
|
20
20
|
### **WORK IN PROGRESS**
|
|
21
21
|
-->
|
|
22
|
+
### 0.0.14 (2024-01-21)
|
|
23
|
+
* (BenAhrdt) bugfix chirpstack directory
|
|
24
|
+
|
|
22
25
|
### 0.0.13 (2024-01-21)
|
|
23
26
|
* (BenAhrdt) change device id selecting in chirpstack out of directory (for downlink queued)
|
|
24
27
|
|
package/io-package.json
CHANGED
|
@@ -1,8 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"common": {
|
|
3
3
|
"name": "lorawan",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.14",
|
|
5
5
|
"news": {
|
|
6
|
+
"0.0.14": {
|
|
7
|
+
"en": "bugfix chirpstack directory",
|
|
8
|
+
"de": "bugfix chirpstack verzeichnis",
|
|
9
|
+
"ru": "bugfix chirpstack directory",
|
|
10
|
+
"pt": "gerenciamento de contas",
|
|
11
|
+
"nl": "bugfix chirpstack-map",
|
|
12
|
+
"fr": "répertoire bugfix chirpstack",
|
|
13
|
+
"it": "bugfix chirpstack directory",
|
|
14
|
+
"es": "directorio bugfix chirpstack",
|
|
15
|
+
"pl": "katalog chirpstock bugfix",
|
|
16
|
+
"uk": "javascript licenses api веб-сайт",
|
|
17
|
+
"zh-cn": "bugfix 奇普斯塔克目录"
|
|
18
|
+
},
|
|
6
19
|
"0.0.13": {
|
|
7
20
|
"en": "change device id selecting in chirpstack out of directory (for downlink queued)",
|
|
8
21
|
"de": "id auswahl in chirpstack aus verzeichnis (für downlink queued)",
|
|
@@ -80,19 +93,6 @@
|
|
|
80
93
|
"pl": "pierwsza realizacja chirpstock",
|
|
81
94
|
"uk": "перша реалізація тирпастука",
|
|
82
95
|
"zh-cn": "首次实施黑社会"
|
|
83
|
-
},
|
|
84
|
-
"0.0.7": {
|
|
85
|
-
"en": "hex to Upper case, more units for decoded payload values",
|
|
86
|
-
"de": "hex to Upper case, mehr Einheiten für decodierte Nutzwerte",
|
|
87
|
-
"ru": "hex to Upper case, more units for decode payload values",
|
|
88
|
-
"pt": "hex para caixa superior, mais unidades para valores de carga descodificados",
|
|
89
|
-
"nl": "hex naar Upper case, meer eenheden voor gedecodeerde lading waarden",
|
|
90
|
-
"fr": "hex à Upper case, plus d'unités pour les valeurs de charge utile décodées",
|
|
91
|
-
"it": "hex to Upper case, più unità per i valori di payload decodificato",
|
|
92
|
-
"es": "hex to Upper case, más unidades para valores de carga descodificados",
|
|
93
|
-
"pl": "hex do górnej skrzyni, więcej jednostek dla dekodowanych wartości ładunku",
|
|
94
|
-
"uk": "hex до верхнього корпусу, більше одиниць для декодованих значень навантаження",
|
|
95
|
-
"zh-cn": "十六进制到大写, 更多解码有效载荷值的单位"
|
|
96
96
|
}
|
|
97
97
|
},
|
|
98
98
|
"title": "LoRaWAN",
|
|
@@ -134,8 +134,7 @@ class directorieshandlerClass {
|
|
|
134
134
|
* ******************************************************************/
|
|
135
135
|
|
|
136
136
|
async generateRekursivObjects(obj,startDirectory,topic,message,options = undefined){
|
|
137
|
-
const activeFunction = "
|
|
138
|
-
|
|
137
|
+
const activeFunction = "generateRekursivObjects";
|
|
139
138
|
try{
|
|
140
139
|
// just proceed with ojects
|
|
141
140
|
if(typeof obj === "object"){
|
|
@@ -160,10 +159,10 @@ class directorieshandlerClass {
|
|
|
160
159
|
if(!this.reachableDirectories){
|
|
161
160
|
this.reachableDirectories = {};
|
|
162
161
|
}
|
|
163
|
-
if(!this.reachableDirectories[this.getObjectDirectory(topic,message,this.searchableAttributeNames.deviceId)]){
|
|
164
|
-
this.reachableDirectories[this.getObjectDirectory(topic,message,this.searchableAttributeNames.deviceId)] = {};
|
|
162
|
+
if(!this.reachableDirectories[await this.getObjectDirectory(topic,message,this.searchableAttributeNames.deviceId)]){
|
|
163
|
+
this.reachableDirectories[await this.getObjectDirectory(topic,message,this.searchableAttributeNames.deviceId)] = {};
|
|
165
164
|
}
|
|
166
|
-
this.reachableDirectories[this.getObjectDirectory(topic,message,this.searchableAttributeNames.deviceId)][obj[elementName].safeDirectory] = objectId;
|
|
165
|
+
this.reachableDirectories[await this.getObjectDirectory(topic,message,this.searchableAttributeNames.deviceId)][obj[elementName].safeDirectory] = objectId;
|
|
167
166
|
}
|
|
168
167
|
await this.adapter.setObjectNotExistsAsync(objectId,{
|
|
169
168
|
// @ts-ignore
|
|
@@ -235,12 +234,19 @@ class directorieshandlerClass {
|
|
|
235
234
|
* ******************************************************************/
|
|
236
235
|
|
|
237
236
|
async getAttributValue(topic,message,resolvetype){
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
case
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
237
|
+
const activeFunction = "getAttributValue";
|
|
238
|
+
try{
|
|
239
|
+
// Select search in case of origin
|
|
240
|
+
switch(this.adapter.config.origin){
|
|
241
|
+
case "ttn":
|
|
242
|
+
return await this.getTtnAttributValue(topic,message,resolvetype);
|
|
243
|
+
case "chirpstack":
|
|
244
|
+
return await this.getChirpstackAttributValue(topic,message,resolvetype);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
catch(error){
|
|
248
|
+
this.adapter.log.error(`error at ${activeFunction}: ` + error);
|
|
249
|
+
this.adapter.log.warn("Message: " + JSON.stringify(message));
|
|
244
250
|
}
|
|
245
251
|
}
|
|
246
252
|
|
|
@@ -248,13 +254,20 @@ class directorieshandlerClass {
|
|
|
248
254
|
* ************************ Object Directory *************************
|
|
249
255
|
* ******************************************************************/
|
|
250
256
|
|
|
251
|
-
getObjectDirectory(topic,message,resolvetype){
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
case
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
257
|
+
async getObjectDirectory(topic,message,resolvetype){
|
|
258
|
+
const activeFunction = "getObjectDirectory";
|
|
259
|
+
try{
|
|
260
|
+
// Select search in case of origin
|
|
261
|
+
switch(this.adapter.config.origin){
|
|
262
|
+
case "ttn":
|
|
263
|
+
return await this.getTtnObjectDirectory(topic,message,resolvetype);
|
|
264
|
+
case "chirpstack":
|
|
265
|
+
return await this.getChirpstackObjectDirectory(topic,message,resolvetype);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
catch(error){
|
|
269
|
+
this.adapter.log.error(`error at ${activeFunction}: ` + error);
|
|
270
|
+
this.adapter.log.warn("Message: " + JSON.stringify(message));
|
|
258
271
|
}
|
|
259
272
|
}
|
|
260
273
|
|
|
@@ -262,13 +275,20 @@ class directorieshandlerClass {
|
|
|
262
275
|
* *********************** Topic resolved ****************************
|
|
263
276
|
* ******************************************************************/
|
|
264
277
|
getTopicResolved(topic){
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
case
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
278
|
+
const activeFunction = "getTopicResolved";
|
|
279
|
+
try{
|
|
280
|
+
this.adapter.log.silly(`topic ${topic} is requested for resolveing`);
|
|
281
|
+
// Select in case of origin
|
|
282
|
+
switch(this.adapter.config.origin){
|
|
283
|
+
case "ttn":
|
|
284
|
+
return this.getTtnTopicResolved(topic);
|
|
285
|
+
case "chirpstack":
|
|
286
|
+
return this.getChirpstackTopicResolved(topic);
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
catch(error){
|
|
290
|
+
this.adapter.log.error(`error at ${activeFunction}: ` + error);
|
|
291
|
+
this.adapter.log.warn("Topic: " + JSON.stringify(topic));
|
|
272
292
|
}
|
|
273
293
|
}
|
|
274
294
|
|
|
@@ -281,21 +301,28 @@ class directorieshandlerClass {
|
|
|
281
301
|
* ******************************************************************/
|
|
282
302
|
|
|
283
303
|
async getTtnAttributValue(topic,message,resolvetype){
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
304
|
+
const activeFunction = "getTtnAttributValue";
|
|
305
|
+
try{
|
|
306
|
+
this.adapter.log.silly(`attribute ${resolvetype} is requested for ttn`);
|
|
307
|
+
const topicResolved = this.getTopicResolved(topic);
|
|
308
|
+
switch(resolvetype){
|
|
309
|
+
case this.searchableAttributeNames.apllicationId:
|
|
310
|
+
return topicResolved?.applicationId;
|
|
289
311
|
|
|
290
|
-
|
|
291
|
-
|
|
312
|
+
case this.searchableAttributeNames.deviceUid:
|
|
313
|
+
return message.end_device_ids.dev_eui;
|
|
292
314
|
|
|
293
|
-
|
|
294
|
-
|
|
315
|
+
case this.searchableAttributeNames.deviceId:
|
|
316
|
+
return topicResolved?.deviceId;
|
|
295
317
|
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
318
|
+
default:
|
|
319
|
+
this.adapter.log.warn(`No attribute with the name ${resolvetype} found.`);
|
|
320
|
+
return "";
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
catch(error){
|
|
324
|
+
this.adapter.log.error(`error at ${activeFunction}: ` + error);
|
|
325
|
+
this.adapter.log.warn("Message: " + JSON.stringify(message));
|
|
299
326
|
}
|
|
300
327
|
}
|
|
301
328
|
|
|
@@ -303,20 +330,27 @@ class directorieshandlerClass {
|
|
|
303
330
|
* ************************ Object Directory *************************
|
|
304
331
|
* ******************************************************************/
|
|
305
332
|
|
|
306
|
-
getTtnObjectDirectory(topic,message,resolvetype){
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
333
|
+
async getTtnObjectDirectory(topic,message,resolvetype){
|
|
334
|
+
const activeFunction = "getTtnObjectDirectory";
|
|
335
|
+
try{
|
|
336
|
+
this.adapter.log.silly(`directory ${resolvetype} is requested for ttn`);
|
|
337
|
+
const topicResolved = this.getTopicResolved(topic);
|
|
338
|
+
if(typeof message !== "string"){
|
|
339
|
+
switch(resolvetype){
|
|
340
|
+
case this.searchableAttributeNames.deviceId:
|
|
341
|
+
return `${topicResolved?.applicationId}.devices.${message.end_device_ids.dev_eui}.${topicResolved?.deviceId}`;
|
|
313
342
|
|
|
314
|
-
|
|
315
|
-
|
|
343
|
+
default:
|
|
344
|
+
return message;
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
else{
|
|
348
|
+
return message;
|
|
316
349
|
}
|
|
317
350
|
}
|
|
318
|
-
|
|
319
|
-
|
|
351
|
+
catch(error){
|
|
352
|
+
this.adapter.log.error(`error at ${activeFunction}: ` + error);
|
|
353
|
+
this.adapter.log.warn("Message: " + JSON.stringify(message));
|
|
320
354
|
}
|
|
321
355
|
}
|
|
322
356
|
|
|
@@ -325,18 +359,25 @@ class directorieshandlerClass {
|
|
|
325
359
|
* ******************************************************************/
|
|
326
360
|
|
|
327
361
|
getTtnTopicResolved(topic){
|
|
328
|
-
const
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
362
|
+
const activeFunction = "getTtnTopicResolved";
|
|
363
|
+
try{
|
|
364
|
+
const topicElements = topic.split("/");
|
|
365
|
+
const topicResolved = {
|
|
366
|
+
applicationId: topicElements[1],
|
|
367
|
+
deviceId: topicElements[3],
|
|
368
|
+
messageType: topicElements[topicElements.length - 1]
|
|
369
|
+
};
|
|
370
|
+
// clean up application id
|
|
371
|
+
const indexOfOrigin = topicResolved.applicationId.indexOf("@");
|
|
372
|
+
if(indexOfOrigin !== -1){
|
|
373
|
+
topicResolved.applicationId = topicResolved.applicationId.substring(0,indexOfOrigin);
|
|
374
|
+
}
|
|
375
|
+
return topicResolved;
|
|
376
|
+
}
|
|
377
|
+
catch(error){
|
|
378
|
+
this.adapter.log.error(`error at ${activeFunction}: ` + error);
|
|
379
|
+
this.adapter.log.warn("Topic: " + JSON.stringify(topic));
|
|
338
380
|
}
|
|
339
|
-
return topicResolved;
|
|
340
381
|
}
|
|
341
382
|
|
|
342
383
|
|
|
@@ -351,38 +392,45 @@ class directorieshandlerClass {
|
|
|
351
392
|
|
|
352
393
|
|
|
353
394
|
async getChirpstackAttributValue(topic,message,resolvetype){
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
if(
|
|
375
|
-
|
|
376
|
-
|
|
395
|
+
const activeFunction = "getChirpstackAttributValue";
|
|
396
|
+
try{
|
|
397
|
+
this.adapter.log.silly(`attribute ${resolvetype} is requested for chirpstack`);
|
|
398
|
+
const topicResolved = this.getTopicResolved(topic);
|
|
399
|
+
let devId = undefined;
|
|
400
|
+
switch(resolvetype){
|
|
401
|
+
case this.searchableAttributeNames.apllicationId:
|
|
402
|
+
return topicResolved?.applicationId;
|
|
403
|
+
|
|
404
|
+
case this.searchableAttributeNames.deviceUid:
|
|
405
|
+
return topicResolved?.deviceUid;
|
|
406
|
+
|
|
407
|
+
case this.searchableAttributeNames.deviceId:
|
|
408
|
+
if(topicResolved?.messageType === "up"){
|
|
409
|
+
devId = message.deviceInfo.deviceName;
|
|
410
|
+
}
|
|
411
|
+
else if(topicResolved?.messageType === "down")
|
|
412
|
+
{
|
|
413
|
+
const adapterObjectsAtStart = await this.adapter.getAdapterObjectsAsync();
|
|
414
|
+
for(const adapterObject of Object.values(adapterObjectsAtStart)){
|
|
415
|
+
if(adapterObject.type === "channel" && adapterObject.common.name !== "Information"){
|
|
416
|
+
const baseDeviceInfo = this.adapter.getBaseDeviceInfo(`${adapterObject._id}.deviceInfo`);
|
|
417
|
+
if(baseDeviceInfo.obectStartDirectory === adapterObject._id){
|
|
418
|
+
devId = baseDeviceInfo.obectStartDirectory;
|
|
419
|
+
break;
|
|
420
|
+
}
|
|
377
421
|
}
|
|
378
422
|
}
|
|
379
423
|
}
|
|
380
|
-
|
|
381
|
-
return devId;
|
|
424
|
+
return devId;
|
|
382
425
|
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
426
|
+
default:
|
|
427
|
+
this.adapter.log.warn(`No attribute with the name ${resolvetype} found.`);
|
|
428
|
+
return "";
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
catch(error){
|
|
432
|
+
this.adapter.log.error(`error at ${activeFunction}: ` + error);
|
|
433
|
+
this.adapter.log.warn("Message: " + JSON.stringify(message));
|
|
386
434
|
}
|
|
387
435
|
}
|
|
388
436
|
|
|
@@ -390,54 +438,68 @@ class directorieshandlerClass {
|
|
|
390
438
|
* ************************ Object Directory *************************
|
|
391
439
|
* ******************************************************************/
|
|
392
440
|
|
|
393
|
-
getChirpstackObjectDirectory(topic,message,resolvetype){
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
devUid =
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
441
|
+
async getChirpstackObjectDirectory(topic,message,resolvetype){
|
|
442
|
+
const activeFunction = "getChirpstackObjectDirectory";
|
|
443
|
+
try{
|
|
444
|
+
this.adapter.log.silly(`directory ${resolvetype} is requested for chirpstack`);
|
|
445
|
+
const topicResolved = this.getTopicResolved(topic);
|
|
446
|
+
let devUid = undefined;
|
|
447
|
+
if(topicResolved?.messageType === "up"){
|
|
448
|
+
devUid = message.deviceInfo.devEui;
|
|
449
|
+
}
|
|
450
|
+
else if(topicResolved?.messageType === "down")
|
|
451
|
+
{
|
|
452
|
+
devUid = message.devEui;
|
|
453
|
+
}
|
|
454
|
+
if(devUid !== undefined){
|
|
455
|
+
if(typeof message !== "string"){
|
|
456
|
+
switch(resolvetype){
|
|
457
|
+
case this.searchableAttributeNames.deviceId:
|
|
458
|
+
return `${topicResolved?.applicationId}.devices.${devUid}.${await this.getChirpstackAttributValue(topic,message,this.searchableAttributeNames.deviceId)}`; // Hier muss die device id rein. (mussnoch mit async geholt werden)
|
|
459
|
+
|
|
460
|
+
default:
|
|
461
|
+
return message;
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
else{
|
|
465
|
+
return message;
|
|
412
466
|
}
|
|
413
467
|
}
|
|
414
468
|
else{
|
|
415
|
-
|
|
469
|
+
this.adapter.log.warn(`no devEui found in message`);
|
|
470
|
+
this.adapter.log.warn(`message: ${message}`);
|
|
416
471
|
}
|
|
417
472
|
}
|
|
418
|
-
|
|
419
|
-
this.adapter.log.
|
|
420
|
-
this.adapter.log.warn(
|
|
473
|
+
catch(error){
|
|
474
|
+
this.adapter.log.error(`error at ${activeFunction}: ` + error);
|
|
475
|
+
this.adapter.log.warn("Message: " + JSON.stringify(message));
|
|
421
476
|
}
|
|
422
477
|
}
|
|
423
478
|
|
|
424
479
|
/*********************************************************************
|
|
425
|
-
* ************************
|
|
480
|
+
* ************************ Resolved Topic ***************************
|
|
426
481
|
* ******************************************************************/
|
|
427
482
|
|
|
428
483
|
getChirpstackTopicResolved(topic){
|
|
429
|
-
const
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
484
|
+
const activeFunction = "getChirpstackTopicResolved";
|
|
485
|
+
try{
|
|
486
|
+
const topicElements = topic.split("/");
|
|
487
|
+
const topicResolved = {
|
|
488
|
+
applicationId: topicElements[1],
|
|
489
|
+
deviceUid: topicElements[3],
|
|
490
|
+
messageType: topicElements[topicElements.length - 1]
|
|
491
|
+
};
|
|
492
|
+
// clean up application id
|
|
493
|
+
const indexOfOrigin = topicResolved.applicationId.indexOf("@");
|
|
494
|
+
if(indexOfOrigin !== -1){
|
|
495
|
+
topicResolved.applicationId = topicResolved.applicationId.substring(0,indexOfOrigin);
|
|
496
|
+
}
|
|
497
|
+
return topicResolved;
|
|
498
|
+
}
|
|
499
|
+
catch(error){
|
|
500
|
+
this.adapter.log.error(`error at ${activeFunction}: ` + error);
|
|
501
|
+
this.adapter.log.warn("Topic: " + JSON.stringify(topic));
|
|
439
502
|
}
|
|
440
|
-
return topicResolved;
|
|
441
503
|
}
|
|
442
504
|
}
|
|
443
505
|
|
|
@@ -110,9 +110,8 @@ class messagehandlerClass {
|
|
|
110
110
|
const messageType = topic.substring(topic.lastIndexOf("/") + 1 ,topic.length);
|
|
111
111
|
this.adapter.log.silly(`the messagetype ${messageType} was determined`);
|
|
112
112
|
// generate startdirectory of device
|
|
113
|
-
const deviceStartdirectory = this.directoryhandler.getObjectDirectory(topic,message,this.directoryhandler.searchableAttributeNames.deviceId);
|
|
113
|
+
const deviceStartdirectory = await this.directoryhandler.getObjectDirectory(topic,message,this.directoryhandler.searchableAttributeNames.deviceId);
|
|
114
114
|
this.adapter.log.silly(`the startdirectory ${deviceStartdirectory} was determined`);
|
|
115
|
-
|
|
116
115
|
/*********************************************************************
|
|
117
116
|
* ************************ Main directories *************************
|
|
118
117
|
* ******************************************************************/
|
|
@@ -135,7 +134,6 @@ class messagehandlerClass {
|
|
|
135
134
|
|
|
136
135
|
// check for uplink message
|
|
137
136
|
if(messageType === "up"){//if(message.uplink_message){
|
|
138
|
-
|
|
139
137
|
/*********************************************************************
|
|
140
138
|
* ************************ Rawdata json *****************************
|
|
141
139
|
* ******************************************************************/
|
|
@@ -159,7 +157,6 @@ class messagehandlerClass {
|
|
|
159
157
|
/*********************************************************************
|
|
160
158
|
* ********************** Rawdata (Base64) ***************************
|
|
161
159
|
* ******************************************************************/
|
|
162
|
-
|
|
163
160
|
// check for frm payload
|
|
164
161
|
if(message.uplink_message.frm_payload){
|
|
165
162
|
// wite base64 data
|
|
@@ -354,7 +351,7 @@ class messagehandlerClass {
|
|
|
354
351
|
const messageType = topic.substring(topic.lastIndexOf("/") + 1 ,topic.length);
|
|
355
352
|
this.adapter.log.silly(`the messagetype ${messageType} was determined`);
|
|
356
353
|
// generate startdirectory of device
|
|
357
|
-
const deviceStartdirectory = this.directoryhandler.getObjectDirectory(topic,message,this.directoryhandler.searchableAttributeNames.deviceId);
|
|
354
|
+
const deviceStartdirectory = await this.directoryhandler.getObjectDirectory(topic,message,this.directoryhandler.searchableAttributeNames.deviceId);
|
|
358
355
|
this.adapter.log.silly(`the startdirectory ${deviceStartdirectory} was determined`);
|
|
359
356
|
|
|
360
357
|
/*********************************************************************
|
|
@@ -397,7 +394,6 @@ class messagehandlerClass {
|
|
|
397
394
|
/*********************************************************************
|
|
398
395
|
* ********************** Rawdata (Base64) ***************************
|
|
399
396
|
* ******************************************************************/
|
|
400
|
-
|
|
401
397
|
// check for data
|
|
402
398
|
if(message.data){
|
|
403
399
|
// wite base64 data
|
|
@@ -452,7 +448,6 @@ class messagehandlerClass {
|
|
|
452
448
|
/*********************************************************************
|
|
453
449
|
* ****************** decoded payload (Object) ***********************
|
|
454
450
|
* ******************************************************************/
|
|
455
|
-
|
|
456
451
|
startDirectory = `${deviceStartdirectory}.${this.directoryhandler.reachableSubfolders.uplinkDecoded}`;
|
|
457
452
|
this.adapter.log.silly(`write decoded payload (Object)`);
|
|
458
453
|
await this.directoryhandler.generateRekursivObjects(message.object,startDirectory,topic,message);
|
|
@@ -554,12 +549,12 @@ class messagehandlerClass {
|
|
|
554
549
|
* ******************************************************************/
|
|
555
550
|
|
|
556
551
|
}
|
|
557
|
-
|
|
558
552
|
/*********************************************************************
|
|
559
553
|
* ********************** downlinkConfigs ****************************
|
|
560
554
|
* ******************************************************************/
|
|
561
555
|
this.adapter.log.silly(`check configed downlinks`);
|
|
562
556
|
await this.fillWithDownlinkConfig(deviceStartdirectory);
|
|
557
|
+
|
|
563
558
|
}
|
|
564
559
|
catch(error){
|
|
565
560
|
this.adapter.log.error(`error at ${activeFunction}: ` + error);
|
package/main.js
CHANGED
|
@@ -53,12 +53,23 @@ class Lorawan extends utils.Adapter {
|
|
|
53
53
|
this.subscribeStatesAsync("*.configuration.*");
|
|
54
54
|
this.subscribeStatesAsync("*downlink.control.*");
|
|
55
55
|
this.log.debug(`the adapter start with the config: ${JSON.stringify(this.config)}.`);
|
|
56
|
+
|
|
57
|
+
/*setTimeout(async () => {
|
|
58
|
+
await this.startSimulation();
|
|
59
|
+
}, 5000);*/
|
|
56
60
|
}
|
|
57
61
|
catch(error){
|
|
58
62
|
this.log.error(`error at ${activeFunction}: ` + error);
|
|
59
63
|
}
|
|
60
64
|
}
|
|
61
65
|
|
|
66
|
+
async startSimulation(){
|
|
67
|
+
|
|
68
|
+
const topic = "application/d63c10b6-9263-4ab3-9299-4308fa19a2ad/device/a84041f621857cd2/event/up";
|
|
69
|
+
const message = {"deduplicationId":"96e4a065-ad5e-402d-a997-7b261072a33c","time":"2024-01-21T17:01:36.641008+00:00","deviceInfo":{"tenantId":"52f14cd4-c6f1-4fbd-8f87-4025e1d49242","tenantName":"ChirpStack","applicationId":"d63c10b6-9263-4ab3-9299-4308fa19a2ad","applicationName":"Benjamin Schmidt","deviceProfileId":"0b46400f-37ec-4f17-8005-168b06159347","deviceProfileName":"Dragino Feuchtesenor","deviceName":"Skimmer","devEui":"a84041f621857cd2","deviceClassEnabled":"CLASS_A","tags":{}},"devAddr":"01fd9738","adr":true,"dr":5,"fCnt":2,"fPort":2,"confirmed":false,"data":"DPYBAAD//wAA","object":{"soilconductivity":0.0,"soiltemperature":-0.1,"volt":3.318,"soilmoisture":0.0},"rxInfo":[{"gatewayId":"50303541b0344750","uplinkId":39169,"gwTime":"2024-01-21T17:01:36.641008+00:00","nsTime":"2024-01-21T17:01:37.695656999+00:00","rssi":-89,"snr":6.25,"rfChain":1,"location":{"latitude":50.69344693065449,"longitude":8.476783633232118},"context":"qESemw==","metadata":{"region_config_id":"eu868","region_common_name":"EU868"},"crcStatus":"CRC_OK"}],"txInfo":{"frequency":868100000,"modulation":{"lora":{"bandwidth":125000,"spreadingFactor":7,"codeRate":"CR_4_5"}}}};
|
|
70
|
+
|
|
71
|
+
await this.messagehandler?.handleMessage(topic, message);
|
|
72
|
+
}
|
|
62
73
|
/**
|
|
63
74
|
* Is called when adapter shuts down - callback has to be called under any circumstances!
|
|
64
75
|
* @param {() => void} callback
|
|
@@ -176,7 +187,6 @@ class Lorawan extends utils.Adapter {
|
|
|
176
187
|
|
|
177
188
|
async writeNextSend(startDirectory,payloadInHex){
|
|
178
189
|
const idFolder = `${startDirectory}.${this.messagehandler?.directoryhandler.directoryStructur.downlinkNextSend}`;
|
|
179
|
-
this.log.warn(payloadInHex);
|
|
180
190
|
await this.setStateAsync(`${idFolder}.hex`,payloadInHex,true);
|
|
181
191
|
}
|
|
182
192
|
|