BLE-Gamepad-Client 0.3.2
Loading...
Searching...
No Matches
BLEController Class Reference

Public Member Functions

 BLEController (NimBLEAddress address)
 BLEController (const std::string &address)
bool begin ()
 Initializes a controller instance and NimBLE stack if it's not already initialized.
bool isConnected () const
 Is controller connected to the board.
NimBLEAddress getAddress () const
 Returns one of the following:
void onConnect (const OnConnect &callback)
 Sets the callback to be invoked when the controller connects.
void onDisconnect (const OnDisconnect &callback)
 Sets the callback to be invoked when the controller disconnects.
void readControls (BLEControlsEvent &event) const
 Read the controls state from the connected controller.
void onControlsUpdate (const OnControlsUpdate &callback)
 Sets the callback to be invoked when the controller sends update to the controls state.
void readBattery (BLEBatteryEvent &event) const
 Read the battery state from the connected controller.
void onBatteryUpdate (const OnBatteryUpdate &callback)
 Sets the callback to be invoked when the controller sends update to the battery state.
void writeVibrations (const BLEVibrationsCommand &cmd) const
 Send the vibrations command to the connected controller.

Member Function Documentation

◆ begin()

bool BLEController::begin ( )

Initializes a controller instance and NimBLE stack if it's not already initialized.

Returns
True if initialization was successful.

◆ getAddress()

NimBLEAddress BLEController::getAddress ( ) const

Returns one of the following:

  • The address of the currently connected controller (if connected)
  • The address of the controller allowed to be assigned to this instance (if predefined via constructor param)
  • A null address (a NimBLEAddress instance for which method isNull() returns true)
Returns
The relevant address based on the current connection or configuration state.

◆ isConnected()

bool BLEController::isConnected ( ) const

Is controller connected to the board.

Returns
True if controller is connected, false otherwise.

◆ onBatteryUpdate()

void BLEController::onBatteryUpdate ( const OnBatteryUpdate & callback)

Sets the callback to be invoked when the controller sends update to the battery state.

Parameters
callbackReference to the callback function.

◆ onConnect()

void BLEController::onConnect ( const OnConnect & callback)

Sets the callback to be invoked when the controller connects.

Parameters
callbackReference to a callback function.

◆ onControlsUpdate()

void BLEController::onControlsUpdate ( const OnControlsUpdate & callback)

Sets the callback to be invoked when the controller sends update to the controls state.

Parameters
callbackReference to the callback function.

◆ onDisconnect()

void BLEController::onDisconnect ( const OnDisconnect & callback)

Sets the callback to be invoked when the controller disconnects.

Parameters
callbackReference to the callback function.

◆ readBattery()

void BLEController::readBattery ( BLEBatteryEvent & event) const

Read the battery state from the connected controller.

Parameters
[out]eventReference to the event instance where the data will be written.

◆ readControls()

void BLEController::readControls ( BLEControlsEvent & event) const

Read the controls state from the connected controller.

Parameters
[out]eventReference to the event instance where the data will be written.

◆ writeVibrations()

void BLEController::writeVibrations ( const BLEVibrationsCommand & cmd) const

Send the vibrations command to the connected controller.

Parameters
cmdCommand enabling specific motors in the controller.

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