Skip to content

Commit 05f1504

Browse files
committed
modifying the file to have classes
1 parent 28d7219 commit 05f1504

File tree

4 files changed

+113
-119
lines changed

4 files changed

+113
-119
lines changed

src/platform/silabs/BLEManagerImpl.h

+9-9
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,13 @@ class BLEManagerImpl final : public BLEManager, private BleLayer, private BlePla
6060

6161
#if (SLI_SI91X_ENABLE_BLE || RSI_BLE_ENABLE)
6262
// Used for posting the event in the BLE queue
63-
void BlePostEvent(BleEvent_t * event);
64-
void HandleConnectEvent(sl_wfx_msg_t * evt);
65-
void HandleConnectionCloseEvent(sl_wfx_msg_t * evt);
66-
void HandleWriteEvent(sl_wfx_msg_t * evt);
67-
void UpdateMtu(sl_wfx_msg_t * evt);
63+
void BlePostEvent(SilabsBleWrapper::BleEvent_t * event);
64+
void HandleConnectEvent(SilabsBleWrapper::sl_wfx_msg_t * evt);
65+
void HandleConnectionCloseEvent(SilabsBleWrapper::sl_wfx_msg_t * evt);
66+
void HandleWriteEvent(SilabsBleWrapper::sl_wfx_msg_t * evt);
67+
void UpdateMtu(SilabsBleWrapper::sl_wfx_msg_t * evt);
6868
void HandleTxConfirmationEvent(BLE_CONNECTION_OBJECT conId);
69-
void HandleTXCharCCCDWrite(sl_wfx_msg_t * evt);
69+
void HandleTXCharCCCDWrite(SilabsBleWrapper::sl_wfx_msg_t * evt);
7070
void HandleSoftTimerEvent(void);
7171
int32_t SendBLEAdvertisementCommand(void);
7272
#else
@@ -83,7 +83,7 @@ class BLEManagerImpl final : public BLEManager, private BleLayer, private BlePla
8383

8484
#if CHIP_ENABLE_ADDITIONAL_DATA_ADVERTISING
8585
#if (SLI_SI91X_ENABLE_BLE || RSI_BLE_ENABLE)
86-
static void HandleC3ReadRequest(sl_wfx_msg_t * rsi_ble_read_req);
86+
static void HandleC3ReadRequest(SilabsBleWrapper::sl_wfx_msg_t * rsi_ble_read_req);
8787
#else
8888
#if CHIP_ENABLE_ADDITIONAL_DATA_ADVERTISING
8989
static void HandleC3ReadRequest(volatile sl_bt_msg_t * evt);
@@ -101,7 +101,7 @@ class BLEManagerImpl final : public BLEManager, private BleLayer, private BlePla
101101
osMessageQueueId_t sBleEventQueue = NULL;
102102
static void sl_ble_event_handling_task(void * args);
103103
void sl_ble_init();
104-
void ProcessEvent(BleEvent_t inEvent);
104+
void ProcessEvent(SilabsBleWrapper::BleEvent_t inEvent);
105105
#endif
106106

107107
// ===== Members that implement the BLEManager internal interface.
@@ -197,7 +197,7 @@ class BLEManagerImpl final : public BLEManager, private BleLayer, private BlePla
197197
#endif
198198

199199
#if (SLI_SI91X_ENABLE_BLE || RSI_BLE_ENABLE)
200-
void HandleRXCharWrite(sl_wfx_msg_t * evt);
200+
void HandleRXCharWrite(SilabsBleWrapper::sl_wfx_msg_t * evt);
201201
#else
202202
void HandleRXCharWrite(volatile sl_bt_msg_t * evt);
203203
#endif

src/platform/silabs/rs911x/BLEManagerImpl.cpp

+21-21
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,11 @@ const uint8_t ShortUUID_CHIPoBLEService[] = { 0xF6, 0xFF };
115115

116116
BLEManagerImpl BLEManagerImpl::sInstance;
117117

