@@ -218,8 +218,7 @@ void BLEManagerImpl::_OnPlatformEvent(const ChipDeviceEvent * event)
218
218
case DeviceEventType::kCHIPoBLESubscribe :
219
219
HandleSubscribeReceived (event->CHIPoBLESubscribe .ConId , &CHIP_BLE_SVC_ID, &ChipUUID_CHIPoBLEChar_TX);
220
220
{
221
- ChipDeviceEvent connectionEvent;
222
- connectionEvent.Type = DeviceEventType::kCHIPoBLEConnectionEstablished ;
221
+ ChipDeviceEvent connectionEvent{ .Type = DeviceEventType::kCHIPoBLEConnectionEstablished };
223
222
PlatformMgr ().PostEventOrDie (&connectionEvent);
224
223
}
225
224
break ;
@@ -465,9 +464,8 @@ void BLEManagerImpl::HandleNewConnection(BLE_CONNECTION_OBJECT conId)
465
464
{
466
465
if (sInstance .mIsCentral )
467
466
{
468
- ChipDeviceEvent event;
469
- event.Type = DeviceEventType::kPlatformLinuxBLECentralConnected ;
470
- event.Platform .BLECentralConnected .mConnection = conId;
467
+ ChipDeviceEvent event{ .Type = DeviceEventType::kPlatformLinuxBLECentralConnected ,
468
+ .Platform = { .BLECentralConnected = { .mConnection = conId } } };
471
469
PlatformMgr ().PostEventOrDie (&event);
472
470
}
473
471
}
@@ -476,27 +474,23 @@ void BLEManagerImpl::HandleConnectFailed(CHIP_ERROR error)
476
474
{
477
475
if (sInstance .mIsCentral )
478
476
{
479
- ChipDeviceEvent event;
480
- event.Type = DeviceEventType::kPlatformLinuxBLECentralConnectFailed ;
481
- event.Platform .BLECentralConnectFailed .mError = error;
477
+ ChipDeviceEvent event{ .Type = DeviceEventType::kPlatformLinuxBLECentralConnectFailed ,
478
+ .Platform = { .BLECentralConnectFailed = { .mError = error } } };
482
479
PlatformMgr ().PostEventOrDie (&event);
483
480
}
484
481
}
485
482
486
483
void BLEManagerImpl::HandleWriteComplete (BLE_CONNECTION_OBJECT conId)
487
484
{
488
- ChipDeviceEvent event;
489
- event.Type = DeviceEventType::kPlatformLinuxBLEWriteComplete ;
490
- event.Platform .BLEWriteComplete .mConnection = conId;
485
+ ChipDeviceEvent event{ .Type = DeviceEventType::kPlatformLinuxBLEWriteComplete ,
486
+ .Platform = { .BLEWriteComplete = { .mConnection = conId } } };
491
487
PlatformMgr ().PostEventOrDie (&event);
492
488
}
493
489
494
490
void BLEManagerImpl::HandleSubscribeOpComplete (BLE_CONNECTION_OBJECT conId, bool subscribed)
495
491
{
496
- ChipDeviceEvent event;
497
- event.Type = DeviceEventType::kPlatformLinuxBLESubscribeOpComplete ;
498
- event.Platform .BLESubscribeOpComplete .mConnection = conId;
499
- event.Platform .BLESubscribeOpComplete .mIsSubscribed = subscribed;
492
+ ChipDeviceEvent event{ .Type = DeviceEventType::kPlatformLinuxBLESubscribeOpComplete ,
493
+ .Platform = { .BLESubscribeOpComplete = { .mConnection = conId, .mIsSubscribed = subscribed } } };
500
494
PlatformMgr ().PostEventOrDie (&event);
501
495
}
502
496
@@ -507,12 +501,12 @@ void BLEManagerImpl::HandleTXCharChanged(BLE_CONNECTION_OBJECT conId, const uint
507
501
508
502
ChipLogDetail (DeviceLayer, " Indication received, conn = %p" , conId);
509
503
504
+ ChipDeviceEvent event{ .Type = DeviceEventType::kPlatformLinuxBLEIndicationReceived ,
505
+ .Platform = { .BLEIndicationReceived = { .mConnection = conId } } };
506
+
510
507
VerifyOrExit (!buf.IsNull (), err = CHIP_ERROR_NO_MEMORY);
511
508
512
- ChipDeviceEvent event;
513
- event.Type = DeviceEventType::kPlatformLinuxBLEIndicationReceived ;
514
- event.Platform .BLEIndicationReceived .mConnection = conId;
515
- event.Platform .BLEIndicationReceived .mData = std::move (buf).UnsafeRelease ();
509
+ event.Platform .BLEIndicationReceived .mData = std::move (buf).UnsafeRelease ();
516
510
PlatformMgr ().PostEventOrDie (&event);
517
511
518
512
exit :
@@ -531,11 +525,9 @@ void BLEManagerImpl::HandleRXCharWrite(BLE_CONNECTION_OBJECT conId, const uint8_
531
525
532
526
// Post an event to the Chip queue to deliver the data into the Chip stack.
533
527
{
534
- ChipDeviceEvent event;
535
- event.Type = DeviceEventType::kCHIPoBLEWriteReceived ;
536
528
ChipLogProgress (Ble, " Write request received debug %p" , conId);
537
- event. CHIPoBLEWriteReceived . ConId = conId;
538
- event .CHIPoBLEWriteReceived . Data = std::move (buf).UnsafeRelease ();
529
+ ChipDeviceEvent event{ . Type = DeviceEventType:: kCHIPoBLEWriteReceived ,
530
+ .CHIPoBLEWriteReceived = { . ConId = conId, . Data = std::move (buf).UnsafeRelease () } } ;
539
531
PlatformMgr ().PostEventOrDie (&event);
540
532
}
541
533
@@ -552,10 +544,8 @@ void BLEManagerImpl::CHIPoBluez_ConnectionClosed(BLE_CONNECTION_OBJECT conId)
552
544
553
545
// If this was a CHIPoBLE connection, post an event to deliver a connection error to the CHIPoBLE layer.
554
546
{
555
- ChipDeviceEvent event;
556
- event.Type = DeviceEventType::kCHIPoBLEConnectionError ;
557
- event.CHIPoBLEConnectionError .ConId = conId;
558
- event.CHIPoBLEConnectionError .Reason = BLE_ERROR_REMOTE_DEVICE_DISCONNECTED;
547
+ ChipDeviceEvent event{ .Type = DeviceEventType::kCHIPoBLEConnectionError ,
548
+ .CHIPoBLEConnectionError = { .ConId = conId, .Reason = BLE_ERROR_REMOTE_DEVICE_DISCONNECTED } };
559
549
PlatformMgr ().PostEventOrDie (&event);
560
550
}
561
551
}
@@ -567,9 +557,9 @@ void BLEManagerImpl::HandleTXCharCCCDWrite(BLE_CONNECTION_OBJECT conId)
567
557
568
558
// Post an event to the Chip queue to process either a CHIPoBLE Subscribe or Unsubscribe based on
569
559
// whether the client is enabling or disabling indications.
570
- ChipDeviceEvent event;
571
- event. Type = conId-> IsNotifyAcquired () ? DeviceEventType:: kCHIPoBLESubscribe : DeviceEventType::kCHIPoBLEUnsubscribe ;
572
- event .CHIPoBLESubscribe .ConId = conId;
560
+ ChipDeviceEvent event{ . Type = conId-> IsNotifyAcquired () ? DeviceEventType:: kCHIPoBLESubscribe
561
+ : DeviceEventType::kCHIPoBLEUnsubscribe ,
562
+ .CHIPoBLESubscribe = { .ConId = conId } } ;
573
563
PlatformMgr ().PostEventOrDie (&event);
574
564
575
565
ChipLogProgress (DeviceLayer, " CHIPoBLE %s received" ,
@@ -579,9 +569,7 @@ void BLEManagerImpl::HandleTXCharCCCDWrite(BLE_CONNECTION_OBJECT conId)
579
569
void BLEManagerImpl::HandleTXComplete (BLE_CONNECTION_OBJECT conId)
580
570
{
581
571
// Post an event to the Chip queue to process the indicate confirmation.
582
- ChipDeviceEvent event;
583
- event.Type = DeviceEventType::kCHIPoBLEIndicateConfirm ;
584
- event.CHIPoBLEIndicateConfirm .ConId = conId;
572
+ ChipDeviceEvent event{ .Type = DeviceEventType::kCHIPoBLEIndicateConfirm , .CHIPoBLEIndicateConfirm = { .ConId = conId } };
585
573
PlatformMgr ().PostEventOrDie (&event);
586
574
}
587
575
@@ -822,50 +810,44 @@ CHIP_ERROR BLEManagerImpl::CancelConnection()
822
810
823
811
void BLEManagerImpl::NotifyBLEAdapterAdded (unsigned int aAdapterId, const char * aAdapterAddress)
824
812
{
825
- ChipDeviceEvent event;
826
- event.Type = DeviceEventType::kPlatformLinuxBLEAdapterAdded ;
827
- event.Platform .BLEAdapter .mAdapterId = aAdapterId;
813
+ ChipDeviceEvent event{ .Type = DeviceEventType::kPlatformLinuxBLEAdapterAdded ,
814
+ .Platform = { .BLEAdapter = { .mAdapterId = aAdapterId } } };
828
815
Platform::CopyString (event.Platform .BLEAdapter .mAdapterAddress , aAdapterAddress);
829
816
PlatformMgr ().PostEventOrDie (&event);
830
817
}
831
818
832
819
void BLEManagerImpl::NotifyBLEAdapterRemoved (unsigned int aAdapterId, const char * aAdapterAddress)
833
820
{
834
- ChipDeviceEvent event;
835
- event.Type = DeviceEventType::kPlatformLinuxBLEAdapterRemoved ;
836
- event.Platform .BLEAdapter .mAdapterId = aAdapterId;
821
+ ChipDeviceEvent event{ .Type = DeviceEventType::kPlatformLinuxBLEAdapterRemoved ,
822
+ .Platform = { .BLEAdapter = { .mAdapterId = aAdapterId } } };
837
823
Platform::CopyString (event.Platform .BLEAdapter .mAdapterAddress , aAdapterAddress);
838
824
PlatformMgr ().PostEventOrDie (&event);
839
825
}
840
826
841
827
void BLEManagerImpl::NotifyBLEPeripheralRegisterAppComplete (CHIP_ERROR error)
842
828
{
843
- ChipDeviceEvent event;
844
- event.Type = DeviceEventType::kPlatformLinuxBLEPeripheralRegisterAppComplete ;
845
- event.Platform .BLEPeripheralRegisterAppComplete .mError = error;
829
+ ChipDeviceEvent event{ .Type = DeviceEventType::kPlatformLinuxBLEPeripheralRegisterAppComplete ,
830
+ .Platform = { .BLEPeripheralRegisterAppComplete = { .mError = error } } };
846
831
PlatformMgr ().PostEventOrDie (&event);
847
832
}
848
833
849
834
void BLEManagerImpl::NotifyBLEPeripheralAdvStartComplete (CHIP_ERROR error)
850
835
{
851
- ChipDeviceEvent event;
852
- event.Type = DeviceEventType::kPlatformLinuxBLEPeripheralAdvStartComplete ;
853
- event.Platform .BLEPeripheralAdvStartComplete .mError = error;
836
+ ChipDeviceEvent event{ .Type = DeviceEventType::kPlatformLinuxBLEPeripheralAdvStartComplete ,
837
+ .Platform = { .BLEPeripheralAdvStartComplete = { .mError = error } } };
854
838
PlatformMgr ().PostEventOrDie (&event);
855
839
}
856
840
857
841
void BLEManagerImpl::NotifyBLEPeripheralAdvStopComplete (CHIP_ERROR error)
858
842
{
859
- ChipDeviceEvent event;
860
- event.Type = DeviceEventType::kPlatformLinuxBLEPeripheralAdvStopComplete ;
861
- event.Platform .BLEPeripheralAdvStopComplete .mError = error;
843
+ ChipDeviceEvent event{ .Type = DeviceEventType::kPlatformLinuxBLEPeripheralAdvStopComplete ,
844
+ .Platform = { .BLEPeripheralAdvStopComplete = { .mError = error } } };
862
845
PlatformMgr ().PostEventOrDie (&event);
863
846
}
864
847
865
848
void BLEManagerImpl::NotifyBLEPeripheralAdvReleased ()
866
849
{
867
- ChipDeviceEvent event;
868
- event.Type = DeviceEventType::kPlatformLinuxBLEPeripheralAdvReleased ;
850
+ ChipDeviceEvent event{ .Type = DeviceEventType::kPlatformLinuxBLEPeripheralAdvReleased };
869
851
PlatformMgr ().PostEventOrDie (&event);
870
852
}
871
853
0 commit comments