|
CodexPad Arduino Lib 3.0.0
|
#include <codex_pad.h>
Public Types | |
| enum class | TxPower : int8_t { kMinus16dBm = -16 , kMinus12dBm = -12 , kMinus8dBm = -8 , kMinus5dBm = -5 , kMinus3dBm = -3 , kMinus1dBm = -1 , k0dBm = 0 , k1dBm = 1 , k2dBm = 2 , k3dBm = 3 , k4dBm = 4 , k5dBm = 5 , k6dBm = 6 } |
Public Member Functions | |
| CodexPad () noexcept | |
| Constructor. | |
| ~CodexPad () noexcept | |
| Destructor. | |
| void | Init () noexcept |
| Initialize. | |
| bool | Connect (const std::string &bluetooth_device_address, uint32_t timeout_ms=5000) noexcept |
| Connect. | |
| bool | ScanAndConnect (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. | |
| bool | set_remote_tx_power (TxPower power) noexcept |
| Set transmission power, only effective when connected, immediately effective for current connection, effective for next connection. | |
| 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. | |
| NimBLEClient * | ble_client () const noexcept |
| Get the BLE client object. | |
CodexPad main class.
Definition at line 23 of file codex_pad.h.
|
strong |
Definition at line 35 of file codex_pad.h.
|
noexcept |
Constructor.
Definition at line 26 of file codex_pad.cpp.
|
noexcept |
Destructor.
Definition at line 28 of file codex_pad.cpp.
|
inlinenoexcept |
Get the BLE client object.
This function returns a pointer to the internal BLE client object. The caller should not try and release/delete it.
Definition at line 383 of file codex_pad.h.
|
noexcept |
Connect.
| [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 |
| true | if connected successfully |
| false | if connection failed |
Definition at line 36 of file codex_pad.cpp.
|
inlinenoexcept |
Disconnect.
Definition at line 277 of file codex_pad.h.
|
noexcept |
Initialize.
Definition at line 30 of file codex_pad.cpp.
|
inlinenoexcept |
Get the input tracker object.
This function returns a reference to the internal input tracker object.
Definition at line 368 of file codex_pad.h.
|
noexcept |
Is connected.
| true | if connected |
| false | if not |
Definition at line 131 of file codex_pad.cpp.
|
inlinenoexcept |
Get model number of the CodexPad.
Definition at line 330 of file codex_pad.h.
|
inlinenoexcept |
Get firmware version of the CodexPad.
Definition at line 354 of file codex_pad.h.
|
inlinenoexcept |
Get model number of the CodexPad.
Definition at line 342 of file codex_pad.h.
|
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.
| [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. |
| true | Connection successful (a device matching the button mask was found and connected). |
| false | Connection failed (no matching device found or connection attempt failed). |
Button::kHome in the button mask. Holding the Home button triggers a device reboot, which will interrupt the connection process. Example: Definition at line 47 of file codex_pad.cpp.
|
noexcept |
Set transmission power, only effective when connected, immediately effective for current connection, effective for next connection.
| [in] | power | Transmission power |
| true | Success |
| false | Fail |
Definition at line 133 of file codex_pad.cpp.
|
noexcept |
Update, need to be called in Loop.
Definition at line 106 of file codex_pad.cpp.