0

I have noticed that scanForPeripheralsWithServices is not working in background. I tried with following:

  1. specified UUID and option nil
  2. set UIBackgroundModes bluetooth-central and bluetooth-peripheral info.plist

I want a background service that should scan BLE devices in background continuously. Thanks for your help!

1 Answers1

0

Background mode works differently for scanning.

Every peripheral is only reported the first single time it is observed (you cannot track proximity through RSSI without connecting to it while in background mode).

You can initiate a connect request to a peripheral that's not within range, and the connection will complete when the peripheral becomes available. Don't have to actively scan for this (except for initial discovery, so you know which UUID to connect).

Maybe, you can solve the problem by sending a connect request instead of scanning, while in background. This way, iOS knows that you are really interested in a specific peripheral and I could imagine that this affects discovery times.

l0gg3r
  • 8,864
  • 3
  • 26
  • 46
  • I want my app should notified when any of my connected peripheral’s RSSI values changes(background).what should I do? – user1517635 Oct 04 '14 at 12:29
  • Just call `[peripheral readRSSI];` (http://stackoverflow.com/questions/14933688/scan-peripheral-on-background/19857901#19857901) – l0gg3r Oct 04 '14 at 12:32
  • Thanks for your fast reply. I have tried this NSTimer *rssiTimer; [rssiTimer invalidate]; rssiTimer = [NSTimer timerWithTimeInterval:1.0 target:peripheral selector:@selector(readRSSI) userInfo:nil repeats:YES]; [[NSRunLoop currentRunLoop]addTimer:rssiTimer forMode:NSRunLoopCommonModes]; Its working fine when application is in foreground but it stops reading rssi value when application goes into background. – user1517635 Oct 06 '14 at 09:46