Skip to content

Commit

Permalink
stopping the ble advertisement after sta was connected
Browse files Browse the repository at this point in the history
  • Loading branch information
chirag-silabs committed Apr 26, 2023
1 parent 373e067 commit 23b23ec
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 14 deletions.
21 changes: 12 additions & 9 deletions examples/platform/silabs/efr32/wf200/host_if.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -602,15 +602,6 @@ static void wfx_events_task(void * p_arg)
retryJoin = 0;
retryInterval = WLAN_MIN_RETRY_TIMER_MS;
wfx_lwip_set_sta_link_up();
#ifdef SLEEP_ENABLED
if (!(wfx_get_wifi_state() & SL_WFX_AP_INTERFACE_UP))
{
// Enable the power save
SILABS_LOG("WF200 going to DTIM based sleep");
sl_wfx_set_power_mode(WFM_PM_MODE_DTIM, WFM_PM_POLL_FAST_PS, BEACON_1);
sl_wfx_enable_device_power_save();
}
#endif // SLEEP_ENABLED
}

if (flags & SL_WFX_DISCONNECT)
Expand Down Expand Up @@ -896,6 +887,18 @@ int32_t wfx_reset_counts()
return -1;
}

/************************************************************************
* @brief
* reset the count
* @return returns -1
**************************************************************************/
void wfx_power_save() {
// Enable the power save
SILABS_LOG("WF200 going to DTIM based sleep");
sl_wfx_set_power_mode(WFM_PM_MODE_DTIM, WFM_PM_POLL_FAST_PS, BEACON_1);
sl_wfx_enable_device_power_save();
}

/*************************************************************************
* @brief
* I think that this is getting called before FreeRTOS threads are ready
Expand Down
5 changes: 2 additions & 3 deletions src/platform/silabs/BLEManagerImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ class BLEManagerImpl final : public BLEManager, private BleLayer, private BlePla
void HandleTxConfirmationEvent(BLE_CONNECTION_OBJECT conId);
void HandleTXCharCCCDWrite(rsi_ble_event_write_t * evt);
void HandleSoftTimerEvent(void);
CHIP_ERROR StartAdvertising(void);
#else
void HandleConnectEvent(volatile sl_bt_msg_t * evt);
void HandleConnectionCloseEvent(volatile sl_bt_msg_t * evt);
Expand All @@ -81,8 +80,9 @@ class BLEManagerImpl final : public BLEManager, private BleLayer, private BlePla
void HandleTxConfirmationEvent(BLE_CONNECTION_OBJECT conId);
void HandleTXCharCCCDWrite(volatile sl_bt_msg_t * evt);
void HandleSoftTimerEvent(volatile sl_bt_msg_t * evt);
CHIP_ERROR StartAdvertising(void);
#endif // RSI_BLE_ENABLE
CHIP_ERROR StartAdvertising(void);
CHIP_ERROR StopAdvertising(void);

#if CHIP_ENABLE_ADDITIONAL_DATA_ADVERTISING
#ifdef RSI_BLE_ENABLE
Expand Down Expand Up @@ -187,7 +187,6 @@ class BLEManagerImpl final : public BLEManager, private BleLayer, private BlePla
CHIP_ERROR MapBLEError(int bleErr);
void DriveBLEState(void);
CHIP_ERROR ConfigureAdvertisingData(void);
CHIP_ERROR StopAdvertising(void);
#if CHIP_ENABLE_ADDITIONAL_DATA_ADVERTISING
CHIP_ERROR EncodeAdditionalDataTlv();
#endif
Expand Down
2 changes: 2 additions & 0 deletions src/platform/silabs/ConnectivityManagerImpl_WIFI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,9 @@ void ConnectivityManagerImpl::OnStationConnected()
event.Type = DeviceEventType::kWiFiConnectivityChange;
event.WiFiConnectivityChange.Result = kConnectivity_Established;
(void) PlatformMgr().PostEvent(&event);
// Setting the rs911x in the power save mode
#if CHIP_DEVICE_CONFIG_ENABLE_SED
chip::DeviceLayer::Internal::BLEManagerImpl().StopAdvertising();
wfx_power_save();
#endif /* CHIP_DEVICE_CONFIG_ENABLE_SED */
UpdateInternetConnectivityState();
Expand Down
4 changes: 2 additions & 2 deletions src/platform/silabs/efr32/rs911x/BLEManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -661,12 +661,12 @@ CHIP_ERROR BLEManagerImpl::StartAdvertising(void)
return CHIP_NO_ERROR; // err;
}

// TODO:: Implementation need to be done.
CHIP_ERROR BLEManagerImpl::StopAdvertising(void)
{
CHIP_ERROR err = CHIP_NO_ERROR;
int32_t status = 0;
if (mFlags.Has(Flags::kAdvertising))
// TODO: change this condition
if (1)
{
mFlags.Clear(Flags::kAdvertising).Clear(Flags::kRestartAdvertising);
mFlags.Set(Flags::kFastAdvertisingEnabled, true);
Expand Down

0 comments on commit 23b23ec

Please sign in to comment.