Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow platforms to disable BLE-related device events and add BleLayer state accessors #37759

Merged
merged 1 commit into from
Feb 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/ble/BleConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,16 @@
#define BLE_READ_REQUEST_CONTEXT void *
#endif // BLE_READ_REQUEST_CONTEXT

/**
* @def BLE_USES_DEVICE_EVENTS
*
* @brief Whether the platform uses / supports BLE-related device events.
* @see chip::DeviceLayer::ChipDeviceEvent
*/
#ifndef BLE_USES_DEVICE_EVENTS
#define BLE_USES_DEVICE_EVENTS 1
#endif

/**
* @def BLE_MAX_RECEIVE_WINDOW_SIZE
*
Expand Down
4 changes: 3 additions & 1 deletion src/ble/BleLayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ class DLL_EXPORT BleLayer
kState_NotInitialized = 0,
kState_Initialized = 1,
kState_Disconnecting = 2
} mState; ///< [READ-ONLY] Current state
} mState; ///< [READ-ONLY] external access is deprecated, use IsInitialized() / IsBleClosing()

// This app state is not used by ble transport etc, it will be used by external ble implementation like Android
void * mAppState = nullptr;
Expand All @@ -236,7 +236,9 @@ class DLL_EXPORT BleLayer
chip::System::Layer * systemLayer);
CHIP_ERROR Init(BlePlatformDelegate * platformDelegate, BleConnectionDelegate * connDelegate,
BleApplicationDelegate * appDelegate, chip::System::Layer * systemLayer);
bool IsInitialized() { return mState != kState_NotInitialized; }
void IndicateBleClosing();
bool IsBleClosing() { return mState == kState_Disconnecting; }
void Shutdown();

CHIP_ERROR CancelBleIncompleteConnection();
Expand Down
5 changes: 5 additions & 0 deletions src/include/platform/CHIPDeviceEvent.h
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,10 @@ typedef void (*AsyncWorkFunct)(intptr_t arg);
#include CHIPDEVICEPLATFORMEVENT_HEADER
#endif // defined(CHIP_DEVICE_LAYER_TARGET)

#if CONFIG_NETWORK_LAYER_BLE
#include <ble/Ble.h>
#endif

#include <inet/InetInterface.h>
#include <lib/support/LambdaBridge.h>
#include <system/SystemEvent.h>
Expand Down Expand Up @@ -467,6 +470,7 @@ struct ChipDeviceEvent final
uint8_t SessionType;
bool IsCommissioner;
} SessionEstablished;
#if CONFIG_NETWORK_LAYER_BLE && BLE_USES_DEVICE_EVENTS
struct
{
BLE_CONNECTION_OBJECT ConId;
Expand All @@ -493,6 +497,7 @@ struct ChipDeviceEvent final
{
BLE_CONNECTION_OBJECT ConId;
} CHIPoBLENotifyConfirm;
#endif // CONFIG_NETWORK_LAYER_BLE && BLE_USES_DEVICE_EVENTS
#if CHIP_DEVICE_CONFIG_ENABLE_WIFIPAF
struct
{
Expand Down
Loading