Hi,
I have been using nRF51822 with my Android app using Android's Bluetooth Low-Energy APIs. In order to get more details, I am currently working on integrating the Android Beacon Library (altbeacon.github.io/.../index.html). By default The library can only detect devices that support the AltBeacon standard. For other devices it is required to add a Beacon Parser (github.com/.../BeaconParser.java). I would like to add a parser for the off-the-shelf nRF51822.
Below is the documentation of the setLayout method of the BeaconParser: Thanks,
"Defines a beacon field parsing algorithm based on a string designating the zero-indexed
offsets to bytes within a BLE advertisement.
If you want to see examples of how other folks have set up BeaconParsers for different
kinds of beacons, try doing a Google search for "getBeaconParsers" (include the quotes in
the search.)
Four prefixes are allowed in the string:
m - matching byte sequence for this beacon type to parse (one allowed)
i - identifier (multiple allowed)
p - power calibration field (one allowed)
d - data field (multiple allowed)
Each prefix is followed by a colon, then an inclusive decimal byte offset for the field from
the beginning of the advertisement. In the case of the m prefix, an = sign follows the byte
offset, followed by a big endian hex representation of the bytes that must be matched for
this beacon type. When multiple i or d entries exist in the string, they will be added in
order of definition to the identifier or data array for the beacon when parsing the beacon
advertisement. Terms are separated by commas.
All offsets from the start of the advertisement are relative to the first byte of the
two byte manufacturer code. The manufacturer code is therefore always at position 0-1
If the expression cannot be parsed, a BeaconLayoutException
is thrown.
Example of a parser string for AltBeacon:
"m:2-3:beac,i:4-19,i:20-21,i:22-23,p:24-24,d:25-25"
This signifies that the beacon type will be decoded when an advertisement is found with
0xbeac in bytes 2-3, and a three-part identifier will be pulled out of bytes 4-19, bytes
20-21 and bytes 22-23, respectively. A signed power calibration value will be pulled out of
byte 24, and a data field will be pulled out of byte 25.
Note: bytes 0-1 of the BLE manufacturer advertisements are the two byte manufacturer code.
Generally you should not match on these two bytes when using a BeaconParser, because it will
limit your parser to matching only a transmitter made by a specific manufacturer. Software
and operating systems that scan for beacons typically ignore these two bytes, allowing beacon
manufacturers to use their own company code assigned by Bluetooth SIG. The default parser
implementation will already pull out this company code and store it in the
beacon.mManufacturer field. Matcher expressions should therefore start with "m2-3:" followed
by the multi-byte hex value that signifies the beacon type."