Client main class.
More...
#include <client.h>
|
| | Client () noexcept |
| | Constructor.
|
| |
| | ~Client () noexcept |
| | Destructor.
|
| |
| void | Init (int8_t local_tx_power=3) noexcept |
| | Initialize.
|
| |
| bool | Connect (const std::string &bluetooth_device_address, uint32_t timeout_ms=5000) noexcept |
| | Connect.
|
| |
| bool | Connect (gamepad::input::Button buttons) noexcept |
| | Scans for nearby CodexPad devices and automatically connects to a device whose button state matches the specified mask.
|
| |
| void | Disconnect () noexcept |
| | Disconnect.
|
| |
| const gamepad::input::Tracker & | Update () noexcept |
| | Update, need to be called in Loop.
|
| |
| bool | is_connected () const noexcept |
| | Is connected.
|
| |
| const std::string & | remote_device_name () const noexcept |
| | Get model number of the CodexPad.
|
| |
| const std::string & | remote_model_number () const noexcept |
| | Get model number of the CodexPad.
|
| |
| const std::array< uint8_t, 3 > & | remote_firmware_version () const noexcept |
| | Get firmware version of the CodexPad.
|
| |
| const gamepad::input::Tracker & | input_tracker () const noexcept |
| | Get the input tracker object.
|
| |
| int32_t | rssi () const noexcept |
| | Get the RSSI of the CodexPad.
|
| |
| NimBLEClient * | ble_client () const noexcept |
| | Get the BLE client object.
|
| |
◆ Client()
| codex_pad::Client::Client |
( |
| ) |
|
|
noexcept |
◆ ~Client()
| codex_pad::Client::~Client |
( |
| ) |
|
|
noexcept |
◆ ble_client()
| NimBLEClient * codex_pad::Client::ble_client |
( |
| ) |
const |
|
inlinenoexcept |
◆ Connect() [1/2]
| bool codex_pad::Client::Connect |
( |
const std::string & | bluetooth_device_address, |
|
|
uint32_t | timeout_ms = 5000 ) |
|
noexcept |
Connect.
- Parameters
-
| [in] | bluetooth_device_address | The Bluetooth device address(BD_ADDR) of the CodexPad, formatted as "XX:XX:XX:XX:XX:XX", X is a number or uppercase letter, colon separated |
| [in] | timeout_ms | Timeout in milliseconds |
- Return values
-
| true | if connected successfully |
| false | if connection failed |
- Examples
- basic_polling.ino, button_mask_connection.ino, and inputs_detection.ino.
Definition at line 48 of file client.cpp.
◆ Connect() [2/2]
| bool codex_pad::Client::Connect |
( |
gamepad::input::Button | buttons | ) |
|
|
noexcept |
Scans for nearby CodexPad devices and automatically connects to a device whose button state matches the specified mask.
This method actively scans for Bluetooth devices. When it discovers one or more CodexPad devices whose current button states exactly match the provided button_mask, it will attempt to establish a connection. If multiple nearby devices match the button mask, the device with the strongest signal (highest RSSI) will be selected for connection.
- Parameters
-
| [in] | button_mask | A 32-bit button mask used to match the target device's button states. Use the ButtonMask() function to combine multiple Button values. |
- Return values
-
| true | Connection successful (a device matching the button mask was found and connected). |
| false | Connection failed (no matching device found or connection attempt failed). |
- Note
- This is a blocking call. It will continuously scan until a matching device is found, a connection is established, or the internal timeout is reached.
- Warning
- DO NOT include
Button::kHome in the button mask. Holding the Home button triggers a device reboot, which will interrupt the connection process. Example:
g_codex_pad_client.
Init();
while (!g_codex_pad_client.ScanAndConnect(gamepad::input::Button::kStart | gamepad::input::Button::kStart)) {
delay(100);
}
Serial.println("CodexPad connected!");
void Init(int8_t local_tx_power=3) noexcept
Initialize.
Definition at line 59 of file client.cpp.
◆ Disconnect()
| void codex_pad::Client::Disconnect |
( |
| ) |
|
|
inlinenoexcept |
◆ Init()
| void codex_pad::Client::Init |
( |
int8_t | local_tx_power = 3 | ) |
|
|
noexcept |
Initialize.
- Parameters
-
| [in] | local_tx_power | The local device TX power in dBm |
Definition at line 41 of file client.cpp.
◆ input_tracker()
| const gamepad::input::Tracker & codex_pad::Client::input_tracker |
( |
| ) |
const |
|
inlinenoexcept |
Get the input tracker object.
This function returns a reference to the internal input tracker object.
- Returns
- Input tracker object
Definition at line 214 of file client.h.
◆ is_connected()
| bool codex_pad::Client::is_connected |
( |
| ) |
const |
|
noexcept |
Is connected.
- Return values
-
| true | if connected |
| false | if not |
Definition at line 143 of file client.cpp.
◆ remote_device_name()
| const std::string & codex_pad::Client::remote_device_name |
( |
| ) |
const |
|
inlinenoexcept |
◆ remote_firmware_version()
| const std::array< uint8_t, 3 > & codex_pad::Client::remote_firmware_version |
( |
| ) |
const |
|
inlinenoexcept |
◆ remote_model_number()
| const std::string & codex_pad::Client::remote_model_number |
( |
| ) |
const |
|
inlinenoexcept |
◆ rssi()
| int32_t codex_pad::Client::rssi |
( |
| ) |
const |
|
noexcept |
◆ Update()
| const gamepad::input::Tracker & codex_pad::Client::Update |
( |
| ) |
|
|
noexcept |
Update, need to be called in Loop.
Definition at line 118 of file client.cpp.
The documentation for this class was generated from the following files: