@@ -651,9 +651,16 @@ - (void)addPeripheralToCache:(CBPeripheral *)peripheral data:(NSData *)data
651
651
{
652
652
dispatch_source_t timeoutTimer;
653
653
654
+ bool shouldLogData = true ;
654
655
if ([_cachedPeripherals objectForKey: peripheral]) {
656
+ shouldLogData = ![data isEqualToData: _cachedPeripherals[peripheral][@" data" ]];
657
+ if (shouldLogData) {
658
+ ChipLogProgress (Ble, " Updating peripheral %p from the cache" , peripheral);
659
+ }
660
+
655
661
timeoutTimer = _cachedPeripherals[peripheral][@" timer" ];
656
662
} else {
663
+ ChipLogProgress (Ble, " Adding peripheral %p to the cache" , peripheral);
657
664
auto delegate = _scannerDelegate;
658
665
if (delegate) {
659
666
dispatch_async (_chipWorkQueue, ^{
@@ -678,12 +685,25 @@ - (void)addPeripheralToCache:(CBPeripheral *)peripheral data:(NSData *)data
678
685
@" data" : data,
679
686
@" timer" : timeoutTimer,
680
687
};
688
+
689
+ if (shouldLogData) {
690
+ ChipBLEDeviceIdentificationInfo info;
691
+ auto bytes = (const uint8_t *) [data bytes ];
692
+ memcpy (&info, bytes, sizeof (info));
693
+
694
+ ChipLogProgress (Ble, " - Version: %u" , info.GetAdvertisementVersion ());
695
+ ChipLogProgress (Ble, " - Discriminator: %u" , info.GetDeviceDiscriminator ());
696
+ ChipLogProgress (Ble, " - VendorId: %u" , info.GetVendorId ());
697
+ ChipLogProgress (Ble, " - ProductId: %u" , info.GetVendorId ());
698
+ }
681
699
}
682
700
683
701
- (void )removePeripheralFromCache : (CBPeripheral *)peripheral
684
702
{
685
703
auto entry = [_cachedPeripherals objectForKey: peripheral];
686
704
if (entry) {
705
+ ChipLogProgress (Ble, " Removing peripheral %p from the cache" , peripheral);
706
+
687
707
dispatch_source_cancel (entry[@" timer" ]);
688
708
[_cachedPeripherals removeObjectForKey: peripheral];
689
709
0 commit comments