diff --git a/src/platform/silabs/SiWx/BUILD.gn b/src/platform/silabs/SiWx/BUILD.gn index 770b57e8bd..e9de211184 100644 --- a/src/platform/silabs/SiWx/BUILD.gn +++ b/src/platform/silabs/SiWx/BUILD.gn @@ -82,6 +82,10 @@ static_library("SiWx") { "${chip_root}/src/app/icd/server:icd-server-config", "${chip_root}/src/platform:platform_base", + # BLE refactor skeleton (Matter channel) + "${silabs_platform_dir}/ble:ble", + "${silabs_platform_dir}/ble/SiWx:ble-siwx", + # sl_matter_enable_siwx_ble "${silabs_platform_dir}/SiWx/ble:siwx-ble", "${silabs_platform_dir}/platformAbstraction:wisemcu", diff --git a/src/platform/silabs/ble/BUILD.gn b/src/platform/silabs/ble/BUILD.gn new file mode 100644 index 0000000000..37b36e3dc9 --- /dev/null +++ b/src/platform/silabs/ble/BUILD.gn @@ -0,0 +1,22 @@ +# Copyright (c) 2025 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build_overrides/chip.gni") + +# Shared BLE channel interface and types (headers only). +# Platform implementations: ble/efr32 (BleChannelMatterEfr32), ble/SiWx (BleChannelMatterSiWx). +source_set("ble") { + public_deps = [ "${chip_root}/src/platform:platform_base" ] + include_dirs = [ "${chip_root}/src/platform/silabs/ble" ] +} diff --git a/src/platform/silabs/ble/BleChannel.h b/src/platform/silabs/ble/BleChannel.h new file mode 100644 index 0000000000..8c237e449e --- /dev/null +++ b/src/platform/silabs/ble/BleChannel.h @@ -0,0 +1,89 @@ +/* + * + * Copyright (c) 2025 Project CHIP Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @file + * Abstract interface for a BLE channel (Matter BLE or side channel). + * BLEManagerImpl holds a Matter channel and an optional side channel; + * all platform BLE operations are delegated to the channel. + * No native stack headers in this interface. + */ + +#pragma once + +#include +#include + +#include "BlePlatformTypes.h" +#include + +namespace chip { +namespace DeviceLayer { +namespace Internal { + +/** + * Abstract base for any BLE channel (Matter BLE or side channel). + * Platform implementations: BleChannelMatterEfr32, BleChannelMatterSiWx (Matter); + * BleSideChannelEfr32, BleSideChannelSiWx (side channel). + */ +class BleChannel +{ +public: + virtual ~BleChannel() = default; + + // ----- Initialization ----- + virtual CHIP_ERROR Init() = 0; + virtual CHIP_ERROR Shutdown() = 0; + + // ----- Advertising ----- + virtual CHIP_ERROR StartAdvertising(const BleAdvertisingParams & params) = 0; + virtual CHIP_ERROR StopAdvertising() = 0; + virtual CHIP_ERROR SetAdvertisingData(const uint8_t * data, size_t length) = 0; + + // ----- Connection ----- + virtual CHIP_ERROR CloseConnection(BleConnectionHandle conId) = 0; + virtual CHIP_ERROR UpdateConnectionParams(BleConnectionHandle conId, const BleConnectionParams & params) = 0; + + // ----- GATT ----- + virtual CHIP_ERROR SendIndication(BleConnectionHandle conId, uint16_t charHandle, const uint8_t * data, size_t length) = 0; + virtual CHIP_ERROR SendWriteRequest(BleConnectionHandle conId, uint16_t charHandle, const uint8_t * data, size_t length) = 0; + virtual CHIP_ERROR SubscribeCharacteristic(BleConnectionHandle conId, uint16_t charHandle) = 0; + virtual CHIP_ERROR UnsubscribeCharacteristic(BleConnectionHandle conId, uint16_t charHandle) = 0; + virtual uint16_t GetMTU(BleConnectionHandle conId) const = 0; + + // ----- Event handling ----- + /** Callback invoked when channel parses an event and produces a BleEvent (e.g. for Matter BLE). */ + virtual void SetEventCallback(BleEventCallback callback, void * context) = 0; + /** Returns true if this channel handles the given platform event id. */ + virtual bool CanHandleEvent(uint32_t eventId) const = 0; + /** Single entry point: parse platform event, optionally build BleEvent and invoke callback. */ + virtual void ParseEvent(void * platformEvent) = 0; + + // ----- Address / identity ----- + virtual CHIP_ERROR GetAddress(uint8_t * addr, size_t * length) = 0; + virtual CHIP_ERROR GetDeviceName(char * buf, size_t bufSize) = 0; + virtual CHIP_ERROR SetDeviceName(const char * name) = 0; + + // ----- Indication timer ----- + virtual CHIP_ERROR StartIndicationTimer(BleConnectionHandle conId, uint32_t timeoutMs, void (*callback)(void *), + void * context) = 0; + virtual CHIP_ERROR CancelIndicationTimer(BleConnectionHandle conId) = 0; +}; + +} // namespace Internal +} // namespace DeviceLayer +} // namespace chip diff --git a/src/platform/silabs/ble/BlePlatformTypes.h b/src/platform/silabs/ble/BlePlatformTypes.h new file mode 100644 index 0000000000..1f6e4374cb --- /dev/null +++ b/src/platform/silabs/ble/BlePlatformTypes.h @@ -0,0 +1,119 @@ +/* + * + * Copyright (c) 2025 Project CHIP Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @file + * Platform-agnostic BLE types used by BleChannel and BLEManagerImpl. + * Shared across Matter BLE and side channel implementations. + */ + +#pragma once + +#include +#include + +#include +#include + +namespace chip { +namespace DeviceLayer { +namespace Internal { + +/** + * Connection handle type for BLE operations. Platform code casts to/from + * BLE_CONNECTION_OBJECT where required by the Matter BleLayer. + */ +using BleConnectionHandle = void *; + +/** + * BLE event types delivered from platform stack to channel (ParseEvent) + * and then to BLEManagerImpl via callback (OnMatterBleEvent). + */ +enum class BleEventType : uint32_t +{ + kConnectionOpened, + kConnectionClosed, + kConnectionParameters, + kMtuExchanged, + kGattWrite, + kGattRead, + kIndicationConfirmation, + kSoftTimerExpired, + kBoot, + kUnknown +}; + +/** + * Unified BLE event passed from channel to BLEManagerImpl. + */ +struct BleEvent +{ + BleEventType type = BleEventType::kUnknown; + BleConnectionHandle connection = nullptr; + void * data = nullptr; + size_t dataLength = 0; + uint16_t attributeHandle = 0; + uint32_t timerId = 0; +}; + +/** + * Advertising parameters for StartAdvertising. + */ +struct BleAdvertisingParams +{ + uint16_t minInterval = 0; + uint16_t maxInterval = 0; + bool connectable = true; + uint8_t * customData = nullptr; + size_t customDataLength = 0; +}; + +/** + * Connection parameters for UpdateConnectionParams. + */ +struct BleConnectionParams +{ + uint16_t minInterval = 0; + uint16_t maxInterval = 0; + uint16_t latency = 0; + uint16_t timeout = 0; +}; + +/** + * Event callback type: channel calls this when it has parsed a platform event + * and produced a BleEvent (e.g. for Matter BLE). + */ +using BleEventCallback = void (*)(const BleEvent & event, void * context); + +/** + * Side-channel advertising configuration (aligns with existing BLEChannel + * AdvConfigStruct). Used by BleSideChannel::ConfigureAdvertising(). + */ +struct AdvConfigStruct +{ + ByteSpan advData; + ByteSpan responseData; + uint32_t intervalMin = 0; + uint32_t intervalMax = 0; + uint8_t advConnectableMode = 0; + uint16_t duration = 0; + uint8_t maxEvents = 0; +}; + +} // namespace Internal +} // namespace DeviceLayer +} // namespace chip diff --git a/src/platform/silabs/ble/BleSideChannel.h b/src/platform/silabs/ble/BleSideChannel.h new file mode 100644 index 0000000000..e61720780c --- /dev/null +++ b/src/platform/silabs/ble/BleSideChannel.h @@ -0,0 +1,95 @@ +/* + * + * Copyright (c) 2025 Project CHIP Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @file + * Abstract base for side channel implementations (e.g. provisioning CLI). + * Aligns with existing BLEChannel.h / BLEChannelImpl in efr32 for refactor. + * Extends BleChannel with side-channel-specific API (GATT read/write/CCCD, + * connection state, CLI GAP/GATT methods, getters). + */ + +#pragma once + +#include "BleChannel.h" +#include "BlePlatformTypes.h" +#include +#include +#include + +namespace chip { +namespace DeviceLayer { +namespace Internal { + +/** + * Abstract base for side channel. Implements BleChannel and adds the same + * surface as the existing BLEChannel (efr32): ConfigureAdvertising with + * AdvConfigStruct, StartAdvertising() (no params), AddConnection/RemoveConnection, + * HandleReadRequest/HandleWriteRequest (ByteSpan/MutableByteSpan), HandleCCCDWriteRequest, + * UpdateMtu, and CLI methods (GAP/GATT client) plus getters. + */ +class BleSideChannel : public BleChannel +{ +public: + ~BleSideChannel() override = default; + + // ----- Side-channel advertising (matches existing BLEChannel) ----- + /** Configure advertising data and parameters; must be called before StartAdvertising(). */ + virtual CHIP_ERROR ConfigureAdvertising(const AdvConfigStruct & config) = 0; + /** Start advertising using configured parameters. */ + virtual CHIP_ERROR StartAdvertising(void) = 0; + virtual CHIP_ERROR StopAdvertising(void) = 0; + + // ----- Connection state (side channel) ----- + virtual void AddConnection(uint8_t connectionHandle, uint8_t bondingHandle) = 0; + virtual bool RemoveConnection(uint8_t connectionHandle) = 0; + + // ----- GATT server (side channel) ----- + virtual void HandleReadRequest(void * platformEvent, ByteSpan data) = 0; + virtual void HandleWriteRequest(void * platformEvent, MutableByteSpan data) = 0; + virtual CHIP_ERROR HandleCCCDWriteRequest(void * platformEvent, bool & isNewSubscription) = 0; + virtual void UpdateMtu(void * platformEvent) = 0; + + // ----- Event handling (side channel) ----- + virtual bool CanHandleEvent(uint32_t eventId) { return false; } + virtual void ParseEvent(void * platformEvent) {} + + // ----- CLI: GAP ----- + virtual CHIP_ERROR GeneratAdvertisingData(uint8_t discoverMove, uint8_t connectMode, const Optional & maxEvents) = 0; + virtual CHIP_ERROR SetAdvertisingParams(uint32_t intervalMin, uint32_t intervalMax, uint16_t duration, + const Optional & maxEvents, const Optional & channelMap) = 0; + virtual CHIP_ERROR OpenConnection(const uint8_t * address, size_t addressLen, uint8_t addrType) = 0; + virtual CHIP_ERROR SetConnectionParams(const Optional & connectionHandle, uint32_t intervalMin, uint32_t intervalMax, + uint16_t latency, uint16_t timeout) = 0; + virtual CHIP_ERROR CloseConnection(void) = 0; + virtual CHIP_ERROR SetAdvHandle(uint8_t handle) = 0; + + // ----- CLI: GATT (client) ----- + virtual CHIP_ERROR DiscoverServices() = 0; + virtual CHIP_ERROR DiscoverCharacteristics(uint32_t serviceHandle) = 0; + virtual CHIP_ERROR SetCharacteristicNotification(uint8_t characteristicHandle, uint8_t flags) = 0; + virtual CHIP_ERROR SetCharacteristicValue(uint8_t characteristicHandle, const ByteSpan & value) = 0; + + // ----- Getters (matches existing BLEChannel) ----- + virtual uint8_t GetAdvHandle(void) const { return 0xff; } + virtual uint8_t GetConnectionHandle(void) const { return 0; } + virtual uint8_t GetBondingHandle(void) const { return 0; } +}; + +} // namespace Internal +} // namespace DeviceLayer +} // namespace chip diff --git a/src/platform/silabs/ble/SiWx/BUILD.gn b/src/platform/silabs/ble/SiWx/BUILD.gn new file mode 100644 index 0000000000..1dcff66b92 --- /dev/null +++ b/src/platform/silabs/ble/SiWx/BUILD.gn @@ -0,0 +1,31 @@ +# Copyright (c) 2025 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build_overrides/chip.gni") + +# Matter BLE channel implementation for SiWx917 (skeleton). +source_set("ble-siwx") { + sources = + [ "${chip_root}/src/platform/silabs/ble/SiWx/BleChannelMatterSiWx.cpp" ] + + public_deps = [ + "${chip_root}/src/platform:platform_base", + "${chip_root}/src/platform/silabs/ble:ble", + ] + + include_dirs = [ + "${chip_root}/src/platform/silabs/ble", + "${chip_root}/src/platform/silabs/ble/SiWx", + ] +} diff --git a/src/platform/silabs/ble/SiWx/BleChannelMatterSiWx.cpp b/src/platform/silabs/ble/SiWx/BleChannelMatterSiWx.cpp new file mode 100644 index 0000000000..d96ff18448 --- /dev/null +++ b/src/platform/silabs/ble/SiWx/BleChannelMatterSiWx.cpp @@ -0,0 +1,128 @@ +/* + * + * Copyright (c) 2025 Project CHIP Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @file + * Matter BLE channel implementation for SiWx917 (skeleton). + */ + +#include "BleChannelMatterSiWx.h" +#include + +namespace chip { +namespace DeviceLayer { +namespace Internal { + +CHIP_ERROR BleChannelMatterSiWx::Init() +{ + return CHIP_NO_ERROR; +} + +CHIP_ERROR BleChannelMatterSiWx::Shutdown() +{ + return CHIP_NO_ERROR; +} + +CHIP_ERROR BleChannelMatterSiWx::StartAdvertising(const BleAdvertisingParams & params) +{ + return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; +} + +CHIP_ERROR BleChannelMatterSiWx::StopAdvertising() +{ + return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; +} + +CHIP_ERROR BleChannelMatterSiWx::SetAdvertisingData(const uint8_t * data, size_t length) +{ + return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; +} + +CHIP_ERROR BleChannelMatterSiWx::CloseConnection(BleConnectionHandle conId) +{ + return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; +} + +CHIP_ERROR BleChannelMatterSiWx::UpdateConnectionParams(BleConnectionHandle conId, const BleConnectionParams & params) +{ + return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; +} + +CHIP_ERROR BleChannelMatterSiWx::SendIndication(BleConnectionHandle conId, uint16_t charHandle, const uint8_t * data, size_t length) +{ + return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; +} + +CHIP_ERROR BleChannelMatterSiWx::SendWriteRequest(BleConnectionHandle conId, uint16_t charHandle, const uint8_t * data, + size_t length) +{ + return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; +} + +CHIP_ERROR BleChannelMatterSiWx::SubscribeCharacteristic(BleConnectionHandle conId, uint16_t charHandle) +{ + return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; +} + +CHIP_ERROR BleChannelMatterSiWx::UnsubscribeCharacteristic(BleConnectionHandle conId, uint16_t charHandle) +{ + return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; +} + +uint16_t BleChannelMatterSiWx::GetMTU(BleConnectionHandle conId) const +{ + return 0; +} + +void BleChannelMatterSiWx::SetEventCallback(BleEventCallback callback, void * context) {} + +bool BleChannelMatterSiWx::CanHandleEvent(uint32_t eventId) const +{ + return false; +} + +void BleChannelMatterSiWx::ParseEvent(void * platformEvent) {} + +CHIP_ERROR BleChannelMatterSiWx::GetAddress(uint8_t * addr, size_t * length) +{ + return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; +} + +CHIP_ERROR BleChannelMatterSiWx::GetDeviceName(char * buf, size_t bufSize) +{ + return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; +} + +CHIP_ERROR BleChannelMatterSiWx::SetDeviceName(const char * name) +{ + return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; +} + +CHIP_ERROR BleChannelMatterSiWx::StartIndicationTimer(BleConnectionHandle conId, uint32_t timeoutMs, void (*callback)(void *), + void * context) +{ + return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; +} + +CHIP_ERROR BleChannelMatterSiWx::CancelIndicationTimer(BleConnectionHandle conId) +{ + return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; +} + +} // namespace Internal +} // namespace DeviceLayer +} // namespace chip diff --git a/src/platform/silabs/ble/SiWx/BleChannelMatterSiWx.h b/src/platform/silabs/ble/SiWx/BleChannelMatterSiWx.h new file mode 100644 index 0000000000..8d44d8250e --- /dev/null +++ b/src/platform/silabs/ble/SiWx/BleChannelMatterSiWx.h @@ -0,0 +1,69 @@ +/* + * + * Copyright (c) 2025 Project CHIP Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @file + * Matter BLE channel implementation for SiWx917 (skeleton). + */ + +#pragma once + +#include "BleChannel.h" +#include "BlePlatformTypes.h" + +namespace chip { +namespace DeviceLayer { +namespace Internal { + +class BleChannelMatterSiWx : public BleChannel +{ +public: + BleChannelMatterSiWx() = default; + ~BleChannelMatterSiWx() override = default; + + CHIP_ERROR Init() override; + CHIP_ERROR Shutdown() override; + + CHIP_ERROR StartAdvertising(const BleAdvertisingParams & params) override; + CHIP_ERROR StopAdvertising() override; + CHIP_ERROR SetAdvertisingData(const uint8_t * data, size_t length) override; + + CHIP_ERROR CloseConnection(BleConnectionHandle conId) override; + CHIP_ERROR UpdateConnectionParams(BleConnectionHandle conId, const BleConnectionParams & params) override; + + CHIP_ERROR SendIndication(BleConnectionHandle conId, uint16_t charHandle, const uint8_t * data, size_t length) override; + CHIP_ERROR SendWriteRequest(BleConnectionHandle conId, uint16_t charHandle, const uint8_t * data, size_t length) override; + CHIP_ERROR SubscribeCharacteristic(BleConnectionHandle conId, uint16_t charHandle) override; + CHIP_ERROR UnsubscribeCharacteristic(BleConnectionHandle conId, uint16_t charHandle) override; + uint16_t GetMTU(BleConnectionHandle conId) const override; + + void SetEventCallback(BleEventCallback callback, void * context) override; + bool CanHandleEvent(uint32_t eventId) const override; + void ParseEvent(void * platformEvent) override; + + CHIP_ERROR GetAddress(uint8_t * addr, size_t * length) override; + CHIP_ERROR GetDeviceName(char * buf, size_t bufSize) override; + CHIP_ERROR SetDeviceName(const char * name) override; + + CHIP_ERROR StartIndicationTimer(BleConnectionHandle conId, uint32_t timeoutMs, void (*callback)(void *), + void * context) override; + CHIP_ERROR CancelIndicationTimer(BleConnectionHandle conId) override; +}; + +} // namespace Internal +} // namespace DeviceLayer +} // namespace chip diff --git a/src/platform/silabs/ble/efr32/BUILD.gn b/src/platform/silabs/ble/efr32/BUILD.gn new file mode 100644 index 0000000000..7e2cca00c7 --- /dev/null +++ b/src/platform/silabs/ble/efr32/BUILD.gn @@ -0,0 +1,31 @@ +# Copyright (c) 2025 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build_overrides/chip.gni") + +# Matter BLE channel implementation for EFR32 (skeleton). +source_set("ble-efr32") { + sources = + [ "${chip_root}/src/platform/silabs/ble/efr32/BleChannelMatterEfr32.cpp" ] + + public_deps = [ + "${chip_root}/src/platform:platform_base", + "${chip_root}/src/platform/silabs/ble:ble", + ] + + include_dirs = [ + "${chip_root}/src/platform/silabs/ble", + "${chip_root}/src/platform/silabs/ble/efr32", + ] +} diff --git a/src/platform/silabs/ble/efr32/BleChannelMatterEfr32.cpp b/src/platform/silabs/ble/efr32/BleChannelMatterEfr32.cpp new file mode 100644 index 0000000000..8d8359288f --- /dev/null +++ b/src/platform/silabs/ble/efr32/BleChannelMatterEfr32.cpp @@ -0,0 +1,129 @@ +/* + * + * Copyright (c) 2025 Project CHIP Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @file + * Matter BLE channel implementation for EFR32 (skeleton). + */ + +#include "BleChannelMatterEfr32.h" +#include + +namespace chip { +namespace DeviceLayer { +namespace Internal { + +CHIP_ERROR BleChannelMatterEfr32::Init() +{ + return CHIP_NO_ERROR; +} + +CHIP_ERROR BleChannelMatterEfr32::Shutdown() +{ + return CHIP_NO_ERROR; +} + +CHIP_ERROR BleChannelMatterEfr32::StartAdvertising(const BleAdvertisingParams & params) +{ + return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; +} + +CHIP_ERROR BleChannelMatterEfr32::StopAdvertising() +{ + return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; +} + +CHIP_ERROR BleChannelMatterEfr32::SetAdvertisingData(const uint8_t * data, size_t length) +{ + return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; +} + +CHIP_ERROR BleChannelMatterEfr32::CloseConnection(BleConnectionHandle conId) +{ + return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; +} + +CHIP_ERROR BleChannelMatterEfr32::UpdateConnectionParams(BleConnectionHandle conId, const BleConnectionParams & params) +{ + return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; +} + +CHIP_ERROR BleChannelMatterEfr32::SendIndication(BleConnectionHandle conId, uint16_t charHandle, const uint8_t * data, + size_t length) +{ + return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; +} + +CHIP_ERROR BleChannelMatterEfr32::SendWriteRequest(BleConnectionHandle conId, uint16_t charHandle, const uint8_t * data, + size_t length) +{ + return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; +} + +CHIP_ERROR BleChannelMatterEfr32::SubscribeCharacteristic(BleConnectionHandle conId, uint16_t charHandle) +{ + return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; +} + +CHIP_ERROR BleChannelMatterEfr32::UnsubscribeCharacteristic(BleConnectionHandle conId, uint16_t charHandle) +{ + return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; +} + +uint16_t BleChannelMatterEfr32::GetMTU(BleConnectionHandle conId) const +{ + return 0; +} + +void BleChannelMatterEfr32::SetEventCallback(BleEventCallback callback, void * context) {} + +bool BleChannelMatterEfr32::CanHandleEvent(uint32_t eventId) const +{ + return false; +} + +void BleChannelMatterEfr32::ParseEvent(void * platformEvent) {} + +CHIP_ERROR BleChannelMatterEfr32::GetAddress(uint8_t * addr, size_t * length) +{ + return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; +} + +CHIP_ERROR BleChannelMatterEfr32::GetDeviceName(char * buf, size_t bufSize) +{ + return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; +} + +CHIP_ERROR BleChannelMatterEfr32::SetDeviceName(const char * name) +{ + return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; +} + +CHIP_ERROR BleChannelMatterEfr32::StartIndicationTimer(BleConnectionHandle conId, uint32_t timeoutMs, void (*callback)(void *), + void * context) +{ + return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; +} + +CHIP_ERROR BleChannelMatterEfr32::CancelIndicationTimer(BleConnectionHandle conId) +{ + return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; +} + +} // namespace Internal +} // namespace DeviceLayer +} // namespace chip diff --git a/src/platform/silabs/ble/efr32/BleChannelMatterEfr32.h b/src/platform/silabs/ble/efr32/BleChannelMatterEfr32.h new file mode 100644 index 0000000000..1884c76b38 --- /dev/null +++ b/src/platform/silabs/ble/efr32/BleChannelMatterEfr32.h @@ -0,0 +1,69 @@ +/* + * + * Copyright (c) 2025 Project CHIP Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @file + * Matter BLE channel implementation for EFR32 (skeleton). + */ + +#pragma once + +#include "BleChannel.h" +#include "BlePlatformTypes.h" + +namespace chip { +namespace DeviceLayer { +namespace Internal { + +class BleChannelMatterEfr32 : public BleChannel +{ +public: + BleChannelMatterEfr32() = default; + ~BleChannelMatterEfr32() override = default; + + CHIP_ERROR Init() override; + CHIP_ERROR Shutdown() override; + + CHIP_ERROR StartAdvertising(const BleAdvertisingParams & params) override; + CHIP_ERROR StopAdvertising() override; + CHIP_ERROR SetAdvertisingData(const uint8_t * data, size_t length) override; + + CHIP_ERROR CloseConnection(BleConnectionHandle conId) override; + CHIP_ERROR UpdateConnectionParams(BleConnectionHandle conId, const BleConnectionParams & params) override; + + CHIP_ERROR SendIndication(BleConnectionHandle conId, uint16_t charHandle, const uint8_t * data, size_t length) override; + CHIP_ERROR SendWriteRequest(BleConnectionHandle conId, uint16_t charHandle, const uint8_t * data, size_t length) override; + CHIP_ERROR SubscribeCharacteristic(BleConnectionHandle conId, uint16_t charHandle) override; + CHIP_ERROR UnsubscribeCharacteristic(BleConnectionHandle conId, uint16_t charHandle) override; + uint16_t GetMTU(BleConnectionHandle conId) const override; + + void SetEventCallback(BleEventCallback callback, void * context) override; + bool CanHandleEvent(uint32_t eventId) const override; + void ParseEvent(void * platformEvent) override; + + CHIP_ERROR GetAddress(uint8_t * addr, size_t * length) override; + CHIP_ERROR GetDeviceName(char * buf, size_t bufSize) override; + CHIP_ERROR SetDeviceName(const char * name) override; + + CHIP_ERROR StartIndicationTimer(BleConnectionHandle conId, uint32_t timeoutMs, void (*callback)(void *), + void * context) override; + CHIP_ERROR CancelIndicationTimer(BleConnectionHandle conId) override; +}; + +} // namespace Internal +} // namespace DeviceLayer +} // namespace chip diff --git a/src/platform/silabs/efr32/BUILD.gn b/src/platform/silabs/efr32/BUILD.gn index 0b68abed2f..cc6934163e 100644 --- a/src/platform/silabs/efr32/BUILD.gn +++ b/src/platform/silabs/efr32/BUILD.gn @@ -93,6 +93,11 @@ static_library("efr32") { "BLEManagerImpl.cpp", ] + public_deps += [ + "${silabs_platform_dir}/ble:ble", + "${silabs_platform_dir}/ble/efr32:ble-efr32", + ] + if (sl_use_internal_ble_side_channel) { sources += [ "BLEChannelImpl.cpp",