diff --git a/src/ble/BleConfig.h b/src/ble/BleConfig.h index c6d7877081f340..90a5daf60fdb03 100644 --- a/src/ble/BleConfig.h +++ b/src/ble/BleConfig.h @@ -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 * diff --git a/src/ble/BleLayer.h b/src/ble/BleLayer.h index 7056a09e5e14d6..5a98c6d3079b14 100644 --- a/src/ble/BleLayer.h +++ b/src/ble/BleLayer.h @@ -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; @@ -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(); diff --git a/src/include/platform/CHIPDeviceEvent.h b/src/include/platform/CHIPDeviceEvent.h index 9618d93f5faa05..71a1b2b454ad00 100644 --- a/src/include/platform/CHIPDeviceEvent.h +++ b/src/include/platform/CHIPDeviceEvent.h @@ -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 +#endif + #include #include #include @@ -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; @@ -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 {