pull in cordio security manager into BLE

pull/6188/head
paul-szczepanek-arm 2018-02-19 17:26:24 +00:00
parent dd7bc50e4b
commit 990e21247c
4 changed files with 28 additions and 65 deletions

View File

@ -439,7 +439,7 @@ ble_error_t GenericGap::getAddress(
BLEProtocol::AddressBytes_t address
) {
*type = _address_type;
pal::address_t address_value;
ble::address_t address_value;
if (_address_type == BLEProtocol::AddressType::PUBLIC) {
address_value = _pal_gap.get_device_address();
} else {
@ -1046,7 +1046,7 @@ void GenericGap::on_connection_complete(const pal::GapConnectionCompleteEvent& e
e.connection_latency,
e.supervision_timeout
};
pal::address_t address;
ble::address_t address;
if (_address_type == BLEProtocol::AddressType::PUBLIC) {
address = _pal_gap.get_device_address();
} else {

View File

@ -23,13 +23,14 @@
#include "CordioHCIDriver.h"
#include "CordioGattServer.h"
#include "CordioSecurityManager.h"
#include "CordioPalAttClient.h"
#include "ble/pal/AttClientToGattClientAdapter.h"
#include "ble/generic/GenericGattClient.h"
#include "CordioPalGap.h"
#include "CordioPalGenericAccessService.h"
#include "ble/generic/GenericGap.h"
#include "ble/generic/GenericSecurityManager.h"
#include "ble/pal/MemorySecurityDB.h"
#include "ble/pal/SimpleEventQueue.h"
namespace ble {
@ -127,6 +128,12 @@ public:
virtual void processEvents();
private:
/**
* Return singleton.
* @return GenericGap instance.
*/
const generic::GenericGap& getGenericGap() const;
static void stack_handler(wsfEventMask_t event, wsfMsgHdr_t* msg);
static void device_manager_cb(dmEvt_t* dm_event);
static void connection_handler(dmEvt_t* dm_event);

View File

@ -1,59 +0,0 @@
/* mbed Microcontroller Library
* Copyright (c) 2017-2017 ARM Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef CORDIO_SECURITY_MANAGER_H_
#define CORDIO_SECURITY_MANAGER_H_
#include <stddef.h>
#include "ble/generic/GenericSecurityManager.h"
#include "ble/pal/MemorySecurityDb.h"
#include "ble/generic/GenericGap.h"
#include "ble/pal/PalSecurityManager.h"
#include "CordioPalSecurityManager.h"
#include "CordioGap.h"
#include "ble/SecurityManager.h"
namespace ble {
namespace vendor {
namespace cordio {
class SecurityManager : public generic::GenericSecurityManager
{
public:
static SecurityManager &getInstance()
{
static pal::MemorySecurityDb m_db;
static pal::vendor::cordio::CordioSecurityManager m_pal;
static SecurityManager m_instance(m_pal, m_db, *(reinterpret_cast<generic::GenericGap*>(&(cordio::Gap::getInstance()))));
return m_instance;
}
public:
SecurityManager(
pal::SecurityManager &palImpl,
pal::SecurityDb &dbImpl,
generic::GenericGap &gapImpl
) : generic::GenericSecurityManager(palImpl, dbImpl, gapImpl) {
/* empty */
}
};
} // namespace cordio
} // namespace vendor
} // namespace ble
#endif /* CORDIO_SECURITY_MANAGER_H_ */

View File

@ -172,6 +172,11 @@ const char* BLE::getVersion()
}
const ::Gap& BLE::getGap() const
{
return getGenericGap();
};
const generic::GenericGap& BLE::getGenericGap() const
{
static pal::vendor::cordio::Gap& cordio_pal_gap =
pal::vendor::cordio::Gap::get_gap();
@ -182,7 +187,7 @@ const ::Gap& BLE::getGap() const
cordio_gap_service
);
return gap;
};
}
GattServer& BLE::getGattServer()
{
@ -206,12 +211,22 @@ const GattServer& BLE::getGattServer() const
SecurityManager& BLE::getSecurityManager()
{
return cordio::SecurityManager::getInstance();
const BLE* self = this;
return const_cast<SecurityManager&>(self->getSecurityManager());
}
const SecurityManager& BLE::getSecurityManager() const
{
return cordio::SecurityManager::getInstance();
const BLE* self = this;
static pal::MemorySecurityDb m_db;
static pal::vendor::cordio::CordioSecurityManager m_pal;
static generic::GenericSecurityManager m_instance(
m_pal,
m_db,
const_cast<generic::GenericGap&>(self->getGenericGap())
);
return m_instance;
}
void BLE::waitForEvent()