mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-03-21 13:21:05 +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) :
|
||||
advertising_event_type(event_packet[2]),
|
||||
rssi(event_packet[10]),
|
||||
data_length(event_packet[11])
|
||||
data_length(event_packet[11]),
|
||||
iBeacon_UUID(NULL)
|
||||
{
|
||||
bd_addr_t addr;
|
||||
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);
|
||||
}
|
||||
|
||||
BLEAdvertisement::~BLEAdvertisement(){
|
||||
if (iBeacon_UUID) delete(iBeacon_UUID);
|
||||
}
|
||||
|
||||
const uint8_t * BLEAdvertisement::getAdvData(void){
|
||||
return data;
|
||||
}
|
||||
@ -426,15 +431,18 @@ bool BLEAdvertisement::isIBeacon(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);
|
||||
};
|
||||
uint16_t BLEAdvertisement::getIBecaonMinorID(void){
|
||||
uint16_t BLEAdvertisement::getIBecaonMinorID(void){
|
||||
return READ_NET_16(data, 27);
|
||||
};
|
||||
uint8_t BLEAdvertisement::getiBeaconMeasuredPower(void){
|
||||
uint8_t BLEAdvertisement::getiBeaconMeasuredPower(void){
|
||||
return data[29];
|
||||
}
|
||||
|
||||
|
@ -57,8 +57,10 @@ private:
|
||||
uint8_t data_length;
|
||||
uint8_t data[10 + LE_ADVERTISING_DATA_SIZE];
|
||||
BD_ADDR bd_addr;
|
||||
UUID * iBeacon_UUID;
|
||||
public:
|
||||
BLEAdvertisement(uint8_t * event_packet);
|
||||
~BLEAdvertisement();
|
||||
BD_ADDR * getBdAddr();
|
||||
BD_ADDR_TYPE getBdAddrType();
|
||||
int getRssi();
|
||||
|
Loading…
x
Reference in New Issue
Block a user