Resync to arduino master

This commit is contained in:
h2zero 2020-04-23 15:17:09 -06:00
parent 6c0e6a2b2c
commit 725807b619
4 changed files with 33 additions and 6 deletions

View file

@ -198,6 +198,15 @@ uint8_t* NimBLECharacteristic::getData() {
} // getData } // getData
/**
* @brief Retrieve the the current data length of the characteristic.
* @return The length of the current characteristic data.
*/
size_t NimBLECharacteristic:: getDataLength() {
return m_value.getLength();
}
int NimBLECharacteristic::handleGapEvent(uint16_t conn_handle, uint16_t attr_handle, int NimBLECharacteristic::handleGapEvent(uint16_t conn_handle, uint16_t attr_handle,
struct ble_gatt_access_ctxt *ctxt, struct ble_gatt_access_ctxt *ctxt,
void *arg) void *arg)

View file

@ -97,6 +97,7 @@ public:
NimBLEUUID getUUID(); NimBLEUUID getUUID();
std::string getValue(); std::string getValue();
uint8_t* getData(); uint8_t* getData();
size_t getDataLength();
void indicate(); void indicate();
void notify(bool is_notification = true); void notify(bool is_notification = true);

View file

@ -443,7 +443,7 @@ void NimBLEDevice::stopAdvertising() {
ble_hs_cfg.sm_mitm = 0; ble_hs_cfg.sm_mitm = 0;
ble_hs_cfg.sm_sc = 1; ble_hs_cfg.sm_sc = 1;
ble_hs_cfg.sm_our_key_dist = 1; ble_hs_cfg.sm_our_key_dist = 1;
ble_hs_cfg.sm_their_key_dist = 1; ble_hs_cfg.sm_their_key_dist = 3;
ble_hs_cfg.store_status_cb = ble_store_util_status_rr; /*TODO: Implement handler for this*/ ble_hs_cfg.store_status_cb = ble_store_util_status_rr; /*TODO: Implement handler for this*/

View file

@ -226,6 +226,7 @@ uint32_t NimBLEServer::getConnectedCount() {
NIMBLE_LOGD(LOG_TAG, ">> handleGapEvent: %s", NIMBLE_LOGD(LOG_TAG, ">> handleGapEvent: %s",
NimBLEUtils::gapEventToString(event->type)); NimBLEUtils::gapEventToString(event->type));
int rc = 0; int rc = 0;
struct ble_gap_conn_desc desc;
switch(event->type) { switch(event->type) {
@ -311,9 +312,25 @@ uint32_t NimBLEServer::getConnectedCount() {
return 0; return 0;
} // BLE_GAP_EVENT_CONN_UPDATE } // BLE_GAP_EVENT_CONN_UPDATE
case BLE_GAP_EVENT_REPEAT_PAIRING: {
/* We already have a bond with the peer, but it is attempting to
* establish a new secure link. This app sacrifices security for
* convenience: just throw away the old bond and accept the new link.
*/
/* Delete the old bond. */
rc = ble_gap_conn_find(event->repeat_pairing.conn_handle, &desc);
assert(rc == 0);
ble_store_util_delete_peer(&desc.peer_id_addr);
/* Return BLE_GAP_REPEAT_PAIRING_RETRY to indicate that the host should
* continue with the pairing operation.
*/
return BLE_GAP_REPEAT_PAIRING_RETRY;
} // BLE_GAP_EVENT_REPEAT_PAIRING
case BLE_GAP_EVENT_ENC_CHANGE: { case BLE_GAP_EVENT_ENC_CHANGE: {
struct ble_gap_conn_desc desc; rc = ble_gap_conn_find(event->conn_update.conn_handle, &desc);
int rc = ble_gap_conn_find(event->conn_update.conn_handle, &desc);
if(rc != 0) { if(rc != 0) {
return BLE_ATT_ERR_INVALID_HANDLE; return BLE_ATT_ERR_INVALID_HANDLE;
} }