Files
gateway/components/gateway_ble/include/gateway_ble.hpp
T
Tony bb3e9178fb feat(gateway_ble): Enhance BLE bridge with shared NimBLE support
This commit fixed BLE gateway coexistance with matter

- Added support for shared NimBLE functionality in the GatewayBleBridge class.
- Introduced methods for preparing and attaching shared NimBLE.
- Implemented advertising change handling for Matter integration.
- Updated CMakeLists.txt to require esp_matter.
- Enhanced device name refresh logic to accommodate shared BLE responses.
- Added new member variables to manage shared state and advertising status.

feat(gateway_matter): Integrate BLE callbacks for shared functionality

- Added BLE prepare and attach callbacks to GatewayMatterBridgeConfig.
- Implemented callback invocations during the start process of GatewayMatterBridge.
- Added handling for BLE advertising change events in MatterEvent.

fix(gateway_network): Guard against missing SoftAP support

- Added compile-time checks to ensure SoftAP support is enabled before starting setup AP.

Signed-off-by: Tony <tonylu@tony-cloud.com>
2026-08-08 03:17:05 +08:00

74 lines
2.1 KiB
C++

#pragma once
#include <array>
#include <cstddef>
#include <cstdint>
#include <string>
#include <vector>
#include "esp_err.h"
struct ble_gap_event;
struct ble_gatt_access_ctxt;
namespace gateway {
class DaliDomainService;
struct DaliRawFrame;
class GatewayController;
class GatewayRuntime;
class GatewayBleBridge {
public:
GatewayBleBridge(GatewayController& controller, GatewayRuntime& runtime,
DaliDomainService& dali_domain);
esp_err_t start();
esp_err_t prepareSharedNimble();
esp_err_t attachSharedNimble();
void handleMatterAdvertisingChange(bool advertising);
void handleSync();
int handleGapEvent(struct ble_gap_event* event);
int handleAccess(uint16_t conn_handle, uint16_t attr_handle,
struct ble_gatt_access_ctxt* ctxt);
private:
static constexpr uint16_t kInvalidConnectionHandle = 0xffff;
esp_err_t prepare();
esp_err_t initNimble();
esp_err_t configureSharedScanResponse();
void refreshDeviceName();
void setEnabled(bool enabled);
void startAdvertising();
void stopAdvertising();
void notifyCharacteristic(size_t index, const std::vector<uint8_t>& payload);
void handleGatewayNotification(const std::vector<uint8_t>& frame);
void handleDaliRawFrame(const DaliRawFrame& frame);
void handleRawWrite(size_t channel_index, const std::vector<uint8_t>& payload);
void handleGatewayWrite(const std::vector<uint8_t>& payload);
std::string resolvedDeviceName() const;
int characteristicIndex(uint16_t attr_handle) const;
GatewayController& controller_;
GatewayRuntime& runtime_;
DaliDomainService& dali_domain_;
bool prepared_{false};
bool started_{false};
bool synced_{false};
bool enabled_{false};
bool shared_nimble_{false};
bool gap_listener_registered_{false};
bool matter_advertising_{false};
bool gateway_advertising_{false};
uint8_t own_addr_type_{0};
uint16_t conn_handle_{kInvalidConnectionHandle};
std::string device_name_;
std::array<bool, 3> notify_enabled_{};
std::array<std::vector<uint8_t>, 3> characteristic_values_{};
std::vector<uint8_t> last_notify_payload_;
int64_t last_notify_at_us_{0};
};
} // namespace gateway