i would wan't to implement support for 1MBPS (mobile phones without extended) and CODED (long range which uses extended) at the same time.
One idea is to use radio notification for changing between 1MBPS and CODED mode, another to use external timer and then switch?
From what i have found you have to stop adv, change the adv_params, configure with it and then start adv again.
With this approach my adv time gets lost (out of sync) because when i start adv i get the radio notification instantly.
What do you suggest?
I use nrf52840 and sdk15.2.
What is getting out of sync? The time between the advertising packets when you switch PHY ?
You are trying to maintain the time between the advertisement packets when switching PHY? (i.e. so that the adverisment interval is always e.g. 100 ms)
Yes. What i would really want is to be able to call sd_ble_gap_adv_set_configure while advertising with different ble_gap_adv_params_t which is not possible at this moment. The documentation says:
Advertising parameters. When this function is used to update advertising data while advertising, this parameter must be NULL. See @ref ble_gap_adv_params_t.
which means that i have to stop the adv make the changes and start again the adv.
schef said:which means that i have to stop the adv make the changes and start again the adv.
That is correct.
schef said:because when i start adv i get the radio notification instantly.
You start advertising again, and then get the radio notification beacuse the radio is activated. If that is problem, then how about using another timer to delay starting the advertising ?
Ok, so if i understand correctly you suggest that i control the timing of advertising manually and execute only one radio per adv start?
When you want to change the PHY, you set a flag to true, and when this flag is true, it will start a one-shot timer (with a timeout equal to the advertising interval) when you receive a radio notification.(remember to set the flag to false afterwards). For the same radio notification, you also stop the advertising and configure the new advertising parameters and data. Then some time later, the timer you stared will timeout, and then you start the advertising again in the timeout callback. I have not tested it myself, but I think it should work.
Let me know if I have misunderstood what you are trying to achieve
Yes, i think this is it :) Thanks.