iobroker.lorawan 0.0.13 → 0.0.15

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 CHANGED
@@ -19,6 +19,12 @@ 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.15 (2024-01-21)
23
+ * (BenAhrdt) bugfix chirpstack directory at downlink queued
24
+
25
+ ### 0.0.14 (2024-01-21)
26
+ * (BenAhrdt) bugfix chirpstack directory
27
+
22
28
  ### 0.0.13 (2024-01-21)
23
29
  * (BenAhrdt) change device id selecting in chirpstack out of directory (for downlink queued)
24
30
 
package/io-package.json CHANGED
@@ -1,8 +1,34 @@
1
1
  {
2
2
  "common": {
3
3
  "name": "lorawan",
4
- "version": "0.0.13",
4
+ "version": "0.0.15",
5
5
  "news": {
6
+ "0.0.15": {
7
+ "en": "bugfix chirpstack directory at downlink queued",
8
+ "de": "bugfix chirpstack verzeichnis bei downlink queued",
9
+ "ru": "bugfix chirpstack directory в очертаниях",
10
+ "pt": "bugfix chirpstack diretório no downlink queued",
11
+ "nl": "bugfix chirpstack directory bij downlink wachtrij",
12
+ "fr": "bugfix répertoire chirpstack au lien descendant en file d'attente",
13
+ "it": "bugfix chirpstack directory in downlink in coda",
14
+ "es": "bugfix chirpstack directorio en downlink queued",
15
+ "pl": "katalog chirpstock bugfix na downlink w kolejce",
16
+ "uk": "javascript licenses api веб-сайт go1.13.8",
17
+ "zh-cn": "下行链路队列时的 bugfix kirpstack 目录"
18
+ },
19
+ "0.0.14": {
20
+ "en": "bugfix chirpstack directory",
21
+ "de": "bugfix chirpstack verzeichnis",
22
+ "ru": "bugfix chirpstack directory",
23
+ "pt": "gerenciamento de contas",
24
+ "nl": "bugfix chirpstack-map",
25
+ "fr": "répertoire bugfix chirpstack",
26
+ "it": "bugfix chirpstack directory",
27
+ "es": "directorio bugfix chirpstack",
28
+ "pl": "katalog chirpstock bugfix",
29
+ "uk": "javascript licenses api веб-сайт",
30
+ "zh-cn": "bugfix 奇普斯塔克目录"
31
+ },
6
32
  "0.0.13": {
7
33
  "en": "change device id selecting in chirpstack out of directory (for downlink queued)",
8
34
  "de": "id auswahl in chirpstack aus verzeichnis (für downlink queued)",
@@ -67,32 +93,6 @@
67
93
  "pl": "pierwsza wersja dla beta",
68
94
  "uk": "перша версія для бета",
69
95
  "zh-cn": "β的第一个版本"
70
- },
71
- "0.0.8": {
72
- "en": "first implementation of chirpstack",
73
- "de": "erste implementierung von chirpstack",
74
- "ru": "первая реализация chirpstack",
75
- "pt": "primeira implementação de chirpstack",
76
- "nl": "eerste implementatie van tsjirpstack",
77
- "fr": "première mise en œuvre de chirpstack",
78
- "it": "prima implementazione di chirpstack",
79
- "es": "primera implementación de chirpstack",
80
- "pl": "pierwsza realizacja chirpstock",
81
- "uk": "перша реалізація тирпастука",
82
- "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 = "handleTtnMessage";
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
- // Select search in case of origin
239
- switch(this.adapter.config.origin){
240
- case "ttn":
241
- return await this.getTtnAttributValue(topic,message,resolvetype);
242
- case "chirpstack":
243
- return await this.getChirpstackAttributValue(topic,message,resolvetype);
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
- // Select search in case of origin
253
- switch(this.adapter.config.origin){
254
- case "ttn":
255
- return this.getTtnObjectDirectory(topic,message,resolvetype);
256
- case "chirpstack":
257
- return this.getChirpstackObjectDirectory(topic,message,resolvetype);
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
- this.adapter.log.silly(`topic ${topic} is requested for resolveing`);
266
- // Select in case of origin
267
- switch(this.adapter.config.origin){
268
- case "ttn":
269
- return this.getTtnTopicResolved(topic);
270
- case "chirpstack":
271
- return this.getChirpstackTopicResolved(topic);
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
- this.adapter.log.silly(`attribute ${resolvetype} is requested for ttn`);
285
- const topicResolved = this.getTopicResolved(topic);
286
- switch(resolvetype){
287
- case this.searchableAttributeNames.apllicationId:
288
- return topicResolved?.applicationId;
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
- case this.searchableAttributeNames.deviceUid:
291
- return message.end_device_ids.dev_eui;
312
+ case this.searchableAttributeNames.deviceUid:
313
+ return message.end_device_ids.dev_eui;
292
314
 
293
- case this.searchableAttributeNames.deviceId:
294
- return topicResolved?.deviceId;
315
+ case this.searchableAttributeNames.deviceId:
316
+ return topicResolved?.deviceId;
295
317
 
296
- default:
297
- this.adapter.log.warn(`No attribute with the name ${resolvetype} found.`);
298
- return "";
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
- this.adapter.log.silly(`directory ${resolvetype} is requested for ttn`);
308
- const topicResolved = this.getTopicResolved(topic);
309
- if(typeof message !== "string"){
310
- switch(resolvetype){
311
- case this.searchableAttributeNames.deviceId:
312
- return `${topicResolved?.applicationId}.devices.${message.end_device_ids.dev_eui}.${topicResolved?.deviceId}`;
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
- default:
315
- return message;
343
+ default:
344
+ return message;
345
+ }
346
+ }
347
+ else{
348
+ return message;
316
349
  }
317
350
  }
318
- else{
319
- return message;
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 topicElements = topic.split("/");
329
- const topicResolved = {
330
- applicationId: topicElements[1],
331
- deviceId: topicElements[3],
332
- messageType: topicElements[topicElements.length - 1]
333
- };
334
- // clean up application id
335
- const indexOfOrigin = topicResolved.applicationId.indexOf("@");
336
- if(indexOfOrigin !== -1){
337
- topicResolved.applicationId = topicResolved.applicationId.substring(0,indexOfOrigin);
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,47 @@ class directorieshandlerClass {
351
392
 
352
393
 
353
394
  async getChirpstackAttributValue(topic,message,resolvetype){
354
- this.adapter.log.silly(`attribute ${resolvetype} is requested for chirpstack`);
355
- const topicResolved = this.getTopicResolved(topic);
356
- let devId = undefined;
357
- switch(resolvetype){
358
- case this.searchableAttributeNames.apllicationId:
359
- return topicResolved?.applicationId;
360
-
361
- case this.searchableAttributeNames.deviceUid:
362
- return topicResolved?.devUid;
363
-
364
- case this.searchableAttributeNames.deviceId:
365
- if(topicResolved?.messageType === "up"){
366
- devId = message.deviceInfo.deviceName;
367
- }
368
- else if(topicResolved?.messageType === "down")
369
- {
370
- const adapterObjectsAtStart = await this.adapter.getAdapterObjectsAsync();
371
- for(const adapterObject of Object.values(adapterObjectsAtStart)){
372
- if(adapterObject.type === "channel" && adapterObject.common.name !== "Information"){
373
- const baseDeviceInfo = this.adapter.getBaseDeviceInfo(`${adapterObject._id}.deviceInfo`);
374
- if(baseDeviceInfo.obectStartDirectory === adapterObject._id){
375
- devId = baseDeviceInfo.obectStartDirectory;
376
- break;
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
+ adapterObject._id = this.adapter.removeNamespace(adapterObject._id);
417
+ const baseDeviceInfo = this.adapter.getBaseDeviceInfo(`${adapterObject._id}.deviceInfo`);
418
+ if(baseDeviceInfo.obectStartDirectory === adapterObject._id){
419
+ devId = baseDeviceInfo.device_id;
420
+ this.adapter.log.warn("Intern: " + devId);
421
+ break;
422
+ }
377
423
  }
378
424
  }
379
425
  }
380
- }
381
- return devId;
426
+ return devId;
382
427
 
383
- default:
384
- this.adapter.log.warn(`No attribute with the name ${resolvetype} found.`);
385
- return "";
428
+ default:
429
+ this.adapter.log.warn(`No attribute with the name ${resolvetype} found.`);
430
+ return "";
431
+ }
432
+ }
433
+ catch(error){
434
+ this.adapter.log.error(`error at ${activeFunction}: ` + error);
435
+ this.adapter.log.warn("Message: " + JSON.stringify(message));
386
436
  }
387
437
  }
388
438
 
@@ -390,54 +440,70 @@ class directorieshandlerClass {
390
440
  * ************************ Object Directory *************************
391
441
  * ******************************************************************/
392
442
 
393
- getChirpstackObjectDirectory(topic,message,resolvetype){
394
- this.adapter.log.silly(`directory ${resolvetype} is requested for chirpstack`);
395
- const topicResolved = this.getTopicResolved(topic);
396
- let devUid = undefined;
397
- if(topicResolved?.messageType === "up"){
398
- devUid = message.deviceInfo.devEui;
399
- }
400
- else if(topicResolved?.messageType === "down")
401
- {
402
- devUid = message.devEui;
403
- }
404
- if(devUid !== undefined){
405
- if(typeof message !== "string"){
406
- switch(resolvetype){
407
- case this.searchableAttributeNames.deviceId:
408
- return `${topicResolved?.applicationId}.devices.${devUid}.${topicResolved?.deviceId}`;
409
-
410
- default:
411
- return message;
443
+ async getChirpstackObjectDirectory(topic,message,resolvetype){
444
+ const activeFunction = "getChirpstackObjectDirectory";
445
+ try{
446
+ this.adapter.log.silly(`directory ${resolvetype} is requested for chirpstack`);
447
+ const topicResolved = this.getTopicResolved(topic);
448
+ let devUid = undefined;
449
+ if(topicResolved?.messageType === "up"){
450
+ devUid = message.deviceInfo.devEui;
451
+ }
452
+ else if(topicResolved?.messageType === "down")
453
+ {
454
+ devUid = message.devEui;
455
+ }
456
+ this.adapter.log.warn("DEV UID: " + devUid);
457
+ if(devUid !== undefined){
458
+ if(typeof message !== "string"){
459
+ switch(resolvetype){
460
+ case this.searchableAttributeNames.deviceId:
461
+ this.adapter.log.warn(await this.getChirpstackAttributValue(topic,message,this.searchableAttributeNames.deviceId));
462
+ return `${topicResolved?.applicationId}.devices.${devUid}.${await this.getChirpstackAttributValue(topic,message,this.searchableAttributeNames.deviceId)}`; // Hier muss die device id rein. (mussnoch mit async geholt werden)
463
+
464
+ default:
465
+ return message;
466
+ }
467
+ }
468
+ else{
469
+ return message;
412
470
  }
413
471
  }
414
472
  else{
415
- return message;
473
+ this.adapter.log.warn(`no devEui found in message`);
474
+ this.adapter.log.warn(`message: ${message}`);
416
475
  }
417
476
  }
418
- else{
419
- this.adapter.log.warn(`no devEui found in message`);
420
- this.adapter.log.warn(`message: ${message}`);
477
+ catch(error){
478
+ this.adapter.log.error(`error at ${activeFunction}: ` + error);
479
+ this.adapter.log.warn("Message: " + JSON.stringify(message));
421
480
  }
422
481
  }
423
482
 
424
483
  /*********************************************************************
425
- * ************************ Object Directory *************************
484
+ * ************************ Resolved Topic ***************************
426
485
  * ******************************************************************/
427
486
 
428
487
  getChirpstackTopicResolved(topic){
429
- const topicElements = topic.split("/");
430
- const topicResolved = {
431
- applicationId: topicElements[1],
432
- deviceUid: topicElements[3],
433
- messageType: topicElements[topicElements.length - 1]
434
- };
435
- // clean up application id
436
- const indexOfOrigin = topicResolved.applicationId.indexOf("@");
437
- if(indexOfOrigin !== -1){
438
- topicResolved.applicationId = topicResolved.applicationId.substring(0,indexOfOrigin);
488
+ const activeFunction = "getChirpstackTopicResolved";
489
+ try{
490
+ const topicElements = topic.split("/");
491
+ const topicResolved = {
492
+ applicationId: topicElements[1],
493
+ deviceUid: topicElements[3],
494
+ messageType: topicElements[topicElements.length - 1]
495
+ };
496
+ // clean up application id
497
+ const indexOfOrigin = topicResolved.applicationId.indexOf("@");
498
+ if(indexOfOrigin !== -1){
499
+ topicResolved.applicationId = topicResolved.applicationId.substring(0,indexOfOrigin);
500
+ }
501
+ return topicResolved;
502
+ }
503
+ catch(error){
504
+ this.adapter.log.error(`error at ${activeFunction}: ` + error);
505
+ this.adapter.log.warn("Topic: " + JSON.stringify(topic));
439
506
  }
440
- return topicResolved;
441
507
  }
442
508
  }
443
509
 
@@ -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,24 @@ 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
+ const topic = "application/d63c10b6-9263-4ab3-9299-4308fa19a2ad/device/a84041f621857cd2/command/down";
71
+ const message = {"devEui":"a84041f621857cd2","confirmed":false,"fPort":1,"data":"AQAqMA=="};
72
+ await this.messagehandler?.handleMessage(topic, message);
73
+ }
62
74
  /**
63
75
  * Is called when adapter shuts down - callback has to be called under any circumstances!
64
76
  * @param {() => void} callback
@@ -176,7 +188,6 @@ class Lorawan extends utils.Adapter {
176
188
 
177
189
  async writeNextSend(startDirectory,payloadInHex){
178
190
  const idFolder = `${startDirectory}.${this.messagehandler?.directoryhandler.directoryStructur.downlinkNextSend}`;
179
- this.log.warn(payloadInHex);
180
191
  await this.setStateAsync(`${idFolder}.hex`,payloadInHex,true);
181
192
  }
182
193
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "iobroker.lorawan",
3
- "version": "0.0.13",
3
+ "version": "0.0.15",
4
4
  "description": "converts the desired lora gateway data to a ioBroker structure",
5
5
  "author": {
6
6
  "name": "BenAhrdt",