Bluenet
5.7.0
Bluenet, firmware for nRF52 smart home devices
|
Implementation of the iBeacon specification. More...
#include <cs_iBeacon.h>
Public Member Functions | |
IBeacon (cs_uuid128_t uuid, uint16_t major, uint16_t minor, int8_t rssi) | |
Default constructor for the iBeacon class. More... | |
uint8_t | size () |
The size of the iBeacon advertisement data. More... | |
uint8_t * | getArray () |
void | setMajor (uint16_t major) |
Set major value. More... | |
uint16_t | getMajor () |
Get major value More... | |
void | setMinor (uint16_t minor) |
Set minor value. More... | |
uint16_t | getMinor () |
Get minor value. More... | |
void | setUUID (cs_uuid128_t &uuid) |
Set UUID. More... | |
cs_uuid128_t | getUUID () |
Get UUID. More... | |
void | setTxPower (int8_t txPower) |
Set RSSI value. More... | |
int8_t | getTxPower () |
Get RSSI value. More... | |
Private Attributes | |
union { | |
struct { | |
uint16_t adv_indicator | |
Advertisement indicator, defined as 0x0215 for iBeacons. More... | |
cs_uuid128_t uuid | |
Proximity UUID, shared for all iBeacons for a given application. More... | |
uint16_t major | |
Major number (group level identifier) More... | |
uint16_t minor | |
Minor number (individual nodes) More... | |
int8_t txPower | |
Known (calibrated) rssi value at 1m distance. More... | |
} _params | |
Individual fields. More... | |
uint8_t _buffer [sizeof(_params)] | |
Buffer. More... | |
}; | |
Union so that we can directly use the array for the advertisment's manufacturing data. More... | |
Implementation of the iBeacon specification.
The implementation of the iBeacon specification is only about advertising at predefined intervals and casting a payload (the manufacturing data of an advertisement package) in the form of a specific structure:
Note that you might not be able to use this commercially! Although I would be surprised if it is possible to patent a "struct" or the Apple prefix.
IBeacon::IBeacon | ( | cs_uuid128_t | uuid, |
uint16_t | major, | ||
uint16_t | minor, | ||
int8_t | rssi | ||
) |
Default constructor for the iBeacon class.
@uuid the UUID for this application
@major the major value for this iBeacon (group level identifier)
@minor the minor value for this iBeacon (individual node)
@rssi the calibrated rssi value at 1m distance
|
inline |
uint16_t IBeacon::getMajor | ( | ) |
Get major value
uint16_t IBeacon::getMinor | ( | ) |
Get minor value.
int8_t IBeacon::getTxPower | ( | ) |
Get RSSI value.
cs_uuid128_t IBeacon::getUUID | ( | ) |
Get UUID.
void IBeacon::setMajor | ( | uint16_t | major | ) |
Set major value.
void IBeacon::setMinor | ( | uint16_t | minor | ) |
Set minor value.
void IBeacon::setTxPower | ( | int8_t | txPower | ) |
Set RSSI value.
void IBeacon::setUUID | ( | cs_uuid128_t & | uuid | ) |
Set UUID.
|
inline |
union { ... } IBeacon::@4 |
Union so that we can directly use the array for the advertisment's manufacturing data.
Because the advertisement package has to be in big-endian, and nordic's chip is using little-endian, the values are converted in the setter/getter functions, so that the array is correct and doesn't need to be converted anymore to be used in the advertisement data. As a result, changes to the IBeacon values, such as major, minor, etc, will directly reflect in the advertisement data once they are changed here.
uint8_t IBeacon::_buffer[sizeof(_params)] |
Buffer.
struct { ... } IBeacon::_params |
Individual fields.
uint16_t IBeacon::adv_indicator |
Advertisement indicator, defined as 0x0215 for iBeacons.
uint16_t IBeacon::major |
Major number (group level identifier)
uint16_t IBeacon::minor |
Minor number (individual nodes)
int8_t IBeacon::txPower |
Known (calibrated) rssi value at 1m distance.
This value has to be calibrated for each iBeacon so that it represents the signal strength of the iBeacon at 1m distance. The value is then used by a smartphone together with the current rssi reading to calculate the current distance from the iBeacon.
cs_uuid128_t IBeacon::uuid |
Proximity UUID, shared for all iBeacons for a given application.