Versions Compared

Key

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

Table of Contents

Introduction

TG-BT5-XX tags can operate in 4 different modes:

...

"AdvData" field structure (max 31 octets/bytes):

Lengthlength of the payload1 octet (15)
Typemanufacturer specific data1 octet (ff)
ManufacturerDatacompany identifier
4
2 octets (
15FF4F09
4F09)
Versionthe version of this advertisement structure1 octet (uint)
UserDatauser-configured part of the payload

1 octet (uint)

Secretoptionally encrypted (AES-ECB) part of the payload
  • secret: salt (for encryption) = 2 octets (uint)
  • secret: acceleration (acceleration in signed 8.8 fixed point format - acceleration of all 3 axis (0=x, 1=y, 2=z)) = 6 octets (uint)
  • secret: temperature (ambient temperature in Celsius in signed 8.8 fixed point format) = 2 octet (int)
  • secret: uptime (uptime in seconds) = 4 octets (uint)
  • secret: flags (bit-mask of flags) = 1 octet (uint)
  • secret: batteryPercentage (battery level in percent) = 1 octet (uint)


Info

Please note that all multi-byte values are in little-endian. Meaning, that if, for example, you want to get the temperature value and #14 and #15 octets indicate the temperature as "a1 19" ("plus" temperature) → the real temperature value is going to be (0x19a1)/256 = 25.6 C.

...

MikroTik PDU Payload structure

015ManufacturerDataLengthlength of the payloadcompany identifier
1FFManufacturerDataTypemanufacturer specific datacompany identifier
24FManufacturerDataCompany identifiercompany identifierMikroTik
309ManufacturerDataCompany identifiercompany identifierMikroTik
401Versionthe version of this advertisement structure
500UserDatauser-configured part of the payload
6xx*Secretsecret: salt
7xx*Secretsecret: salt
8xx*Secretsecret: acceleration on the X-axis
9xx*Secretsecret: acceleration on the X-axis
10xx*Secretsecret: acceleration on the Y-axis
11xx*Secretsecret: acceleration on the Y-axis
12xx*Secretsecret: acceleration on the Z-axis
13xx*Secretsecret: acceleration on the Z-axis
14xx*Secretsecret: temperature
15xx*Secretsecret: temperature
16xx*Secretsecret: uptime
17xx*Secretsecret: uptime
18xx*Secretsecret: uptime
19xx*Secretsecret: uptime
2000Secretsecret: flags
2164xx*Secretsecret: batteryPercentage

...

  • - can vary

Example

An example of the payload configured in MikroTik's format (non-encrypted) would be:

...

15ff4f09 (first 4 octets) ManufacturerData. Is the same (constant data) for every MikroTik format's payloadLength (0x15 hex-to-dec is 21). Type (0xff). Company identifier (0x4f09).

01 (5th 4th octet)Current version of the payload's structure. Should be the same for every payload (constant data).

00 (6th 5th octet) → Indicates that the payload is not encrypted. "01" would mean it is encrypted.

cea6 (6th and 7th and 8th octets) → data used for encryptionSalt. Each new payload should have a different salt value generated. You can use this value to check whether the identical payloads are encrypted differently. The value itself does not contain any useful information. If you see that the salt value is identical for two payloads received during different time intervals, it would mean that the two payloads received are exactly identical. You can calculate the salt value using the same principle that applies to the uptime calculation (17th to 20th octets) - see below.

0000 (8th and 9th and 10th octets) → acceleration on the X-axis at the moment of the broadcast = 0 m/s2. Check acceleration calculation for the Z-axis below.

0000 (10th and 11th and 12th octets) → acceleration on the Y-axis at the moment of the broadcast = 0 m/s2. Check acceleration calculation for the Z-axis below.

