cancel
Showing results for 
Search instead for 
Did you mean: 

BlueNRG-MS v7.2c Mode4 simultaneous Scan & Advertise example?

Scott Löhr
Senior II
Posted on July 11, 2018 at 03:45

I have achieved scanning or advertising as well as a connection as a slave to 1 master and simultaneously a master of 2 slaves.

Now I need simultaneous scan & advertise (whether or not in connection as a slave or master), but cannot achieve it.

Would someone please point me to an example which achieves this or show some code snippets that worked for them?

I am following guidelines of en.DM00141271 BlueNRG Prog Man Rev 6 Dec 2016, Chapter 4: BlueNRG multiple connections timing strategy

Specifically wrt advice 4:

Every time you start Advertising:

b) If not Direct Advertising, choose Advertising_Interval_Min = Advertising_Interval_Max such that (Advertising_Interval_Min + 5ms) is an integer multiple of the shortest allocated connection interval

The error I am getting is 0x85: BLE_STATUS_INTERVAL_TOO_LARGE

Order of work:

0. initialize Mode4:

uint8_t DataMode = 4;

aci_hal_write_config_data(CONFIG_DATA_MODE_OFFSET, CONFIG_DATA_MODE_LEN, &DataMode));

and of course dual gap role

uint8_t GapRole = GAP_PERIPHERAL_ROLE_IDB05A1 | GAP_CENTRAL_ROLE_IDB05A1;

aci_gap_init_IDB05A1(GapRole, 1, strlen(DeviceName), &gapRoleHdl, &devNameHdl, &devAppearHdl));

1. start scanning forever:

aci_gap_start_selective_conn_establish_proc(ACTIVE_SCAN, 96, 16, PUBLIC_ADDR, true, 2, whitelist);

(so 60-msec scan interval, 10-msec scan window)

2. get advertisement from one of the two slaves in the whitelist and connect:

 aci_gap_create_connection(96, 16, AddrType, Addr, PUBLIC_ADDR, 48, 48, 2, 72, 16, 16);   

(so same scan parameters as above and 60-msec conn interval, 10-msec conn length)

3. attempt to start advertising (while previously started scan continues looking for second slave in the whitelist):

aci_gap_set_discoverable(ADV_IND, 44, 44, PUBLIC_ADDR, NO_WHITE_LIST_USE, 0, NULL, 0, NULL, 0, 0)))

(so 55-msec advertising interval, obeying advice to be even interval of (60-msec - 5-msec)

Return value of above call is always error 0x85.

#simultaneous-scan-&-advertise #ble_status_interval_too_large
1 ACCEPTED SOLUTION

Accepted Solutions
Scott Löhr
Senior II
Posted on July 14, 2018 at 01:27

I have spent two full days on nothing but this issue and have designed a set of values that is working for scanning and advertising simultaneously and hopefully for the future connections as a master, but now I have an issue not being able to scan while in connection as a slave or after that connection ends (I have to reset the BlueNRG-MS) - but that is for a new thread.

Anyway, I made heavy use of aci_hal_get_anchor_period(uint32_t *anchor_period, uint32_t *max_free_slot) in order to resolve this very tedious number picking.

View solution in original post

5 REPLIES 5
Antonio Vilei
Senior III
Posted on July 11, 2018 at 17:28

Hi Scott,

maybe this related thread (

https://community.st.com/0D50X00009XkfB9SAJ

) could help you.

Best regards,

Antonio

Posted on July 11, 2018 at 22:22

Antonio - thanks for trying to help, but since I am a major contributor to that thread, even before you did, what part do you think would help me? Perhaps your suggestion to look at this:

/external-link.jspa?url=http%3A%2F%2Fwww.st.com%2Fen%2Fembedded-software%2Ffp-net-blestar1.html

 

Thanks again, but it doesn&39t help me - that sample app uses Mode-3 as you are surely aware and has very specific, detailed code that manages either advertising or scanning, never both, by keeping a state variable.

Posted on July 12, 2018 at 11:56

Hi Scott,

that old post was quite long, with different people jumping in over time. I didn't realize that you had contributed at the beginning of the discussion 🙂

Coming back to your question, please do note that you have to use different multiplying factors for advertising and connection interval, as specified by the Bluetooth SIG.

When you want to calculate the advertising interval, in order to get a value that is expressed in millisecond, you have to multiply the parameter by 0.625. 

Instead, if you need to calculate the connection interval, you have to multiply by 1.25 to get a value that is expressed in millisecond.

In your previous description, when you start advertising with

aci_gap_set_discoverable, you have specified 44 as the interval. That value doesn't correspond to 55 ms, as you thought, but to 27.5 ms (i.e. 44*0.625). 

That's probably why you';re getting that error.

If you want a 

55 ms advertising interval, c

ould you please try passing 88 (instead of 44) as the interval value to aci_gap_set_discoverable and see if this works for you?

Best regards,

Antonio

Scott Löhr
Senior II
Posted on July 14, 2018 at 01:27

I have spent two full days on nothing but this issue and have designed a set of values that is working for scanning and advertising simultaneously and hopefully for the future connections as a master, but now I have an issue not being able to scan while in connection as a slave or after that connection ends (I have to reset the BlueNRG-MS) - but that is for a new thread.

Anyway, I made heavy use of aci_hal_get_anchor_period(uint32_t *anchor_period, uint32_t *max_free_slot) in order to resolve this very tedious number picking.

Posted on July 14, 2018 at 01:21

Thanks Antonio - I only made the error in this thread, not the code, sorry.