This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CCS/LAUNCHXL-CC2640R2: SimpleLink academy / BLE4.2 /Scanning and Advertising lab / Advertising Task 3 (Change Filter Policy) doesn't work

Part Number: LAUNCHXL-CC2640R2
Other Parts Discussed in Thread: CC2640R2F

Tool/software: Code Composer Studio

Hello everyone,

I'm new user of this TI product, and performing many trials before developping a new project.

At this step, I'm trying to inhibit connexion from any device except the one which is declared in the whitelist.

I follow the explanation supplied in the lab for advertising filtering, but can't have a correct result.

Here is a screenshot of the context I'm talking about :

- Example program : "simple_peripheral" from "blestack" of "cc2640r2 LaunchPad" in "SimpleLink CC2640R2 SDK - v:2.40..."

- Lab from "Simple Link Academy v:2.40.03..." chapter "Bluetooth 4.2 - Scanning and Advertising", and "Task 3".

I made no other modification and tested with a smartphone running "BLE Scanner" on Androïd.

The problem is that I can't avoid my smartphone to connect to the peripheral, regardless of any BDA address I register in the whitelist.

I mean that, even If my smartphone address is or not in the whitelist, It remains possible to connect.

What can be the reason for that ?

Is there any other thing to do ?

What is the right BDA address to set (it seems confused to me) :

- the one which is displayed on Putty debug terminal when I don't use white list ?

- the one I can read into my phone parameters under "blutooth mac address" ?

THank's alot in advance for any help and recommendation.

