White list clear not working?

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

I have an application in which I am trying to create the following flow:

1. A white list of one address is created after a peripheral disconnects from the central, where the peripheral will only allow this central to connect for a period of time.

2. After the period of time expires, I want to clear the white list, letting any central connect.

In my initial version of the code, I used the following:

my_connection_down() {


setAdvData( adv );

bleprofile_GenerateADVData( adv, 3 );

bleprofile_Discoverable( HIGH_UNDIRECTED_DISCOVERABLE, nullAddr );

pRemoteAddr = emconninfo_getPeerAddr(); // Get the address of peer that just disconnected

BT_MEMCPY(allowedAddr.addr, pRemoteAddr, 6);

allowedAddr.type = emconninfo_getPeerAddrType();

blecm_SelectAddress(&allowedAddr, 1); // Only allow this peer to reconnect


}


my_timeout() {


  memset( allowedAddr.addr,  0, BD_ADDR_LEN );

  if ( !blecm_SelectAddress( &zero_addr, 0 ) ) { // Reset the white-list, allow anyone to connect.

      ble_trace0( "Unable to reset white-list" );

     } else {

       ble_trace0( "Reset white-list" );

     }

    setAdvData( adv );

    bleprofile_GenerateADVData( adv, 3 );

    bleprofile_Discoverable( HIGH_UNDIRECTED_DISCOVERABLE, nullAddr );

}

With this code the white-list works correctly, however, I am unable to get the white-list reset to work correctly. When I do a clear via setting num=0, the end result is that the peripheral is unable to accept ANY incoming connections.

Next, I created some sample code, based on the example in the blog

Adding and removing master nodes to a whitelist running on a peripheral device

(A lot of it seemed to be overkill like repeating the enable TRUE/FALSE, etc., but I tried to follow the example):


static void my_StartAdvertisements( bool isConnectable, bool useWhiteList )

{

UINT8 connectableFlag = isConnectable ? HCIULP_ADV_TYPE_UNDIRECTED_SCAN_INDICATE : HCIULP_ADV_TYPE_NONCONNECTABLE;

//UINT8 whiteListFlag = useWhiteList ? HCIULP_ADV_FILTER_POLICY_SCAN_ANY_CONN_WHITE_LIST : HCIULP_ADV_FILTER_POLICY_WHITE_LIST_NOT_USED;

UINT8 whiteListFlag = HCIULP_ADV_FILTER_POLICY_SCAN_ANY_CONN_WHITE_LIST;

static BLECM_SELECT_ADDR zero_addr = {{0,0,0,0,0,0},0};

    blecm_setAdvEnable(FALSE);

    blecm_enableAddressSelection(); // Enable use of a white list

    if ( useWhiteList ) {

      if ( !blecm_SelectAddress( &allowedAddr, 1 ) ) { // Use the white-list to let only the allowed address to connect.

        ble_trace0( "Unable to set white-list" );

      } else {

        ble_trace0( "Set white-list" );

      }

    } else {

      if ( !blecm_SelectAddress( &zero_addr, 0 ) ) { // Reset the white-list, allow anyone to connect.

        ble_trace0( "Unable to reset white-list" );

      } else {

        ble_trace0( "Reset white-list" );

      }

    }

    blecm_setAdvEnable(TRUE);

    setAdvData();

    blecm_startAdv(

        connectableFlag,          

        160,                                // adv interval 100 milli-seconds

        HCIULP_ADV_CHANNEL_MAP_MASK ,       // all channels

        HCIULP_ADV_ADDR_TYPE_PUBLIC,        // int advAdrType,

        whiteListFlag,             

        HCIULP_ADV_ADDR_TYPE_PUBLIC,        // int initiatorAdrType,

        NULL);                              // UINT8* initiatorAdr

}


However, in this version, I've not even been able to get the white list accepted address part to work. Can someone please point out any "gotchas" in using white-lists? Any connection between the use of blecm_startAdv and bleprofile_Discoverable and white-lists? I didn't think it would be so hard...

Any help is appreciated!

Arvind

0 Likes
1 Solution
Anonymous
Not applicable

Hi arvindraghavan,

Once you have implemented a whitelist in your code, you cannot completely remove the whitelist or as you put it "clear the whitelist"

Thanks,

Kevin

View solution in original post

0 Likes
5 Replies
Anonymous
Not applicable
0 Likes
Anonymous
Not applicable

Hello Arvind,

Did you run the example from the link?

Please check to see if your address is Little-Endian?

Thanks

JT

0 Likes
Anonymous
Not applicable

Thanks, JT.

Unfortunately, the example from the link does not show how to "remove" the white-list filter. It has code that clears the white-list, but that is immediately followed by code that adds another address to it. What I'm trying to accomplish is to clear the white-list, and make the peripheral available for ANY central to connect. To this end, I've tried using the HCIULP_ADV_FILTER_POLICY_WHITE_LIST_NOT_USED flag in my advertisements after I clear the white list, but it doesn't seem to help. In addition, the use of  doesn't seem to work either.

Also regarding the endianness of the address, as I point out, I can get the white-list to work for the "allow only one address" case when I use the bleprofile_Discoverable() function, so I don't think endianness is an issue. The issue is trying to go from the "allow only one address" back to "allow any address". I am able to go from an initial setting of "allow any address" to "allow only one address", but can't reset things back to "allow any address". Hope this clarifies my problem more, and looking forward to any other suggestions you may have.

Thanks again!

Arvind

0 Likes
Anonymous
Not applicable

Hi arvindraghavan,

Once you have implemented a whitelist in your code, you cannot completely remove the whitelist or as you put it "clear the whitelist"

Thanks,

Kevin

0 Likes
Anonymous
Not applicable

Thanks, kwang, I figured out as much by trial and error. The clear seems to remove all addresses, thereby allowing no connections, the exact opposite of what I wanted to achieve. Also, as it turns out, if you are interfacing with Android Lollipop or iOS centrals, random addresses are used. As such, I couldn't find a good way to use whitelists to accomplish my flow. I am forced to let the central connect first and then force a disconnect if I don't like the central. Not ideal, but it seems to be the only way out, and I have that working now. Or do you see any other way to accomplish the flow I've described?

Any suggestions are greatly appreciated.

Regards,


Arvind

0 Likes