mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-03-24 22:43:35 +00:00
arduino: link UUID to iBeacon Advertisement and free it together
This commit is contained in:
parent
a0a5d73f40
commit
0e3a0c45a4
@ -374,7 +374,8 @@ BD_ADDR_TYPE BD_ADDR::getAddressType(void){
|
|||||||
BLEAdvertisement::BLEAdvertisement(uint8_t * event_packet) :
|
BLEAdvertisement::BLEAdvertisement(uint8_t * event_packet) :
|
||||||
advertising_event_type(event_packet[2]),
|
advertising_event_type(event_packet[2]),
|
||||||
rssi(event_packet[10]),
|
rssi(event_packet[10]),
|
||||||
data_length(event_packet[11])
|
data_length(event_packet[11]),
|
||||||
|
iBeacon_UUID(NULL)
|
||||||
{
|
{
|
||||||
bd_addr_t addr;
|
bd_addr_t addr;
|
||||||
bt_flip_addr(addr, &event_packet[4]);
|
bt_flip_addr(addr, &event_packet[4]);
|
||||||
@ -382,6 +383,10 @@ data_length(event_packet[11])
|
|||||||
memcpy(data, &event_packet[12], LE_ADVERTISING_DATA_SIZE);
|
memcpy(data, &event_packet[12], LE_ADVERTISING_DATA_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BLEAdvertisement::~BLEAdvertisement(){
|
||||||
|
if (iBeacon_UUID) delete(iBeacon_UUID);
|
||||||
|
}
|
||||||
|
|
||||||
const uint8_t * BLEAdvertisement::getAdvData(void){
|
const uint8_t * BLEAdvertisement::getAdvData(void){
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
@ -426,7 +431,10 @@ bool BLEAdvertisement::isIBeacon(void){
|
|||||||
}
|
}
|
||||||
|
|
||||||
const UUID * BLEAdvertisement::getIBeaconUUID(void){
|
const UUID * BLEAdvertisement::getIBeaconUUID(void){
|
||||||
return new UUID(&data[9]);
|
if (!iBeacon_UUID){
|
||||||
|
iBeacon_UUID = new UUID(&data[9]);
|
||||||
|
}
|
||||||
|
return iBeacon_UUID;
|
||||||
};
|
};
|
||||||
uint16_t BLEAdvertisement::getIBeaconMajorID(void){
|
uint16_t BLEAdvertisement::getIBeaconMajorID(void){
|
||||||
return READ_NET_16(data, 25);
|
return READ_NET_16(data, 25);
|
||||||
|
@ -57,8 +57,10 @@ private:
|
|||||||
uint8_t data_length;
|
uint8_t data_length;
|
||||||
uint8_t data[10 + LE_ADVERTISING_DATA_SIZE];
|
uint8_t data[10 + LE_ADVERTISING_DATA_SIZE];
|
||||||
BD_ADDR bd_addr;
|
BD_ADDR bd_addr;
|
||||||
|
UUID * iBeacon_UUID;
|
||||||
public:
|
public:
|
||||||
BLEAdvertisement(uint8_t * event_packet);
|
BLEAdvertisement(uint8_t * event_packet);
|
||||||
|
~BLEAdvertisement();
|
||||||
BD_ADDR * getBdAddr();
|
BD_ADDR * getBdAddr();
|
||||||
BD_ADDR_TYPE getBdAddrType();
|
BD_ADDR_TYPE getBdAddrType();
|
||||||
int getRssi();
|
int getRssi();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user