Compare commits

...

6 Commits

24 changed files with 53 additions and 39 deletions

View File

@ -14,11 +14,12 @@ elseif("nimble" IN_LIST BUILD_COMPONENTS OR "__nimble" IN_LIST __hack_component_
) )
endif() endif()
if("arduino" IN_LIST BUILD_COMPONENTS OR __hack_component_targets MATCHES "__idf_arduino") # Dont use arduino bullshit
list(APPEND ESP_NIMBLE_PRIV_REQUIRES #if("arduino" IN_LIST BUILD_COMPONENTS OR __hack_component_targets MATCHES "__idf_arduino")
arduino # list(APPEND ESP_NIMBLE_PRIV_REQUIRES
) # arduino
endif() # )
#endif()
idf_component_register( idf_component_register(
REQUIRED_IDF_TARGETS REQUIRED_IDF_TARGETS
@ -53,7 +54,12 @@ idf_component_register(
REQUIRES REQUIRES
bt bt
nvs_flash nvs_flash
esp_ringbuf
PRIV_REQUIRES PRIV_REQUIRES
${ESP_NIMBLE_PRIV_REQUIRES} ${ESP_NIMBLE_PRIV_REQUIRES}
) )
target_compile_options(${COMPONENT_TARGET}
PUBLIC
-DDONT_USE_ARDUINO_BULLSHIT
)

View File

@ -155,7 +155,7 @@ void FreeRTOS::Semaphore::give() {
} else { } else {
xSemaphoreGive(m_semaphore); xSemaphoreGive(m_semaphore);
} }
// #ifdef ARDUINO_ARCH_ESP32 // #if defined(ARDUINO_ARCH_ESP32) && !defined(DONT_USE_ARDUINO_BULLSHIT)
// FreeRTOS::sleep(10); // FreeRTOS::sleep(10);
// #endif // #endif
@ -243,7 +243,7 @@ bool FreeRTOS::Semaphore::take(uint32_t timeoutMs, std::string owner) {
std::string FreeRTOS::Semaphore::toString() { std::string FreeRTOS::Semaphore::toString() {
char hex[9]; char hex[9];
std::string res = "name: " + m_name + " (0x"; std::string res = "name: " + m_name + " (0x";
snprintf(hex, sizeof(hex), "%08x", (uint32_t)m_semaphore); snprintf(hex, sizeof(hex), "%08lx", (uint32_t)m_semaphore);
res += hex; res += hex;
res += "), owner: " + m_owner; res += "), owner: " + m_owner;
return res; return res;

View File

@ -45,7 +45,7 @@
/* of data as per HID Class standard */ /* of data as per HID Class standard */
/* Main items */ /* Main items */
#ifdef ARDUINO_ARCH_ESP32 #if defined(ARDUINO_ARCH_ESP32) && !defined(DONT_USE_ARDUINO_BULLSHIT)
#define HIDINPUT(size) (0x80 | size) #define HIDINPUT(size) (0x80 | size)
#define HIDOUTPUT(size) (0x90 | size) #define HIDOUTPUT(size) (0x90 | size)
#else #else

View File

@ -12,7 +12,7 @@
* Author: kolban * Author: kolban
*/ */
#include "sdkconfig.h" #include "sdkconfig.h"
#if defined(CONFIG_BT_ENABLED) #if defined(CONFIG_BT_ENABLED) && defined(CONFIG_NIMBLE_ENABLED)
#include <algorithm> #include <algorithm>

View File

@ -15,7 +15,7 @@
#ifndef COMPONENTS_NIMBLEADDRESS_H_ #ifndef COMPONENTS_NIMBLEADDRESS_H_
#define COMPONENTS_NIMBLEADDRESS_H_ #define COMPONENTS_NIMBLEADDRESS_H_
#include "sdkconfig.h" #include "sdkconfig.h"
#if defined(CONFIG_BT_ENABLED) #if defined(CONFIG_BT_ENABLED) && defined(CONFIG_NIMBLE_ENABLED)
#include "nimble/ble.h" #include "nimble/ble.h"
/**** FIX COMPILATION ****/ /**** FIX COMPILATION ****/

View File

@ -12,7 +12,7 @@
* Author: kolban * Author: kolban
*/ */
#include "sdkconfig.h" #include "sdkconfig.h"
#if defined(CONFIG_BT_ENABLED) #if defined(CONFIG_BT_ENABLED) && defined(CONFIG_NIMBLE_ENABLED)
#include <string.h> #include <string.h>
#include <algorithm> #include <algorithm>

View File

@ -15,6 +15,7 @@
#ifndef MAIN_NIMBLEBEACON_H_ #ifndef MAIN_NIMBLEBEACON_H_
#define MAIN_NIMBLEBEACON_H_ #define MAIN_NIMBLEBEACON_H_
#if defined(CONFIG_BT_ENABLED) && defined(CONFIG_NIMBLE_ENABLED)
#include "NimBLEUUID.h" #include "NimBLEUUID.h"
/** /**
* @brief Representation of a beacon. * @brief Representation of a beacon.
@ -48,4 +49,5 @@ public:
void setSignalPower(int8_t signalPower); void setSignalPower(int8_t signalPower);
}; // NimBLEBeacon }; // NimBLEBeacon
#endif
#endif /* MAIN_NIMBLEBEACON_H_ */ #endif /* MAIN_NIMBLEBEACON_H_ */

View File

@ -473,7 +473,7 @@ NimBLECharacteristicCallbacks* NimBLECharacteristic::getCallbacks() {
* @param [in] length The length of the data in bytes. * @param [in] length The length of the data in bytes.
*/ */
void NimBLECharacteristic::setValue(const uint8_t* data, size_t length) { void NimBLECharacteristic::setValue(const uint8_t* data, size_t length) {
#if CONFIG_LOG_DEFAULT_LEVEL > 3 || (ARDUINO_ARCH_ESP32 && CORE_DEBUG_LEVEL >= 4) #if CONFIG_LOG_DEFAULT_LEVEL > 3 || (ARDUINO_ARCH_ESP32 && !defined(DONT_USE_ARDUINO_BULLSHIT) && CORE_DEBUG_LEVEL >= 4)
char* pHex = NimBLEUtils::buildHexData(nullptr, data, length); char* pHex = NimBLEUtils::buildHexData(nullptr, data, length);
NIMBLE_LOGD(LOG_TAG, ">> setValue: length=%d, data=%s, characteristic UUID=%s", length, pHex, getUUID().toString().c_str()); NIMBLE_LOGD(LOG_TAG, ">> setValue: length=%d, data=%s, characteristic UUID=%s", length, pHex, getUUID().toString().c_str());
free(pHex); free(pHex);

View File

@ -1034,7 +1034,7 @@ uint16_t NimBLEClient::getMTU() {
NIMBLE_LOGD(LOG_TAG, "ble_sm_inject_io result: %d", rc); NIMBLE_LOGD(LOG_TAG, "ble_sm_inject_io result: %d", rc);
} else if (event->passkey.params.action == BLE_SM_IOACT_NUMCMP) { } else if (event->passkey.params.action == BLE_SM_IOACT_NUMCMP) {
NIMBLE_LOGD(LOG_TAG, "Passkey on device's display: %d", event->passkey.params.numcmp); NIMBLE_LOGD(LOG_TAG, "Passkey on device's display: %lu", event->passkey.params.numcmp);
pkey.action = event->passkey.params.action; pkey.action = event->passkey.params.action;
// Compatibility only - Do not use, should be removed the in future // Compatibility only - Do not use, should be removed the in future
if(NimBLEDevice::m_securityCallbacks != nullptr) { if(NimBLEDevice::m_securityCallbacks != nullptr) {

View File

@ -12,7 +12,7 @@
* Author: kolban * Author: kolban
*/ */
#include "sdkconfig.h" #include "sdkconfig.h"
#if defined(CONFIG_BT_ENABLED) #if defined(CONFIG_BT_ENABLED) && defined(CONFIG_NIMBLE_ENABLED)
#include "nimconfig.h" #include "nimconfig.h"
#include "NimBLEDevice.h" #include "NimBLEDevice.h"
@ -30,7 +30,7 @@
#include "services/gap/ble_svc_gap.h" #include "services/gap/ble_svc_gap.h"
#include "services/gatt/ble_svc_gatt.h" #include "services/gatt/ble_svc_gatt.h"
#ifdef CONFIG_ENABLE_ARDUINO_DEPENDS #if defined(CONFIG_ENABLE_ARDUINO_DEPENDS) && !defined(DONT_USE_ARDUINO_BULLSHIT)
#include "esp32-hal-bt.h" #include "esp32-hal-bt.h"
#endif #endif
@ -740,7 +740,7 @@ NimBLEAddress NimBLEDevice::getWhiteListAddress(size_t index) {
int rc=0; int rc=0;
esp_err_t errRc = ESP_OK; esp_err_t errRc = ESP_OK;
#ifdef CONFIG_ENABLE_ARDUINO_DEPENDS #if defined(CONFIG_ENABLE_ARDUINO_DEPENDS) && !defined(DONT_USE_ARDUINO_BULLSHIT)
// make sure the linker includes esp32-hal-bt.c so ardruino init doesn't release BLE memory. // make sure the linker includes esp32-hal-bt.c so ardruino init doesn't release BLE memory.
btStarted(); btStarted();
#endif #endif
@ -783,6 +783,8 @@ NimBLEAddress NimBLEDevice::getWhiteListAddress(size_t index) {
// Set the device name. // Set the device name.
rc = ble_svc_gap_device_name_set(deviceName.c_str()); rc = ble_svc_gap_device_name_set(deviceName.c_str());
if (rc != 0)
NIMBLE_LOGE(LOG_TAG, "ble_svc_gap_device_name_set() failed %i name_size=%zd", rc, deviceName.size());
assert(rc == 0); assert(rc == 0);
ble_store_config_init(); ble_store_config_init();
@ -808,10 +810,12 @@ NimBLEAddress NimBLEDevice::getWhiteListAddress(size_t index) {
if (ret == 0) { if (ret == 0) {
nimble_port_deinit(); nimble_port_deinit();
#if 0
ret = esp_nimble_hci_and_controller_deinit(); ret = esp_nimble_hci_and_controller_deinit();
if (ret != ESP_OK) { if (ret != ESP_OK) {
NIMBLE_LOGE(LOG_TAG, "esp_nimble_hci_and_controller_deinit() failed with error: %d", ret); NIMBLE_LOGE(LOG_TAG, "esp_nimble_hci_and_controller_deinit() failed with error: %d", ret);
} }
#endif
initialized = false; initialized = false;
m_synced = false; m_synced = false;

View File

@ -15,7 +15,7 @@
#ifndef MAIN_NIMBLEDEVICE_H_ #ifndef MAIN_NIMBLEDEVICE_H_
#define MAIN_NIMBLEDEVICE_H_ #define MAIN_NIMBLEDEVICE_H_
#include "sdkconfig.h" #include "sdkconfig.h"
#if defined(CONFIG_BT_ENABLED) #if defined(CONFIG_BT_ENABLED) && defined(CONFIG_NIMBLE_ENABLED)
#include "nimconfig.h" #include "nimconfig.h"

View File

@ -12,7 +12,7 @@
* Author: pcbreflux * Author: pcbreflux
*/ */
#include "sdkconfig.h" #include "sdkconfig.h"
#if defined(CONFIG_BT_ENABLED) #if defined(CONFIG_BT_ENABLED) && defined(CONFIG_NIMBLE_ENABLED)
#include "NimBLEEddystoneTLM.h" #include "NimBLEEddystoneTLM.h"
#include "NimBLELog.h" #include "NimBLELog.h"
@ -124,30 +124,30 @@ std::string NimBLEEddystoneTLM::toString() {
out += " C\n"; out += " C\n";
out += "Adv. Count "; out += "Adv. Count ";
snprintf(val, sizeof(val), "%d", ENDIAN_CHANGE_U32(m_eddystoneData.advCount)); snprintf(val, sizeof(val), "%lu", ENDIAN_CHANGE_U32(m_eddystoneData.advCount));
out += val; out += val;
out += "\n"; out += "\n";
out += "Time in seconds "; out += "Time in seconds ";
snprintf(val, sizeof(val), "%d", rawsec/10); snprintf(val, sizeof(val), "%lu", rawsec/10);
out += val; out += val;
out += "\n"; out += "\n";
out += "Time "; out += "Time ";
snprintf(val, sizeof(val), "%04d", rawsec / 864000); snprintf(val, sizeof(val), "%04lu", rawsec / 864000);
out += val; out += val;
out += "."; out += ".";
snprintf(val, sizeof(val), "%02d", (rawsec / 36000) % 24); snprintf(val, sizeof(val), "%02lu", (rawsec / 36000) % 24);
out += val; out += val;
out += ":"; out += ":";
snprintf(val, sizeof(val), "%02d", (rawsec / 600) % 60); snprintf(val, sizeof(val), "%02lu", (rawsec / 600) % 60);
out += val; out += val;
out += ":"; out += ":";
snprintf(val, sizeof(val), "%02d", (rawsec / 10) % 60); snprintf(val, sizeof(val), "%02lu", (rawsec / 10) % 60);
out += val; out += val;
out += "\n"; out += "\n";

View File

@ -14,6 +14,8 @@
#ifndef _NimBLEEddystoneTLM_H_ #ifndef _NimBLEEddystoneTLM_H_
#define _NimBLEEddystoneTLM_H_ #define _NimBLEEddystoneTLM_H_
#if defined(CONFIG_BT_ENABLED) && defined(CONFIG_NIMBLE_ENABLED)
#include "NimBLEUUID.h" #include "NimBLEUUID.h"
#include <string> #include <string>
@ -57,4 +59,5 @@ private:
}; // NimBLEEddystoneTLM }; // NimBLEEddystoneTLM
#endif
#endif /* _NimBLEEddystoneTLM_H_ */ #endif /* _NimBLEEddystoneTLM_H_ */

View File

@ -12,7 +12,7 @@
* Author: pcbreflux * Author: pcbreflux
*/ */
#include "sdkconfig.h" #include "sdkconfig.h"
#if defined(CONFIG_BT_ENABLED) #if defined(CONFIG_BT_ENABLED) && defined(CONFIG_NIMBLE_ENABLED)
#include "NimBLEEddystoneURL.h" #include "NimBLEEddystoneURL.h"
#include "NimBLELog.h" #include "NimBLELog.h"

View File

@ -14,6 +14,7 @@
#ifndef _NIMBLEEddystoneURL_H_ #ifndef _NIMBLEEddystoneURL_H_
#define _NIMBLEEddystoneURL_H_ #define _NIMBLEEddystoneURL_H_
#if defined(CONFIG_BT_ENABLED) && defined(CONFIG_NIMBLE_ENABLED)
#include "NimBLEUUID.h" #include "NimBLEUUID.h"
#include <string> #include <string>
@ -49,4 +50,5 @@ private:
}; // NIMBLEEddystoneURL }; // NIMBLEEddystoneURL
#endif
#endif /* _NIMBLEEddystoneURL_H_ */ #endif /* _NIMBLEEddystoneURL_H_ */

View File

@ -10,9 +10,7 @@
#include "sdkconfig.h" #include "sdkconfig.h"
#if defined(CONFIG_BT_ENABLED) #if defined(ARDUINO_ARCH_ESP32) && !defined(DONT_USE_ARDUINO_BULLSHIT)
#ifdef ARDUINO_ARCH_ESP32
#include "syscfg/syscfg.h" #include "syscfg/syscfg.h"
#include "modlog/modlog.h" #include "modlog/modlog.h"
@ -62,5 +60,4 @@
#endif /*ARDUINO_ARCH_ESP32*/ #endif /*ARDUINO_ARCH_ESP32*/
#endif /*CONFIG_BT_ENABLED*/ #endif /*MAIN_NIMBLELOG_H_*/
#endif /*MAIN_NIMBLELOG_H_*/

View File

@ -284,7 +284,7 @@ bool NimBLEScan::isScanning() {
* @return True if scan started or false if there was an error. * @return True if scan started or false if there was an error.
*/ */
bool NimBLEScan::start(uint32_t duration, void (*scanCompleteCB)(NimBLEScanResults), bool is_continue) { bool NimBLEScan::start(uint32_t duration, void (*scanCompleteCB)(NimBLEScanResults), bool is_continue) {
NIMBLE_LOGD(LOG_TAG, ">> start(duration=%d)", duration); NIMBLE_LOGD(LOG_TAG, ">> start(duration=%lu)", duration);
// Save the callback to be invoked when the scan completes. // Save the callback to be invoked when the scan completes.
m_scanCompleteCB = scanCompleteCB; m_scanCompleteCB = scanCompleteCB;

View File

@ -13,7 +13,7 @@
*/ */
#include "sdkconfig.h" #include "sdkconfig.h"
#if defined(CONFIG_BT_ENABLED) #if defined(CONFIG_BT_ENABLED) && defined(CONFIG_NIMBLE_ENABLED)
#include "NimBLESecurity.h" #include "NimBLESecurity.h"
#include "NimBLEDevice.h" #include "NimBLEDevice.h"

View File

@ -15,7 +15,7 @@
#ifndef COMPONENTS_NIMBLESECURITY_H_ #ifndef COMPONENTS_NIMBLESECURITY_H_
#define COMPONENTS_NIMBLESECURITY_H_ #define COMPONENTS_NIMBLESECURITY_H_
#include "sdkconfig.h" #include "sdkconfig.h"
#if defined(CONFIG_BT_ENABLED) #if defined(CONFIG_BT_ENABLED) && defined(CONFIG_NIMBLE_ENABLED)
#include "host/ble_gap.h" #include "host/ble_gap.h"
/**** FIX COMPILATION ****/ /**** FIX COMPILATION ****/

View File

@ -174,7 +174,7 @@ void NimBLEServer::start() {
abort(); abort();
} }
#if CONFIG_LOG_DEFAULT_LEVEL > 3 || (ARDUINO_ARCH_ESP32 && CORE_DEBUG_LEVEL >= 4) #if CONFIG_LOG_DEFAULT_LEVEL > 3 || (ARDUINO_ARCH_ESP32 && !defined(DONT_USE_ARDUINO_BULLSHIT) && CORE_DEBUG_LEVEL >= 4)
ble_gatts_show_local(); ble_gatts_show_local();
#endif #endif
/*** Future use *** /*** Future use ***
@ -524,7 +524,7 @@ NimBLEConnInfo NimBLEServer::getPeerIDInfo(uint16_t id) {
NIMBLE_LOGD(LOG_TAG, "BLE_SM_IOACT_DISP; ble_sm_inject_io result: %d", rc); NIMBLE_LOGD(LOG_TAG, "BLE_SM_IOACT_DISP; ble_sm_inject_io result: %d", rc);
} else if (event->passkey.params.action == BLE_SM_IOACT_NUMCMP) { } else if (event->passkey.params.action == BLE_SM_IOACT_NUMCMP) {
NIMBLE_LOGD(LOG_TAG, "Passkey on device's display: %d", event->passkey.params.numcmp); NIMBLE_LOGD(LOG_TAG, "Passkey on device's display: %lu", event->passkey.params.numcmp);
pkey.action = event->passkey.params.action; pkey.action = event->passkey.params.action;
// Compatibility only - Do not use, should be removed the in future // Compatibility only - Do not use, should be removed the in future
if(NimBLEDevice::m_securityCallbacks != nullptr) { if(NimBLEDevice::m_securityCallbacks != nullptr) {

View File

@ -12,7 +12,7 @@
* Author: kolban * Author: kolban
*/ */
#include "sdkconfig.h" #include "sdkconfig.h"
#if defined(CONFIG_BT_ENABLED) #if defined(CONFIG_BT_ENABLED) && defined(CONFIG_NIMBLE_ENABLED)
#include "NimBLEUtils.h" #include "NimBLEUtils.h"
#include "NimBLEUUID.h" #include "NimBLEUUID.h"

View File

@ -15,7 +15,7 @@
#ifndef COMPONENTS_NIMBLEUUID_H_ #ifndef COMPONENTS_NIMBLEUUID_H_
#define COMPONENTS_NIMBLEUUID_H_ #define COMPONENTS_NIMBLEUUID_H_
#include "sdkconfig.h" #include "sdkconfig.h"
#if defined(CONFIG_BT_ENABLED) #if defined(CONFIG_BT_ENABLED) && defined(CONFIG_NIMBLE_ENABLED)
#include "host/ble_uuid.h" #include "host/ble_uuid.h"
/**** FIX COMPILATION ****/ /**** FIX COMPILATION ****/

View File

@ -7,7 +7,7 @@
*/ */
#include "sdkconfig.h" #include "sdkconfig.h"
#if defined(CONFIG_BT_ENABLED) #if defined(CONFIG_BT_ENABLED) && defined(CONFIG_NIMBLE_ENABLED)
#include "NimBLEUtils.h" #include "NimBLEUtils.h"
#include "NimBLELog.h" #include "NimBLELog.h"

View File

@ -9,7 +9,7 @@
#ifndef COMPONENTS_NIMBLEUTILS_H_ #ifndef COMPONENTS_NIMBLEUTILS_H_
#define COMPONENTS_NIMBLEUTILS_H_ #define COMPONENTS_NIMBLEUTILS_H_
#include "sdkconfig.h" #include "sdkconfig.h"
#if defined(CONFIG_BT_ENABLED) #if defined(CONFIG_BT_ENABLED) && defined(CONFIG_NIMBLE_ENABLED)
#include "host/ble_gap.h" #include "host/ble_gap.h"