ESPHome 2026.3.0
Loading...
Searching...
No Matches
rp2040_ble.h
Go to the documentation of this file.
1#pragma once
2
3#include "esphome/core/defines.h" // Must be included before conditional includes
4
5#ifdef USE_RP2040_BLE
6
8
9#include <btstack.h>
10
11namespace esphome::rp2040_ble {
12
13enum class BLEComponentState : uint8_t {
14 OFF = 0,
16 ACTIVE,
19};
20
21class RP2040BLE : public Component {
22 public:
23 void setup() override;
24 void loop() override;
25 void dump_config() override;
26 float get_setup_priority() const override;
27
28 void enable();
29 void disable();
30 bool is_active() const { return this->state_ == BLEComponentState::ACTIVE; }
31
32 void set_enable_on_boot(bool enable_on_boot) { this->enable_on_boot_ = enable_on_boot; }
33
34 protected:
35 static void packet_handler_(uint8_t type, uint16_t channel, uint8_t *packet, uint16_t size);
36
37 btstack_packet_callback_registration_t hci_event_callback_registration_{};
38 btstack_packet_callback_registration_t sm_event_callback_registration_{};
39
41 bool enable_on_boot_{true};
43 bool active_logged_{false};
44};
45
46// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
47extern RP2040BLE *global_ble;
48
49} // namespace esphome::rp2040_ble
50
51#endif // USE_RP2040_BLE
float get_setup_priority() const override
static void packet_handler_(uint8_t type, uint16_t channel, uint8_t *packet, uint16_t size)
void set_enable_on_boot(bool enable_on_boot)
Definition rp2040_ble.h:32
btstack_packet_callback_registration_t hci_event_callback_registration_
Definition rp2040_ble.h:37
btstack_packet_callback_registration_t sm_event_callback_registration_
Definition rp2040_ble.h:38
uint16_t type
RP2040BLE * global_ble
size_t size
Definition helpers.h:929