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. 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. 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 bool onConfirmPIN(uint32_t pin); // accept or reject the passkey
void onAuthenticationComplete(ble_gap_conn_desc* desc); // auth complete - details in desc 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 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 bool onConfirmPIN(uint32_t pin); // accept or reject the passkey
void onAuthenticationComplete(ble_gap_conn_desc* desc); // auth complete - details in desc 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 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. * @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. ** 0x10 BLE_SM_PAIR_AUTHREQ_KEYPRESS - not yet supported.
** 0xe2 BLE_SM_PAIR_AUTHREQ_RESERVED - for reference only. ** 0xe2 BLE_SM_PAIR_AUTHREQ_RESERVED - for reference only.
*/ */
void NimBLEDevice::setSecuityAuth(uint8_t auth_req) void NimBLEDevice::setSecurityAuth(uint8_t auth_req)

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

@ -38,4 +38,3 @@ This library is intended to be compatible with the original ESP32 BLE functions
2. Create documentation. 2. Create documentation.
3. Expose more NimBLE features. 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] 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. * @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) { Ringbuffer::Ringbuffer(size_t length, ringbuf_type_t type) {
#endif
m_handle = ::xRingbufferCreate(length, type); m_handle = ::xRingbufferCreate(length, type);
} // Ringbuffer } // Ringbuffer

View file

@ -61,7 +61,11 @@ public:
*/ */
class Ringbuffer { class Ringbuffer {
public: 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); Ringbuffer(size_t length, ringbuf_type_t type = RINGBUF_TYPE_NOSPLIT);
#endif
~Ringbuffer(); ~Ringbuffer();
void* receive(size_t* size, TickType_t wait = portMAX_DELAY); void* receive(size_t* size, TickType_t wait = portMAX_DELAY);

View file

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

View file

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

View file

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

View file

@ -352,7 +352,7 @@ std::string NimBLERemoteCharacteristic::readValue() {
case BLE_HS_ATT_ERR(BLE_ATT_ERR_INSUFFICIENT_ENC): case BLE_HS_ATT_ERR(BLE_ATT_ERR_INSUFFICIENT_ENC):
if (retryCount && pClient->secureConnection()) if (retryCount && pClient->secureConnection())
break; break;
/* Else falls through. */
default: default:
return ""; return "";
} }
@ -551,7 +551,7 @@ bool NimBLERemoteCharacteristic::writeValue(uint8_t* data, size_t length, bool r
case BLE_HS_ATT_ERR(BLE_ATT_ERR_INSUFFICIENT_ENC): case BLE_HS_ATT_ERR(BLE_ATT_ERR_INSUFFICIENT_ENC):
if (retryCount && pClient->secureConnection()) if (retryCount && pClient->secureConnection())
break; break;
/* Else falls through. */
default: default:
return false; return false;
} }

View file

@ -140,7 +140,7 @@ std::string NimBLERemoteDescriptor::readValue() {
case BLE_HS_ATT_ERR(BLE_ATT_ERR_INSUFFICIENT_ENC): case BLE_HS_ATT_ERR(BLE_ATT_ERR_INSUFFICIENT_ENC):
if (retryCount && pClient->secureConnection()) if (retryCount && pClient->secureConnection())
break; break;
/* Else falls through. */
default: default:
return ""; return "";
} }
@ -271,7 +271,7 @@ bool NimBLERemoteDescriptor::writeValue(uint8_t* data, size_t length, bool respo
case BLE_HS_ATT_ERR(BLE_ATT_ERR_INSUFFICIENT_ENC): case BLE_HS_ATT_ERR(BLE_ATT_ERR_INSUFFICIENT_ENC):
if (retryCount && pClient->secureConnection()) if (retryCount && pClient->secureConnection())
break; break;
/* Else falls through. */
default: default:
return false; return false;
} }

View file

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

View file

@ -490,7 +490,7 @@ const char* NimBLEUtils::gapEventToString(uint8_t eventType) {
case BLE_GAP_EVENT_EXT_DISC: //19 case BLE_GAP_EVENT_EXT_DISC: //19
return "BLE_GAP_EVENT_EXT_DISC"; 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 case BLE_GAP_EVENT_PERIODIC_SYNC: //20
return "BLE_GAP_EVENT_PERIODIC_SYNC"; 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 case BLE_GAP_EVENT_SCAN_REQ_RCVD: //23
return "BLE_GAP_EVENT_SCAN_REQ_RCVD"; return "BLE_GAP_EVENT_SCAN_REQ_RCVD";
#endif
default: default:
NIMBLE_LOGD(LOG_TAG, "gapEventToString: Unknown event type %d 0x%.2x", eventType, eventType); NIMBLE_LOGD(LOG_TAG, "gapEventToString: Unknown event type %d 0x%.2x", eventType, eventType);
return "Unknown event type"; return "Unknown event type";