mirror of
https://github.com/h2zero/esp-nimble-cpp.git
synced 2024-11-22 05:00:55 +01:00
Fix compile errors in latest IDF (NimBLE 1.3.0) see (#37).
Const qualifiers were added to multiple struct members in NimBLE 1.3.0. This solves compilation errors related to those.
This commit is contained in:
parent
7bec9c240a
commit
ef049ddf19
3 changed files with 14 additions and 20 deletions
|
@ -734,7 +734,7 @@ uint8_t* NimBLEAdvertisedDevice::getPayload() {
|
||||||
* @param [in] length The length of the payload in bytes.
|
* @param [in] length The length of the payload in bytes.
|
||||||
* @param [in] append Indicates if the the data should be appended (scan response).
|
* @param [in] append Indicates if the the data should be appended (scan response).
|
||||||
*/
|
*/
|
||||||
void NimBLEAdvertisedDevice::setPayload(uint8_t *payload, uint8_t length, bool append) {
|
void NimBLEAdvertisedDevice::setPayload(const uint8_t *payload, uint8_t length, bool append) {
|
||||||
if(!append) {
|
if(!append) {
|
||||||
m_advLength = length;
|
m_advLength = length;
|
||||||
m_payload.assign(payload, payload + length);
|
m_payload.assign(payload, payload + length);
|
||||||
|
|
|
@ -137,7 +137,7 @@ private:
|
||||||
|
|
||||||
void setAddress(NimBLEAddress address);
|
void setAddress(NimBLEAddress address);
|
||||||
void setAdvType(uint8_t advType);
|
void setAdvType(uint8_t advType);
|
||||||
void setPayload(uint8_t *payload, uint8_t length, bool append);
|
void setPayload(const uint8_t *payload, uint8_t length, bool append);
|
||||||
void setRSSI(int rssi);
|
void setRSSI(int rssi);
|
||||||
uint8_t findAdvField(uint8_t type, uint8_t index = 0, uint8_t *data_loc = nullptr);
|
uint8_t findAdvField(uint8_t type, uint8_t index = 0, uint8_t *data_loc = nullptr);
|
||||||
uint8_t findServiceData(uint8_t index, uint8_t* bytes);
|
uint8_t findServiceData(uint8_t index, uint8_t* bytes);
|
||||||
|
|
|
@ -471,16 +471,14 @@ bool NimBLEAdvertising::start(uint32_t duration, void (*advCompleteCB)(NimBLEAdv
|
||||||
}
|
}
|
||||||
payloadLen += add;
|
payloadLen += add;
|
||||||
|
|
||||||
if(nullptr == (m_advData.uuids16 = (ble_uuid16_t*)realloc(m_advData.uuids16,
|
if(nullptr == (m_advData.uuids16 = (ble_uuid16_t*)realloc((void*)m_advData.uuids16,
|
||||||
(m_advData.num_uuids16 + 1) * sizeof(ble_uuid16_t))))
|
(m_advData.num_uuids16 + 1) * sizeof(ble_uuid16_t))))
|
||||||
{
|
{
|
||||||
NIMBLE_LOGC(LOG_TAG, "Error, no mem");
|
NIMBLE_LOGC(LOG_TAG, "Error, no mem");
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
memcpy(&m_advData.uuids16[m_advData.num_uuids16].value,
|
memcpy((void*)&m_advData.uuids16[m_advData.num_uuids16],
|
||||||
&it.getNative()->u16.value, 2);
|
&it.getNative()->u16, sizeof(ble_uuid16_t));
|
||||||
|
|
||||||
m_advData.uuids16[m_advData.num_uuids16].u.type = BLE_UUID_TYPE_16;
|
|
||||||
m_advData.uuids16_is_complete = 1;
|
m_advData.uuids16_is_complete = 1;
|
||||||
m_advData.num_uuids16++;
|
m_advData.num_uuids16++;
|
||||||
}
|
}
|
||||||
|
@ -492,16 +490,14 @@ bool NimBLEAdvertising::start(uint32_t duration, void (*advCompleteCB)(NimBLEAdv
|
||||||
}
|
}
|
||||||
payloadLen += add;
|
payloadLen += add;
|
||||||
|
|
||||||
if(nullptr == (m_advData.uuids32 = (ble_uuid32_t*)realloc(m_advData.uuids32,
|
if(nullptr == (m_advData.uuids32 = (ble_uuid32_t*)realloc((void*)m_advData.uuids32,
|
||||||
(m_advData.num_uuids32 + 1) * sizeof(ble_uuid32_t))))
|
(m_advData.num_uuids32 + 1) * sizeof(ble_uuid32_t))))
|
||||||
{
|
{
|
||||||
NIMBLE_LOGC(LOG_TAG, "Error, no mem");
|
NIMBLE_LOGC(LOG_TAG, "Error, no mem");
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
memcpy(&m_advData.uuids32[m_advData.num_uuids32].value,
|
memcpy((void*)&m_advData.uuids32[m_advData.num_uuids32],
|
||||||
&it.getNative()->u32.value, 4);
|
&it.getNative()->u32, sizeof(ble_uuid32_t));
|
||||||
|
|
||||||
m_advData.uuids32[m_advData.num_uuids32].u.type = BLE_UUID_TYPE_32;
|
|
||||||
m_advData.uuids32_is_complete = 1;
|
m_advData.uuids32_is_complete = 1;
|
||||||
m_advData.num_uuids32++;
|
m_advData.num_uuids32++;
|
||||||
}
|
}
|
||||||
|
@ -513,16 +509,14 @@ bool NimBLEAdvertising::start(uint32_t duration, void (*advCompleteCB)(NimBLEAdv
|
||||||
}
|
}
|
||||||
payloadLen += add;
|
payloadLen += add;
|
||||||
|
|
||||||
if(nullptr == (m_advData.uuids128 = (ble_uuid128_t*)realloc(m_advData.uuids128,
|
if(nullptr == (m_advData.uuids128 = (ble_uuid128_t*)realloc((void*)m_advData.uuids128,
|
||||||
(m_advData.num_uuids128 + 1) * sizeof(ble_uuid128_t))))
|
(m_advData.num_uuids128 + 1) * sizeof(ble_uuid128_t))))
|
||||||
{
|
{
|
||||||
NIMBLE_LOGC(LOG_TAG, "Error, no mem");
|
NIMBLE_LOGC(LOG_TAG, "Error, no mem");
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
memcpy(&m_advData.uuids128[m_advData.num_uuids128].value,
|
memcpy((void*)&m_advData.uuids128[m_advData.num_uuids128],
|
||||||
&it.getNative()->u128.value, 16);
|
&it.getNative()->u128, sizeof(ble_uuid128_t));
|
||||||
|
|
||||||
m_advData.uuids128[m_advData.num_uuids128].u.type = BLE_UUID_TYPE_128;
|
|
||||||
m_advData.uuids128_is_complete = 1;
|
m_advData.uuids128_is_complete = 1;
|
||||||
m_advData.num_uuids128++;
|
m_advData.num_uuids128++;
|
||||||
}
|
}
|
||||||
|
@ -599,19 +593,19 @@ bool NimBLEAdvertising::start(uint32_t duration, void (*advCompleteCB)(NimBLEAdv
|
||||||
}
|
}
|
||||||
|
|
||||||
if(m_advData.num_uuids128 > 0) {
|
if(m_advData.num_uuids128 > 0) {
|
||||||
free(m_advData.uuids128);
|
free((void*)m_advData.uuids128);
|
||||||
m_advData.uuids128 = nullptr;
|
m_advData.uuids128 = nullptr;
|
||||||
m_advData.num_uuids128 = 0;
|
m_advData.num_uuids128 = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(m_advData.num_uuids32 > 0) {
|
if(m_advData.num_uuids32 > 0) {
|
||||||
free(m_advData.uuids32);
|
free((void*)m_advData.uuids32);
|
||||||
m_advData.uuids32 = nullptr;
|
m_advData.uuids32 = nullptr;
|
||||||
m_advData.num_uuids32 = 0;
|
m_advData.num_uuids32 = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(m_advData.num_uuids16 > 0) {
|
if(m_advData.num_uuids16 > 0) {
|
||||||
free(m_advData.uuids16);
|
free((void*)m_advData.uuids16);
|
||||||
m_advData.uuids16 = nullptr;
|
m_advData.uuids16 = nullptr;
|
||||||
m_advData.num_uuids16 = 0;
|
m_advData.num_uuids16 = 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue