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

Feature/rs911x ble implementation updated master #47

Open
wants to merge 25 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
ae505df
Add ble init file
shgutte Oct 11, 2022
33df8df
Added ble implementation fixes for rs911x
shgutte Oct 13, 2022
4d82732
Removed header file changes
shgutte Oct 13, 2022
0211292
updated gn files for linking errors
bhmanda-silabs Oct 13, 2022
a7a5577
Added code for freertos assert issue
bhmanda-silabs Oct 13, 2022
91b574a
Added code for ble events and GATT service
bhmanda-silabs Oct 13, 2022
ef95bd6
Added code for inhouse ble bringup
shgutte Oct 14, 2022
556f645
Added harcoded code for commissioning
shgutte Oct 14, 2022
4bae1da
Added the matter sdk support
shgutte Oct 15, 2022
535c9dd
Added code GETconnection fix
shgutte Oct 17, 2022
cb6d03f
Refactored the code
shgutte Oct 17, 2022
e48f4ac
Add changes for callback
shgutte Oct 18, 2022
aa464e4
Removed all EFR32 calls from BLEManagerCpp
shgutte Oct 19, 2022
77cf88b
Adds write fix for indication
shgutte Oct 19, 2022
8d8b296
Added the ble task event
shgutte Oct 20, 2022
ee286d2
Added code for the ble manager
shgutte Oct 20, 2022
3b10a66
Changed the value of RSI_BLE_GATT_ASYNC_ENABLE
shgutte Oct 20, 2022
723a57f
Refactoring the code
bhmanda-silabs Oct 20, 2022
e939b15
Added cleanup code for BLE
shgutte Oct 21, 2022
6d5dc3b
Adds fix for memcpy in ble init
shgutte Oct 21, 2022
f2ec599
Removed the build errors
shgutte Oct 21, 2022
81b25be
Added changes for ble events memcpy
bhmanda-silabs Oct 28, 2022
20690bc
Added disconnect event
bhmanda-silabs Oct 29, 2022
48ce43d
Added support for mg24
bhmanda-silabs Nov 1, 2022
64b3128
Added code for mg24
bhmanda-silabs Nov 1, 2022
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
3 changes: 3 additions & 0 deletions examples/lighting-app/efr32/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@ efr32_sdk("sdk") {
]

include_dirs = [
"${chip_root}/examples/platform/efr32/rs911x",
"${chip_root}/examples/platform/efr32/rs911x/hal",
"${chip_root}/third_party/silabs/wiseconnect-wifi-bt-sdk/sapi/include",
"${chip_root}/src/platform/EFR32",
"${efr32_project_dir}/include",
"${examples_plat_dir}",
Expand Down
3 changes: 2 additions & 1 deletion examples/lighting-app/efr32/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "init_efrPlatform.h"
#include "sl_simple_button_instances.h"
#include "sl_system_kernel.h"
#include "wfx_host_events.h"
#include <DeviceInfoProviderImpl.h>
#include <app/server/Server.h>
#include <credentials/DeviceAttestationCredsProvider.h>
Expand All @@ -33,7 +34,7 @@
#include <credentials/examples/DeviceAttestationCredsExample.h>
#endif

#define BLE_DEV_NAME "SiLabs-Light"
#define BLE_DEV_NAME "RSI-BLE"
using namespace ::chip;
using namespace ::chip::Inet;
using namespace ::chip::DeviceLayer;
Expand Down
10 changes: 10 additions & 0 deletions examples/platform/efr32/matter_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ using namespace ::chip::Inet;
using namespace ::chip::DeviceLayer;

#include <crypto/CHIPCryptoPAL.h>

#include "event_groups.h"
#include "wfx_rsi.h"

// If building with the EFR32-provided crypto backend, we can use the
// opaque keystore
#if CHIP_CRYPTO_PLATFORM
Expand Down Expand Up @@ -148,8 +152,14 @@ CHIP_ERROR EFR32MatterConfig::InitMatter(const char * appName)
EFR32_LOG("Init CHIP Stack");
// Init Chip memory management before the stack
ReturnErrorOnFailure(chip::Platform::MemoryInit());

// EFR32_LOG("Init RSI 911x Platform");
// wfx_rsi_init_platform();

EFR32_LOG("Init CHIP PlatformMgr ChipStack");
ReturnErrorOnFailure(PlatformMgr().InitChipStack());

EFR32_LOG("Init Set BLE Device Name");
chip::DeviceLayer::ConnectivityMgr().SetBLEDeviceName(appName);

#if CHIP_ENABLE_OPENTHREAD
Expand Down
3 changes: 3 additions & 0 deletions examples/platform/efr32/rs911x/rs911x.gni
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@ rs911x_src_plat = [
"${examples_plat_dir}/rs911x/hal/rsi_hal_mcu_timer.c",
"${examples_plat_dir}/rs911x/hal/efx_spi.c",
]

rs911x_plat_incs = [
"${wifi_sdk_dir}",
"${wifi_sdk_dir}/hal",
"${chip_root}/src/platform/EFR32",
"${chip_root}/src/platform/EFR32/RS911x",
]

#
Expand Down Expand Up @@ -95,6 +97,7 @@ rs911x_defs = [
"RSI_SPI_INTERFACE",
"RSI_WITH_OS",
]

rs911x_sock_defs = [
"RS911X_SOCKETS",
"RSI_IPV6_ENABLE",
Expand Down
174 changes: 100 additions & 74 deletions examples/platform/efr32/rs911x/rsi_if.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <stdlib.h>
#include <string.h>


#include "em_bus.h"
#include "em_cmu.h"
#include "em_gpio.h"
Expand All @@ -31,6 +32,7 @@
#include "event_groups.h"
#include "task.h"

#include "wfx_sl_ble_init.h"
#include "wfx_host_events.h"

#include "rsi_driver.h"
Expand All @@ -48,15 +50,17 @@
#include "rsi_bootup_config.h"
#include "rsi_error.h"

#include "rsi_bt_common.h"
#include "rsi_ble_apis.h"
#include "rsi_bt_common_apis.h"
#include "rsi_ble_config.h"
#include "rsi_utils.h"

#include "dhcp_client.h"
#include "wfx_host_events.h"
#include "wfx_rsi.h"

/* Rsi driver Task will use as its stack */
StackType_t driverRsiTaskStack[WFX_RSI_WLAN_TASK_SZ] = { 0 };

/* Structure that will hold the TCB of the wfxRsi Task being created. */
StaticTask_t driverRsiTaskBuffer;

/* Declare a variable to hold the data associated with the created event group. */
StaticEventGroup_t rsiDriverEventGroup;
Expand All @@ -70,7 +74,7 @@ bool hasNotifiedWifiConnectivity = false;
/*
* This file implements the interface to the RSI SAPIs
*/
static uint8_t wfx_rsi_drv_buf[WFX_RSI_BUF_SZ];
//static uint8_t wfx_rsi_drv_buf[WFX_RSI_BUF_SZ];
wfx_wifi_scan_ext_t * temp_reset;
uint8_t security;

Expand Down Expand Up @@ -293,76 +297,74 @@ static void wfx_rsi_wlan_pkt_cb(uint16_t status, uint8_t * buf, uint32_t len)
static int32_t wfx_rsi_init(void)
{
int32_t status;
uint8_t buf[RSI_RESPONSE_HOLD_BUFF_SIZE];
extern void rsi_hal_board_init(void);

WFX_RSI_LOG("%s: starting(HEAP_SZ = %d)", __func__, SL_HEAP_SIZE);
//! Driver initialization
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);
return status;
}

WFX_RSI_LOG("%s: rsi_device_init", __func__);
/* ! Redpine module intialisation */
if ((status = rsi_device_init(LOAD_NWP_FW)) != RSI_SUCCESS)
{
WFX_RSI_LOG("%s: error: rsi_device_init failed with status: %02x", __func__, status);
return status;
}
WFX_RSI_LOG("%s: start wireless drv task", __func__);
/*
* Create the driver task
*/
wfx_rsi.drv_task = xTaskCreateStatic((TaskFunction_t) rsi_wireless_driver_task, "rsi_drv", WFX_RSI_WLAN_TASK_SZ, NULL,
WLAN_TASK_PRIORITY, driverRsiTaskStack, &driverRsiTaskBuffer);
if (NULL == wfx_rsi.drv_task)
{
WFX_RSI_LOG("%s: error: rsi_wireless_driver_task failed", __func__);
return RSI_ERROR_INVALID_PARAM;
}

/* Initialize WiSeConnect or Module features. */
WFX_RSI_LOG("%s: rsi_wireless_init", __func__);
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);
return status;
}
// uint8_t buf[RSI_RESPONSE_HOLD_BUFF_SIZE];
// extern void rsi_hal_board_init(void);

// WFX_RSI_LOG("%s: starting(HEAP_SZ = %d)", __func__, SL_HEAP_SIZE);
// //! Driver initialization
// 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);
// return status;
// }
//
// WFX_RSI_LOG("%s: rsi_device_init", __func__);
// /* ! Redpine module intialisation */
// if ((status = rsi_device_init(LOAD_NWP_FW)) != RSI_SUCCESS)
// {
// WFX_RSI_LOG("%s: error: rsi_device_init failed with status: %02x", __func__, status);
// return status;
// }
// WFX_RSI_LOG("%s: start wireless drv task", __func__);
// /*
// * Create the driver task
// */
// wfx_rsi.drv_task = xTaskCreateStatic((TaskFunction_t) rsi_wireless_driver_task, "rsi_drv", WFX_RSI_WLAN_TASK_SZ, NULL,
// WLAN_TASK_PRIORITY, driverRsiTaskStack, &driverRsiTaskBuffer);
// if (NULL == wfx_rsi.drv_task)
// {
// WFX_RSI_LOG("%s: error: rsi_wireless_driver_task failed", __func__);
// return RSI_ERROR_INVALID_PARAM;
// }
//
// /* Initialize WiSeConnect or Module features. */
// WFX_RSI_LOG("%s: rsi_wireless_init", __func__);
// 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);
// return status;
// }
//
// WFX_RSI_LOG("%s: get FW version..", __func__);
// /*
// * Get the MAC and other info to let the user know about it.
// */
// if (rsi_wlan_get(RSI_FW_VERSION, buf, sizeof(buf)) != RSI_SUCCESS)
// {
// WFX_RSI_LOG("%s: error: rsi_wlan_get(RSI_FW_VERSION) failed with status: %02x", __func__, status);
// return status;
// }
//
// buf[sizeof(buf) - 1] = 0;
// WFX_RSI_LOG("%s: RSI firmware version: %s", __func__, buf);
// //! Send feature frame
// if ((status = rsi_send_feature_frame()) != RSI_SUCCESS)
// {
// WFX_RSI_LOG("%s: error: rsi_send_feature_frame failed with status: %02x", __func__, status);
// return status;
// }
//
// WFX_RSI_LOG("%s: sent rsi_send_feature_frame", __func__);
// /* initializes wlan radio parameters and WLAN supplicant parameters.
// */
// (void) rsi_wlan_radio_init(); /* Required so we can get MAC address */
// if ((status = rsi_wlan_get(RSI_MAC_ADDRESS, &wfx_rsi.sta_mac.octet[0], RESP_BUFF_SIZE)) != RSI_SUCCESS)
// {
// WFX_RSI_LOG("%s: error: rsi_wlan_get failed with status: %02x", __func__, status);
// return status;
// }

WFX_RSI_LOG("%s: get FW version..", __func__);
/*
* Get the MAC and other info to let the user know about it.
*/
if (rsi_wlan_get(RSI_FW_VERSION, buf, sizeof(buf)) != RSI_SUCCESS)
{
WFX_RSI_LOG("%s: error: rsi_wlan_get(RSI_FW_VERSION) failed with status: %02x", __func__, status);
return status;
}

buf[sizeof(buf) - 1] = 0;
WFX_RSI_LOG("%s: RSI firmware version: %s", __func__, buf);
//! Send feature frame
if ((status = rsi_send_feature_frame()) != RSI_SUCCESS)
{
WFX_RSI_LOG("%s: error: rsi_send_feature_frame failed with status: %02x", __func__, status);
return status;
}

WFX_RSI_LOG("%s: sent rsi_send_feature_frame", __func__);
/* initializes wlan radio parameters and WLAN supplicant parameters.
*/
(void) rsi_wlan_radio_init(); /* Required so we can get MAC address */
if ((status = rsi_wlan_get(RSI_MAC_ADDRESS, &wfx_rsi.sta_mac.octet[0], RESP_BUFF_SIZE)) != RSI_SUCCESS)
{
WFX_RSI_LOG("%s: error: rsi_wlan_get failed with status: %02x", __func__, status);
return status;
}

WFX_RSI_LOG("%s: WLAN: MAC %02x:%02x:%02x %02x:%02x:%02x", __func__, wfx_rsi.sta_mac.octet[0], wfx_rsi.sta_mac.octet[1],
wfx_rsi.sta_mac.octet[2], wfx_rsi.sta_mac.octet[3], wfx_rsi.sta_mac.octet[4], wfx_rsi.sta_mac.octet[5]);
wfx_rsi.events = xEventGroupCreateStatic(&rsiDriverEventGroup);
/*
* Register callbacks - We are only interested in the connectivity CBs
Expand Down Expand Up @@ -849,4 +851,28 @@ int32_t wfx_rsi_send_data(void * p, uint16_t len)
return status;
}



struct wfx_rsi wfx_rsi;

//void rsi_init_task(void * arg)
//{
// uint32_t rsi_status = wfx_sl_module_init();
// if (rsi_status != RSI_SUCCESS)
// {
// WFX_RSI_LOG("%s: error: wfx_sl_module_init with status: %02x", __func__, rsi_status);
// return;
// }
// WFX_RSI_LOG("After wfx_sl_module_init");
// rsi_task_suspend((rsi_task_handle_t *)wfx_rsi.init_task);
//}
//
//void wfx_rsi_init_platform()
//{
// /*init task - RS911x*/
// WFX_RSI_LOG("WFX:Start ble task");
// if (xTaskCreate((TaskFunction_t) rsi_init_task, "rsi_init", WFX_RSI_TASK_SZ, NULL, 54, &wfx_rsi.init_task) != pdPASS)
// {
// WFX_RSI_LOG("ERR: RSI ble task create");
// }
//}
3 changes: 3 additions & 0 deletions examples/platform/efr32/rs911x/wfx_rsi.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ struct wfx_rsi
EventGroupHandle_t events;
TaskHandle_t drv_task;
TaskHandle_t wlan_task;
TaskHandle_t init_task;
TaskHandle_t ble_task;
uint16_t dev_state;
uint16_t ap_chan; /* The chan our STA is using */
wfx_wifi_provision_t sec;
Expand Down Expand Up @@ -87,6 +89,7 @@ int32_t wfx_rsi_get_ap_info(wfx_wifi_scan_result_t * ap);
int32_t wfx_rsi_get_ap_ext(wfx_wifi_scan_ext_t * extra_info);
int32_t wfx_rsi_reset_count();
int32_t wfx_rsi_disconnect();
void wfx_rsi_init_platform();
#define WFX_RSI_LOG(...) efr32Log(__VA_ARGS__);

#ifdef __cplusplus
Expand Down
2 changes: 1 addition & 1 deletion src/include/platform/internal/BLEManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ extern BLEManagerImpl & BLEMgrImpl();
#ifdef EXTERNAL_BLEMANAGERIMPL_HEADER
#include EXTERNAL_BLEMANAGERIMPL_HEADER
#elif defined(CHIP_DEVICE_LAYER_TARGET)
#define BLEMANAGERIMPL_HEADER <platform/CHIP_DEVICE_LAYER_TARGET/BLEManagerImpl.h>
#define BLEMANAGERIMPL_HEADER <platform/CHIP_DEVICE_LAYER_TARGET/RS911x/BLEManagerImpl.h>
#include BLEMANAGERIMPL_HEADER
#endif // defined(CHIP_DEVICE_LAYER_TARGET)

Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
7 changes: 5 additions & 2 deletions src/platform/EFR32/BLEManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ extern "C" {
#include <lib/support/CodeUtils.h>
#include <lib/support/logging/CHIPLogging.h>
#include <platform/CommissionableDataProvider.h>
#include <platform/DeviceInstanceInfoProvider.h>
#include <platform/DeviceInstanceInfoProvider.h>![](C:/Users/shgutte/AppData/Local/Temp/download.jpg)
#include <sl_bt_rtos_adaptation.h>

#if CHIP_ENABLE_ADDITIONAL_DATA_ADVERTISING
Expand Down Expand Up @@ -1017,7 +1017,7 @@ extern "C" void sl_bt_on_event(sl_bt_msg_t * evt)
break;
case sl_bt_evt_connection_parameters_id: {
// ChipLogProgress(DeviceLayer, "Connection parameter ID received");
}

break;
case sl_bt_evt_connection_phy_status_id: {
// ChipLogProgress(DeviceLayer, "PHY update procedure is completed");
Expand Down Expand Up @@ -1045,10 +1045,13 @@ extern "C" void sl_bt_on_event(sl_bt_msg_t * evt)
case sl_bt_evt_gatt_server_characteristic_status_id: {
sl_bt_gatt_server_characteristic_status_flag_t StatusFlags;



StatusFlags = (sl_bt_gatt_server_characteristic_status_flag_t) evt->data.evt_gatt_server_characteristic_status.status_flags;

if (sl_bt_gatt_server_confirmation == StatusFlags)
{

chip::DeviceLayer::Internal::BLEMgrImpl().HandleTxConfirmationEvent(
evt->data.evt_gatt_server_characteristic_status.connection);
}
Expand Down
7 changes: 5 additions & 2 deletions src/platform/EFR32/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,11 @@ static_library("EFR32") {
sources = [
"../FreeRTOS/SystemTimeSupport.cpp",
"../SingletonConfigurationManager.cpp",
"BLEManagerImpl.cpp",
"BLEManagerImpl.h",
"RS911x/BLEManagerImpl.cpp",
"RS911x/wfx_sl_ble_init.h",
"RS911x/wfx_sl_ble_init.c",
"RS911x/rsi_ble_config.h",
"RS911x/BLEManagerImpl.h",
"BlePlatformConfig.h",
"CHIPDevicePlatformConfig.h",
"CHIPDevicePlatformEvent.h",
Expand Down
Loading