Bluenet  5.7.0
Bluenet, firmware for nRF52 smart home devices
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
IBeacon Class Reference

Implementation of the iBeacon specification. More...

#include <cs_iBeacon.h>

Collaboration diagram for IBeacon:

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...
 

Detailed Description

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:

  • iBeacon Prefix
  • proximity UUID. An identifier which should be used to distinguish your beacons from others (for a given application, all of your iBeacons share the same UUID), the individual iBeacons are then distinguished by major and minor numbers
  • major (group level identifier, e.g. on the level of a building, unique amongst all nodes with a given proximity UUID)
  • minor (individual nodes, unique amongst all nodes with a given proximity UUID and major number)
  • rssi value (known rssi value at 1m distance, used to calculate actual distance from the iBeacon)

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.

Constructor & Destructor Documentation

◆ IBeacon()

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

Member Function Documentation

◆ getArray()

uint8_t * IBeacon::getArray ( )
inline

◆ getMajor()

uint16_t IBeacon::getMajor ( )

Get major value

◆ getMinor()

uint16_t IBeacon::getMinor ( )

Get minor value.

◆ getTxPower()

int8_t IBeacon::getTxPower ( )

Get RSSI value.

◆ getUUID()

cs_uuid128_t IBeacon::getUUID ( )

Get UUID.

◆ setMajor()

void IBeacon::setMajor ( uint16_t  major)

Set major value.

◆ setMinor()

void IBeacon::setMinor ( uint16_t  minor)

Set minor value.

◆ setTxPower()

void IBeacon::setTxPower ( int8_t  txPower)

Set RSSI value.

◆ setUUID()

void IBeacon::setUUID ( cs_uuid128_t uuid)

Set UUID.

◆ size()

uint8_t IBeacon::size ( )
inline

The size of the iBeacon advertisement data.

size is calculated as: 2B advertisement indicator 16B uuid (as byte array) 2B major 2B minor

1B rssi

23B total

Returns
the size of the advertisement data

Member Data Documentation

◆ 

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.

◆ _buffer

uint8_t IBeacon::_buffer[sizeof(_params)]

Buffer.

◆ 

struct { ... } IBeacon::_params

Individual fields.

◆ adv_indicator

uint16_t IBeacon::adv_indicator

Advertisement indicator, defined as 0x0215 for iBeacons.

◆ major

uint16_t IBeacon::major

Major number (group level identifier)

◆ minor

uint16_t IBeacon::minor

Minor number (individual nodes)

◆ txPower

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.

◆ uuid

cs_uuid128_t IBeacon::uuid

Proximity UUID, shared for all iBeacons for a given application.


The documentation for this class was generated from the following file: