My Project
Loading...
Searching...
No Matches
BLEHub Class Referenceabstract

#include <BLEHub.h>

Inheritance diagram for BLEHub:
Collaboration diagram for BLEHub:

Public Member Functions

 BLEHub (BLEHubConfiguration *config)
 
bool IsDiscovered ()
 
bool IsConnected ()
 
void SetConnectCallback (std::function< void(bool)> callback)
 
std::string GetRawAddress ()
 
NimBLEAddress GetAddress ()
 
void Drive (const int16_t minPwrPerc, const int16_t pwrPerc)
 
int16_t GetCurrentDrivePwrPerc ()
 
void Execute (MCLocoAction *action)
 
void BlinkLights (int durationInMs)
 
void SetHubLedColor (HubLedColor color)
 
void SetManualBrake (const bool enabled)
 
void SetEmergencyBrake (const bool enabled)
 
bool Connect (const uint8_t watchdogTimeOutInTensOfSeconds)
 
virtual bool SetWatchdogTimeout (const uint8_t watchdogTimeOutInTensOfSeconds)=0
 
virtual void DriveTaskLoop ()=0
 
virtual int16_t MapPwrPercToRaw (int pwrPerc)=0
 
virtual void NotifyCallback (NimBLERemoteCharacteristic *pBLERemoteCharacteristic, uint8_t *pData, size_t length, bool isNotify)=0
 

Protected Member Functions

void initChannelControllers ()
 
void dumpPData (uint8_t *pData, size_t length)
 
void setTargetPwrPercByAttachedDevice (DeviceType device, int16_t minPwrPerc, int16_t pwrPerc)
 
HubLedColor getRawLedColorForController (BLEHubChannelController *controller)
 
uint8_t getRawChannelPwrForController (BLEHubChannelController *controller)
 
BLEHubChannelControllerfindControllerByChannel (BLEHubChannel channel)
 
bool attachCharacteristic (NimBLEUUID serviceUUID, NimBLEUUID characteristicUUID)
 
bool startDriveTask ()
 
void connected ()
 
void disconnected ()
 

Static Protected Member Functions

static void driveTaskImpl (void *)
 

Protected Attributes

std::function< void(bool)> _onConnectionChangedCallback
 
BLEHubConfiguration_config
 
std::vector< BLEHubChannelController * > _channelControllers
 
TaskHandle_t _driveTaskHandle
 
NimBLEAdvertisedDevice * _advertisedDevice
 
NimBLEAdvertisedDeviceCallbacks * _advertisedDeviceCallback
 
NimBLEClient * _hub
 
NimBLEClientCallbacks * _clientCallback
 
bool _mbrake
 
bool _ebrake
 
bool _blinkLights
 
ulong _blinkUntil
 
bool _isDiscovered
 
bool _isConnected
 
uint16_t _watchdogTimeOutInTensOfSeconds
 
NimBLERemoteService * _remoteControlService
 
NimBLERemoteCharacteristic * _remoteControlCharacteristic
 

Friends

class BLEClientCallback
 
class BLEDeviceCallbacks
 

Constructor & Destructor Documentation

◆ BLEHub()

BLEHub::BLEHub ( BLEHubConfiguration * config)
Here is the call graph for this function:

Member Function Documentation

◆ attachCharacteristic()

bool BLEHub::attachCharacteristic ( NimBLEUUID serviceUUID,
NimBLEUUID characteristicUUID )
protected
Here is the caller graph for this function:

◆ BlinkLights()

void BLEHub::BlinkLights ( int durationInMs)

◆ Connect()

bool BLEHub::Connect ( const uint8_t watchdogTimeOutInTensOfSeconds)

Check if we have a client we should reuse first

Special case when we already know this device, we send false as the second argument in connect() to prevent refreshing the service database. This saves considerable time and power.

We don't already have a client that knows this device, we will check for a client that is disconnected that we can use.

No client to reuse? Create a new one.

Set how long we are willing to wait for the connection to complete (seconds)

Created a client but failed to connect, don't need to keep it as it has no data

Here is the call graph for this function:

◆ connected()

void BLEHub::connected ( )
protected

◆ disconnected()

void BLEHub::disconnected ( )
protected

◆ Drive()

void BLEHub::Drive ( const int16_t minPwrPerc,
const int16_t pwrPerc )
Here is the call graph for this function:

◆ driveTaskImpl()

void BLEHub::driveTaskImpl ( void * _this)
staticprotected
Here is the caller graph for this function:

◆ DriveTaskLoop()

virtual void BLEHub::DriveTaskLoop ( )
pure virtual

Implemented in BuWizz2Hub, PUHub, and SBrickHub.

◆ dumpPData()

void BLEHub::dumpPData ( uint8_t * pData,
size_t length )
protected
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Execute()

void BLEHub::Execute ( MCLocoAction * action)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ findControllerByChannel()

BLEHubChannelController * BLEHub::findControllerByChannel ( BLEHubChannel channel)
protected
Here is the caller graph for this function:

◆ GetAddress()

NimBLEAddress BLEHub::GetAddress ( )

◆ GetCurrentDrivePwrPerc()

int16_t BLEHub::GetCurrentDrivePwrPerc ( )

◆ GetRawAddress()

std::string BLEHub::GetRawAddress ( )

◆ getRawChannelPwrForController()

uint8_t BLEHub::getRawChannelPwrForController ( BLEHubChannelController * controller)
protected
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getRawLedColorForController()

HubLedColor BLEHub::getRawLedColorForController ( BLEHubChannelController * controller)
protected
Here is the call graph for this function:
Here is the caller graph for this function:

◆ initChannelControllers()

void BLEHub::initChannelControllers ( )
protected
Here is the caller graph for this function:

◆ IsConnected()

bool BLEHub::IsConnected ( )

◆ IsDiscovered()

bool BLEHub::IsDiscovered ( )

◆ MapPwrPercToRaw()

virtual int16_t BLEHub::MapPwrPercToRaw ( int pwrPerc)
pure virtual

Implemented in BuWizz2Hub, PUHub, and SBrickHub.

Here is the caller graph for this function:

◆ NotifyCallback()

virtual void BLEHub::NotifyCallback ( NimBLERemoteCharacteristic * pBLERemoteCharacteristic,
uint8_t * pData,
size_t length,
bool isNotify )
pure virtual

Implemented in BuWizz2Hub, PUHub, and SBrickHub.

Here is the caller graph for this function:

◆ SetConnectCallback()

void BLEHub::SetConnectCallback ( std::function< void(bool)> callback)

◆ SetEmergencyBrake()

void BLEHub::SetEmergencyBrake ( const bool enabled)

◆ SetHubLedColor()

void BLEHub::SetHubLedColor ( HubLedColor color)
Here is the call graph for this function:

◆ SetManualBrake()

void BLEHub::SetManualBrake ( const bool enabled)

◆ setTargetPwrPercByAttachedDevice()

void BLEHub::setTargetPwrPercByAttachedDevice ( DeviceType device,
int16_t minPwrPerc,
int16_t pwrPerc )
protected
Here is the caller graph for this function:

◆ SetWatchdogTimeout()

virtual bool BLEHub::SetWatchdogTimeout ( const uint8_t watchdogTimeOutInTensOfSeconds)
pure virtual

Implemented in BuWizz2Hub, PUHub, and SBrickHub.

Here is the caller graph for this function:

◆ startDriveTask()

bool BLEHub::startDriveTask ( )
protected
Here is the call graph for this function:
Here is the caller graph for this function:

Friends And Related Symbol Documentation

◆ BLEClientCallback

friend class BLEClientCallback
friend

◆ BLEDeviceCallbacks

friend class BLEDeviceCallbacks
friend

Member Data Documentation

◆ _advertisedDevice

NimBLEAdvertisedDevice* BLEHub::_advertisedDevice
protected

◆ _advertisedDeviceCallback

NimBLEAdvertisedDeviceCallbacks* BLEHub::_advertisedDeviceCallback
protected

◆ _blinkLights

bool BLEHub::_blinkLights
protected

◆ _blinkUntil

ulong BLEHub::_blinkUntil
protected

◆ _channelControllers

std::vector<BLEHubChannelController *> BLEHub::_channelControllers
protected

◆ _clientCallback

NimBLEClientCallbacks* BLEHub::_clientCallback
protected

◆ _config

BLEHubConfiguration* BLEHub::_config
protected

◆ _driveTaskHandle

TaskHandle_t BLEHub::_driveTaskHandle
protected

◆ _ebrake

bool BLEHub::_ebrake
protected

◆ _hub

NimBLEClient* BLEHub::_hub
protected

◆ _isConnected

bool BLEHub::_isConnected
protected

◆ _isDiscovered

bool BLEHub::_isDiscovered
protected

◆ _mbrake

bool BLEHub::_mbrake
protected

◆ _onConnectionChangedCallback

std::function<void(bool)> BLEHub::_onConnectionChangedCallback
protected

◆ _remoteControlCharacteristic

NimBLERemoteCharacteristic* BLEHub::_remoteControlCharacteristic
protected

◆ _remoteControlService

NimBLERemoteService* BLEHub::_remoteControlService
protected

◆ _watchdogTimeOutInTensOfSeconds

uint16_t BLEHub::_watchdogTimeOutInTensOfSeconds
protected

The documentation for this class was generated from the following files: