I have got the same problem, and I have two idea.
1.
First, you should have some service that got corebluetooth delegate periodly.
F
or my example, I have a battery service that I can got delegate with didUpdateValueForCharacteristic
periodly.
Second, set readRSSI function in didUpdateValueForCharacteristic
. And don't forget to set background mode with Corebluetooth.So now you can got the RSSI updating when update battery value.
This works fine for me, but I got another idea from some sample code.
2.
Use the code below whenever you want to start the RSSI reader:
NSTimer *rssiTimer;
[rssiTimer invalidate];
rssiTimer = [NSTimer timerWithTimeInterval:1.0 target:peripheral selector:@selector(readRSSI) userInfo:nil repeats:YES];
[[NSRunLoop currentRunLoop]addTimer:rssiTimer forMode:NSRunLoopCommonModes];
It works fine for me too.