Skip to content

Commit

Permalink
Refactor : Applying Coding guideline of Silabs src/platform
Browse files Browse the repository at this point in the history
  • Loading branch information
sharad-patil24 committed Apr 4, 2023
1 parent 2f02c91 commit 3d9e0b5
Show file tree
Hide file tree
Showing 25 changed files with 417 additions and 496 deletions.
60 changes: 30 additions & 30 deletions src/platform/silabs/SiWx917/BLEManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ void sl_ble_event_handling_task(void)
//! This semaphore is waiting for wifi module initialization.
rsi_semaphore_wait(&sl_rs_ble_init_sem, 0);

// Initialize BLE and starts BLE Advertisement
sl_ble_init();

// Application event map
Expand Down Expand Up @@ -174,19 +175,19 @@ namespace Internal {

namespace {

#define CHIP_ADV_DATA_TYPE_FLAGS 0x01
#define CHIP_ADV_DATA_TYPE_UUID 0x03
#define CHIP_ADV_DATA_TYPE_NAME 0x09
#define CHIP_ADV_DATA_TYPE_SERVICE_DATA 0x16
#define CHIP_ADV_DATA_TYPE_FLAGS (0x01)
#define CHIP_ADV_DATA_TYPE_UUID (0x03)
#define CHIP_ADV_DATA_TYPE_NAME (0x09)
#define CHIP_ADV_DATA_TYPE_SERVICE_DATA (0x16)

#define CHIP_ADV_DATA_FLAGS 0x06
#define CHIP_ADV_DATA_FLAGS (0x06)

#define CHIP_ADV_DATA 0
#define CHIP_ADV_SCAN_RESPONSE_DATA 1
#define CHIP_ADV_SHORT_UUID_LEN 2
#define CHIP_ADV_DATA (0)
#define CHIP_ADV_SCAN_RESPONSE_DATA (1)
#define CHIP_ADV_SHORT_UUID_LEN (2)

#define MAX_RESPONSE_DATA_LEN 31
#define MAX_ADV_DATA_LEN 31
#define MAX_RESPONSE_DATA_LEN (31)
#define MAX_ADV_DATA_LEN (31)

// Timer Frequency used.
#define TIMER_CLK_FREQ ((uint32_t) 32768)
Expand All @@ -212,7 +213,7 @@ namespace {
#define BLE_CONFIG_MIN_CE_LENGTH (0) // Leave to min value
#define BLE_CONFIG_MAX_CE_LENGTH (0xFFFF) // Leave to max value

#define BLE_DEFAULT_TIMER_PERIOD 1
#define BLE_DEFAULT_TIMER_PERIOD_MS (1)

TimerHandle_t sbleAdvTimeoutTimer; // FreeRTOS sw timer.

Expand Down Expand Up @@ -251,7 +252,7 @@ CHIP_ERROR BLEManagerImpl::_Init()

// Create FreeRTOS sw timer for BLE timeouts and interval change.
sbleAdvTimeoutTimer = xTimerCreate("BleAdvTimer", // Just a text name, not used by the RTOS kernel
pdMS_TO_TICKS(BLE_DEFAULT_TIMER_PERIOD), // == default timer period
pdMS_TO_TICKS(BLE_DEFAULT_TIMER_PERIOD_MS), // == default timer period
false, // no timer reload (==one-shot)
(void *) this, // init timer id = ble obj context
BleAdvTimeoutHandler // timer callback handler
Expand Down Expand Up @@ -314,7 +315,7 @@ CHIP_ERROR BLEManagerImpl::_SetAdvertisingMode(BLEAdvertisingMode mode)
return CHIP_NO_ERROR;
}

CHIP_ERROR BLEManagerImpl::_GetDeviceName(char * buf, size_t bufSize)
CHIP_ERROR BLEManagerImpl::_GetDeviceName(char *buf, size_t bufSize)
{
if (strlen(mDeviceName) >= bufSize)
{
Expand All @@ -324,7 +325,7 @@ CHIP_ERROR BLEManagerImpl::_GetDeviceName(char * buf, size_t bufSize)
return CHIP_NO_ERROR;
}

CHIP_ERROR BLEManagerImpl::_SetDeviceName(const char * deviceName)
CHIP_ERROR BLEManagerImpl::_SetDeviceName(const char *deviceName)
{
ChipLogProgress(DeviceLayer, "_SetDeviceName Started");
if (mServiceMode == ConnectivityManager::kCHIPoBLEServiceMode_NotSupported)
Expand Down Expand Up @@ -353,7 +354,7 @@ CHIP_ERROR BLEManagerImpl::_SetDeviceName(const char * deviceName)
return CHIP_NO_ERROR;
}

void BLEManagerImpl::_OnPlatformEvent(const ChipDeviceEvent * event)
void BLEManagerImpl::_OnPlatformEvent(const ChipDeviceEvent *event)
{
switch (event->Type)
{
Expand Down Expand Up @@ -398,13 +399,13 @@ void BLEManagerImpl::_OnPlatformEvent(const ChipDeviceEvent * event)
}
}

bool BLEManagerImpl::SubscribeCharacteristic(BLE_CONNECTION_OBJECT conId, const ChipBleUUID * svcId, const ChipBleUUID * charId)
bool BLEManagerImpl::SubscribeCharacteristic(BLE_CONNECTION_OBJECT conId, const ChipBleUUID *svcId, const ChipBleUUID *charId)
{
ChipLogProgress(DeviceLayer, "BLEManagerImpl::SubscribeCharacteristic() not supported");
return false;
}

bool BLEManagerImpl::UnsubscribeCharacteristic(BLE_CONNECTION_OBJECT conId, const ChipBleUUID * svcId, const ChipBleUUID * charId)
bool BLEManagerImpl::UnsubscribeCharacteristic(BLE_CONNECTION_OBJECT conId, const ChipBleUUID *svcId, const ChipBleUUID *charId)
{
ChipLogProgress(DeviceLayer, "BLEManagerImpl::UnsubscribeCharacteristic() not supported");
return false;
Expand All @@ -430,7 +431,7 @@ uint16_t BLEManagerImpl::GetMTU(BLE_CONNECTION_OBJECT conId) const
return (conState != NULL) ? conState->mtu : 0;
}

bool BLEManagerImpl::SendIndication(BLE_CONNECTION_OBJECT conId, const ChipBleUUID * svcId, const ChipBleUUID * charId,
bool BLEManagerImpl::SendIndication(BLE_CONNECTION_OBJECT conId, const ChipBleUUID *svcId, const ChipBleUUID *charId,
PacketBufferHandle data)
{
int32_t status = 0;
Expand All @@ -439,37 +440,37 @@ bool BLEManagerImpl::SendIndication(BLE_CONNECTION_OBJECT conId, const ChipBleUU
data->Start());
if (status != RSI_SUCCESS)
{
ChipLogProgress(DeviceLayer, "indication %d failed with error code %lx ", status);
ChipLogProgress(DeviceLayer, "indication failed with error code %lx ", status);
return false;
}

return true;
}

bool BLEManagerImpl::SendWriteRequest(BLE_CONNECTION_OBJECT conId, const ChipBleUUID * svcId, const ChipBleUUID * charId,
bool BLEManagerImpl::SendWriteRequest(BLE_CONNECTION_OBJECT conId, const ChipBleUUID *svcId, const ChipBleUUID *charId,
PacketBufferHandle pBuf)
{
ChipLogProgress(DeviceLayer, "BLEManagerImpl::SendWriteRequest() not supported");
return false;
}

bool BLEManagerImpl::SendReadRequest(BLE_CONNECTION_OBJECT conId, const ChipBleUUID * svcId, const ChipBleUUID * charId,
bool BLEManagerImpl::SendReadRequest(BLE_CONNECTION_OBJECT conId, const ChipBleUUID *svcId, const ChipBleUUID *charId,
PacketBufferHandle pBuf)
{
ChipLogProgress(DeviceLayer, "BLEManagerImpl::SendReadRequest() not supported");
return false;
}

bool BLEManagerImpl::SendReadResponse(BLE_CONNECTION_OBJECT conId, BLE_READ_REQUEST_CONTEXT requestContext,
const ChipBleUUID * svcId, const ChipBleUUID * charId)
const ChipBleUUID *svcId, const ChipBleUUID *charId)
{
ChipLogProgress(DeviceLayer, "BLEManagerImpl::SendReadResponse() not supported");
return false;
}

void BLEManagerImpl::NotifyChipConnectionClosed(BLE_CONNECTION_OBJECT conId)
{
// Nothing to do
// Nothing to do : Placeholder
}

CHIP_ERROR BLEManagerImpl::MapBLEError(int bleErr)
Expand All @@ -493,12 +494,11 @@ CHIP_ERROR BLEManagerImpl::MapBLEError(int bleErr)

void BLEManagerImpl::DriveBLEState(void)
{

ChipLogProgress(DeviceLayer, "DriveBLEState starting");
CHIP_ERROR err = CHIP_NO_ERROR;

// Check if BLE stack is initialized
// VerifyOrExit(mFlags.Has(Flags::kEFRBLEStackInitialized), /* */);
// VerifyOrExit(mFlags.Has(Flags::kEFRBLEStackInitialized),);

ChipLogProgress(DeviceLayer, "Start advertising if needed...");
// Start advertising if needed...
Expand Down Expand Up @@ -768,7 +768,7 @@ void BLEManagerImpl::HandleWriteEvent(rsi_ble_event_write_t evt)
}

// TODO:: Need to implement this
void BLEManagerImpl::HandleTXCharCCCDWrite(rsi_ble_event_write_t * evt)
void BLEManagerImpl::HandleTXCharCCCDWrite(rsi_ble_event_write_t *evt)
{
CHIP_ERROR err = CHIP_NO_ERROR;
bool isIndicationEnabled = false;
Expand Down Expand Up @@ -800,7 +800,7 @@ void BLEManagerImpl::HandleTXCharCCCDWrite(rsi_ble_event_write_t * evt)
}
}

void BLEManagerImpl::HandleRXCharWrite(rsi_ble_event_write_t * evt)
void BLEManagerImpl::HandleRXCharWrite(rsi_ble_event_write_t *evt)
{
uint8_t conId = 1;
CHIP_ERROR err = CHIP_NO_ERROR;
Expand Down Expand Up @@ -860,7 +860,7 @@ bool BLEManagerImpl::RemoveConnection(uint8_t connectionHandle)

void BLEManagerImpl::AddConnection(uint8_t connectionHandle, uint8_t bondingHandle)
{
CHIPoBLEConState * bleConnState = GetConnectionState(connectionHandle, true);
CHIPoBLEConState *bleConnState = GetConnectionState(connectionHandle, true);

if (bleConnState != NULL)
{
Expand Down Expand Up @@ -935,10 +935,10 @@ CHIP_ERROR BLEManagerImpl::EncodeAdditionalDataTlv()
return err;
}

// TODO:: Need the
// TODO:: Need to do the correct implementation
void BLEManagerImpl::HandleC3ReadRequest(void)
{

// TODO
// if (ret != SL_STATUS_OK)
// {
// ChipLogDetail(DeviceLayer, "Failed to send read response, err:%ld", ret);
Expand Down
Loading

0 comments on commit 3d9e0b5

Please sign in to comment.