mirror of https://github.com/ARMmbed/mbed-os.git
pull in cordio security manager into BLE
parent
dd7bc50e4b
commit
990e21247c
|
@ -439,7 +439,7 @@ ble_error_t GenericGap::getAddress(
|
||||||
BLEProtocol::AddressBytes_t address
|
BLEProtocol::AddressBytes_t address
|
||||||
) {
|
) {
|
||||||
*type = _address_type;
|
*type = _address_type;
|
||||||
pal::address_t address_value;
|
ble::address_t address_value;
|
||||||
if (_address_type == BLEProtocol::AddressType::PUBLIC) {
|
if (_address_type == BLEProtocol::AddressType::PUBLIC) {
|
||||||
address_value = _pal_gap.get_device_address();
|
address_value = _pal_gap.get_device_address();
|
||||||
} else {
|
} else {
|
||||||
|
@ -1046,7 +1046,7 @@ void GenericGap::on_connection_complete(const pal::GapConnectionCompleteEvent& e
|
||||||
e.connection_latency,
|
e.connection_latency,
|
||||||
e.supervision_timeout
|
e.supervision_timeout
|
||||||
};
|
};
|
||||||
pal::address_t address;
|
ble::address_t address;
|
||||||
if (_address_type == BLEProtocol::AddressType::PUBLIC) {
|
if (_address_type == BLEProtocol::AddressType::PUBLIC) {
|
||||||
address = _pal_gap.get_device_address();
|
address = _pal_gap.get_device_address();
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -23,13 +23,14 @@
|
||||||
|
|
||||||
#include "CordioHCIDriver.h"
|
#include "CordioHCIDriver.h"
|
||||||
#include "CordioGattServer.h"
|
#include "CordioGattServer.h"
|
||||||
#include "CordioSecurityManager.h"
|
|
||||||
#include "CordioPalAttClient.h"
|
#include "CordioPalAttClient.h"
|
||||||
#include "ble/pal/AttClientToGattClientAdapter.h"
|
#include "ble/pal/AttClientToGattClientAdapter.h"
|
||||||
#include "ble/generic/GenericGattClient.h"
|
#include "ble/generic/GenericGattClient.h"
|
||||||
#include "CordioPalGap.h"
|
#include "CordioPalGap.h"
|
||||||
#include "CordioPalGenericAccessService.h"
|
#include "CordioPalGenericAccessService.h"
|
||||||
#include "ble/generic/GenericGap.h"
|
#include "ble/generic/GenericGap.h"
|
||||||
|
#include "ble/generic/GenericSecurityManager.h"
|
||||||
|
#include "ble/pal/MemorySecurityDB.h"
|
||||||
#include "ble/pal/SimpleEventQueue.h"
|
#include "ble/pal/SimpleEventQueue.h"
|
||||||
|
|
||||||
namespace ble {
|
namespace ble {
|
||||||
|
@ -127,6 +128,12 @@ public:
|
||||||
virtual void processEvents();
|
virtual void processEvents();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
/**
|
||||||
|
* Return singleton.
|
||||||
|
* @return GenericGap instance.
|
||||||
|
*/
|
||||||
|
const generic::GenericGap& getGenericGap() const;
|
||||||
|
|
||||||
static void stack_handler(wsfEventMask_t event, wsfMsgHdr_t* msg);
|
static void stack_handler(wsfEventMask_t event, wsfMsgHdr_t* msg);
|
||||||
static void device_manager_cb(dmEvt_t* dm_event);
|
static void device_manager_cb(dmEvt_t* dm_event);
|
||||||
static void connection_handler(dmEvt_t* dm_event);
|
static void connection_handler(dmEvt_t* dm_event);
|
||||||
|
|
|
@ -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_ */
|
|
|
@ -172,6 +172,11 @@ const char* BLE::getVersion()
|
||||||
}
|
}
|
||||||
|
|
||||||
const ::Gap& BLE::getGap() const
|
const ::Gap& BLE::getGap() const
|
||||||
|
{
|
||||||
|
return getGenericGap();
|
||||||
|
};
|
||||||
|
|
||||||
|
const generic::GenericGap& BLE::getGenericGap() const
|
||||||
{
|
{
|
||||||
static pal::vendor::cordio::Gap& cordio_pal_gap =
|
static pal::vendor::cordio::Gap& cordio_pal_gap =
|
||||||
pal::vendor::cordio::Gap::get_gap();
|
pal::vendor::cordio::Gap::get_gap();
|
||||||
|
@ -182,7 +187,7 @@ const ::Gap& BLE::getGap() const
|
||||||
cordio_gap_service
|
cordio_gap_service
|
||||||
);
|
);
|
||||||
return gap;
|
return gap;
|
||||||
};
|
}
|
||||||
|
|
||||||
GattServer& BLE::getGattServer()
|
GattServer& BLE::getGattServer()
|
||||||
{
|
{
|
||||||
|
@ -206,12 +211,22 @@ const GattServer& BLE::getGattServer() const
|
||||||
|
|
||||||
SecurityManager& BLE::getSecurityManager()
|
SecurityManager& BLE::getSecurityManager()
|
||||||
{
|
{
|
||||||
return cordio::SecurityManager::getInstance();
|
const BLE* self = this;
|
||||||
|
return const_cast<SecurityManager&>(self->getSecurityManager());
|
||||||
}
|
}
|
||||||
|
|
||||||
const SecurityManager& BLE::getSecurityManager() const
|
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()
|
void BLE::waitForEvent()
|
||||||
|
|
Loading…
Reference in New Issue