118-
void BLEManagerImpl::ProcessEvent(BleEvent_t inEvent)
118+
void BLEManagerImpl::ProcessEvent(SilabsBleWrapper::BleEvent_t inEvent)
119119
{
120120
switch (inEvent.eventType)
121121
{
122-
case RSI_BLE_CONN_EVENT: {
122+
case SilabsBleWrapper::BleEventType_e::RSI_BLE_CONN_EVENT: {
123123
BLEMgrImpl().HandleConnectEvent((inEvent.eventData));
124124
// Requests the connection parameters change with the remote device
125125
rsi_ble_conn_params_update(inEvent.eventData->resp_enh_conn.dev_addr, BLE_MIN_CONNECTION_INTERVAL_MS,
@@ -131,17 +131,17 @@ void BLEManagerImpl::ProcessEvent(BleEvent_t inEvent)
131131
ble_measurement_hndl = inEvent.eventData->rsi_ble_measurement_hndl;
132132
}
133133
break;
134-
case RSI_BLE_DISCONN_EVENT: {
134+
case SilabsBleWrapper::BleEventType_e::RSI_BLE_DISCONN_EVENT: {
135135
// event invokes when disconnection was completed
136136
BLEMgrImpl().HandleConnectionCloseEvent(inEvent.eventData);
137137
}
138138
break;
139-
case RSI_BLE_MTU_EVENT: {
139+
case SilabsBleWrapper::BleEventType_e::RSI_BLE_MTU_EVENT: {
140140
// event invokes when write/notification events received
141141
BLEMgrImpl().UpdateMtu(inEvent.eventData);
142142
}
143143
break;
144-
case RSI_BLE_EVENT_GATT_RD: {
144+
case SilabsBleWrapper::BleEventType_e::RSI_BLE_EVENT_GATT_RD: {
145145
#if CHIP_ENABLE_ADDITIONAL_DATA_ADVERTISING
146146
if (inEvent.eventData->rsi_ble_read_req->type == 0)
147147
{
@@ -150,12 +150,12 @@ void BLEManagerImpl::ProcessEvent(BleEvent_t inEvent)
150150
#endif // CHIP_ENABLE_ADDITIONAL_DATA_ADVERTISING
151151
}
152152
break;
153-
case RSI_BLE_GATT_WRITE_EVENT: {
153+
case SilabsBleWrapper::BleEventType_e::RSI_BLE_GATT_WRITE_EVENT: {
154154
// event invokes when write/notification events received
155155
BLEMgrImpl().HandleWriteEvent(inEvent.eventData);
156156
}
157157
break;
158-
case RSI_BLE_GATT_INDICATION_CONFIRMATION: {
158+
case SilabsBleWrapper::BleEventType_e::RSI_BLE_GATT_INDICATION_CONFIRMATION: {
159159
BLEMgrImpl().HandleTxConfirmationEvent(1);
160160
}
161161
break;
@@ -164,7 +164,7 @@ void BLEManagerImpl::ProcessEvent(BleEvent_t inEvent)
164164
}
165165
}
166166

167-
void BLEManagerImpl::BlePostEvent(BleEvent_t * event)
167+
void BLEManagerImpl::BlePostEvent(SilabsBleWrapper::BleEvent_t * event)
168168
{
169169
sl_status_t status = osMessageQueuePut(sInstance.sBleEventQueue, event, 0, 0);
170170
if (status != osOK)
@@ -177,7 +177,7 @@ void BLEManagerImpl::BlePostEvent(BleEvent_t * event)
177177
void BLEManagerImpl::sl_ble_event_handling_task(void * args)
178178
{
179179
sl_status_t status;
180-
BleEvent_t bleEvent;
180+
SilabsBleWrapper::BleEvent_t bleEvent;
181181

182182
//! This semaphore is waiting for wifi module initialization.
183183
osSemaphoreAcquire(sl_rs_ble_init_sem, osWaitForever);
@@ -210,16 +210,16 @@ void BLEManagerImpl::sl_ble_init()
210210
randomAddrBLE[(RSI_BLE_ADDR_LENGTH - 1)] |= 0xC0;
211211

212212
// registering the GAP callback functions
213-
rsi_ble_gap_register_callbacks(NULL, NULL, rsi_ble_on_disconnect_event, NULL, NULL, NULL, rsi_ble_on_enhance_conn_status_event,
213+
rsi_ble_gap_register_callbacks(NULL, NULL, SilabsBleWrapper::rsi_ble_on_disconnect_event, NULL, NULL, NULL, SilabsBleWrapper::rsi_ble_on_enhance_conn_status_event,
214214
NULL, NULL, NULL);
215215

216216
// registering the GATT call back functions
217-
rsi_ble_gatt_register_callbacks(NULL, NULL, NULL, NULL, NULL, NULL, NULL, rsi_ble_on_gatt_write_event, NULL, NULL,
218-
rsi_ble_on_read_req_event, rsi_ble_on_mtu_event, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
219-
NULL, rsi_ble_on_event_indication_confirmation, NULL);
217+
rsi_ble_gatt_register_callbacks(NULL, NULL, NULL, NULL, NULL, NULL, NULL, SilabsBleWrapper::rsi_ble_on_gatt_write_event, NULL, NULL,
218+
SilabsBleWrapper::rsi_ble_on_read_req_event, SilabsBleWrapper::rsi_ble_on_mtu_event, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
219+
NULL, SilabsBleWrapper::rsi_ble_on_event_indication_confirmation, NULL);
220220

221221
// Exchange of GATT info with BLE stack
222-
rsi_ble_add_matter_service();
222+
SilabsBleWrapper::rsi_ble_add_matter_service();
223223
rsi_ble_set_random_address_with_value(randomAddrBLE);
224224

225225
sInstance.sBleEventQueue = osMessageQueueNew(WFX_QUEUE_SIZE, sizeof(WfxEvent_t), NULL);
@@ -733,7 +733,7 @@ CHIP_ERROR BLEManagerImpl::StopAdvertising(void)
733733
return err;
734734
}
735735

736-
void BLEManagerImpl::UpdateMtu(sl_wfx_msg_t * evt)
736+
void BLEManagerImpl::UpdateMtu(SilabsBleWrapper::sl_wfx_msg_t * evt)
737737
{
738738
CHIPoBLEConState * bleConnState = GetConnectionState(evt->connectionHandle);
739739
if (bleConnState != NULL)
@@ -762,14 +762,14 @@ void BLEManagerImpl::HandleBootEvent(void)
762762
PlatformMgr().ScheduleWork(DriveBLEState, 0);
763763
}
764764

765-
void BLEManagerImpl::HandleConnectEvent(sl_wfx_msg_t * evt)
765+
void BLEManagerImpl::HandleConnectEvent(SilabsBleWrapper::sl_wfx_msg_t * evt)
766766
{
767767
AddConnection(evt->connectionHandle, evt->bondingHandle);
768768
PlatformMgr().ScheduleWork(DriveBLEState, 0);
769769
}
770770

771771
// TODO:: Implementation need to be done.
772-
void BLEManagerImpl::HandleConnectionCloseEvent(sl_wfx_msg_t * evt)
772+
void BLEManagerImpl::HandleConnectionCloseEvent(SilabsBleWrapper::sl_wfx_msg_t * evt)
773773
{
774774
uint8_t connHandle = 1;
775775

@@ -803,7 +803,7 @@ void BLEManagerImpl::HandleConnectionCloseEvent(sl_wfx_msg_t * evt)
803803
}
804804
}
805805

806-
void BLEManagerImpl::HandleWriteEvent(sl_wfx_msg_t * evt)
806+
void BLEManagerImpl::HandleWriteEvent(SilabsBleWrapper::sl_wfx_msg_t * evt)
807807
{
808808
ChipLogProgress(DeviceLayer, "Char Write Req, packet type %d", evt->rsi_ble_write.pkt_type);
809809

@@ -818,7 +818,7 @@ void BLEManagerImpl::HandleWriteEvent(sl_wfx_msg_t * evt)
818818
}
819819

820820
// TODO:: Need to implement this
821-
void BLEManagerImpl::HandleTXCharCCCDWrite(sl_wfx_msg_t * evt)
821+
void BLEManagerImpl::HandleTXCharCCCDWrite(SilabsBleWrapper::sl_wfx_msg_t * evt)
822822
{
823823
CHIP_ERROR err = CHIP_NO_ERROR;
824824
bool isIndicationEnabled = false;
@@ -863,7 +863,7 @@ void BLEManagerImpl::HandleTXCharCCCDWrite(sl_wfx_msg_t * evt)
863863
}
864864
}
865865

866-
void BLEManagerImpl::HandleRXCharWrite(sl_wfx_msg_t * evt)
866+
void BLEManagerImpl::HandleRXCharWrite(SilabsBleWrapper::sl_wfx_msg_t * evt)
867867
{
868868
uint8_t conId = 1;
869869
CHIP_ERROR err = CHIP_NO_ERROR;
@@ -996,7 +996,7 @@ CHIP_ERROR BLEManagerImpl::EncodeAdditionalDataTlv()
996996
return err;
997997
}
998998

999-
void BLEManagerImpl::HandleC3ReadRequest(sl_wfx_msg_t * evt)
999+
void BLEManagerImpl::HandleC3ReadRequest(SilabsBleWrapper::sl_wfx_msg_t * evt)
10001000
{
10011001
sl_status_t ret = rsi_ble_gatt_read_response(evt->rsi_ble_read_req.dev_addr, GATT_READ_RESP, evt->rsi_ble_read_req.handle,
10021002
GATT_READ_ZERO_OFFSET, sInstance.c3AdditionalDataBufferHandle->DataLength(),

src/platform/silabs/rs911x/wfx_sl_ble_init.cpp

+25-31
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,13 @@
2222
*/
2323
#include <lib/support/logging/CHIPLogging.h>
2424
#include <platform/CHIPDeviceLayer.h>
25-
// #include <platform/internal/BLEManager.h>
2625
#include <platform/silabs/BLEManagerImpl.h>
27-
28-
#ifdef __cplusplus
29-
extern "C" {
30-
#endif
3126
#include "wfx_sl_ble_init.h"
32-
#ifdef __cplusplus
33-
}
34-
#endif
27+
28+
using namespace chip::DeviceLayer::Internal;
3529

3630
// Global Variables
37-
BleEvent_t bleEvent;
31+
SilabsBleWrapper::BleEvent_t bleEvent;
3832

3933
/*==============================================*/
4034
/**
@@ -45,11 +39,11 @@ BleEvent_t bleEvent;
4539
* @section description
4640
* This callback function is invoked when mtu exhange event is received
4741
*/
48-
void rsi_ble_on_mtu_event(rsi_ble_event_mtu_t * rsi_ble_mtu)
42+
void SilabsBleWrapper::rsi_ble_on_mtu_event(rsi_ble_event_mtu_t * rsi_ble_mtu)
4943
{
50-
bleEvent.eventType = RSI_BLE_MTU_EVENT;
44+
bleEvent.eventType = BleEventType_e::RSI_BLE_MTU_EVENT;
5145
memcpy(&bleEvent.eventData->rsi_ble_mtu, rsi_ble_mtu, sizeof(rsi_ble_event_mtu_t));
52-
chip::DeviceLayer::Internal::BLEMgrImpl().BlePostEvent(&bleEvent);
46+
BLEMgrImpl().BlePostEvent(&bleEvent);
5347
}
5448

5549
/*==============================================*/
@@ -62,12 +56,12 @@ void rsi_ble_on_mtu_event(rsi_ble_event_mtu_t * rsi_ble_mtu)
6256
* @section description
6357
* This callback function is invoked when write/notify/indication events are received
6458
*/
65-
void rsi_ble_on_gatt_write_event(uint16_t event_id, rsi_ble_event_write_t * rsi_ble_write)
59+
void SilabsBleWrapper::rsi_ble_on_gatt_write_event(uint16_t event_id, rsi_ble_event_write_t * rsi_ble_write)
6660
{
67-
bleEvent.eventType = RSI_BLE_GATT_WRITE_EVENT;
61+
bleEvent.eventType = BleEventType_e::RSI_BLE_GATT_WRITE_EVENT;
6862
bleEvent.eventData->event_id = event_id;
6963
memcpy(&bleEvent.eventData->rsi_ble_write, rsi_ble_write, sizeof(rsi_ble_event_write_t));
70-
chip::DeviceLayer::Internal::BLEMgrImpl().BlePostEvent(&bleEvent);
64+
BLEMgrImpl().BlePostEvent(&bleEvent);
7165
}
7266

7367
/*==============================================*/
@@ -79,13 +73,13 @@ void rsi_ble_on_gatt_write_event(uint16_t event_id, rsi_ble_event_write_t * rsi_
7973
* @section description
8074
* This callback function indicates the status of the connection
8175
*/
82-
void rsi_ble_on_enhance_conn_status_event(rsi_ble_event_enhance_conn_status_t * resp_enh_conn)
76+
void SilabsBleWrapper::rsi_ble_on_enhance_conn_status_event(rsi_ble_event_enhance_conn_status_t * resp_enh_conn)
8377
{
84-
bleEvent.eventType = RSI_BLE_CONN_EVENT;
78+
bleEvent.eventType = BleEventType_e::RSI_BLE_CONN_EVENT;
8579
bleEvent.eventData->connectionHandle = 1;
8680
bleEvent.eventData->bondingHandle = 255;
8781
memcpy(bleEvent.eventData->resp_enh_conn.dev_addr, resp_enh_conn->dev_addr, RSI_DEV_ADDR_LEN);
88-
chip::DeviceLayer::Internal::BLEMgrImpl().BlePostEvent(&bleEvent);
82+
BLEMgrImpl().BlePostEvent(&bleEvent);
8983
}
9084

9185
/*==============================================*/
@@ -98,11 +92,11 @@ void rsi_ble_on_enhance_conn_status_event(rsi_ble_event_enhance_conn_status_t *
9892
* @section description
9993
* This callback function indicates disconnected device information and status
10094
*/
101-
void rsi_ble_on_disconnect_event(rsi_ble_event_disconnect_t * resp_disconnect, uint16_t reason)
95+
void SilabsBleWrapper::rsi_ble_on_disconnect_event(rsi_ble_event_disconnect_t * resp_disconnect, uint16_t reason)
10296
{
103-
bleEvent.eventType = RSI_BLE_DISCONN_EVENT;
97+
bleEvent.eventType = BleEventType_e::RSI_BLE_DISCONN_EVENT;
10498
bleEvent.eventData->reason = reason;
105-
chip::DeviceLayer::Internal::BLEMgrImpl().BlePostEvent(&bleEvent);
99+
BLEMgrImpl().BlePostEvent(&bleEvent);
106100
}
107101

108102
/*==============================================*/
@@ -114,12 +108,12 @@ void rsi_ble_on_disconnect_event(rsi_ble_event_disconnect_t * resp_disconnect, u
114108
* @return none
115109
* @section description
116110
*/
117-
void rsi_ble_on_event_indication_confirmation(uint16_t resp_status, rsi_ble_set_att_resp_t * rsi_ble_event_set_att_rsp)
111+
void SilabsBleWrapper::rsi_ble_on_event_indication_confirmation(uint16_t resp_status, rsi_ble_set_att_resp_t * rsi_ble_event_set_att_rsp)
118112
{
119-
bleEvent.eventType = RSI_BLE_GATT_INDICATION_CONFIRMATION;
113+
bleEvent.eventType = BleEventType_e::RSI_BLE_GATT_INDICATION_CONFIRMATION;
120114
bleEvent.eventData->resp_status = resp_status;
121115
memcpy(&bleEvent.eventData->rsi_ble_event_set_att_rsp, rsi_ble_event_set_att_rsp, sizeof(rsi_ble_set_att_resp_t));
122-
chip::DeviceLayer::Internal::BLEMgrImpl().BlePostEvent(&bleEvent);
116+
BLEMgrImpl().BlePostEvent(&bleEvent);
123117
}
124118

125119
/*==============================================*/
@@ -132,12 +126,12 @@ void rsi_ble_on_event_indication_confirmation(uint16_t resp_status, rsi_ble_set_
132126
* @section description
133127
* This callback function is invoked when read events are received
134128
*/
135-
void rsi_ble_on_read_req_event(uint16_t event_id, rsi_ble_read_req_t * rsi_ble_read_req)
129+
void SilabsBleWrapper::rsi_ble_on_read_req_event(uint16_t event_id, rsi_ble_read_req_t * rsi_ble_read_req)
136130
{
137-
bleEvent.eventType = RSI_BLE_EVENT_GATT_RD;
131+
bleEvent.eventType = BleEventType_e::RSI_BLE_EVENT_GATT_RD;
138132
bleEvent.eventData->event_id = event_id;
139133
memcpy(&bleEvent.eventData->rsi_ble_read_req, rsi_ble_read_req, sizeof(rsi_ble_read_req_t));
140-
chip::DeviceLayer::Internal::BLEMgrImpl().BlePostEvent(&bleEvent);
134+
BLEMgrImpl().BlePostEvent(&bleEvent);
141135
}
142136

143137
/*==============================================*/
@@ -153,7 +147,7 @@ void rsi_ble_on_read_req_event(uint16_t event_id, rsi_ble_read_req_t * rsi_ble_r
153147
* @section description
154148
* This function is used to store all attribute records
155149
*/
156-
void rsi_gatt_add_attribute_to_list(rsi_ble_t * p_val, uint16_t handle, uint16_t data_len, uint8_t * data, uuid_t uuid,
150+
void SilabsBleWrapper::rsi_gatt_add_attribute_to_list(rsi_ble_t * p_val, uint16_t handle, uint16_t data_len, uint8_t * data, uuid_t uuid,
157151
uint8_t char_prop)
158152
{
159153
if ((p_val->DATA_ix + data_len) >= BLE_ATT_REC_SIZE)
@@ -187,7 +181,7 @@ void rsi_gatt_add_attribute_to_list(rsi_ble_t * p_val, uint16_t handle, uint16_t
187181
* @section description
188182
* This function is used at application to add characteristic attribute
189183
*/
190-
void rsi_ble_add_char_serv_att(void * serv_handler, uint16_t handle, uint8_t val_prop, uint16_t att_val_handle, uuid_t att_val_uuid)
184+
void SilabsBleWrapper::rsi_ble_add_char_serv_att(void * serv_handler, uint16_t handle, uint8_t val_prop, uint16_t att_val_handle, uuid_t att_val_uuid)
191185
{
192186
rsi_ble_req_add_att_t new_att = { 0 };
193187

@@ -235,7 +229,7 @@ void rsi_ble_add_char_serv_att(void * serv_handler, uint16_t handle, uint8_t val
235229
* This function is used at application to create new service.
236230
*/
237231

238-
void rsi_ble_add_char_val_att(void * serv_handler, uint16_t handle, uuid_t att_type_uuid, uint8_t val_prop, uint8_t * data,
232+
void SilabsBleWrapper::rsi_ble_add_char_val_att(void * serv_handler, uint16_t handle, uuid_t att_type_uuid, uint8_t val_prop, uint8_t * data,
239233
uint8_t data_len, uint8_t auth_read)
240234
{
241235
rsi_ble_req_add_att_t new_att = { 0 };
@@ -297,7 +291,7 @@ void rsi_ble_add_char_val_att(void * serv_handler, uint16_t handle, uuid_t att_t
297291
* This function is used at application to create new service.
298292
*/
299293

300-
uint32_t rsi_ble_add_matter_service(void)
294+
uint32_t SilabsBleWrapper::rsi_ble_add_matter_service(void)
301295
{
302296
uuid_t custom_service = { RSI_BLE_MATTER_CUSTOM_SERVICE_UUID };
303297
custom_service.size = RSI_BLE_MATTER_CUSTOM_SERVICE_SIZE;

0 commit comments

Comments
 (0)