Skip to content

Commit 3917c49

Browse files
committed
Add more API compatibility
1 parent 518221d commit 3917c49

File tree

5 files changed

+34
-12
lines changed

5 files changed

+34
-12
lines changed

Diff for: libraries/BLE/src/BLEAddress.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ class BLEAddress : private ble_addr_t {
7272
// Compatibility with old API
7373
[[deprecated("Use getBase() instead")]]
7474
const uint8_t *getNative() const {
75-
return &(getBase()->val);
75+
return getBase()->val;
7676
}
7777
};
7878

Diff for: libraries/BLE/src/BLEAdvertisedDevice.h

+11-8
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,14 @@
2020
#include "soc/soc_caps.h"
2121
#if SOC_BLE_SUPPORTED
2222

23+
typedef enum {
24+
BLE_UNKNOWN_FRAME,
25+
BLE_EDDYSTONE_UUID_FRAME,
26+
BLE_EDDYSTONE_URL_FRAME,
27+
BLE_EDDYSTONE_TLM_FRAME,
28+
BLE_FRAME_MAX
29+
} ble_frame_type_t;
30+
2331
#include "btconfig.h"
2432
#if defined(CONFIG_NIMBLE_ENABLED) && defined(CONFIG_BT_NIMBLE_ROLE_OBSERVER)
2533

@@ -95,6 +103,9 @@ class BLEAdvertisedDevice {
95103
const std::vector<uint8_t>::const_iterator begin() const;
96104
const std::vector<uint8_t>::const_iterator end() const;
97105

106+
// Compatibility with Bluedroid
107+
[[deprecated]] ble_frame_type_t getFrameType() const;
108+
98109
/**
99110
* @brief A template to convert the service data to <type\>.
100111
* @tparam T The type to convert the data to.
@@ -190,14 +201,6 @@ class BLEAdvertisedDevice {
190201
#include "BLEScan.h"
191202
#include "BLEUUID.h"
192203

193-
typedef enum {
194-
BLE_UNKNOWN_FRAME,
195-
BLE_EDDYSTONE_UUID_FRAME,
196-
BLE_EDDYSTONE_URL_FRAME,
197-
BLE_EDDYSTONE_TLM_FRAME,
198-
BLE_FRAME_MAX
199-
} ble_frame_type_t;
200-
201204
class BLEScan;
202205
/**
203206
* @brief A representation of a %BLE advertised device found by a scan.

Diff for: libraries/BLE/src/BLEExtAdvertising.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ class BLEExtAdvertisement {
8181
void setDirected(bool enable, bool high_duty = true);
8282
void setAnonymous(bool enable);
8383
void setPrimaryChannels(bool ch37, bool ch38, bool ch39);
84-
void setTxPower(int8_t dbm);
84+
void setTXPower(int8_t dbm);
8585
void setAddress(const BLEAddress &addr);
8686
void enableScanRequestCallback(bool enable);
8787
void clearData();

Diff for: libraries/BLE/src/NimBLEAdvertisedDevice.cpp

+19
Original file line numberDiff line numberDiff line change
@@ -782,4 +782,23 @@ const std::vector<uint8_t>::const_iterator BLEAdvertisedDevice::end() const {
782782
return m_payload.cend();
783783
}
784784

785+
// API compatibility with Bluedroid
786+
787+
ble_frame_type_t BLEAdvertisedDevice::getFrameType() {
788+
size_t m_payloadLength = m_payload.size();
789+
for (int i = 0; i < m_payloadLength; ++i) {
790+
log_d("check [%d]=0x%02X", i, m_payload[i]);
791+
if (m_payload[i] == 0x16 && m_payloadLength >= i + 3 && m_payload[i + 1] == 0xAA && m_payload[i + 2] == 0xFE && m_payload[i + 3] == 0x00) {
792+
return BLE_EDDYSTONE_UUID_FRAME;
793+
}
794+
if (m_payload[i] == 0x16 && m_payloadLength >= i + 3 && m_payload[i + 1] == 0xAA && m_payload[i + 2] == 0xFE && m_payload[i + 3] == 0x10) {
795+
return BLE_EDDYSTONE_URL_FRAME;
796+
}
797+
if (m_payload[i] == 0x16 && m_payloadLength >= i + 3 && m_payload[i + 1] == 0xAA && m_payload[i + 2] == 0xFE && m_payload[i + 3] == 0x20) {
798+
return BLE_EDDYSTONE_TLM_FRAME;
799+
}
800+
}
801+
return BLE_UNKNOWN_FRAME;
802+
}
803+
785804
#endif /* CONFIG_NIMBLE_ENABLED && CONFIG_BT_NIMBLE_ROLE_CENTRAL */

Diff for: libraries/BLE/src/NimBLEExtAdvertising.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -370,9 +370,9 @@ void BLEExtAdvertisement::setScannable(bool enable) {
370370
* @param [in] dbm the transmission power to use in dbm.
371371
* @details The allowable value range depends on device hardware.
372372
*/
373-
void BLEExtAdvertisement::setTxPower(int8_t dbm) {
373+
void BLEExtAdvertisement::setTXPower(int8_t dbm) {
374374
m_params.tx_power = dbm;
375-
} // setTxPower
375+
} // setTXPower
376376

377377
/**
378378
* @brief Sets wether this advertisement should advertise as a connectable device.

0 commit comments

Comments
 (0)