Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ServiceData GAP event #305

Merged
merged 1 commit into from
Dec 21, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions cpp_utils/BLEAdvertisedDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,14 @@ int8_t BLEAdvertisedDevice::getTXPower() {
return m_txPower;
} // getTXPower

/**
* @brief Get the service data.
* @return The ServiceData of the advertised device.
*/
uint8_t* BLEAdvertisedDevice::getServiceData() {
return m_serviceData;
} //getServiceData

/**
* @brief Does this advertisement have an appearance value?
* @return True if there is an appearance value present.
Expand Down Expand Up @@ -274,6 +282,11 @@ void BLEAdvertisedDevice::parseAdvertisement(uint8_t* payload) {
break;
} // ESP_BLE_AD_MANUFACTURER_SPECIFIC_TYPE

case ESP_BLE_AD_TYPE_SERVICE_DATA: {
setServiceData(payload);
break;
} //ESP_BLE_AD_TYPE_SERVICE_DATA

default: {
ESP_LOGD(LOG_TAG, "Unhandled type: adType: %d - 0x%.2x", ad_type, ad_type);
break;
Expand Down Expand Up @@ -393,6 +406,13 @@ void BLEAdvertisedDevice::setTXPower(int8_t txPower) {
ESP_LOGD(LOG_TAG, "- txPower: %d", m_txPower);
} // setTXPower

/**
* @brief Set the ServiceData value.
* @param [in] data ServiceData value.
*/
void BLEAdvertisedDevice::setServiceData(uint8_t* data) {
m_serviceData = data;
} //setServiceData

/**
* @brief Create a string representation of this device.
Expand Down
3 changes: 3 additions & 0 deletions cpp_utils/BLEAdvertisedDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class BLEAdvertisedDevice {
BLEScan* getScan();
BLEUUID getServiceUUID();
int8_t getTXPower();
uint8_t* getServiceData();

bool isAdvertisingService(BLEUUID uuid);
bool haveAppearance();
Expand All @@ -63,6 +64,7 @@ class BLEAdvertisedDevice {
void setServiceUUID(const char* serviceUUID);
void setServiceUUID(BLEUUID serviceUUID);
void setTXPower(int8_t txPower);
void setServiceData(uint8_t* data);

bool m_haveAppearance;
bool m_haveManufacturerData;
Expand All @@ -82,6 +84,7 @@ class BLEAdvertisedDevice {
int m_rssi;
std::vector<BLEUUID> m_serviceUUIDs;
int8_t m_txPower;
uint8_t* m_serviceData;
};

/**
Expand Down