-
Notifications
You must be signed in to change notification settings - Fork 0
/
beacon.cpp
32 lines (30 loc) · 874 Bytes
/
beacon.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include "pxt.h"
#include "BluetoothBeaconService.h"
using namespace pxt;
/**
* A set of functions to advertise beacon with Bluetooth
*/
namespace bluetooth
{
BluetoothBeaconService *pBeaconInstance = nullptr;
BluetoothBeaconService *getBeaconService()
{
if (pBeaconInstance == nullptr)
{
pBeaconInstance = new BluetoothBeaconService(uBit.ble);
}
return pBeaconInstance;
}
//%
void advertiseIBeacon(StringData *uuid, uint16_t major, uint16_t minor, int8_t calibratedPower)
{
ManagedString uuidStr(uuid);
getBeaconService()->advertiseIBeacon(uuidStr, major, minor, calibratedPower);
}
//%
void advertiseAltBeacon(uint16_t manufacturerId, BufferData *beaconId, int8_t refRSSI, uint8_t reserved)
{
ManagedBuffer beaconIdBuffer(beaconId);
getBeaconService()->advertiseAltBeacon(manufacturerId, beaconIdBuffer, refRSSI, reserved);
}
}