miro
Alarm

 

Payload Format

1. Overview

The payload of up and downlink messages consists of an arbitrary number of data structs (DS) of different types and lengths.

DS 1 DS 2 …​ DS n

Each data struct is a combination of a header and the actual data payload:

L T payload

The header consits of two fields:

Field Description

L

Length of data struct, 1 byte, not including the length byte itself

T

Data struct type, 1 byte

1.1. Data Encoding

Unless otherwise noted, payloads will use big endian data encoding.

2.1. Regular Status Message

The device sends a regular status messages at a configurable interval. The content of the status message consists of three messages:

  • Battery Message

  • Current Scene Message

  • BatteryVoltage Message

An additional purpose of the status message is to allow reception of downlink messages if the network server does not support class C.

2.2. Battery

The battery message type is used to get information about the battery usage.

Message type T = 0x02 and length L = 0x04.

Byte Size Description Format

0

1

Message lenght

Byte

1

1

Message type

Byte

2

4

Accu uAh

Word 32 bit

Example 1. Battery

05:02:00:00:00:55

Accu

0x55 uAh

2.3. CurrentScene

The CurrentScene message type is used to get information about the current scene.

Message type T = 0x04 and length L = 0x02.

Byte Size Description Format

0

1

Message lenght

Byte

1

1

Message type

Byte

2

1

Current Scene

Byte

Example 2. CurrentScene

02:04:07

CurrentScene

7

2.4. BatteryVoltage

The BatteryVoltage message type is used to get information about the battery voltage.

Message type T = 0x03 and length L = 0x03.

Byte Size Description Format

0

1

Message lenght

Byte

1

1

Message type

Byte

2

2

Battery Voltage in mV

Word 16bit

Example 3. BatteryVoltage

03:03:0C:E4

BatteryVoltage

3300mV

Downlink messages are used to change the configuration of the device. They use the same general payload format as uplinks.

All downlinks must be sent on the LoRaWAN port 3!

3.1. Device Configuration

The device configuration message type is used to set general device configuration.

Message type T = 0x80 and length L = 0x06.

Byte Size Description Format

0

1

Message lenght

1

1

Message type

2

1

Flags, bitwise or combination:
Bit 7 = Confirmed uplinks (0 = off, 1 = on)
Bit 6 = Duty Cycle (0 = off, 1 = on)
Bit 5 = LoRaWAN Class (0 = A, 1 = C)
Bit 4 = Buzzer (0 = off, 1 = on)
Bits 0-3: RFU

Bitfield

3-4

2

Status interval

uint16, minutes

5

1

Number of LEDs in ring (max 48)

uint8

6

1

Automatic reset time (0 = disabled)

uint8, hours

Example 4. Device Configuration

06:80:40:00:0A:10:0A

Flags

Class C

Status interval

10 minutes

Number of LEDs

16

Reset time

10

3.2. Set Scene

This downlink command is used to set the scene. A scene is a preprogrammed LED color. The same color is set on all LEDs. Optionally, a scene also includes a buzzer melody to be played, either once or on repeat until the scene ends. Only a select few melodies are available. A scene is valid until next scene will be set with another downlink command or until its preconfigured timeout is reached.

Message type T = 0x81 and length L = 0x02:

Byte Size Description Format

0

1

Message length

1

1

Message type

2

1

Scene (0=Off)

0-4

Example 5. Set Scene

02:81:01

Scene

1

3.3. Set Brightness

Set LED brightness.

Message type T = 0x82 and length L = 0x02.

Byte Size Description Format

0

1

Message length

1

1

Message type

2

1

Brightness [0=darkest,255=brightest

uint8

Example 6. Set Brightness

02:82:80

Brightness

128 = 50%

3.4. Set Volume

Set LED volume.

Message type T = 0x85 and length L = 0x02.

Byte Size Description Format

0

1

Message length

1

1

Message type

2

1

Volume [0=off,1=low,2=medium,3=high]

enum

It is recommended to use the buzzer flag instead of setting the volume to 0.
Example 7. Set Volume

02:85:03

Volume

High

3.5. Configure Scene (only LED)

Configure an LED scene by changing its color and timout time.

Message type T = 0x83 and length L = 0x07.

Byte Size Description Format

0

1

Message length

1

1

Message type

2

1

Scene to configure

1-4

3

1

Red value

uint8

4

1

Green value

uint8

5

1

Blue value

uint8

6-7

2

Timeout time of scene (0=no timeout)

uint8, minutes

Example 8. Configure Scene (only LED)

07:83:02:FF:9A:00:00:0A

Scene

2

Red value

0xFF = 255

Green value

0x9A = 154

Blue value

0x00 = 0

Timeout time

10 minutes

The hex color 0xff9a00 is a yellow.

3.6. Configure Scene (LED and Buzzer)

Configure an LED scene by changin its color and timeout time. Additionally configure the buzzer melody for this specific scene.

Message type T = 0x84 and length L = 0x09.

Byte Size Description Format

0

1

Message length

1

1

Message type

2

1

Scene to configure

1-4

3

1

Red value

uint8

4

1

Green value

uint8

5

1

Blue value

uint8

6-7

2

Timeout time of scene (0=no timeout)

uint8, minutes

8

1

Melody:
0 = None
1 = Fast
2 = Medium
3 = Slow
4 = Ascending
5 = DoubleUp
6 = Double+ 7 = Triple

enum

9

1

Repeat [0=disabled,1=unabled]

bool

Example 9. Configure Scene (only LED)

09:84:02:FF:9A:00:00:0A:03:01

Scene

2

Red value

0xFF = 255

Green value

0x9A = 154

Blue value

0x00 = 0

Timeout time

10 minutes

Melody

slow

Repeat

enabled

4. Decoder example

function decodeMiroAlarm(fPort, bytes) {
    // Decode an uplink message from a buffer
    // (array) of bytes to an object of fields.
    var decoded = {};

    if (fPort == 15) {
        n = bytes.length;
        idx = 0;
        while (n > idx) {
            s = bytes[idx++];
            decoded.type = bytes[idx];
            if (bytes[idx] == 4) {
                decoded.current_scene = bytes[idx + 1];
            }
            if (bytes[idx] == 2) {
                decoded.uah = bytes[idx + 1] + (bytes[idx + 2] << 8) + (bytes[idx + 3] << 16) + (bytes[idx + 4] << 24);
            }
            if (bytes[idx] == 3) {
                decoded.battery_v = (bytes[idx + 1] + (bytes[idx + 2] << 8))/1000;
            }
            idx += s;
        }
    }
    return decoded;
}