<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: KW36 central device can not scan the device problem in Wireless MCU</title>
    <link>https://community.nxp.com/t5/Wireless-MCU/KW36-central-device-can-not-scan-the-device-problem/m-p/1446142#M13118</link>
    <description>&lt;P&gt;Hi,&amp;nbsp;&lt;SPAN&gt;Ricardo&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;This is my test project, using evk test, I can see the timer printing after pressing the button to start the scan. This number is mFoundDevicesCount, each time gDeviceScanned_c adds one, after the program runs for a while mFoundDevicesCount remains the same, proving that there is no gDeviceScanned_c anymore.&lt;/P&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="企业微信截图_16502708832406.png" style="width: 300px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/177413i1EA5CE319ADF22F4/image-size/large?v=v2&amp;amp;px=999" role="button" title="企业微信截图_16502708832406.png" alt="企业微信截图_16502708832406.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 20 Apr 2022 06:34:03 GMT</pubDate>
    <dc:creator>jictannu</dc:creator>
    <dc:date>2022-04-20T06:34:03Z</dc:date>
    <item>
      <title>KW36 central device can not scan the device problem</title>
      <link>https://community.nxp.com/t5/Wireless-MCU/KW36-central-device-can-not-scan-the-device-problem/m-p/1444367#M13102</link>
      <description>&lt;P&gt;I am using sdk version 2.2.10, setting KW36 as the central device, and the scan configuration is as follows, I&amp;nbsp; restart scanning every 100 and print the number of times scanned.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;void BleApp_Start(bool_t addDevice)
{
	if (!mScanningOn)
	{
        /* Set low power mode */
#if defined(cPWR_UsePowerDownMode) &amp;amp;&amp;amp; (cPWR_UsePowerDownMode)
      #if defined(MULTICORE_APPLICATION_CORE) &amp;amp;&amp;amp; (MULTICORE_APPLICATION_CORE)
        #if defined(gErpcLowPowerApiServiceIncluded_c) &amp;amp;&amp;amp; (gErpcLowPowerApiServiceIncluded_c)
            (void)PWR_ChangeBlackBoxDeepSleepMode(gAppDeepSleepMode_c);
        #endif
      #else
        (void)PWR_ChangeDeepSleepMode(gAppDeepSleepMode_c);
      #endif
#endif

		/* Range: 0U = -30dbM to 31U = +3,5dBm, steplength ~ 1dbm */
		Controller_SetTxPowerLevel(31U,gConnTxChannel_c); // = 3,5 dbm

		if(addDevice)
		{
			gScanParams.filterPolicy = gScanAll_c;
		}
		else
		{
			gScanParams.filterPolicy = gScanWithWhiteList_c;
		}

        /* Start scanning */
        (void)App_StartScanning(&amp;amp;gScanParams, BleApp_ScanningCallback, gGapDuplicateFilteringEnable_c, gGapScanContinuously_d, gGapScanPeriodicDisabled_d);
	}
}
static void BleApp_ScanningCallback(gapScanningEvent_t* pScanningEvent)
{
	static bool_t isScanTimeout = FALSE;

	switch (pScanningEvent-&amp;gt;eventType)
	{

	case gDeviceScanned_c:
	{

		mFoundDeviceToConnect = CheckScanEvent(	&amp;amp;pScanningEvent-&amp;gt;eventData.scannedDevice);
		if (mFoundDeviceToConnect)
		{
			gConnReqParams.peerAddressType = pScanningEvent-&amp;gt;eventData.scannedDevice.addressType;
			FLib_MemCpy(gConnReqParams.peerAddress, pScanningEvent-&amp;gt;eventData.scannedDevice.aAddress, sizeof(bleDeviceAddress_t));
			bleResult_t Gap_StopScanning_status = Gap_StopScanning();
			#if defined(gAppUsePrivacy_d) &amp;amp;&amp;amp; (gAppUsePrivacy_d)
				gConnReqParams.usePeerIdentityAddress = pScanningEvent-&amp;gt;eventData.scannedDevice.advertisingAddressResolved;
			#endif

			bleResult_t App_Connect_status = App_Connect(&amp;amp;gConnReqParams, BleApp_ConnectionCallback);

			#if Debug_Support
				SEGGER_RTT_printf(0, "\r\nGap_StopScanning() status:0x%X \r\n", Gap_StopScanning_status);
				SEGGER_RTT_printf(0, "\r\nApp_Connect() status:0x%X \r\n", App_Connect_status);
			#endif
		}
		mFoundDevicesCount++;
	}
		break;

	case gScanStateChanged_c:
	{
		mScanningOn = !mScanningOn;

		/* Node starts scanning */
		if (mScanningOn)
		{
			mFoundDeviceToConnect = FALSE;
			#if Debug_Support
				SEGGER_RTT_printf(0, "\r\nScanning...\r\n");
			#endif
			/* Start scanning timer */
			// TMR_StartLowPowerTimer(mAppTimerId,
			// gTmrLowPowerSecondTimer_c, gScanningTime_c, ScanningTimeoutTimerCallback, NULL);
				isScanTimeout = FALSE;
			TMR_StartLowPowerTimer(mAppTimerId,
					gTmrLowPowerIntervalMillisTimer_c, 100, ScanningTimeoutTimerCallback, &amp;amp;isScanTimeout);
			#if (cPWR_UsePowerDownMode)
				Led1On();
			#else
				LED_StopFlashingAllLeds();
				Led1Flashing();
			#endif
		}
		/* Node is not scanning */
		else
		{
			 TMR_StopTimer(mAppTimerId);
			#if Debug_Support
				SEGGER_RTT_printf(0, "\r\nStopped scanning!\r\n");
			#endif

			if (mFoundDeviceToConnect)
			{
//				App_Connect(&amp;amp;gConnReqParams, BleApp_ConnectionCallback);
			} 
			else
			{
				if (mCurrentLearingKeyNum != gInvalidKeyNumber_c &amp;amp;&amp;amp; isScanTimeout == FALSE)
				{
					BleApp_KeyLearningStateMachineHandler();
				}
				else
				{
					BleApp_Start(true);
				}
				#if (cPWR_UsePowerDownMode)
						Led1Off();
						/* Go to sleep */
                    #if defined(MULTICORE_APPLICATION_CORE) &amp;amp;&amp;amp; (MULTICORE_APPLICATION_CORE)
                        #if defined(gErpcLowPowerApiServiceIncluded_c) &amp;amp;&amp;amp; (gErpcLowPowerApiServiceIncluded_c)
                            (void)PWR_ChangeBlackBoxDeepSleepMode(cPWR_DeepSleepMode);
                        #endif
                    #else
                        (void)PWR_ChangeDeepSleepMode(cPWR_DeepSleepMode);
                    #endif
				#else
			
				#endif
			}
		}
	}
		break;

	case gScanCommandFailed_c:
	{
		#if Debug_Support
			SEGGER_RTT_printf(0, "\r\nScan command failed! Reason = 0x%X \r\n", pScanningEvent-&amp;gt;eventData.failReason);
		#endif
	}
	break;

	default:
	{
		; /* No action required */
	}
		break;
	}
}
static void ScanningTimeoutTimerCallback(void* pParam)
{
	static uint32_t cnt = 0;
	static uint32_t oldFoundDevicesCount = 0;
	bool_t *pTimeOut = (bool_t*)pParam;
	cnt++;
	*pTimeOut = TRUE;
//	if (oldFoundDevicesCount != mFoundDevicesCount)
//	{
//		oldFoundDevicesCount = mFoundDevicesCount;
//	}
#if Debug_Support
	SEGGER_RTT_printf(0, "\r\nDeviceScanned... %d, %d ms\r\n", mFoundDevicesCount, cnt * 100);
#endif

	/* Stop scanning */
	if (mScanningOn)
	{
		Gap_StopScanning();
	}
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;but after a while no new devices are scanned, resulting in no connection.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;00&amp;gt; DeviceScanned... 16363, 125600 ms
00&amp;gt; 
00&amp;gt; Stopped scanning!
00&amp;gt; 
00&amp;gt; Scanning...
00&amp;gt; 
00&amp;gt; DeviceScanned... 16373, 125700 ms
00&amp;gt; 
00&amp;gt; Stopped scanning!
00&amp;gt; 
00&amp;gt; Scanning...
00&amp;gt; 
00&amp;gt; DeviceScanned... 16384, 125800 ms
00&amp;gt; 
00&amp;gt; Stopped scanning!
00&amp;gt; 
00&amp;gt; Scanning...
00&amp;gt; 
00&amp;gt; DeviceScanned... 16384, 125900 ms
00&amp;gt; 
00&amp;gt; Stopped scanning!
00&amp;gt; 
00&amp;gt; Scanning...
00&amp;gt; 
00&amp;gt; DeviceScanned... 16384, 126000 ms
00&amp;gt; 
00&amp;gt; Stopped scanning!
00&amp;gt; 
00&amp;gt; Scanning...
00&amp;gt; 
00&amp;gt; DeviceScanned... 16384, 126100 ms
00&amp;gt; 
00&amp;gt; Stopped scanning!
00&amp;gt; 
00&amp;gt; Scanning...
00&amp;gt; 
00&amp;gt; DeviceScanned... 16384, 126200 ms
00&amp;gt; 
00&amp;gt; Stopped scanning!
00&amp;gt; 
00&amp;gt; Scanning...
00&amp;gt; 
00&amp;gt; DeviceScanned... 16384, 126300 ms
00&amp;gt; 
00&amp;gt; Stopped scanning!
00&amp;gt; 
00&amp;gt; Scanning...
00&amp;gt; 
00&amp;gt; DeviceScanned... 16384, 126400 ms&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope to get your help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Apr 2022 02:38:45 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Wireless-MCU/KW36-central-device-can-not-scan-the-device-problem/m-p/1444367#M13102</guid>
      <dc:creator>jictannu</dc:creator>
      <dc:date>2022-04-15T02:38:45Z</dc:date>
    </item>
    <item>
      <title>Re: KW36 central device can not scan the device problem</title>
      <link>https://community.nxp.com/t5/Wireless-MCU/KW36-central-device-can-not-scan-the-device-problem/m-p/1445945#M13115</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What SDK example are you taking as a base? What other modifications did you made?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What is the porpoise of restarting the scanning continually? Are you connecting to a peripheral?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Ricardo&lt;/P&gt;</description>
      <pubDate>Tue, 19 Apr 2022 20:47:54 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Wireless-MCU/KW36-central-device-can-not-scan-the-device-problem/m-p/1445945#M13115</guid>
      <dc:creator>Ricardo_Zamora</dc:creator>
      <dc:date>2022-04-19T20:47:54Z</dc:date>
    </item>
    <item>
      <title>Re: KW36 central device can not scan the device problem</title>
      <link>https://community.nxp.com/t5/Wireless-MCU/KW36-central-device-can-not-scan-the-device-problem/m-p/1446013#M13117</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;SPAN&gt;Ricardo&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;I've tested this on w_uart and it happens too. Because the normal logic of my code is scan -&amp;gt; connect &amp;amp; stop scanning -&amp;gt; disconnect -&amp;gt; scan, and after using it multiple times I found that I couldn't scan any devices, so I used this to test if the scan would be abnormal after multiple restarts&lt;/P&gt;</description>
      <pubDate>Wed, 20 Apr 2022 02:16:10 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Wireless-MCU/KW36-central-device-can-not-scan-the-device-problem/m-p/1446013#M13117</guid>
      <dc:creator>jictannu</dc:creator>
      <dc:date>2022-04-20T02:16:10Z</dc:date>
    </item>
    <item>
      <title>Re: KW36 central device can not scan the device problem</title>
      <link>https://community.nxp.com/t5/Wireless-MCU/KW36-central-device-can-not-scan-the-device-problem/m-p/1446142#M13118</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;SPAN&gt;Ricardo&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;This is my test project, using evk test, I can see the timer printing after pressing the button to start the scan. This number is mFoundDevicesCount, each time gDeviceScanned_c adds one, after the program runs for a while mFoundDevicesCount remains the same, proving that there is no gDeviceScanned_c anymore.&lt;/P&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="企业微信截图_16502708832406.png" style="width: 300px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/177413i1EA5CE319ADF22F4/image-size/large?v=v2&amp;amp;px=999" role="button" title="企业微信截图_16502708832406.png" alt="企业微信截图_16502708832406.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Apr 2022 06:34:03 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Wireless-MCU/KW36-central-device-can-not-scan-the-device-problem/m-p/1446142#M13118</guid>
      <dc:creator>jictannu</dc:creator>
      <dc:date>2022-04-20T06:34:03Z</dc:date>
    </item>
  </channel>
</rss>

