Skip to content

Commit

Permalink
Merge pull request #14710 from noonfom/non-low-power-devices
Browse files Browse the repository at this point in the history
BLE: support non-low power devices
  • Loading branch information
0xc0170 committed Jun 1, 2021
2 parents 543bcb5 + 8ee7fb8 commit 0738aab
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -745,7 +745,7 @@ void BLEInstanceBase::callDispatcher()

wsfOsDispatcher();

static mbed::LowPowerTimeout nextTimeout;
static Timeout nextTimeout;
mbed::CriticalSectionLock critical_section;

if (wsfOsReadyToSleep()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,13 @@
#include "source/PalPrivateAddressControllerImpl.h"
#include "source/generic/PrivateAddressController.h"

#include "drivers/Timeout.h"
#ifdef DEVICE_LPTICKER
#include "drivers/LowPowerTimeout.h"
#include "drivers/LowPowerTimer.h"
#else
#include "drivers/Timer.h"
#endif

namespace ble {

Expand All @@ -57,6 +63,14 @@ namespace impl {
* @see BLEInstanceBase
*/
class BLEInstanceBase final : public ble::BLEInstanceBase {
#ifdef DEVICE_LPTICKER
using Timeout = mbed::LowPowerTimeout;
using Timer = mbed::LowPowerTimer;
#else
using Timeout = mbed::Timeout;
using Timer = mbed::Timer;
#endif

friend PalSigningMonitor;

/**
Expand Down Expand Up @@ -200,7 +214,7 @@ class BLEInstanceBase final : public ble::BLEInstanceBase {
} initialization_status;

mutable ble::impl::PalEventQueue _event_queue;
mbed::LowPowerTimer _timer;
Timer _timer;
uint64_t _last_update_us;
};

Expand Down
24 changes: 19 additions & 5 deletions connectivity/FEATURE_BLE/source/generic/GapImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@

#include <algorithm>

#include "drivers/LowPowerTimeout.h"
#include "drivers/LowPowerTicker.h"
#include "platform/mbed_error.h"

#include "ble/common/BLERoles.h"
Expand All @@ -43,6 +41,14 @@

#include "ble/Gap.h"

#ifdef DEVICE_LPTICKER
#include "drivers/LowPowerTimeout.h"
#include "drivers/LowPowerTicker.h"
#else
#include "drivers/Timeout.h"
#include "drivers/Ticker.h"
#endif

namespace ble {

class PalGenericAccessService;
Expand Down Expand Up @@ -75,6 +81,14 @@ class Gap :
public:
using PreferredConnectionParams_t = ::ble::Gap::PreferredConnectionParams_t ;

#ifdef DEVICE_LPTICKER
using Timeout = mbed::LowPowerTimeout;
using Ticker = mbed::LowPowerTicker;
#else
using Timeout = mbed::Timeout;
using Ticker = mbed::Ticker;
#endif

#if BLE_FEATURE_PRIVACY
#if BLE_ROLE_BROADCASTER
/**
Expand Down Expand Up @@ -927,9 +941,9 @@ class Gap :
ConnectionParameters *_connect_to_host_resolved_address_parameters = nullptr;
#endif // BLE_GAP_HOST_BASED_PRIVATE_ADDRESS_RESOLUTION

mbed::LowPowerTimeout _advertising_timeout;
mbed::LowPowerTimeout _scan_timeout;
mbed::LowPowerTicker _address_rotation_ticker;
Timeout _advertising_timeout;
Timeout _scan_timeout;
Ticker _address_rotation_ticker;

bool _initiating = false;

Expand Down
15 changes: 13 additions & 2 deletions connectivity/FEATURE_BLE/source/generic/PrivateAddressController.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,17 @@

#include <cstdio>

#include "drivers/LowPowerTicker.h"
#include "ble/common/BLETypes.h"
#include "ble/common/blecommon.h"
#include "source/pal/PalEventQueue.h"
#include "source/pal/PalPrivateAddressController.h"

#ifdef DEVICE_LPTICKER
#include "drivers/LowPowerTicker.h"
#else
#include "drivers/Ticker.h"
#endif

namespace ble {

/**
Expand All @@ -38,6 +43,12 @@ namespace ble {
*/
class PrivateAddressController : private PalPrivateAddressController::EventHandler {
public:
#ifdef DEVICE_LPTICKER
using Ticker = mbed::LowPowerTicker;
#else
using Ticker = mbed::Ticker;
#endif

struct EventHandler {
/**
* Called when a new resolvable private address has been generated.
Expand Down Expand Up @@ -313,7 +324,7 @@ class PrivateAddressController : private PalPrivateAddressController::EventHandl
bool _generation_started;
irk_t _local_irk = {};
EventHandler *_event_handler = nullptr;
mbed::LowPowerTicker _address_rotation_ticker;
Ticker _address_rotation_ticker;
address_t _resolvable_address = {};
address_t _non_resolvable_address = {};

Expand Down

0 comments on commit 0738aab

Please sign in to comment.