Skip to content

Commit

Permalink
[Silabs] [EFR32] Adds RS9116 BLE enabled for all applications (#24914)
Browse files Browse the repository at this point in the history
* Added changes for RS9116 BLE

* Resolved build errors for EFR ble

* Added changes rs916 ble manager

* Added inlcude path of rs911x BLE

* Added change for ble indication

* Added change for ble indication

* Reduced the rs9116 ble advertisingg interval

* Resolved review comments

* Adds namespace for the BLE function call

* Resolved review comments

* Added changes for remove RS91X_BLE_ENABLE define and used the SAPI RSI_BLE_ENABLE define

* Adds changes for the clear

* Adds changes for RS9116 ble config file path

* Adds fixes for EFR32 BLE build

* Restyling the PR

---------

Co-authored-by: shgutte <[email protected]>
  • Loading branch information
2 people authored and pull[bot] committed Jan 8, 2024
1 parent fed6080 commit 1130004
Show file tree
Hide file tree
Showing 20 changed files with 1,981 additions and 32 deletions.
12 changes: 12 additions & 0 deletions examples/light-switch-app/silabs/efr32/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ assert(current_os == "freertos")
efr32_project_dir = "${chip_root}/examples/light-switch-app/silabs/efr32"
examples_plat_dir = "${chip_root}/examples/platform/silabs/efr32"
examples_common_plat_dir = "${chip_root}/examples/platform/silabs"
if (chip_enable_ble_rs911x) {
src_plat_dir = "${chip_root}/src/platform/silabs/efr32"
}

import("${examples_plat_dir}/args.gni")

Expand Down Expand Up @@ -62,6 +65,15 @@ efr32_sdk("sdk") {
include_dirs += [ "${examples_plat_dir}/wf200" ]
}

if (chip_enable_ble_rs911x) {
# TODO efr32_sdk should not need a header from this location
include_dirs += [
"${src_plat_dir}/rs911x",
"${examples_plat_dir}/rs911x",
"${examples_plat_dir}/rs911x/hal",
]
}

defines = []
if (chip_enable_pw_rpc) {
defines += [
Expand Down
13 changes: 13 additions & 0 deletions examples/lighting-app/silabs/efr32/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ efr32_project_dir = "${chip_root}/examples/lighting-app/silabs/efr32"
examples_plat_dir = "${chip_root}/examples/platform/silabs/efr32"
examples_common_plat_dir = "${chip_root}/examples/platform/silabs"

if (chip_enable_ble_rs911x) {
src_plat_dir = "${chip_root}/src/platform/silabs/efr32"
}

import("${examples_plat_dir}/args.gni")

declare_args() {
Expand All @@ -61,6 +65,15 @@ efr32_sdk("sdk") {
include_dirs += [ "${examples_plat_dir}/wf200" ]
}

if (chip_enable_ble_rs911x) {
# TODO efr32_sdk should not need a header from this location
include_dirs += [
"${src_plat_dir}/rs911x",
"${examples_plat_dir}/rs911x",
"${examples_plat_dir}/rs911x/hal",
]
}

defines = []
if (chip_enable_pw_rpc) {
defines += [
Expand Down
13 changes: 13 additions & 0 deletions examples/lock-app/silabs/efr32/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ efr32_project_dir = "${chip_root}/examples/lock-app/silabs/efr32"
examples_plat_dir = "${chip_root}/examples/platform/silabs/efr32"
examples_common_plat_dir = "${chip_root}/examples/platform/silabs"

if (chip_enable_ble_rs911x) {
src_plat_dir = "${chip_root}/src/platform/silabs/efr32"
}

import("${examples_plat_dir}/args.gni")

declare_args() {
Expand All @@ -61,6 +65,15 @@ efr32_sdk("sdk") {
include_dirs += [ "${examples_plat_dir}/wf200" ]
}

if (chip_enable_ble_rs911x) {
# TODO efr32_sdk should not need a header from this location
include_dirs += [
"${src_plat_dir}/rs911x",
"${examples_plat_dir}/rs911x",
"${examples_plat_dir}/rs911x/hal",
]
}

defines = []
if (chip_enable_pw_rpc) {
defines += [
Expand Down
4 changes: 2 additions & 2 deletions examples/platform/silabs/SiWx917/SiWx917/rsi_if.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ bool hasNotifiedIPV4 = false;
#endif /* CHIP_DEVICE_CONFIG_ENABLE_IPV4 */
bool hasNotifiedWifiConnectivity = false;

extern rsi_semaphore_handle_t sl_ble_init_sem;
extern rsi_semaphore_handle_t sl_rs_ble_init_sem;
/*
* This file implements the interface to the RSI SAPIs
*/
Expand Down Expand Up @@ -340,7 +340,7 @@ static int32_t wfx_rsi_init(void)
}
#endif
wfx_rsi.dev_state |= WFX_RSI_ST_DEV_READY;
rsi_semaphore_post(&sl_ble_init_sem);
rsi_semaphore_post(&sl_rs_ble_init_sem);
WFX_RSI_LOG("%s: RSI: OK", __func__);
return RSI_SUCCESS;
}
Expand Down
20 changes: 16 additions & 4 deletions examples/platform/silabs/efr32/rs911x/rsi_if.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ bool is_wifi_disconnection_event = false;
/* Declare a variable to hold connection time intervals */
uint32_t retryInterval = WLAN_MIN_RETRY_TIMER_MS;

#if (RSI_BLE_ENABLE)
extern rsi_semaphore_handle_t sl_rs_ble_init_sem;
#endif

/*
* This file implements the interface to the RSI SAPIs
*/
Expand Down Expand Up @@ -317,7 +321,7 @@ static int32_t wfx_rsi_init(void)
status = rsi_driver_init(wfx_rsi_drv_buf, WFX_RSI_BUF_SZ);
if ((status < RSI_DRIVER_STATUS) || (status > WFX_RSI_BUF_SZ))
{
WFX_RSI_LOG("%s: error: RSI drv init failed with status: %02x", __func__, status);
WFX_RSI_LOG("%s: error: RSI Driver initialization failed with status: %02x", __func__, status);
return status;
}

Expand All @@ -340,11 +344,14 @@ static int32_t wfx_rsi_init(void)
return RSI_ERROR_INVALID_PARAM;
}

/* Initialize WiSeConnect or Module features. */
WFX_RSI_LOG("%s: rsi_wireless_init", __func__);
#if (RSI_BLE_ENABLE)
if ((status = rsi_wireless_init(OPER_MODE_0, RSI_OPERMODE_WLAN_BLE)) != RSI_SUCCESS)
{
#else
if ((status = rsi_wireless_init(OPER_MODE_0, COEX_MODE_0)) != RSI_SUCCESS)
{
WFX_RSI_LOG("%s: error: rsi_wireless_init failed with status: %02x", __func__, status);
#endif
WFX_RSI_LOG("%s: error: Initialize WiSeConnect failed with status: %02x", __func__, status);
return status;
}

Expand Down Expand Up @@ -397,6 +404,11 @@ static int32_t wfx_rsi_init(void)
return status;
}
#endif

#if (RSI_BLE_ENABLE)
rsi_semaphore_post(&sl_rs_ble_init_sem);
#endif

wfx_rsi.dev_state |= WFX_RSI_ST_DEV_READY;
WFX_RSI_LOG("%s: RSI: OK", __func__);
return RSI_SUCCESS;
Expand Down
3 changes: 3 additions & 0 deletions examples/platform/silabs/efr32/rs911x/wfx_rsi.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ struct wfx_rsi
EventGroupHandle_t events;
TaskHandle_t drv_task;
TaskHandle_t wlan_task;
#ifdef RSI_BLE_ENABLE
TaskHandle_t ble_task;
#endif
uint16_t dev_state;
uint16_t ap_chan; /* The chan our STA is using */
wfx_wifi_provision_t sec;
Expand Down
12 changes: 12 additions & 0 deletions examples/thermostat/silabs/efr32/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ assert(current_os == "freertos")
efr32_project_dir = "${chip_root}/examples/thermostat/silabs/efr32"
examples_plat_dir = "${chip_root}/examples/platform/silabs/efr32"
examples_common_plat_dir = "${chip_root}/examples/platform/silabs"
if (chip_enable_ble_rs911x) {
src_plat_dir = "${chip_root}/src/platform/silabs/efr32"
}

import("${examples_plat_dir}/args.gni")

Expand Down Expand Up @@ -65,6 +68,15 @@ efr32_sdk("sdk") {
include_dirs += [ "${examples_plat_dir}/wf200" ]
}

if (chip_enable_ble_rs911x) {
# TODO efr32_sdk should not need a header from this location
include_dirs += [
"${src_plat_dir}/rs911x",
"${examples_plat_dir}/rs911x",
"${examples_plat_dir}/rs911x/hal",
]
}

defines = []
if (chip_enable_pw_rpc) {
defines += [
Expand Down
12 changes: 12 additions & 0 deletions examples/window-app/silabs/efr32/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ project_dir = "${chip_root}/examples/window-app"
efr32_project_dir = "${project_dir}/silabs/efr32"
examples_plat_dir = "${chip_root}/examples/platform/silabs/efr32"
examples_common_plat_dir = "${chip_root}/examples/platform/silabs"
if (chip_enable_ble_rs911x) {
src_plat_dir = "${chip_root}/src/platform/silabs/efr32"
}

import("${examples_plat_dir}/args.gni")

Expand All @@ -54,6 +57,15 @@ efr32_sdk("sdk") {
# TODO efr32_sdk should not need a header from this location
include_dirs += [ "${examples_plat_dir}/wf200" ]
}

if (chip_enable_ble_rs911x) {
# TODO efr32_sdk should not need a header from this location
include_dirs += [
"${src_plat_dir}/rs911x",
"${examples_plat_dir}/rs911x",
"${examples_plat_dir}/rs911x/hal",
]
}
}

efr32_executable("window_app") {
Expand Down
14 changes: 7 additions & 7 deletions src/platform/silabs/BLEManagerImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

#include "FreeRTOS.h"
#include "timers.h"
#ifdef RS91X_BLE_ENABLE
#ifdef RSI_BLE_ENABLE
#ifdef __cplusplus
extern "C" {
#endif
Expand All @@ -41,7 +41,7 @@ extern "C" {
#include "gatt_db.h"
#include "sl_bgapi.h"
#include "sl_bt_api.h"
#endif // RS91X_BLE_ENABLE
#endif // RSI_BLE_ENABLE

namespace chip {
namespace DeviceLayer {
Expand All @@ -58,7 +58,7 @@ class BLEManagerImpl final : public BLEManager, private BleLayer, private BlePla
public:
void HandleBootEvent(void);

#ifdef RS91X_BLE_ENABLE
#ifdef RSI_BLE_ENABLE
void HandleConnectEvent(void);
void HandleConnectionCloseEvent(uint16_t reason);
void HandleWriteEvent(rsi_ble_event_write_t evt);
Expand All @@ -76,10 +76,10 @@ class BLEManagerImpl final : public BLEManager, private BleLayer, private BlePla
void HandleTXCharCCCDWrite(volatile sl_bt_msg_t * evt);
void HandleSoftTimerEvent(volatile sl_bt_msg_t * evt);
CHIP_ERROR StartAdvertising(void);
#endif // RS91X_BLE_ENABLE
#endif // RSI_BLE_ENABLE

#if CHIP_ENABLE_ADDITIONAL_DATA_ADVERTISING
#ifdef RS91X_BLE_ENABLE
#ifdef RSI_BLE_ENABLE
static void HandleC3ReadRequest(void);
#else
#if CHIP_ENABLE_ADDITIONAL_DATA_ADVERTISING
Expand Down Expand Up @@ -156,7 +156,7 @@ class BLEManagerImpl final : public BLEManager, private BleLayer, private BlePla

struct CHIPoBLEConState
{
#ifndef RS91X_BLE_ENABLE
#ifndef RSI_BLE_ENABLE
bd_addr address;
#endif
uint16_t mtu : 10;
Expand Down Expand Up @@ -186,7 +186,7 @@ class BLEManagerImpl final : public BLEManager, private BleLayer, private BlePla
CHIP_ERROR EncodeAdditionalDataTlv();
#endif

#ifdef RS91X_BLE_ENABLE
#ifdef RSI_BLE_ENABLE
void HandleRXCharWrite(rsi_ble_event_write_t * evt);
#else
void HandleRXCharWrite(volatile sl_bt_msg_t * evt);
Expand Down
6 changes: 3 additions & 3 deletions src/platform/silabs/SiWx917/BLEManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ extern rsi_ble_event_conn_status_t conn_event_to_app;
extern sl_wfx_msg_t event_msg;

StaticTask_t rsiBLETaskStruct;
rsi_semaphore_handle_t sl_ble_init_sem;
rsi_semaphore_handle_t sl_rs_ble_init_sem;
rsi_semaphore_handle_t sl_ble_event_sem;

/* wfxRsi Task will use as its stack */
Expand Down Expand Up @@ -99,9 +99,9 @@ void sl_ble_event_handling_task(void)
int32_t event_id;

WFX_RSI_LOG("%s starting", __func__);
rsi_semaphore_create(&sl_ble_init_sem, 0);
rsi_semaphore_create(&sl_rs_ble_init_sem, 0);
//! This semaphore is waiting for wifi module initialization.
rsi_semaphore_wait(&sl_ble_init_sem, 0);
rsi_semaphore_wait(&sl_rs_ble_init_sem, 0);

sl_ble_init();

Expand Down
1 change: 0 additions & 1 deletion src/platform/silabs/SiWx917/bluetooth/wfx_sl_ble_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ void rsi_ble_on_disconnect_event(rsi_ble_event_disconnect_t * resp_disconnect, u
{
WFX_RSI_LOG("%s: starting", __func__);
event_msg.reason = reason;
memcpy(event_msg.resp_disconnect, resp_disconnect, sizeof(rsi_ble_event_disconnect_t));
rsi_ble_app_set_event(RSI_BLE_DISCONN_EVENT);
}

Expand Down
15 changes: 12 additions & 3 deletions src/platform/silabs/efr32/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@

import("//build_overrides/chip.gni")

import("${chip_root}/src/platform/device.gni")

import("${chip_root}/build/chip/buildconfig_header.gni")
import("${chip_root}/src/crypto/crypto.gni")
import("${chip_root}/src/platform/device.gni")
import("${chip_root}/third_party/silabs/silabs_board.gni")

silabs_platform_dir = "${chip_root}/src/platform/silabs"
Expand Down Expand Up @@ -66,12 +65,22 @@ static_library("efr32") {
"${silabs_platform_dir}/SystemPlatformConfig.h",
"../../FreeRTOS/SystemTimeSupport.cpp",
"../../SingletonConfigurationManager.cpp",
"BLEManagerImpl.cpp",
"ConfigurationManagerImpl.cpp",
"KeyValueStoreManagerImpl.cpp",
"PlatformManagerImpl.cpp",
]

if (chip_enable_ble_rs911x) {
sources += [
"rs911x/BLEManagerImpl.cpp",
"rs911x/rsi_ble_config.h",
"rs911x/wfx_sl_ble_init.c",
"rs911x/wfx_sl_ble_init.h",
]
} else {
sources += [ "BLEManagerImpl.cpp" ]
}

if (chip_enable_ota_requestor) {
sources += [
"OTAImageProcessorImpl.cpp",
Expand Down
Loading

0 comments on commit 1130004

Please sign in to comment.