Sunday, 15 August 2010

ios - i schedule a Timer to read RSSI using readRSSI function ,but the timer stops when my app go into background -


I schedule a timer to read RSSI using the readRSSI function, but when my app goes into the background The timer stops, the app comes in the background, so the peripheral notification is a good way to get the RSSI price but I do not know how to do anybody can help me? Anyone have a better way?

I have a single problem, and I have two ideas.

1.

First of all, you should have some service that can be received from Core Bluetooth representatives from time to time. F or my example, I have a battery service that has been updated with me time code with didUpdateValueForCharacteristic The timely representative can be found.

Second, set the readSSSSI function in didUpdateValueForCharacteristic . And do not forget to set background mode with Corebluetooth. Now you can update RSSI when updating.

This works fine for me, but I got another idea from some sample code.

2.

Whenever you want to start an RSS reader, use the code below:

  NSTimer * rssiTimer; [Invalid RSS timer]; RssiTimer = [NSTimer timer with timer: 1.0 Goal: Peripheral Selector: @Selector (Reid RSSI) userInfo: Zero repeats: Yes]; [[NSRunLoop currentRunLoop] addTimer: rssiTimer forMode: NSRunLoopCommonModes];   

This works fine for me as well.

No comments:

Post a Comment