Skip to content

Commit a6730ad

Browse files
authored
Merge pull request #13365 from paul-szczepanek-arm/ble-streamlining
BLE streamlining
2 parents 3daee1d + 6aac3ac commit a6730ad

File tree

746 files changed

+7010
-10038
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

746 files changed

+7010
-10038
lines changed

.astyleignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
^BUILD
22
^cmsis
3+
^connectivity/drivers/ble
4+
^connectivity/FEATURE_BLE
35
^connectivity/libraries/mbed-coap
46
^connectivity/libraries/ppp
57
^connectivity/drivers/emac
68
^features/cryptocell
7-
^features/FEATURE_BLE
89
^features/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV
910
^features/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_TFM
1011
^features/frameworks

components/BLE/COMPONENT_BlueNRG_MS/BlueNrgMsHCIDriver.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
#include "platform/mbed_wait_api.h"
2828

2929
// FEATURE_BLE/targets/TARGET_CORDIO
30-
#include "CordioBLE.h"
30+
#include "BLEInstanceBase.h"
3131
#include "CordioHCIDriver.h"
3232
#include "CordioHCITransportDriver.h"
3333
#include "hci_api.h"
@@ -64,17 +64,17 @@ namespace bluenrg_ms {
6464

6565
/**
6666
* BlueNRG_MS HCI driver implementation.
67-
* @see cordio::CordioHCIDriver
67+
* @see CordioHCIDriver
6868
*/
69-
class HCIDriver : public cordio::CordioHCIDriver {
69+
class HCIDriver : public CordioHCIDriver {
7070
public:
7171
/**
7272
* Construction of the BlueNRG_MS HCIDriver.
7373
* @param transport: Transport of the HCI commands.
7474
* @param rst: Name of the reset pin
7575
*/
76-
HCIDriver(cordio::CordioHCITransportDriver &transport_driver, PinName rst) :
77-
cordio::CordioHCIDriver(transport_driver), rst(rst) { }
76+
HCIDriver(CordioHCITransportDriver &transport_driver, PinName rst) :
77+
CordioHCIDriver(transport_driver), rst(rst) { }
7878

7979
/**
8080
* @see CordioHCIDriver::do_initialize
@@ -87,10 +87,10 @@ class HCIDriver : public cordio::CordioHCIDriver {
8787
/**
8888
* @see CordioHCIDriver::get_buffer_pool_description
8989
*/
90-
ble::vendor::cordio::buf_pool_desc_t get_buffer_pool_description()
90+
ble::buf_pool_desc_t get_buffer_pool_description()
9191
{
9292
// Use default buffer pool
93-
return ble::vendor::cordio::CordioHCIDriver::get_default_buffer_pool_description();
93+
return ble::CordioHCIDriver::get_default_buffer_pool_description();
9494
}
9595

9696
/**
@@ -435,7 +435,7 @@ class HCIDriver : public cordio::CordioHCIDriver {
435435
* event from the stack. This might not be the best solution for all BLE chip;
436436
* especially this one.
437437
*/
438-
class TransportDriver : public cordio::CordioHCITransportDriver {
438+
class TransportDriver : public CordioHCITransportDriver {
439439
public:
440440
/**
441441
* Construct the transport driver required by a BlueNRG_MS module.
@@ -607,7 +607,7 @@ class TransportDriver : public cordio::CordioHCITransportDriver {
607607
/**
608608
* Cordio HCI driver factory
609609
*/
610-
ble::vendor::cordio::CordioHCIDriver &ble_cordio_get_hci_driver()
610+
ble::CordioHCIDriver &ble_cordio_get_hci_driver()
611611
{
612612
static ble::vendor::bluenrg_ms::TransportDriver transport_driver(
613613
MBED_CONF_BLUENRG_MS_SPI_MOSI,
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

features/FEATURE_BLE/ble/BLE.h renamed to connectivity/FEATURE_BLE/include/ble/BLE.h

Lines changed: 60 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
/* mbed Microcontroller Library
2-
* Copyright (c) 2006-2013 ARM Limited
2+
* Copyright (c) 2006-2020 ARM Limited
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
35
*
46
* Licensed under the Apache License, Version 2.0 (the "License");
57
* you may not use this file except in compliance with the License.
@@ -17,27 +19,23 @@
1719
#ifndef MBED_BLE_H__
1820
#define MBED_BLE_H__
1921

20-
#include "BLERoles.h"
22+
#include "FunctionPointerWithContext.h"
23+
#include "platform/mbed_error.h"
24+
#include "platform/mbed_assert.h"
25+
#include "platform/mbed_toolchain.h"
26+
27+
#include "ble/common/ble/BLERoles.h"
28+
#include "ble/common/ble/BLETypes.h"
29+
#include "ble/common/ble/blecommon.h"
2130

22-
#include "blecommon.h"
2331
#include "ble/Gap.h"
24-
#include "ble/GattServer.h"
2532
#include "ble/GattClient.h"
33+
#include "ble/GattServer.h"
2634
#include "ble/SecurityManager.h"
2735

28-
#include "ble/FunctionPointerWithContext.h"
29-
30-
#ifdef YOTTA_CFG_MBED_OS
31-
#include "mbed-drivers/mbed_error.h"
32-
#else
33-
34-
#include "platform/mbed_error.h"
35-
36-
#endif
37-
38-
#include "platform/mbed_toolchain.h"
39-
4036
/* Forward declaration for the implementation class */
37+
38+
namespace ble {
4139
class BLEInstanceBase;
4240

4341
/**
@@ -140,25 +138,41 @@ class BLE {
140138
public:
141139
/**
142140
* Opaque type used to store the ID of a BLE instance.
141+
* @deprecated BLE singleton supports one instance. You may create multiple instances by using the constructor.
143142
*/
144143
typedef unsigned InstanceID_t;
145144

146145
/**
147146
* The value of the BLE::InstanceID_t for the default BLE instance.
147+
* @deprecated BLE singleton supports one instance. You may create multiple instances by using the constructor.
148148
*/
149149
static const InstanceID_t DEFAULT_INSTANCE = 0;
150150

151-
#ifndef YOTTA_CFG_BLE_INSTANCES_COUNT
152151
/**
153152
* The number of permitted BLE instances for the application.
153+
* @deprecated BLE singleton supports one instance. You may create multiple instances by using the constructor.
154154
*/
155155
static const InstanceID_t NUM_INSTANCES = 1;
156-
#else
156+
157157
/**
158-
* The number of permitted BLE instances for the application.
158+
* Get a reference to the BLE singleton.
159+
*
160+
* @note Calling Instance() is preferred over constructing a BLE object
161+
* directly because it returns a reference to singleton.
162+
*
163+
* @return A reference to a single object.
159164
*/
160-
static const InstanceID_t NUM_INSTANCES = YOTTA_CFG_BLE_INSTANCES_COUNT;
161-
#endif
165+
static BLE &Instance();
166+
167+
/**
168+
* Constructor for a handle to a BLE instance (the BLE stack). BLE handles
169+
* are thin wrappers around a transport object (that is, ptr. to
170+
* ble::BLEInstanceBase).
171+
*
172+
* @param[in] transport Ble transport used for the BLE instance.
173+
* @note Cordio supports only one instance.
174+
*/
175+
BLE(ble::BLEInstanceBase &transport);
162176

163177
/**
164178
* Get a reference to the BLE singleton corresponding to a given interface.
@@ -173,17 +187,25 @@ class BLE {
173187
* @return A reference to a single object.
174188
*
175189
* @pre id shall be less than NUM_INSTANCES.
190+
*
176191
*/
177-
static BLE &Instance(InstanceID_t id = DEFAULT_INSTANCE);
192+
MBED_DEPRECATED_SINCE("mbed-os-6.3.0", "BLE singleton supports one instance. You may create multiple"
193+
"instances by using the constructor. Please use BLE::Instance().")
194+
static BLE &Instance(InstanceID_t id)
195+
{
196+
return Instance();
197+
}
178198

179199
/**
180200
* Fetch the ID of a BLE instance.
181201
*
182202
* @return Instance id of this BLE instance.
183203
*/
204+
MBED_DEPRECATED_SINCE("mbed-os-6.3.0", "BLE singleton supports one instance. You may create multiple"
205+
"instances by using the constructor.")
184206
InstanceID_t getInstanceID(void) const
185207
{
186-
return instanceID;
208+
return DEFAULT_INSTANCE;
187209
}
188210

189211
/**
@@ -348,14 +370,14 @@ class BLE {
348370
*
349371
* @return A reference to a Gap object associated to this BLE instance.
350372
*/
351-
Gap &gap();
373+
ble::Gap &gap();
352374

353375
/**
354376
* A const alternative to gap().
355377
*
356378
* @return A const reference to a Gap object associated to this BLE instance.
357379
*/
358-
const Gap &gap() const;
380+
const ble::Gap &gap() const;
359381

360382
#if BLE_FEATURE_GATT_SERVER
361383
/**
@@ -364,15 +386,15 @@ class BLE {
364386
*
365387
* @return A reference to a GattServer object associated to this BLE instance.
366388
*/
367-
GattServer &gattServer();
389+
ble::GattServer &gattServer();
368390

369391
/**
370392
* A const alternative to gattServer().
371393
*
372394
* @return A const reference to a GattServer object associated to this BLE
373395
* instance.
374396
*/
375-
const GattServer &gattServer() const;
397+
const ble::GattServer &gattServer() const;
376398
#endif // BLE_FEATURE_GATT_SERVER
377399

378400
#if BLE_FEATURE_GATT_CLIENT
@@ -382,15 +404,15 @@ class BLE {
382404
*
383405
* @return A reference to a GattClient object associated to this BLE instance.
384406
*/
385-
GattClient &gattClient();
407+
ble::GattClient &gattClient();
386408

387409
/**
388410
* A const alternative to gattClient().
389411
*
390412
* @return A const reference to a GattClient object associated to this BLE
391413
* instance.
392414
*/
393-
const GattClient &gattClient() const;
415+
const ble::GattClient &gattClient() const;
394416
#endif // BLE_FEATURE_GATT_CLIENT
395417

396418
#if BLE_FEATURE_SECURITY
@@ -401,15 +423,15 @@ class BLE {
401423
* @return A reference to a SecurityManager object associated to this BLE
402424
* instance.
403425
*/
404-
SecurityManager &securityManager();
426+
ble::SecurityManager &securityManager();
405427

406428
/**
407429
* A const alternative to securityManager().
408430
*
409431
* @return A const reference to a SecurityManager object associated to this
410432
* BLE instance.
411433
*/
412-
const SecurityManager &securityManager() const;
434+
const ble::SecurityManager &securityManager() const;
413435
#endif // BLE_FEATURE_SECURITY
414436

415437
/**
@@ -421,18 +443,6 @@ class BLE {
421443
*/
422444
static const char *errorToString(ble_error_t error);
423445

424-
private:
425-
friend class BLEInstanceBase;
426-
427-
/**
428-
* Constructor for a handle to a BLE instance (the BLE stack). BLE handles
429-
* are thin wrappers around a transport object (that is, ptr. to
430-
* BLEInstanceBase).
431-
*
432-
* @param[in] instanceID BLE Instance ID to get.
433-
*/
434-
BLE(InstanceID_t instanceID = DEFAULT_INSTANCE);
435-
436446
/**
437447
* This function allows the BLE stack to signal that there is work to do and
438448
* event processing should be done (BLE::processEvent()).
@@ -442,6 +452,9 @@ class BLE {
442452
*/
443453
void signalEventsToProcess();
444454

455+
private:
456+
friend class ble::BLEInstanceBase;
457+
445458
/**
446459
* Implementation of init() [internal to BLE_API].
447460
*
@@ -455,16 +468,17 @@ class BLE {
455468
private:
456469
// Prevent copy construction and copy assignment of BLE.
457470
BLE(const BLE &);
458-
459471
BLE &operator=(const BLE &);
460472

461473
private:
462-
InstanceID_t instanceID;
463-
BLEInstanceBase *transport; /* The device-specific backend */
474+
ble::BLEInstanceBase &transport; /* The device-specific backend */
464475
OnEventsToProcessCallback_t whenEventsToProcess;
465476
bool event_signaled;
466477
};
467478

479+
}
480+
481+
using ble::BLE;
468482
/**
469483
* @namespace ble Entry namespace for all %BLE API definitions.
470484
*/

0 commit comments

Comments
 (0)