0200 (12th and 13th and 14th octets) → acceleration on the Z-axis at the moment of the broadcast = 0.0078 m/s2. To get the decimal value out of the hex format you will need to follow the steps:

  • As noted before, multi-byte values are in little-endian and that means, to calculate the realm value, you will need to switch octets places (switch octets order). So the first step is to swap places for the values from 0x0200 to 0x0002. 0x0002 converted from hexadecimal to decimal is 02.
  • Keep in mind that acceleration is in signed 8.8 fixed point format (two's complement) and that means that you basically need to divide the result by "256". The second step is to divide the value by 256 → (0x0002 hex or 02 dec)/256 = 0.0078 m/s2.
  • The same calculation principle applies to the acceleration for the X and Y-axis. In our example, they just happen to be 0 → 0x0000/256=0.

a01c (14th and 15th and 16th octets) → temperature detected by the tag in Celsius = 28.625 C. Temperature is in little-endian (as it is a multi-byte value) and it is insigned 16-bit integer [twos complement] 8.8 fixed point format, so so the same "formula" applies here as well:

  • 0x1ca0/256=28.625 C.

91085700 (17th 16th to 20th19th octets) → tag's uptime in seconds = 5703825 s. 0x91085700 is in little-endian, so just swap the octets to 0x00570891 and the result is 5703825 in decimal. That is 1584.395833 hours or66-day uptime.

00 (21st 20th octet) → trigger (flag) that sent the payload. If it is "00" it means that no trigger was detected and that it is just a periodically broadcasted payload (based on the advertisement interval configured for the tag). If the value would be "04" it would mean that the device was dropped (freefalling triggered). You can find more information on the "flags" and the "Secret" section above in the packet structure section.

5f (22nd 21st octet) → battery percentage of the tag = 95 %. 0x5f from hex to dec is95.

Info

Starting with v7.11, you can use the Peripheral Device section or/and Decode-ad feature to view decoded values!

Script for decoding

Add a new script under the "System>Scripts" tab and import the script there (for non-encrypted payloads).

...

01aManufacturerDatacompany identifier
1ffManufacturerDatacompany identifier
24cManufacturerDatacompany identifier
300ManufacturerDatacompany identifier
402BeaconTypea secondary identifier
51521RemainingDataLengthdefines the remaining length for the payload in bytes
6b2xx*UserDataProximity UUID
7b9xx*UserDataProximity UUID
88dxx*UserDataProximity UUID
9e4xx*UserDataProximity UUID
10c8xx*UserDataProximity UUID
111cxx*UserDataProximity UUID
1247xx*UserDataProximity UUID
13c2xx*UserDataProximity UUID
14b1xx*UserDataProximity UUID
154exx*UserDataProximity UUID
1679xx*UserDataProximity UUID
171bxx*UserDataProximity UUID
183exx*UserDataProximity UUID
1955xx*UserDataProximity UUID
2087xx*UserDataProximity UUID
21ecxx*UserDataProximity UUID
22xx*UserDataMajor Number
23xx*UserDataMajor Number
24xx*UserDataMinor Number
25xx*UserDataMinor Number
26xx*TxPowerindicates the signal strength at one meter from the device

...

003CommonPayloadCompleteUUID
103CommonPayloadCompleteUUID
2aaCommonPayloadCompleteUUID
3feCommonPayloadCompleteUUID
417CommonPayloadServiceData
516CommonPayloadServiceData
6aaCommonPayloadServiceData
7feCommonPayloadServiceData
800CommonPayloadFrameType
9xx*UidPayloadRanging Data
10b2xx*UidPayloadNspace
11b9xx*UidPayloadNspace
128dxx*UidPayloadNspace
13e4xx*UidPayloadNspace
14c8xx*UidPayloadNspace
151cxx*UidPayloadNspace
1647xx*UidPayloadNspace
17c2xx*UidPayloadNspace
18b1xx*UidPayloadNspace
194exx*UidPayloadNspace
20xx*UidPayloadInstance
21xx*UidPayloadInstance
22xx*UidPayloadInstance
23xx*UidPayloadInstance
24xx*UidPayloadInstance
25xx*UidPayloadInstance
2600UidPayloadRFU1
2700UidPayloadRFU2

...