mirror of
https://github.com/Threnklyn/esphome-dev.git
synced 2026-06-13 16:13:32 +02:00
Update the ibeacon code (#3859)
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
#ifdef USE_ESP32
|
||||
|
||||
#include <esp_gap_ble_api.h>
|
||||
#include <esp_bt.h>
|
||||
|
||||
namespace esphome {
|
||||
namespace esp32_ble_beacon {
|
||||
@@ -14,8 +15,8 @@ typedef struct {
|
||||
uint8_t flags[3];
|
||||
uint8_t length;
|
||||
uint8_t type;
|
||||
uint16_t company_id;
|
||||
uint16_t beacon_type;
|
||||
uint8_t company_id[2];
|
||||
uint8_t beacon_type[2];
|
||||
} __attribute__((packed)) esp_ble_ibeacon_head_t;
|
||||
|
||||
// NOLINTNEXTLINE(modernize-use-using)
|
||||
@@ -42,6 +43,10 @@ class ESP32BLEBeacon : public Component {
|
||||
|
||||
void set_major(uint16_t major) { this->major_ = major; }
|
||||
void set_minor(uint16_t minor) { this->minor_ = minor; }
|
||||
void set_min_interval(uint16_t val) { this->min_interval_ = val; }
|
||||
void set_max_interval(uint16_t val) { this->max_interval_ = val; }
|
||||
void set_measured_power(int8_t val) { this->measured_power_ = val; }
|
||||
void set_tx_power(int8_t val) { this->tx_power_ = val; }
|
||||
|
||||
protected:
|
||||
static void gap_event_handler(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t *param);
|
||||
@@ -51,6 +56,10 @@ class ESP32BLEBeacon : public Component {
|
||||
std::array<uint8_t, 16> uuid_;
|
||||
uint16_t major_{};
|
||||
uint16_t minor_{};
|
||||
uint16_t min_interval_{};
|
||||
uint16_t max_interval_{};
|
||||
int8_t measured_power_{};
|
||||
int8_t tx_power_{};
|
||||
};
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
|
||||
Reference in New Issue
Block a user