# Adeunis FTD TTNMAPPER java script

**URL:** <https://www.thethingsnetwork.org/forum/t/adeunis-ftd-ttnmapper-java-script/52864>\
**Category:** The Things Stack v3\
**Tags:** ttn-mapper\
**Created:** [November 2, 2021, 3:13pm UTC](https://www.thethingsnetwork.org/forum/t/adeunis-ftd-ttnmapper-java-script/52864 "2021-11-02T15:13:51Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![AW\_DWW](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/aw_dww/32/35697_2.png) [@AW\_DWW](https://www.thethingsnetwork.org/forum/u/AW_DWW)\
**Post date:** [November 2, 2021, 3:13pm UTC](https://www.thethingsnetwork.org/forum/t/adeunis-ftd-ttnmapper-java-script/52864/1 "2021-11-02T15:13:51Z")

</div>

Hi,

I migrated my gateway TTIG and the adeunis FTP from v2 to v3 and I’m able to see the live data from the FTD.

I setup the app with the java script (not from me designed) from

> <https://github.com/fikalab/ttn-decoders/blob/master/adeunis-field-tester.js>

adapted to V3 prerequisites for sending data to TTNmapper as I did in v2:

* * *

// TTN decoder function for the Adeunis Field Test Device LoRaWAN  
// [Test IoT network coverage: Sigfox, LoRaWAN | Adeunis](https://www.adeunis.com/en/produit/ftd-868-915-2/)

```auto

function decodeUplink(input,port) {
  var data = {};
  
  
  var offset = 0;
  if (offset + 1 <= input.bytes.length) {
    var status = input.bytes[offset++]; // bitmask indicating the presence of the other fields
    if (status & 0x80 && offset + 1 < input.bytes.length) {
      // Temperature information (degree Celsius)
      var temperature = input.bytes[offset];
      if (temperature > 127) {
        temperature = temperature - 256;
      }
      data.temperature = temperature;
      offset += 1;
    }
    if (status & 0x40) {
      // Transmission triggered by the accelerometer
      data.trigger = "accelerometer";
    }
    if (status & 0x20) {
      // Transmission triggered by pressing the pushbutton
      data.trigger = "pushbutton";
    }
    if (status & 0x10 && offset + 9 <= input.bytes.length) {
      // GPS information
      var latDeg10 = input.bytes[offset] >> 4;
      var latDeg1 = input.bytes[offset] & 0x0f;
      var latMin10 = input.bytes[offset + 1] >> 4;
      var latMin1 = input.bytes[offset + 1] & 0x0f;
      var latMin01 = input.bytes[offset + 2] >> 4;
      var latMin001 = input.bytes[offset + 2] & 0x0f;
      var latMin0001 = input.bytes[offset + 3] >> 4;
      var latSign = input.bytes[offset + 3] & 0x01 ? -1 : 1;
      data.latitude = latSign * (latDeg10 * 10 + latDeg1 + (latMin10 * 10 + latMin1 + latMin01 * 0.1 + latMin001 * 0.01 + latMin0001 * 0.001) / 60);
      var lonDeg100 = input.bytes[offset + 4] >> 4;
      var lonDeg10 = input.bytes[offset + 4] & 0x0f;
      var lonDeg1 = input.bytes[offset + 5] >> 4;
      var lonMin10 = input.bytes[offset + 5] & 0x0f;
      var lonMin1 = input.bytes[offset + 6] >> 4;
      var lonMin01 = input.bytes[offset + 6] & 0x0f;
      var lonMin001 = input.bytes[offset + 7] >> 4;
      var lonSign = input.bytes[offset + 7] & 0x01 ? -1 : 1;
      data.longitude = lonSign * (lonDeg100 * 100 + lonDeg10 * 10 + lonDeg1 + (lonMin10 * 10 + lonMin1 + lonMin01 * 0.1 + lonMin001 * 0.01) / 60);
      data.altitude = 0; // altitude information not available
      data.sats = input.bytes[offset + 8] & 0x0f; // number of satellites
      offset += 9;
    }
    if (status & 0x08 && offset + 1 <= input.bytes.length) {
      // Uplink frame counter
      data.uplink = input.bytes[offset];
      offset += 1;
    }
    if (status & 0x04 && offset + 1 <= input.bytes.length) {
      // Downlink frame counter
      data.downlink = input.bytes[offset];
      offset += 1;
    }
    if (status & 0x02 && offset + 2 <= input.bytes.length) {
      // Battery level information (mV)
      data.battery = input.bytes[offset] << 8 | input.bytes[offset + 1];
      offset += 2;
    }
    if (status & 0x01 && offset + 2 <= input.bytes.length) {
      // RSSI (dBm) and SNR (dB) information
      data.rssi = - input.bytes[offset];
      var snr = input.bytes[offset + 1];
      if (snr > 127) {
        snr = snr - 256;
      }
      data.snr = snr;
      offset += 2;
    }
  }
 return {
    data: data
  };
    
}
*************

```

I see then in live data the decoded payload but it is not forwarded to the webkooks.

Error msg: Failed to send to webhook, Error:undefined, undefined.

Any idea or help?Thx for any help in advance.

br AW  
 ![image](https://www.thethingsnetwork.org/forum/uploads/default/original/3X/6/a/6a8bd8d013f7d0c514bdacd28617baf3056d6dce.png)

---

<div class="post-metadata">

**Author:** ![descartes](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/descartes/32/47220_2.png) [@descartes](https://www.thethingsnetwork.org/forum/u/descartes)\
**Post date:** [November 3, 2021, 11:40am UTC](https://www.thethingsnetwork.org/forum/t/adeunis-ftd-ttnmapper-java-script/52864/2 "2021-11-03T11:40:08Z")

</div>

Given the Rolls Royce / premium price of the product, it would seem unusual for Adeunis not to have released an updated JS formatter along with instructions.

But now you’ve got the formatter working (which I formatted as per [guidelines](https://www.thethingsnetwork.org/forum/t/how-do-i-format-my-forum-post-howto/8735)) it would be good to see what you have setup for your webhook - as a minimum you need to give it a working URL (ie one that works in a web browser) and click a tick against at least one of the message types.

I’ve seen only one other instance of triggering an error with a Webhook - it may be the destination server is having issues.

---

<div class="post-metadata">

**Author:** ![AW\_DWW](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/aw_dww/32/35697_2.png) [@AW\_DWW](https://www.thethingsnetwork.org/forum/u/AW_DWW)\
**Post date:** [November 3, 2021, 12:06pm UTC](https://www.thethingsnetwork.org/forum/t/adeunis-ftd-ttnmapper-java-script/52864/3 "2021-11-03T12:06:51Z")

</div>

I just update the ADEUNIS JS formater from the version from V2. They don’t offer a new one for v3, or I was unable to found it.

Here the settings of the TTNMAP webhook.

Thx aw

![image](https://www.thethingsnetwork.org/forum/uploads/default/original/3X/7/2/721862ed9c3146177113ad8e35689370cc78f107.png)  
 ![image](https://www.thethingsnetwork.org/forum/uploads/default/original/3X/e/3/e309793e814f4bc7572ab285d78bd4a8cac038a6.png)

---

<div class="post-metadata">

**Author:** ![AW\_DWW](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/aw_dww/32/35697_2.png) [@AW\_DWW](https://www.thethingsnetwork.org/forum/u/AW_DWW)\
**Post date:** [November 3, 2021, 6:34pm UTC](https://www.thethingsnetwork.org/forum/t/adeunis-ftd-ttnmapper-java-script/52864/4 "2021-11-03T18:34:36Z")

</div>

Hi, I added to the TTNMAPPER webhook header and name for an experiment and now it works even when the error msg ‘failed to send to webhook, Error:undefined,undefined’ is still there in the live data. Br, AW

---

<div class="post-metadata">

**Author:** ![descartes](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/descartes/32/47220_2.png) [@descartes](https://www.thethingsnetwork.org/forum/u/descartes)\
**Post date:** [September 26, 2023, 10:10am UTC](https://www.thethingsnetwork.org/forum/t/adeunis-ftd-ttnmapper-java-script/52864/6 "2023-09-26T10:10:54Z")

</div>

Not relevant to the topic and a double post - please don’t.

---

<div class="post-metadata">

**Author:** ![descartes](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/descartes/32/47220_2.png) [@descartes](https://www.thethingsnetwork.org/forum/u/descartes)\
**Post date:** [September 26, 2023, 10:10am UTC](https://www.thethingsnetwork.org/forum/t/adeunis-ftd-ttnmapper-java-script/52864/7 "2023-09-26T10:10:57Z")

</div>


