Search code examples
androidbluetooth-lowenergyaltbeacon

BeaconParser instance issue Android beacon library


I am trying to collect temperature and humidity from beacons, that sends this raw data:

020106 020AFC 0A16 ABFE 70BF01 00DB00DB

where:

0x02 – length (2 bytes)
0x01 – type (flags)
0x06 – value (BIN=00000110)

0x02 -length (2 bytes)
0x0A type («Tx Power Level»)
0xFC – value (DEC =-4)

0x0A – length (10 bytes)
0x16 - type («Service Data - 16-bit UUID»
0xABFE - UUID = FEAB
0x70 – frame type (temperature and humidity)
0xBF – TX@1m
0x01 – TX power

0x00DB – temperature (DEC=219 = 21.9 C)
0x00DB – humidity (DEC – 219= 21.9C)

I am trying to build an instance, but it looks like that it is not correct, WAIDW?

m:9-10=feab, i:11-14, p:6-6, d:14-17

Thank you for your help


Solution

  • Try this:

    "s:0-1=feab,m:2-2=70,i:3-8,p:3-3,d:5-6,d:7-8"

    That expression will:

    • match on a 16 bit service UUID 0xFEAB (which you show)
    • make sure the first byte after the service UUID is 0x70 (which you show). This will ensure it is a temp and humidity frame
    • put the full bytes of the frame into the first identifier field accessible by beacon.getId1() (this is not very useful, but you are required to have at least one identifier field for your beacon parser)
    • put the raw temperature value into the first data field accessible by beacon.beacon.getDataFields().get(0)
    • put the raw humidity value into the second data field accessible by beacon.beacon.getDataFields().get(1)