LBLEAdvertisementData
This helper class helps to configure and parse BLE GAP advertisement packets.
BLE peripherals advertises information about their capabilities and other information in advertisement packets. The packet is of finite length, but the format is very flexible.
This class helps you to create several common advertisement formats, e.g. ibeacon:
LBLEAdvertisementData beaconData;
// This is a common AirLocate example UUID.
LBLEUuid uuid("E2C56DB5-DFFB-48D2-B060-D0F5A71096E0");
beaconData.configAsIBeacon(uuid, 01, 02, -40);You can then simply call LBLEPeripheral.advertise to start advertise.
Constructors
LBLEAdvertisementData()
Creates an LBLEAdvertisementData instance.
Syntax
Parameters
none
Returns
none
Methods
configAsConnectableDevice()
configAsEddystoneURL()
configAsIBeacon()
Create an advertisement that allows BLE centrals, e.g. smartphones, to connect to this device.
This methods RESETS all the advertisement data fields
Note that you need to define corresponding GATT services with LBLEPeripheral before start advertising your device.
Syntax
Parameters
deviceName: must be shorter than 27 bytes.
serviceUUID: service UUID to be included in advertisement.
Returns
none
Configure an Eddystone URL Note that total length must not exceed 17 bytes.
Syntax
advData.configAsEddystoneURL(prefix, url, suffix, tail);
Parameters
You can use prefix, suffix, and tail parameters to compress common URL parts to a single byte. e.g. "https://www.mediatek.com" => configAsEddystoneURL(EDDY_HTTPS_WWW, "mediatek", EDDY_DOT_COM) e.g. "https://www.asp.net/learn" => configAsEddystoneURL(EDDY_HTTPS_WWW, "asp", EDDY_DOT_NET_SLASH, "learn")
Please refer to https://github.com/google/eddystone/tree/master/eddystone-url#url-scheme-prefix to know how the prefix/suffix/tails are expanded.
Returns
none
Create an iBeacon advertisement.
This methods RESETS all the advertisement data fields and replace them with iBeacon format (flag + manufacturer data)
if you don't know which UUID to use, use LBLEUuid("74278BDA-B644-4520-8F0C-720EAF059935"), since this is the UUID used by iOS AirLocate example. (https://developer.apple.com/library/content/samplecode/AirLocate/Introduction/Intro.html)
major, minor, and txPower are all user defined values.
Syntax
Parameters
uuid: UUID of the iBeacon device. if you don't know which UUID to use, use LBLEUuid("74278BDA-B644-4520-8F0C-720EAF059935"), since this is the UUID used by iOS AirLocate example. (https://developer.apple.com/library/content/samplecode/AirLocate/Introduction/Intro.html)
major: user-defined values for the iBeacon
minor: user-defined values for the iBeacon
txPower: user-defined TxPower values for the iBeacon - usually a value that can be calibrated for central devices to estimate distance to the beacon.
Returns
none
Last updated