@@ -68,6 +68,13 @@ extern "C" {
68
68
#include < setup_payload/AdditionalDataPayloadGenerator.h>
69
69
#endif
70
70
71
+ #define BLE_MIN_CONNECTION_INTERVAL_MS 45 // 45 msec
72
+ #define BLE_MAX_CONNECTION_INTERVAL_MS 45 // 45 msec
73
+ #define BLE_SLAVE_LATENCY_MS 0
74
+ #define BLE_TIMEOUT_MS 400
75
+ #define BLE_DEFAULT_TIMER_PERIOD_MS (1 )
76
+ #define BLE_SEND_INDICATION_TIMER_PERIOD_MS (5000 )
77
+
71
78
extern sl_wfx_msg_t event_msg;
72
79
73
80
StaticTask_t rsiBLETaskStruct;
@@ -246,9 +253,6 @@ namespace {
246
253
#define BLE_CONFIG_MIN_CE_LENGTH (0 ) // Leave to min value
247
254
#define BLE_CONFIG_MAX_CE_LENGTH (0xFFFF ) // Leave to max value
248
255
249
- #define BLE_DEFAULT_TIMER_PERIOD_MS (1 )
250
- #define BLE_SEND_INDICATION_TIMER_PERIOD_MS (10 )
251
-
252
256
TimerHandle_t sbleAdvTimeoutTimer; // FreeRTOS sw timer.
253
257
254
258
const uint8_t UUID_CHIPoBLEService[] = { 0xFB , 0x34 , 0x9B , 0x5F , 0x80 , 0x00 , 0x00 , 0x80 ,
@@ -302,6 +306,17 @@ CHIP_ERROR BLEManagerImpl::_Init()
302
306
return err;
303
307
}
304
308
309
+ void BLEManagerImpl::OnSendIndicationTimeout (System::Layer * aLayer, void * appState)
310
+ {
311
+ uint8_t connHandle = 1 ;
312
+ ChipLogProgress (DeviceLayer, " BLEManagerImpl::HandleSoftTimerEvent CHIPOBLE_PROTOCOL_ABORT" );
313
+ ChipDeviceEvent event;
314
+ event.Type = DeviceEventType::kCHIPoBLEConnectionError ;
315
+ event.CHIPoBLEConnectionError .ConId = connHandle;
316
+ event.CHIPoBLEConnectionError .Reason = BLE_ERROR_CHIPOBLE_PROTOCOL_ABORT;
317
+ PlatformMgr ().PostEventOrDie (&event);
318
+ }
319
+
305
320
uint16_t BLEManagerImpl::_NumConnections (void )
306
321
{
307
322
uint16_t numCons = 0 ;
@@ -424,6 +439,7 @@ void BLEManagerImpl::_OnPlatformEvent(const ChipDeviceEvent * event)
424
439
425
440
case DeviceEventType::kCHIPoBLEIndicateConfirm : {
426
441
ChipLogProgress (DeviceLayer, " _OnPlatformEvent kCHIPoBLEIndicateConfirm" );
442
+ DeviceLayer::SystemLayer ().CancelTimer (OnSendIndicationTimeout, this );
427
443
HandleIndicationConfirmation (event->CHIPoBLEIndicateConfirm .ConId , &CHIP_BLE_SVC_ID, &ChipUUID_CHIPoBLEChar_TX);
428
444
}
429
445
break ;
@@ -466,11 +482,7 @@ uint16_t BLEManagerImpl::GetMTU(BLE_CONNECTION_OBJECT conId) const
466
482
return (conState != NULL ) ? conState->mtu : 0 ;
467
483
}
468
484
469
- void BLEManagerImpl::OnSendIndicationTimeout (System::Layer * aLayer, void * appState)
470
- {
471
- BLEManagerImpl * pBLEManagerImpl = reinterpret_cast <BLEManagerImpl *>(appState);
472
- pBLEManagerImpl->HandleSoftTimerEvent ();
473
- }
485
+
474
486
475
487
bool BLEManagerImpl::SendIndication (BLE_CONNECTION_OBJECT conId, const ChipBleUUID * svcId, const ChipBleUUID * charId,
476
488
PacketBufferHandle data)
@@ -935,19 +947,6 @@ void BLEManagerImpl::HandleTxConfirmationEvent(BLE_CONNECTION_OBJECT conId)
935
947
ChipDeviceEvent event;
936
948
event.Type = DeviceEventType::kCHIPoBLEIndicateConfirm ;
937
949
event.CHIPoBLEIndicateConfirm .ConId = conId;
938
- DeviceLayer::SystemLayer ().CancelTimer (OnSendIndicationTimeout, this );
939
- PlatformMgr ().PostEventOrDie (&event);
940
- }
941
-
942
-
943
- void BLEManagerImpl::HandleSoftTimerEvent (void )
944
- {
945
- uint8_t connHandle = 1 ;
946
- ChipLogProgress (DeviceLayer, " BLEManagerImpl::HandleSoftTimerEvent CHIPOBLE_PROTOCOL_ABORT" );
947
- ChipDeviceEvent event;
948
- event.Type = DeviceEventType::kCHIPoBLEConnectionError ;
949
- event.CHIPoBLEConnectionError .ConId = connHandle;
950
- event.CHIPoBLEConnectionError .Reason = BLE_ERROR_CHIPOBLE_PROTOCOL_ABORT;
951
950
PlatformMgr ().PostEventOrDie (&event);
952
951
}
953
952
0 commit comments