samples: Bluetooth: broadcaster_multiple: Refactor for reuse
Refactor the sample so that multiple advertising setup can be reused in other sample if required. Bluetooth enable can be in the sample that reuses the advertising setup. Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This commit is contained in:
parent
7048b0fa4b
commit
bb4c44153b
3 changed files with 18 additions and 7 deletions
|
@ -77,13 +77,6 @@ int broadcaster_multiple(void)
|
||||||
};
|
};
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
/* Initialize the Bluetooth Subsystem */
|
|
||||||
err = bt_enable(NULL);
|
|
||||||
if (err) {
|
|
||||||
printk("Bluetooth init failed (err %d)\n", err);
|
|
||||||
return err;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int index = 0; index < CONFIG_BT_EXT_ADV_MAX_ADV_SET; index++) {
|
for (int index = 0; index < CONFIG_BT_EXT_ADV_MAX_ADV_SET; index++) {
|
||||||
/* Use advertising set instance index as SID */
|
/* Use advertising set instance index as SID */
|
||||||
adv_param.sid = index;
|
adv_param.sid = index;
|
||||||
|
|
|
@ -5,13 +5,23 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <zephyr/sys/printk.h>
|
#include <zephyr/sys/printk.h>
|
||||||
|
#include <zephyr/bluetooth/bluetooth.h>
|
||||||
|
|
||||||
int broadcaster_multiple(void);
|
int broadcaster_multiple(void);
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
|
int err;
|
||||||
|
|
||||||
printk("Starting Multiple Broadcaster Demo\n");
|
printk("Starting Multiple Broadcaster Demo\n");
|
||||||
|
|
||||||
|
/* Initialize the Bluetooth Subsystem */
|
||||||
|
err = bt_enable(NULL);
|
||||||
|
if (err) {
|
||||||
|
printk("Bluetooth init failed (err %d)\n", err);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
(void)broadcaster_multiple();
|
(void)broadcaster_multiple();
|
||||||
|
|
||||||
printk("Exiting %s thread.\n", __func__);
|
printk("Exiting %s thread.\n", __func__);
|
||||||
|
|
|
@ -51,6 +51,14 @@ static void test_adv_main(void)
|
||||||
extern int broadcaster_multiple(void);
|
extern int broadcaster_multiple(void);
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
|
err = bt_enable(NULL);
|
||||||
|
if (err) {
|
||||||
|
FAIL("Bluetooth init failed\n");
|
||||||
|
|
||||||
|
bs_trace_silent_exit(err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
err = broadcaster_multiple();
|
err = broadcaster_multiple();
|
||||||
if (err) {
|
if (err) {
|
||||||
FAIL("Adv tests failed\n");
|
FAIL("Adv tests failed\n");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue