Detect Siri Remote from iPhone via Bluetooth
Asked Answered
A

0

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);
}
Audley answered 4/3, 2016 at 0:30 Comment(4)
Just a hunch. Have you tried "unpairing/disconnecting" the Siri remote before you do your scan - maybe it's not advertising?Tolan
@Tolan I have not. Ideally, I'd like to detect the Siri Remote even if it's already paired with the Apple TV.Audley
According to a French Article on SiriMote.app, you would have to unfair before, and to a special manipulation to activate a discovering mode: macg.co/logiciels/2015/12/… You may find more info about that with SiriMoteUnboned
@Unboned 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.Audley

© 2022 - 2024 — McMap. All rights reserved.