upgrade nimble to 1.4.1 again

This commit is contained in:
technyon
2022-12-24 17:53:58 +01:00
parent 422f336f7a
commit dedac325ca
12 changed files with 50 additions and 15 deletions

View File

@@ -336,6 +336,7 @@ bool NimBLEClient::connect(const NimBLEAddress &address, bool deleteAttributes)
* @return True on success.
*/
bool NimBLEClient::secureConnection() {
NIMBLE_LOGD(LOG_TAG, ">> secureConnection()");
TaskHandle_t cur_task = xTaskGetCurrentTaskHandle();
ble_task_data_t taskData = {this, cur_task, 0, nullptr};
@@ -345,7 +346,7 @@ bool NimBLEClient::secureConnection() {
m_pTaskData = &taskData;
int rc = NimBLEDevice::startSecurity(m_conn_id);
if(rc != 0){
if(rc != 0 && rc != BLE_HS_EALREADY){
m_lastErr = rc;
m_pTaskData = nullptr;
return false;
@@ -360,9 +361,11 @@ bool NimBLEClient::secureConnection() {
if(taskData.rc != 0){
m_lastErr = taskData.rc;
NIMBLE_LOGE(LOG_TAG, "secureConnection: failed rc=%d", taskData.rc);
return false;
}
NIMBLE_LOGD(LOG_TAG, "<< secureConnection: success");
return true;
} // secureConnection

View File

@@ -407,7 +407,7 @@ int NimBLEDevice::getPower(esp_ble_power_type_t powerType) {
case ESP_PWR_LVL_N6:
return -6;
case ESP_PWR_LVL_N3:
return -6;
return -3;
case ESP_PWR_LVL_N0:
return 0;
case ESP_PWR_LVL_P3:
@@ -971,6 +971,15 @@ void NimBLEDevice::deinit(bool clearAll) {
}
} // deinit
/**
* @brief Set the BLEDevice's name
* @param [in] deviceName The device name of the device.
*/
/* STATIC */
void NimBLEDevice::setDeviceName(const std::string &deviceName) {
ble_svc_gap_device_name_set(deviceName.c_str());
} // setDeviceName
/**
* @brief Check if the initialization is complete.

View File

@@ -97,6 +97,7 @@ class NimBLEDevice {
public:
static void init(const std::string &deviceName);
static void deinit(bool clearAll = false);
static void setDeviceName(const std::string &deviceName);
static bool getInitialized();
static NimBLEAddress getAddress();
static std::string toString();
@@ -150,7 +151,8 @@ public:
int max_events = 0);
static bool stopAdvertising(uint8_t inst_id);
static bool stopAdvertising();
# else
# endif
# if !CONFIG_BT_NIMBLE_EXT_ADV || defined(_DOXYGEN_)
static NimBLEAdvertising* getAdvertising();
static bool startAdvertising();
static bool stopAdvertising();

View File

@@ -203,12 +203,12 @@ void NimBLEHIDDevice::setBatteryLevel(uint8_t level) {
/*
* @brief Returns battery level characteristic
* @ return battery level characteristic
*//*
BLECharacteristic* BLEHIDDevice::batteryLevel() {
*/
NimBLECharacteristic* NimBLEHIDDevice::batteryLevel() {
return m_batteryLevelCharacteristic;
}
/*
BLECharacteristic* BLEHIDDevice::reportMap() {
return m_reportMapCharacteristic;

View File

@@ -55,7 +55,7 @@ public:
void pnp(uint8_t sig, uint16_t vid, uint16_t pid, uint16_t version);
//NimBLECharacteristic* hidInfo();
void hidInfo(uint8_t country, uint8_t flags);
//NimBLECharacteristic* batteryLevel();
NimBLECharacteristic* batteryLevel();
void setBatteryLevel(uint8_t level);

View File

@@ -616,7 +616,6 @@ bool NimBLERemoteCharacteristic::setNotify(uint16_t val, notify_callback notifyC
NIMBLE_LOGD(LOG_TAG, "<< setNotify()");
response = true; // Always write with response as per Bluetooth core specification.
return desc->writeValue((uint8_t *)&val, 2, response);
} // setNotify

View File

@@ -73,8 +73,8 @@ public:
bool subscribe(bool notifications = true,
notify_callback notifyCallback = nullptr,
bool response = true);
bool unsubscribe(bool response = true);
bool response = false);
bool unsubscribe(bool response = false);
bool registerForNotify(notify_callback notifyCallback,
bool notifications = true,
bool response = true)

View File

@@ -58,7 +58,8 @@ public:
int duration = 0,
int max_events = 0);
bool stopAdvertising(uint8_t inst_id);
#else
#endif
#if !CONFIG_BT_NIMBLE_EXT_ADV || defined(_DOXYGEN_)
NimBLEAdvertising* getAdvertising();
bool startAdvertising();
#endif

View File

@@ -138,7 +138,9 @@ int ble_hci_trans_hs_acl_tx(struct os_mbuf *om)
{
uint16_t len = 0;
uint8_t data[MYNEWT_VAL(BLE_ACL_BUF_SIZE) + 3], rc = 0;
#ifndef CONFIG_FREERTOS_UNICORE
bool tx_using_nimble_core = 0;
#endif
/* If this packet is zero length, just free it */
if (OS_MBUF_PKTLEN(om) == 0) {
os_mbuf_free_chain(om);