6 Replies Latest reply on Jan 9, 2020 4:28 AM by LePo_1062026

    Can I scan advertisements on only one channel?

    LePo_1062026

      I'm trying to do something pretty unconventional.   I have an Observer node that I'm trying to scan only ONE channel for advertisements.

       

      I'd like to know if the following are possible?  If so, what are the API calls?

      • Configure the Observer to scan, 1, or 2 channels.  3 channels are the default.   I know how to configure the Broadcaster for 1, 2 or 3 channels.  I was wondering if there was a converse function for the Observer.
      • Configure which of 1 or 2 channels is being scanned.
      • When I receive an Advertising report on the Observer, is there a way to tell  which channel it was received on.  Note:  The reason for this request is that I currently have a Broadcaster advertising on 3 channels.  I have an Observer scanning all 3 channels.   The Broadcaster is with 1 mm of the Observer and not moving. When I receive the advertised packets, I notice that I get different RSSI values for each of the 3 channels (37, 38, 39).  Each varies about 6dBm.
        However if only Broadcast on only one channel, my RSSI results are at most 1dBm and usually 0dBm.

       

      Again, I realize this is unconventional, however I do have an application I am targeting.  If successful, I will share some example code with the forum.

       

      Thanks for everyone's help in advance.

       

      Len

        • 1. Re: Can I scan advertisements on only one channel?
          ShipingW_81

          The following KBA doc maybe helpful for your application - Configuring BLE Central Device to work in a particular Scan and Connection Channel - KBA218992

           

          It's originally for PRoC BLE device, but it also applicable to PSoC 6 BLE in general.

          1 of 1 people found this helpful
          • 2. Re: Can I scan advertisements on only one channel?
            LePo_1062026

            WangS,

             

            Thank you again.  I've done a little research on the KBA218992 you cited.

             

            CyBle_GapGetChannelMap() and CyBle_GapcSetHostChannelClassification() on the PRoC are renamed to

            Cy_BLE_GapGetChannelMap() and Cy_BLE_GapcSetHostChannelClassification() on the PSoC6.

             

            However as the KBA indicates this is only for control of the Data channels not the Scan.

             

            According to the KBA, to control the Advertising channels you need to set the BLE resource registers directly.

            Example:

            Scan the 37th channel and use the below code in CYBLE_EVT_STACK_ON before CyBle_GapcStartScan() API:

            #define CYREG_BLE_BLELL_SCAN_CONFIG_USER (*(uint32*) BLE_BLELL_SCAN_CONFIG)

            CYREG_BLE_BLELL_SCAN_CONFIG_USER=BLE_BLELL_SCAN_CONFIG_USER & 0xFFFF2FFF;

            Since the standard model for the PSoC is for the CM0+ core to directly control the BLE registers and the CM4 core to indirectly control the BLE resources, is this a good idea to reach past the IPC interface to touch the BLE_BLELL_SCAN_CONFIG register with the application-side (CM4)?

             

            Len

            • 3. Re: Can I scan advertisements on only one channel?
              NazarP_56

              Hi Len,

               

              It should be OK to modify this register from host side (CM4). You can use macros CY_REG32_CLR_SET (e.g. CY_REG32_CLR_SET(BLE->BLELL.SCAN_CONFIG, BLE_BLELL_SCAN_CONFIG_SCAN_CHANNEL_MAP, 0x1);)

               

              "When I receive an Advertising report on the Observer, is there a way to tell  which channel it was received on..." - in current implementation, there is no way to get this information.

               

              "...I notice that I get different RSSI values for each of the 3 channels (37, 38, 39).  Each varies about 6dBm." - RSSI is different because the impedance matching at the antenna changes for different frequencies. It is a perfect notch at only one particular frequency within the 2440 - 2448 MHz band. At that frequency, we get the maximum RSSI. At all other frequencies, it will be lower. This is expected.

               

              Regards,
              Nazar

              1 of 1 people found this helpful
              • 4. Re: Can I scan advertisements on only one channel?
                LePo_1062026

                Nazar,

                 

                Thank you again for your help.

                 

                You can use macros CY_REG32_CLR_SET (e.g. CY_REG32_CLR_SET(BLE->BLELL.SCAN_CONFIG, BLE_BLELL_SCAN_CONFIG_SCAN_CHANNEL_MAP, 0x1);)

                The macros you referenced do not appear in the PSoC Creator environment for the PSoC6.  Therefore I needed to look to another solution.

                 

                However, the code below (although probably not the safest) does appear to work.  To enable only one Scan channel, I just change user_advmap to the desired channel then call StartScan();

                 

                #define ADV_CHAN_37_MASK 0b001
                #define ADV_CHAN_38_MASK 0b010
                #define ADV_CHAN_39_MASK 0b100
                
                uint8 user_advmap = ADV_CHAN_37_MASK | ADV_CHAN_38_MASK | ADV_CHAN_39_MASK;
                
                void StartScan(uint8_t new_advmap)
                {
                //CY_REG32_CLR_SET(BLE->BLELL.SCAN_CONFIG, BLE_BLELL_SCAN_CONFIG_SCAN_CHANNEL_MAP, 0x1);
                    *((uint32_t *)CYREG_BLE_BLELL_SCAN_CONFIG) = (*((uint32_t *)CYREG_BLE_BLELL_SCAN_CONFIG) // Get the current map
                        & (0xFFFFFFFF ^ (0b111 << CYFLD_BLE_BLELL_SCAN_CHANNEL_MAP__OFFSET)))    // clear the adv chan bits
                        | (new_advmap << CYFLD_BLE_BLELL_SCAN_CHANNEL_MAP__OFFSET);                // set the adv chan bit(s) as per advmap
                   
                    Cy_BLE_GAPC_StartScan(CY_BLE_SCANNING_FAST, CY_BLE_OBSERVER_CONFIGURATION_0_INDEX);
                }
                
                {
                ...
                    StartScan(user_advmap);
                ...
                }
                

                 

                If anyone can find a better (safer) way, please let me know.

                Len

                • 5. Re: Can I scan advertisements on only one channel?
                  NazarP_56

                  Hi Len,

                   

                  The code above is the same proposed in KBA218992. I think you do not have another way here.

                   

                  Regarding CY_REG32_CLR_SET macro, looks like you are using PDL3.0.4. CY_REG32_CLR_SET was added in PDL3.1.0. In PDL3.0.4 there is _CLR_SET_FLD32U(BLE->BLELL.SCAN_CONFIG, BLE_BLELL_SCAN_CONFIG_SCAN_CHANNEL_MAP, user_advmap);)

                   

                  The CY_REG32_CLR_SET or _CLR_SET_FLD32U macros - do the same field/bit manipulations as your code.

                   

                  Also, I recommend using the latest PDL for your development...


                  Regards,

                  Nazar

                  • 6. Re: Can I scan advertisements on only one channel?
                    LePo_1062026

                    Nazar,

                     

                    For PDL 3.04 that I am using

                    BLE->BLELL.SCAN_CONFIG = _CLR_SET_FLD32U(BLE->BLELL.SCAN_CONFIG, BLE_BLELL_SCAN_CONFIG_SCAN_CHANNEL_MAP, new_advmap);
                    

                    works as a tighter (cleaner) substitute for:

                        *((uint32_t *)CYREG_BLE_BLELL_SCAN_CONFIG) = (*((uint32_t *)CYREG_BLE_BLELL_SCAN_CONFIG) // Get the current map  
                            & (0xFFFFFFFF ^ (0b111 << CYFLD_BLE_BLELL_SCAN_CHANNEL_MAP__OFFSET)))    // clear the adv chan bits  
                            | (new_advmap << CYFLD_BLE_BLELL_SCAN_CHANNEL_MAP__OFFSET);                // set the adv chan bit(s) as per advmap  
                    

                     

                    I'm am using PDL 3.0.4 right now instead of PDL3.1.0 because when I did convert to 3.1.0 the CY8CKIT-062-BLE I also use would not work with > PDL 3.0.4.

                    See:

                    Beware of automatic updating your project PDL components to the latest.

                     

                    Len