Patrick

  • Hi Patrick,
    I'm assigning this thread to an experts, stay tuned for an answer.
  • OK thank's a lot !

    By the time I'm trying other labs.

    I hope I will have some explanation.

  • Hello Patrick,
    I could reproduce this issue on the first connect after I programmed the device. After I disconnect and try to connect the second time, then the filtering seems to work and the peripheral will ignore all scan requests and connection requests.
    Can you confirm that it only works the first time you connect?

    You need to enter the desired initiator BD address (central) into the white list to allow only that device to connect. In this case it is the phone Bluetooth address. It will also be listed in the peripheral log when you enter a connection. It makes no sense for a peripheral device to enter it's own address.
  • Hello Eirik

    THank you for your reply.

    I confirm that connection is possible only at first time. In fact it seems to be, but it's always the same situation, even if I register the right Bluetooth MAC address of my phone in the WHITELIST. With the "imple_peripheral" project modification explained in LAB Task3, the connection is just possible only one time and that for any central address.

    Today I tried to follow agin this lab but the result is the same.

    And I already looked at ressources links you sent me, but still found no explanation for that.

    So, I continue investigations, and if you find more solution or ideas, be kind to let me know.

    Best regards
    Patrick
  • Hello Patrick,

    I found a workaround. The issue is due to how the GAPRole task inherently enable initial advertising. The filter policy for the initial advertisement is set to default value (GAP_FILTER_POLICY_ALL) in the GAP role task (peripheral.c) before the user defined value is set. This will only take effect the next time the advertisement is restarted, for example after a connection is terminated.

    Workaround (restart advertising):

    1. Disable Initial Advertising:

    uint8_t initialAdvertEnable = FALSE;

    2. Enable advertising after you enable whitelist:

    // Enable advertising.
    uint8_t advertEnable = TRUE;
    GAPRole_SetParameter(GAPROLE_ADVERT_ENABLED, sizeof(uint8_t),
                         &advertEnable);

  • HI !

    THank's for this reply.

    I did what you suggested and here is what I could see.

    At first run,that's OK, the Peripheral is invisible.

    But in fact, it remains invisibe form my smartphone, regardless of any address I put !

    At first I have set the Bluetooth Mac address which is indicated in phone settings.

    As it didn't work, I tried to read and check the MAC address with Putty connected to the Peripheral, while suppressing the filtering policy.

    So, I put this new address as filtering policy parameter, but the Peripheral still can't be seen.

    Then I set again the initial advertising True to check again the Mac address, and this time, the displayed address in Putty was different...

    Here is the portion of modified code :

    static void SimplePeripheral_init(void)
    {
      // ******************************************************************
      // N0 STACK API CALLS CAN OCCUR BEFORE THIS CALL TO ICall_registerApp
      // ******************************************************************
      // Register the current thread as an ICall dispatcher application
      // so that the application can send and receive messages.
      ICall_registerApp(&selfEntity, &syncEvent);
    
    #ifdef USE_RCOSC
      RCOSC_enableCalibration();
    #endif // USE_RCOSC
    
    #if defined( USE_FPGA )
      // configure RF Core SMI Data Link
      IOCPortConfigureSet(IOID_12, IOC_PORT_RFC_GPO0, IOC_STD_OUTPUT);
      IOCPortConfigureSet(IOID_11, IOC_PORT_RFC_GPI0, IOC_STD_INPUT);
    
      // configure RF Core SMI Command Link
      IOCPortConfigureSet(IOID_10, IOC_IOCFG0_PORT_ID_RFC_SMI_CL_OUT, IOC_STD_OUTPUT);
      IOCPortConfigureSet(IOID_9, IOC_IOCFG0_PORT_ID_RFC_SMI_CL_IN, IOC_STD_INPUT);
    
      // configure RF Core tracer IO
      IOCPortConfigureSet(IOID_8, IOC_PORT_RFC_TRC, IOC_STD_OUTPUT);
    #else // !USE_FPGA
      #if defined( DEBUG_SW_TRACE )
        // configure RF Core tracer IO
        IOCPortConfigureSet(IOID_8, IOC_PORT_RFC_TRC, IOC_STD_OUTPUT | IOC_CURRENT_4MA | IOC_SLEW_ENABLE);
      #endif // DEBUG_SW_TRACE
    #endif // USE_FPGA
    
      // Create an RTOS queue for message from profile to be sent to app.
      appMsgQueue = Util_constructQueue(&appMsg);
    
      // Create one-shot clocks for internal periodic events.
      Util_constructClock(&periodicClock, SimplePeripheral_clockHandler,
                          SBP_PERIODIC_EVT_PERIOD, 0, false, SBP_PERIODIC_EVT);
    
      dispHandle = Display_open(SBP_DISPLAY_TYPE, NULL);
    
      // Set GAP Parameters: After a connection was established, delay in seconds
      // before sending when GAPRole_SetParameter(GAPROLE_PARAM_UPDATE_ENABLE,...)
      // uses GAPROLE_LINK_PARAM_UPDATE_INITIATE_BOTH_PARAMS or
      // GAPROLE_LINK_PARAM_UPDATE_INITIATE_APP_PARAMS
      // For current defaults, this has no effect.
      GAP_SetParamValue(TGAP_CONN_PAUSE_PERIPHERAL, DEFAULT_CONN_PAUSE_PERIPHERAL);
      
      // Start the Device: 
      // Please Notice that in case of wanting to use the GAPRole_SetParameter 
      // function with GAPROLE_IRK or GAPROLE_SRK parameter - Perform 
      // these function calls before the GAPRole_StartDevice use. 
      // (because Both cases are updating the gapRole_IRK & gapRole_SRK variables). 
      VOID GAPRole_StartDevice(&SimplePeripheral_gapRoleCBs);
    
      // Setup the Peripheral GAPRole Profile. For more information see the User's
      // Guide:
      // software-dl.ti.com/.../
      {
        // Device starts advertising upon initialization of GAP
        uint8_t initialAdvertEnable = FALSE;            // ASE30 (TRUE => FALSE)
    
        // By setting this to zero, the device will go into the waiting state after
        // being discoverable for 30.72 second, and will not being advertising again
        // until re-enabled by the application
        uint16_t advertOffTime = 0;
    
        uint8_t enableUpdateRequest = DEFAULT_ENABLE_UPDATE_REQUEST;
        uint16_t desiredMinInterval = DEFAULT_DESIRED_MIN_CONN_INTERVAL;
        uint16_t desiredMaxInterval = DEFAULT_DESIRED_MAX_CONN_INTERVAL;
        uint16_t desiredSlaveLatency = DEFAULT_DESIRED_SLAVE_LATENCY;
        uint16_t desiredConnTimeout = DEFAULT_DESIRED_CONN_TIMEOUT;
    
        // Set the Peripheral GAPRole Parameters
        GAPRole_SetParameter(GAPROLE_ADVERT_ENABLED, sizeof(uint8_t),
                             &initialAdvertEnable);
        GAPRole_SetParameter(GAPROLE_ADVERT_OFF_TIME, sizeof(uint16_t),
                             &advertOffTime);
    
        GAPRole_SetParameter(GAPROLE_SCAN_RSP_DATA, sizeof(scanRspData),
                             scanRspData);
        GAPRole_SetParameter(GAPROLE_ADVERT_DATA, sizeof(advertData), advertData);
    
        GAPRole_SetParameter(GAPROLE_PARAM_UPDATE_ENABLE, sizeof(uint8_t),
                             &enableUpdateRequest);
        GAPRole_SetParameter(GAPROLE_MIN_CONN_INTERVAL, sizeof(uint16_t),
                             &desiredMinInterval);
        GAPRole_SetParameter(GAPROLE_MAX_CONN_INTERVAL, sizeof(uint16_t),
                             &desiredMaxInterval);
        GAPRole_SetParameter(GAPROLE_SLAVE_LATENCY, sizeof(uint16_t),
                             &desiredSlaveLatency);
        GAPRole_SetParameter(GAPROLE_TIMEOUT_MULTIPLIER, sizeof(uint16_t),
                             &desiredConnTimeout);
      }
    
      // ASE30 --------- Debut
    
      if(1)
      {
          //set ADV filter policy to allow scan and connect request from white list only
          uint8_t advFilterPolicy = GAP_FILTER_POLICY_WHITE;
    
          //remember to change the values below to the BDA of your central device
          // static uint8 bdAddressPeer[6] = {0x00,0x90,0x78,0x56,0x34,0x12};  // ASE30 (MAC address unknown)
          // static uint8 bdAddressPeer[6] = {0x4C,0x22,0xF5,0x8C,0x56,0x62};  // ASE30 (MAC address MOTO G2 read by Peripheral on PuTTY)
          // static uint8 bdAddressPeer[6] = {0xEC,0x88,0x92,0xBD,0xD2,0x21};  // ASE30 (MAC address MOTO G2 ead in smartphone settings)
          // static uint8 bdAddressPeer[6] = {0x47,0x68,0x01,0x31,0x3E,0x94};  // ASE30 (MAC address MOTO G2  read by Peripheral on PuTTY, another time)
          static uint8 bdAddressPeer[6] = {0x5C,0x49,0x97,0x78,0x76,0xE5};  // ASE30 (MAC address MOTO G2 lue  read by Peripheral on PuTTY, another time again...)
    
          HCI_LE_AddWhiteListCmd(ADDRMODE_PUBLIC, bdAddressPeer);
    
          GAPRole_SetParameter(GAPROLE_ADV_FILTER_POLICY, sizeof(uint8_t), &advFilterPolicy);
    
          // Enable advertising
          uint8_t advertEnable = TRUE ;
          GAPRole_SetParameter(GAPROLE_ADVERT_ENABLED, sizeof(uint8_t),
                               &advertEnable);
      }
    
      // ASE30 ---------- Fin
    
    
      // Set the Device Name characteristic in the GAP GATT Service
      // For more information, see the section in the User's Guide:
      // software-dl.ti.com/.../html
      GGS_SetParameter(GGS_DEVICE_NAME_ATT, GAP_DEVICE_NAME_LEN, attDeviceName);
    
    

    It looks like if the address was changing depending upon the software I load into the Peripheral device. I never have the same.

    I'm a bit disapointed.

    Do y have explanation ?

  • Hello
    It is because the phone will use privacy with RPA (Resolvable Private Address ).
    You can learn more about it in the Software Developers Guide in the Privacy chapter.
    Also refer to the Bluetooth SIG core specification section "PRIVACY FEATURE".

    This thread is also relevant:
    e2e.ti.com/.../632878

    You can either set up another device (for example HostTest with BTool) that only use public address without privacy or you can pair and bond with the phone to store the IRK (Identity Resolving Key).
  • Hi again Eirik !

    Ok, thank's again.
    I started to read the BLE5_Stack user's guide which describes the topic you told me. Unfortunately, as I'm an independant worker, I can't subscribe to the Bluetooth SIG and have an access to the core specification... I hou know another to do, I would appreciate !

    So I can now have a better understanding on what happens in my case.
    I also tried to simply associate (pair) my phone with the CC2640R2F, it appears as "bonded", but it still doesn't work.
    In fact, I don't understand how I can find the right address to set in the wiltelist (the RPA).

    I continue to read the documentation and will make test with another CC2640R2F and BTools.

    To be continued !...
    Best Regards.
    PAtrick
  • This is exaplined in the "Privacy and White List" section in the Users Guide.
    Refer to GAPBOND_AUTO_SYNC_WL.
  • HEllo

    So here is my progress status :

    - After pairing my phone :

          - the white list seemed to correctly manage connection,

          - I mean :

                  - if phone is bonded, I can connect, disconnect, connect again... and Putty shows my true MAC address.

                  - if not, I can connect only the first time, then, once I disconnect, the peripheral becomes no more visible (still advertising)...

          - I observe that the peripheral sometime disappears... without any reason,

          - So it's not so clean.

    - Then I tried with another board running HostTest sample program and BTool :

          - At first, I tested BTools and HostTest program with ProjectZero program on the first board.

          - All was Ok and I become a little more familiar with the tool !

          - At next step, I followed the explaination of the Stack User Manuel (Using Privacy in BLE stack)

          - On the first board, I modifies and load SimplePeripheral program as explained.

          - But the problem I encounter is that I  cant set Btool because of an error with GapBondMgr_SetParameter : see picture...

          - I checkd twice, and I really followed all the explainations of the user manual

    It's a long time I'm having this issue now, I think I will give up ad find another solution for my application.

    Do you know if there is another way for having an efficient approach of this platform ?

    I tried to find a training, but without any succes

    Thank you for help again !

    Patrick

  • Hello Patrick,
    There is a Bluetooth low energy Security Fundamentals lab here:
    dev.ti.com/.../

    I found some issues when I used BLE3 with BTool. Try to load the BLE5 stack hostTest and use the BLE5 Btool version for testing.