Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The simplest method of getting occupancy status from 1 and 2 is shown in the following Java Script code example:

Expand
titleJavaScript code example

The first example is for cases when the payload type is string (Nwave HTTP Calls for example):

Code Block
languagejs
payload = "E91F345678"

// cut out 1st byte and convert to integer
first_byte = parseInt(payload.slice(0,2), 16)

// the sensor is occupied if 1st bit is 1
occupied = Boolean(first_byte & 0x01 === 1)

console.log("Occupied: ", occupied);

The second example is for cases when the payload type is array of integers (TTN, TTI for example):

Code Block
languagejs
payload = [0xE9, 0x1F, 0x34, 0x56, 0x78]

// the sensor is occupied if 1st bit of the first byte is 1
occupied = Boolean(payload[0] & 0x01 === 1)

console.log("Occupied: ", occupied);
Info

You can also refer to our Java Script payload decoder shared on the Github.

Examples of decoded messages are available on the TTN device page.

Please refer to the sections below for detailed information on message payload structure.

...


The parking status message uses port 1 and is confirmed by default. It may be configured as unconfirmed with or without repetitions (see downlink messages).

Byte

Bits

Name

0

0

Parking status

0: Free parking space

1: Occupied parking space

7..1

Compressed duration of the previous status

...