<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>scan status</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/13756/scan-status</link><description>Hi, 
 Is there any nordic softdevice API to know whether scanning is going on or it is stopped. 
 Thanks</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 12 May 2016 11:52:57 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/13756/scan-status" /><item><title>RE: scan status</title><link>https://devzone.nordicsemi.com/thread/52584?ContentTypeID=1</link><pubDate>Thu, 12 May 2016 11:52:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:32150f42-1b19-4c2d-8c09-c4f825c715e3</guid><dc:creator>Swetika</dc:creator><description>&lt;p&gt;In how many cases BLE_GAP_TIMEOUT_SRC_SCAN is received?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: scan status</title><link>https://devzone.nordicsemi.com/thread/52583?ContentTypeID=1</link><pubDate>Wed, 11 May 2016 08:54:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0e7e7eea-cabd-4917-a069-6df0f284801a</guid><dc:creator>Swetika</dc:creator><description>&lt;p&gt;Thanks Martin!!&lt;/p&gt;
&lt;p&gt;If I go for second solution, BLE_GAP_EVT_TIMEOUT event occurs only when sd_ble_gap_scan_start() api is called with timeout. I have implemented scan without timeout. I do set a flag that keeps the track of scan status. But I have observed sometimes when there are few connect disconnect, flag is set but I wont receive any BLE_GAP_EVT_ADV_REPORT event. I assume it is because scan is stopped. I also have a flag to check that scanning and connection process wont happen at same time.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: scan status</title><link>https://devzone.nordicsemi.com/thread/52582?ContentTypeID=1</link><pubDate>Wed, 11 May 2016 08:08:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:024c7648-06d9-4d3f-b07a-be9fe074555d</guid><dc:creator>MartinBL</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;A quick and dirty solution is to call &lt;code&gt;sd_ble_gap_scan_start()&lt;/code&gt; this function will return &lt;code&gt;NRF_ERROR_INVALID_STATE&lt;/code&gt; if scanning is already in progress or a connection is in the process of being established.&lt;/p&gt;
&lt;p&gt;A different solution is to start scanning with &lt;code&gt;sd_ble_gap_scan_start()&lt;/code&gt; (naturally you should be able to have control over this) and set a flag like &lt;code&gt;is_scanning&lt;/code&gt;, or something like that, to indicate that you are scanning. Then you can wait for a &lt;code&gt;BLE_GAP_EVT_TIMEOUT&lt;/code&gt; event and check the source of the error like this:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;static void on_ble_evt(ble_evt_t * p_ble_evt)
{
    ....
    ....
    ....

    case BLE_GAP_EVT_TIMEOUT:
        if (p_gap_evt-&amp;gt;params.timeout.src == BLE_GAP_TIMEOUT_SRC_SCAN)
        {
            printf(&amp;quot;SCANNING TIMED OUT\r\n&amp;quot;);
            
            err_code = sd_ble_gap_scan_stop();
            APP_ERROR_CHECK(err_code);
                
            err_code = bsp_indication_set(BSP_INDICATE_IDLE);
            APP_ERROR_CHECK(err_code);
        }
        break;
    ....
    ....
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;So now you know when scanning starts and stops.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>