How to get Ruuvi Tag Advertisement readable / ionic / typescript / cordova

Hi all,

i am trying to read out the advertisement of a ruuvi tag with android. I am building an application with ionic 4 and cordova. Program language is typescript/angular.

I receive the advertisement like this:

Discovered {
  "address": "CB:CF:3F:44:40:BB",
  "name": null,
  "rssi": -59,
  "advertisement": "AgEGEf+ZBANSGULHEv/6/9gEBQyRAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=",
  "status": "scanResult"
}

Then i encode the string to byte (unit8Array):

0: 2
1: 1
2: 6
3: 17
4: 255
5: 153
6: 4
7: 3
8: 82
9: 25
10: 66
11: 199
12: 18
13: 255
14: 250
15: 255
16: 216
17: 4
18: 5
19: 12
20: 145
21: 0
22: 0
23: 0
24: 0
25: 0
26: 0
27: 0
28: 0
29: 0
30: 0
31: 0
32: 0
33: 0
34: 0
35: 0
36: 0
37: 0
38: 0
39: 0
40: 0
41: 0
42: 0
43: 0
44: 0
45: 0
46: 0
47: 0
48: 0
49: 0
50: 0
51: 0
52: 0
53: 0
54: 0
55: 0
56: 0
57: 0
58: 0
59: 0
60: 0
61: 0

How can i interprete these data?

Hello,

I’m not familiar with Ionic or Cordova, but it seems that your application gives you the largest possible payload, with advertisement and scan response for a total of 31 + 31 bytes.

The 0x02 01 06 is a mandatory header in BLE advertisement packet, it means
02 -> 2 bytes of data (type, payload, not counting length byte)
01 -> With the type of Flags
06 -> LE General Discoverable Mode (2) + BR/EDR not supported. (4)

The 0x11 FF 99 04 is manufacturer specific data header, it means
11 -> 17 bytes of data, including header, not including length byte
FF -> Manufacturer specific data
99 04 -> Little endian, is actually 0499. Ruuvi Innovations BLE SIG number.

Rest of the data is Ruuvi format 3, full description of data format is here.

Trailing NULLs are given to you by the application and are not sent by RuuviTag

You might also be interested in @io53’s Javascript/Node parser: https://github.com/io53/node-ruuvitag

I think i understand what to do, but i am not able to do this with typescript. I have no idea how …

I once toyed around with doing a desktop app with Angular and Electron, and later abandoned the project as the bluetooth library Noble is not very reliable across different platforms.

Anyway, the parsers I wrote are at https://github.com/ojousima/ojousima.ruuvi_endpoints.ts ,
essentially the parsers take a look into first data payload byte (check src/index.ts) and then return a parsers for the given data format