correct beacon, wrap up advertising
This commit is contained in:
1 parent
eef021aec6
commit
4101f96a2f
6 files changed
+18
-16
No files matched your search
@@ -17,10 +17,11 @@
|
||||
// 0x004C is Apple
|
||||
#define MANUFACTURER_ID 0x004C
|
||||
|
||||
// AirLocate UUID: E2C56DB5-DFFB-48D2-B060-D0F5A71096E0
|
||||
uint8_t beaconUuid[16] =
|
||||
{
|
||||
0x01, 0x12, 0x23, 0x34, 0x45, 0x56, 0x67, 0x78,
|
||||
0x89, 0x9A, 0xAB, 0xBC, 0xCD, 0xDE, 0xEF, 0xF0
|
||||
0xE2, 0xC5, 0x6D, 0xB5, 0xDF, 0xFB, 0x48, 0xD2,
|
||||
0xB0, 0x60, 0xD0, 0xF5, 0xA7, 0x10, 0x96, 0xE0,
|
||||
};
|
||||
|
||||
// uuid, major, minor, rssi @1m
|
||||
@@ -48,6 +49,8 @@ void setupAdv(void)
|
||||
{
|
||||
Bluefruit.Advertising.setBeacon(beacon);
|
||||
|
||||
char* adv = Bluefruit.Advertising.getData();
|
||||
|
||||
// There is no room for Name in Advertising packet
|
||||
// Use Scan response for Name
|
||||
Bluefruit.ScanResponse.addName();
|
||||
|
||||
@@ -171,10 +171,9 @@ uint8_t BLEAdvertising::count(void)
|
||||
return _count;
|
||||
}
|
||||
|
||||
uint8_t BLEAdvertising::getData(uint8_t* buffer)
|
||||
char* BLEAdvertising::getData(void)
|
||||
{
|
||||
memcpy(buffer, _data, _count);
|
||||
return _count;
|
||||
return (char*) _data;
|
||||
}
|
||||
|
||||
bool BLEAdvertising::setData(uint8_t const * data, uint8_t count)
|
||||
|
||||
@@ -76,7 +76,7 @@ public:
|
||||
|
||||
// Custom API
|
||||
uint8_t count(void);
|
||||
uint8_t getData(uint8_t* buffer);
|
||||
char* getData(void);
|
||||
bool setData(const uint8_t* data, uint8_t count);
|
||||
void clearData(void);
|
||||
|
||||
|
||||
@@ -421,7 +421,7 @@ void adafruit_soc_task(void* arg)
|
||||
{
|
||||
case NRF_EVT_FLASH_OPERATION_SUCCESS:
|
||||
case NRF_EVT_FLASH_OPERATION_ERROR:
|
||||
PRINT_INT(soc_evt);
|
||||
// PRINT_INT(soc_evt);
|
||||
if (hal_flash_event_cb) hal_flash_event_cb(soc_evt);
|
||||
break;
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ void BLEBeacon::_init(void)
|
||||
_manufacturer_id = 0x004C; // default Apple --> iBeacon
|
||||
_uuid128 = NULL;
|
||||
|
||||
_major = _minor = 0;
|
||||
_major_be = _minor_be = 0;
|
||||
_rssi_at_1m = -54;
|
||||
}
|
||||
|
||||
@@ -60,8 +60,8 @@ BLEBeacon::BLEBeacon(uint8_t const uuid128[16], uint16_t major, uint16_t minor,
|
||||
{
|
||||
_init();
|
||||
_uuid128 = uuid128;
|
||||
_major = major;
|
||||
_minor = minor;
|
||||
_major_be = __swap16(major);
|
||||
_minor_be = __swap16(minor);
|
||||
_rssi_at_1m = rssi;
|
||||
}
|
||||
|
||||
@@ -77,8 +77,8 @@ void BLEBeacon::setUuid(uint8_t const uuid128[16])
|
||||
|
||||
void BLEBeacon::setMajorMinor(uint16_t major, uint16_t minor)
|
||||
{
|
||||
_major = major;
|
||||
_minor = minor;
|
||||
_major_be = major;
|
||||
_minor_be = minor;
|
||||
}
|
||||
|
||||
void BLEBeacon::setRssiAt1m(int8_t rssi)
|
||||
@@ -112,8 +112,8 @@ bool BLEBeacon::start(BLEAdvertising& adv)
|
||||
.beacon_type = 0x02,
|
||||
.beacon_len = sizeof(beacon_data) - 4, // len of uuid + major + minor + rssi
|
||||
.uuid128 = { 0 },
|
||||
.major = _major,
|
||||
.minor = _minor,
|
||||
.major = _major_be,
|
||||
.minor = _minor_be,
|
||||
.rssi_at_1m = _rssi_at_1m
|
||||
};
|
||||
|
||||
|
||||
@@ -48,8 +48,8 @@ class BLEBeacon
|
||||
private:
|
||||
uint16_t _manufacturer_id;
|
||||
uint8_t const* _uuid128;
|
||||
uint16_t _major;
|
||||
uint16_t _minor;
|
||||
uint16_t _major_be; // Big Endian
|
||||
uint16_t _minor_be; // Big Endian
|
||||
int8_t _rssi_at_1m;
|
||||
|
||||
void _init(void);
|
||||
|
||||
Reference in new issue
Block a user