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

cross mob
Anonymous
Not applicable

Hello,

I am referring to Day#6: BLE Central example project.

I understand that address_store stores  the addresses returned by Scanning results.

Since the array size is only 10, I assume it can maximum store only ten addresses in a  scan interval.

There is not much information on when this array is overwritten or cleared with respect to scan interval.

I'm using this variable to identify all the new/unique BLE devices reported by the Central.

Even though I have only 14 pheripherals around, the following code identifies around 34 new devices.

I do see duplicate addresses when I print all the scan response packets.

Here is the code snippet.

-------------------------------------------

1)   /* If the device address is new, then add the device to our existing list and compare the address

with our expected address to see if the desired peripheral is advertising or not.*/

list_of_devices[addedDevices].peerBdAddr = &address_store[addedDevices][0];

2)  if(FALSE == memcmp(list_of_devices.peerBdAddr, scanReport->peerBdAddr, ADV_ADDR_LEN))

{

newDevice = FALSE;

etc...

}

----------------------------------------------

Q1: Can the parameter 'addeddevices' in address_store[addedDevices][0] be more than 100?

Q2: If not, how will I detect more than 10 (about 100) new addresses?

Q3: Do I need to clear this array, or is it done internally in every scan interval?

Q4: In short, if I have to uniquely identify 100 device addresses using the BLE central (over one minute time), please suggest me how should I make use of 'address_store[addedDevices][0]' variable.

Q4: My device has to be always in scanning mode, and will be wall powered. So I have given same values for scan interval and scan window. No timeout is given.

It was working fine. Only issue is with the 'address_store[addedDevices][0]' reporting old addresses too. Do I need to make changes in scan settings so that I get only unique addresses returned by the above variable?

Regards,

Reshmi

0 Likes
1 Solution
SayaniS_66
Moderator
Moderator
Moderator
10 likes received First like received

Hello Reshmi,

Q1: Can the parameter 'addeddevices' in address_store[addedDevices][0] be more than 100?

Ans: Yes, You can declare it to be more than 100.

Q2: If not, how will I detect more than 10 (about 100) new addresses?

Ans: Yes , you can store more devices by declaring a large array.

Q3: Do I need to clear this array, or is it done internally in every scan interval?

Ans: You have to clear this array. It is not done in this project.

Q4: In short, if I have to uniquely identify 100 device addresses using the BLE central (over one minute time), please suggest me how should I make use of 'address_store[addedDevices][0]' variable.

Ans: Two changes should be made -

         address_store[10][6] -> address_store[100][6].

         #define CYBLE_MAX_ADV_DEVICES   100u.

Q5: My device has to be always in scanning mode, and will be wall powered. So I have given same values for scan interval and scan window. No timeout is given.

It was working fine. Only issue is with the 'address_store[addedDevices][0]' reporting old addresses too. Do I need to make changes in scan settings so that I get only unique addresses returned by the above variable?

Ans: In this project the HandleScanDevices() function checks for a new device if it is already in the list_of_devices or not. Below code snippet does this -

""""""""""""""""""""""""

for(i = 0; i < addedDevices; i++)

{

/* Initialize the peerBdAddr element of our list.*/

list_of_devices.peerBdAddr = &address_store[0];

/* In this for loop, compare the new device address with the existing addresses in the list to

determine if the address is new or not. If the address exists in the list, then the device

is not new.*/

if(FALSE == memcmp(list_of_devices.peerBdAddr, scanReport->peerBdAddr, ADV_ADDR_LEN))

{

newDevice = FALSE;

break;

}

}

"""""""""""""""""""""""""""""

Note: CYBLE_EVT_GAPC_SCAN_PROGRESS_RESULT event triggers twice for a same peripheral device if your central device is doing Active scanning.

-Sayani.

View solution in original post

0 Likes
1 Reply
SayaniS_66
Moderator
Moderator
Moderator
10 likes received First like received

Hello Reshmi,

Q1: Can the parameter 'addeddevices' in address_store[addedDevices][0] be more than 100?

Ans: Yes, You can declare it to be more than 100.

Q2: If not, how will I detect more than 10 (about 100) new addresses?

Ans: Yes , you can store more devices by declaring a large array.

Q3: Do I need to clear this array, or is it done internally in every scan interval?

Ans: You have to clear this array. It is not done in this project.

Q4: In short, if I have to uniquely identify 100 device addresses using the BLE central (over one minute time), please suggest me how should I make use of 'address_store[addedDevices][0]' variable.

Ans: Two changes should be made -

         address_store[10][6] -> address_store[100][6].

         #define CYBLE_MAX_ADV_DEVICES   100u.

Q5: My device has to be always in scanning mode, and will be wall powered. So I have given same values for scan interval and scan window. No timeout is given.

It was working fine. Only issue is with the 'address_store[addedDevices][0]' reporting old addresses too. Do I need to make changes in scan settings so that I get only unique addresses returned by the above variable?

Ans: In this project the HandleScanDevices() function checks for a new device if it is already in the list_of_devices or not. Below code snippet does this -

""""""""""""""""""""""""

for(i = 0; i < addedDevices; i++)

{

/* Initialize the peerBdAddr element of our list.*/

list_of_devices.peerBdAddr = &address_store[0];

/* In this for loop, compare the new device address with the existing addresses in the list to

determine if the address is new or not. If the address exists in the list, then the device

is not new.*/

if(FALSE == memcmp(list_of_devices.peerBdAddr, scanReport->peerBdAddr, ADV_ADDR_LEN))

{

newDevice = FALSE;

break;

}

}

"""""""""""""""""""""""""""""

Note: CYBLE_EVT_GAPC_SCAN_PROGRESS_RESULT event triggers twice for a same peripheral device if your central device is doing Active scanning.

-Sayani.

0 Likes