Add CMakeLists.txt.

Fix compilation in strict enviroments.
Fix compliation in IDF v4.0.
This commit is contained in:
h2zero 2020-03-31 20:16:27 -06:00
parent a77f33e251
commit 74ba03e3a8
12 changed files with 71 additions and 18 deletions

View file

@ -120,13 +120,13 @@ The default configuration will use "just-works" pairing with no bonding, if you
Security callback functions are now incorporated in the client/server Callbacks class.
However backward compatibility with the `BLESecurity` class is retained to minimize app code changes.
The relevent server callbacks are defined as:
The relevant server callbacks are defined as:
```
bool onConfirmPIN(uint32_t pin); // accept or reject the passkey
void onAuthenticationComplete(ble_gap_conn_desc* desc); // auth complete - details in desc
bool onPassKeyNotify(uint32_t pass_key); // receive the passkey sent by the client, accept or reject
```
The relevent client callbacks are defined as:
The relevant client callbacks are defined as:
```
bool onConfirmPIN(uint32_t pin); // accept or reject the passkey
void onAuthenticationComplete(ble_gap_conn_desc* desc); // auth complete - details in desc
@ -148,7 +148,7 @@ static void setSecurityRespKey(uint8_t init_key);
* @param mitm, if true we are capable of man in the middle protection, false if not.
* @param sc, if true we will perform secure connection pairing, false we will use legacy pairing.
*/
void NimBLEDevice::setSecuityAuth(bool bonding, bool mitm, bool sc)
void NimBLEDevice::setSecurityAuth(bool bonding, bool mitm, bool sc)
@ -162,7 +162,7 @@ void NimBLEDevice::setSecuityAuth(bool bonding, bool mitm, bool sc)
** 0x10 BLE_SM_PAIR_AUTHREQ_KEYPRESS - not yet supported.
** 0xe2 BLE_SM_PAIR_AUTHREQ_RESERVED - for reference only.
*/
void NimBLEDevice::setSecuityAuth(uint8_t auth_req)
void NimBLEDevice::setSecurityAuth(uint8_t auth_req)
@ -204,4 +204,4 @@ void NimBLEDevice::setSecurityRespKey(uint8_t init_key)
```
I'm sure there are more things I have forgotten but this is all the majors.
I will update this document as necessary.
I will update this document as necessary.

34
CMakeLists.txt Normal file
View file

@ -0,0 +1,34 @@
# The following lines of boilerplate have to be in your project's
# CMakeLists in this exact order for cmake to work correctly
cmake_minimum_required(VERSION 3.5)
set(SUPPORTED_TARGETS esp32)
idf_component_register(SRCS "src/FreeRTOS.cpp"
"src/NimBLE2902.cpp"
"src/NimBLE2904.cpp"
"src/NimBLEAddress.cpp"
"src/NimBLEAdvertisedDevice.cpp"
"src/NimBLEAdvertising.cpp"
"src/NimBLEBeacon.cpp"
"src/NimBLECharacteristic.cpp"
"src/NimBLECharacteristicMap.cpp"
"src/NimBLEClient.cpp"
"src/NimBLEDescriptor.cpp"
"src/NimBLEDescriptorMap.cpp"
"src/NimBLEDevice.cpp"
"src/NimBLEEddystoneTLM.cpp"
"src/NimBLEEddystoneURL.cpp"
"src/NimBLERemoteCharacteristic.cpp"
"src/NimBLERemoteDescriptor.cpp"
"src/NimBLERemoteService.cpp"
"src/NimBLEScan.cpp"
"src/NimBLESecurity.cpp"
"src/NimBLEServer.cpp"
"src/NimBLEService.cpp"
"src/NimBLEServiceMap.cpp"
"src/NimBLEUtils.cpp"
"src/NimBLEUUID.cpp"
"src/NimBLEValue.cpp"
INCLUDE_DIRS "src"
REQUIRES bt)

View file

@ -37,5 +37,4 @@ This library is intended to be compatible with the original ESP32 BLE functions
1. Code cleanup.
2. Create documentation.
3. Expose more NimBLE features.
4. Add BLE Mesh code.
4. Add BLE Mesh code.

View file

@ -261,7 +261,11 @@ void FreeRTOS::Semaphore::setName(std::string name) {
* @param [in] length The amount of storage to allocate for the ring buffer.
* @param [in] type The type of buffer. One of RINGBUF_TYPE_NOSPLIT, RINGBUF_TYPE_ALLOWSPLIT, RINGBUF_TYPE_BYTEBUF.
*/
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(4, 0, 0)
Ringbuffer::Ringbuffer(size_t length, RingbufferType_t type) {
#else
Ringbuffer::Ringbuffer(size_t length, ringbuf_type_t type) {
#endif
m_handle = ::xRingbufferCreate(length, type);
} // Ringbuffer

View file

@ -61,7 +61,11 @@ public:
*/
class Ringbuffer {
public:
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(4, 0, 0)
Ringbuffer(size_t length, RingbufferType_t type = RINGBUF_TYPE_NOSPLIT);
#else
Ringbuffer(size_t length, ringbuf_type_t type = RINGBUF_TYPE_NOSPLIT);
#endif
~Ringbuffer();
void* receive(size_t* size, TickType_t wait = portMAX_DELAY);

View file

@ -504,7 +504,7 @@ std::string NimBLEAdvertisedDevice::toString() {
}
if (haveTXPower()) {
char val[4];
char val[5];
snprintf(val, sizeof(val), "%d", getTXPower());
res += ", txPower: ";
res += val;

View file

@ -18,6 +18,10 @@
#if defined(CONFIG_BT_ENABLED)
#include "host/ble_gap.h"
/**** FIX COMPILATION ****/
#undef min
#undef max
/**************************/
#include "NimBLEUUID.h"
#include "FreeRTOS.h"

View file

@ -17,6 +17,10 @@
#if defined(CONFIG_BT_ENABLED)
#include "host/ble_hs.h"
/**** FIX COMPILATION ****/
#undef min
#undef max
/**************************/
typedef enum {
READ = BLE_GATT_CHR_F_READ,

View file

@ -346,13 +346,13 @@ std::string NimBLERemoteCharacteristic::readValue() {
switch(rc){
case 0:
break;
case BLE_HS_ATT_ERR(BLE_ATT_ERR_INSUFFICIENT_AUTHEN):
case BLE_HS_ATT_ERR(BLE_ATT_ERR_INSUFFICIENT_AUTHOR):
case BLE_HS_ATT_ERR(BLE_ATT_ERR_INSUFFICIENT_ENC):
if (retryCount && pClient->secureConnection())
break;
/* Else falls through. */
default:
return "";
}
@ -545,13 +545,13 @@ bool NimBLERemoteCharacteristic::writeValue(uint8_t* data, size_t length, bool r
switch(rc){
case 0:
break;
case BLE_HS_ATT_ERR(BLE_ATT_ERR_INSUFFICIENT_AUTHEN):
case BLE_HS_ATT_ERR(BLE_ATT_ERR_INSUFFICIENT_AUTHOR):
case BLE_HS_ATT_ERR(BLE_ATT_ERR_INSUFFICIENT_ENC):
if (retryCount && pClient->secureConnection())
break;
/* Else falls through. */
default:
return false;
}

View file

@ -134,13 +134,13 @@ std::string NimBLERemoteDescriptor::readValue() {
switch(rc){
case 0:
break;
case BLE_HS_ATT_ERR(BLE_ATT_ERR_INSUFFICIENT_AUTHEN):
case BLE_HS_ATT_ERR(BLE_ATT_ERR_INSUFFICIENT_AUTHOR):
case BLE_HS_ATT_ERR(BLE_ATT_ERR_INSUFFICIENT_ENC):
if (retryCount && pClient->secureConnection())
break;
/* Else falls through. */
default:
return "";
}
@ -265,13 +265,13 @@ bool NimBLERemoteDescriptor::writeValue(uint8_t* data, size_t length, bool respo
switch(rc){
case 0:
break;
case BLE_HS_ATT_ERR(BLE_ATT_ERR_INSUFFICIENT_AUTHEN):
case BLE_HS_ATT_ERR(BLE_ATT_ERR_INSUFFICIENT_AUTHOR):
case BLE_HS_ATT_ERR(BLE_ATT_ERR_INSUFFICIENT_ENC):
if (retryCount && pClient->secureConnection())
break;
/* Else falls through. */
default:
return false;
}

View file

@ -18,6 +18,10 @@
#if defined(CONFIG_BT_ENABLED)
#include "host/ble_uuid.h"
/**** FIX COMPILATION ****/
#undef min
#undef max
/**************************/
#include <string>

View file

@ -490,7 +490,7 @@ const char* NimBLEUtils::gapEventToString(uint8_t eventType) {
case BLE_GAP_EVENT_EXT_DISC: //19
return "BLE_GAP_EVENT_EXT_DISC";
#ifdef BLE_GAP_EVENT_PERIODIC_SYNC // IDF 4.0 does not support these
case BLE_GAP_EVENT_PERIODIC_SYNC: //20
return "BLE_GAP_EVENT_PERIODIC_SYNC";
@ -502,7 +502,7 @@ const char* NimBLEUtils::gapEventToString(uint8_t eventType) {
case BLE_GAP_EVENT_SCAN_REQ_RCVD: //23
return "BLE_GAP_EVENT_SCAN_REQ_RCVD";
#endif
default:
NIMBLE_LOGD(LOG_TAG, "gapEventToString: Unknown event type %d 0x%.2x", eventType, eventType);
return "Unknown event type";