BLE: Fixed used of parent pointer in implementation classes.

pull/13475/head
Vincent Coubard 2020-09-04 13:25:32 +01:00
parent 5943a7360c
commit 702c1b9756
6 changed files with 11 additions and 18 deletions

View File

@ -39,7 +39,7 @@ ble_error_t SecurityManager::setDatabaseFilepath(const char *dbFilepath)
ble_error_t SecurityManager::reset()
{
return impl->reset(this);
return impl->reset();
}
ble_error_t SecurityManager::preserveBondingStateOnReset(bool enable)

View File

@ -253,7 +253,6 @@ ble::GattClient &BLEInstanceBase::getGattClient()
{
auto &impl = getGattClientImpl();
static ble::GattClient gatt_client(&impl);
impl.setInterface(&gatt_client);
return gatt_client;
}
@ -368,8 +367,8 @@ void BLEInstanceBase::stack_handler(wsfEventMask_t event, wsfMsgHdr_t *msg)
#endif
deviceInstance().initialization_status = INITIALIZED;
_init_callback.call(&context);
}
break;
} break;
#if MBED_CONF_CORDIO_ROUTE_UNHANDLED_COMMAND_COMPLETE_EVENTS
case DM_UNHANDLED_CMD_CMPL_EVT_IND: {
// upcast to unhandled command complete event to access the payload

View File

@ -23,6 +23,7 @@
#include <cstdlib>
#include <algorithm>
#include "ble/BLE.h"
#include "ble/SecurityManager.h"
#include "ble/gatt/DiscoveredService.h"
#include "ble/gatt/DiscoveredCharacteristic.h"
@ -401,7 +402,7 @@ struct GattClient::DiscoveryControlBlock final : public ProcedureControlBlock {
const Span<const uint8_t> value
) : DiscoveredCharacteristic()
{
gattc = client->client;
gattc = &ble::BLE::Instance().gattClient();
uuid = get_uuid(value);
props = get_properties(value);
declHandle = decl_handle;
@ -965,7 +966,7 @@ struct GattClient::DescriptorDiscoveryControlBlock final : public ProcedureContr
{
for (size_t i = 0; i < response.size(); ++i) {
DiscoveredCharacteristicDescriptor descriptor(
client->client, connection_handle, response[i].handle, response[i].uuid
&ble::BLE::Instance().gattClient(), connection_handle, response[i].handle, response[i].uuid
);
CharacteristicDescriptorDiscovery::DiscoveryCallbackParams_t params = {
characteristic,
@ -1387,7 +1388,7 @@ ble_error_t GattClient::negotiateAttMtu(
ble_error_t GattClient::reset()
{
/* Notify that the instance is about to shut down. */
shutdownCallChain.call(client);
shutdownCallChain.call(&ble::BLE::Instance().gattClient());
shutdownCallChain.clear();
onDataReadCallbackChain.clear();

View File

@ -24,7 +24,6 @@
#include "ble/common/CallChainOfFunctionPointersWithContext.h"
#include <algorithm>
#include "ble/common/blecommon.h"
#include "ble/gatt/GattAttribute.h"
#include "ble/gatt/ServiceDiscovery.h"
@ -249,8 +248,6 @@ private:
mutable ProcedureControlBlock *control_blocks;
bool _is_reseting;
::ble::GattClient *client = nullptr;
private:
/**
* Create a PalGattClient from a PalGattClient
@ -258,11 +255,6 @@ private:
GattClient(PalGattClient &pal_client);
~GattClient() = default;
void setInterface(ble::GattClient *client_interface)
{
client = client_interface;
}
};
} // namespace impl

View File

@ -16,6 +16,7 @@
* limitations under the License.
*/
#include "ble/BLE.h"
#include "ble/common/BLERoles.h"
#include "source/pal/PalSecurityManager.h"
@ -173,14 +174,14 @@ ble_error_t SecurityManager::setDatabaseFilepath(
}
ble_error_t SecurityManager::reset(ble::SecurityManager* sm)
ble_error_t SecurityManager::reset()
{
delete _db;
_db = nullptr;
_pal.reset();
/* Notify that the instance is about to shutdown */
shutdownCallChain.call(sm);
shutdownCallChain.call(&ble::BLE::Instance().securityManager());
shutdownCallChain.clear();
eventHandler = &defaultEventHandler;

View File

@ -78,7 +78,7 @@ public:
ble_error_t setDatabaseFilepath(const char *dbFilepath = nullptr);
ble_error_t reset(ble::SecurityManager* sm);
ble_error_t reset();
ble_error_t preserveBondingStateOnReset(bool enable);