Scan peripheral in background

Hello,


We know if our APP want to scan peripheral in background, it must explicitly scan for one or more services by specifying them in the

serviceUUIDs
parameter.


Our question is, can we put this service UUID in SCAN_RSP packet? Or it can ony put in ADV_Data packet?


Because our ADV_Data is already over 31 bytes, so we put the service UUID data in SCAN_RSP packet.

In APP foreground, scan with our specific service UUID is good.

But when APP in background, we can not scan anything.


So, if we want our APP can scan periperial in background, dose it must put the service UUID in ADV_Data but not SCAN_RSP?


Thank you.

Accepted Reply

From time to time, Apple devices may go into passive scan mode, in which case it will not send the SCAN_REQ after reading the ADV_IND packets - which means, if you have the service UUID in SCAN_RSP, it will not be read, and the peripheral would not be discovered as far as your app is concerned.


If you put the service in the SCAN_RSP, it will sometimes work, and will likely work in your test cases, as it does take some time of being idle for the devices to switch to passive scanning. But if you want your app to be able to detect the peripherals under all conditions, you must put the service in the ADV_IND


That said, by the time the device is in passive scan mode, it will also be in a slow scan mode. So, it becomes critical that the peripheral advertises using the specific advertising intervals we state, and the fastest interval as possible to avoid missing the advertisements while scanning slowly.


You can consult https://developer.apple.com/library/archive/qa/qa1931/_index.html for the recommended advertising intervals.

Replies

From time to time, Apple devices may go into passive scan mode, in which case it will not send the SCAN_REQ after reading the ADV_IND packets - which means, if you have the service UUID in SCAN_RSP, it will not be read, and the peripheral would not be discovered as far as your app is concerned.


If you put the service in the SCAN_RSP, it will sometimes work, and will likely work in your test cases, as it does take some time of being idle for the devices to switch to passive scanning. But if you want your app to be able to detect the peripherals under all conditions, you must put the service in the ADV_IND


That said, by the time the device is in passive scan mode, it will also be in a slow scan mode. So, it becomes critical that the peripheral advertises using the specific advertising intervals we state, and the fastest interval as possible to avoid missing the advertisements while scanning slowly.


You can consult https://developer.apple.com/library/archive/qa/qa1931/_index.html for the recommended advertising intervals.

Thank you so much.