7

Is it possible to detect the Apple TV 4 Siri Remote from an iOS application using CoreBluetooth? I'm able to detect the Apple TV, but I'm not having any luck detecting the Siri Remote. The Siri Remote uses Bluetooth 4.0 so I'm assuming it is detectable. Ideally, I'd like to detect the Siri Remote even if it's already paired with the Apple TV.

Simply being able to detect any signal from the Siri Remote/know it's in the vicinity of the users iPhone is what I'm after.

#import "ViewController.h"
@import CoreBluetooth;

@interface ViewController () <CBPeripheralDelegate, CBCentralManagerDelegate>

@end

@implementation ViewController {
    CBCentralManager *btManager;
}

-(void)viewDidLoad {
    [super viewDidLoad];
    btManager = [[CBCentralManager alloc] initWithDelegate:self queue:nil];
}

#pragma mark - CBCentralManagerDelegate Methods

-(void)centralManager:(CBCentralManager *)central didDiscoverPeripheral:(CBPeripheral *)peripheral advertisementData:(NSDictionary<NSString *, id> *)advertisementData RSSI:(NSNumber *)RSSI {
    NSLog(@"peripheral name: %@", peripheral.name);
    NSLog(@"peripheral services: %@", peripheral.services);
    NSLog(@"peripheral identifier: %@", peripheral.identifier);
    NSLog(@"peripheral state: %ld", (long)peripheral.state);
    NSLog(@"RSSI: %@ \n\n", RSSI);
}

-(void)centralManagerDidUpdateState:(CBCentralManager *)central {
    NSString *nsLogMessage;

    switch (central.state) {
        case CBCentralManagerStateUnknown: {
            nsLogMessage = [NSString stringWithFormat:@"State unknown, update imminent."];
            break;
        }
        case CBCentralManagerStateResetting: {
            nsLogMessage = [NSString stringWithFormat:@"The connection with the system service was momentarily lost, update imminent."];
            break;
        }
        case CBCentralManagerStateUnsupported: {
            nsLogMessage = [NSString stringWithFormat:@"The platform doesn't support Bluetooth Low Energy"];
            break;
        }
        case CBCentralManagerStateUnauthorized: {
            nsLogMessage = [NSString stringWithFormat:@"The app is not authorized to use Bluetooth Low Energy"];
            break;
        }
        case CBCentralManagerStatePoweredOff: {
            nsLogMessage = [NSString stringWithFormat:@"Bluetooth is currently powered off."];
            break;
        }
        case CBCentralManagerStatePoweredOn: {
            nsLogMessage = [NSString stringWithFormat:@"Bluetooth is currently powered on and available to use."];

            NSDictionary *scanningOptions = @{CBCentralManagerScanOptionAllowDuplicatesKey: @YES};
            [btManager scanForPeripheralsWithServices:nil options:scanningOptions];
            break;
        }
    }
    NSLog(@"%@", nsLogMessage);
}
Daniel Storm
  • 18,301
  • 9
  • 84
  • 152
  • 1
    Just a hunch. Have you tried "unpairing/disconnecting" the Siri remote before you do your scan - maybe it's not advertising? – n3rd4n1 Mar 04 '16 at 01:26
  • @n3rd4n1 I have not. Ideally, I'd like to detect the Siri Remote even if it's already paired with the Apple TV. – Daniel Storm Mar 04 '16 at 02:24
  • According to a French Article on SiriMote.app, you would have to unfair before, and to a special manipulation to activate a discovering mode: http://www.macg.co/logiciels/2015/12/sirimote-controlez-votre-mac-avec-la-siri-remote-92071 You may find more info about that with SiriMote – Larme Mar 04 '16 at 13:03
  • @Larme thank you. I don't require pairing for my purposes though. Simply being able to detect any signal from the Siri Remote/know it's in the vicinity of the users iPhone is what I'm after. – Daniel Storm Mar 04 '16 at 13:07

0 Answers0