1 /* main.c - Application main entry point */
2 
3 /*
4  * Copyright (c) 2015-2016 Intel Corporation
5  *
6  * SPDX-License-Identifier: Apache-2.0
7  */
8 
9 #include <zephyr/types.h>
10 #include <stddef.h>
11 #include <zephyr/sys/printk.h>
12 #include <zephyr/sys/util.h>
13 
14 #include <zephyr/bluetooth/bluetooth.h>
15 #include <zephyr/bluetooth/hci.h>
16 
17 static uint8_t mfg_data[] = { 0xff, 0xff, 0x00 };
18 
19 static const struct bt_data ad[] = {
20 	BT_DATA(BT_DATA_MANUFACTURER_DATA, mfg_data, 3),
21 };
22 
main(void)23 int main(void)
24 {
25 	int err;
26 
27 	printk("Starting Broadcaster\n");
28 
29 	/* Initialize the Bluetooth Subsystem */
30 	err = bt_enable(NULL);
31 	if (err) {
32 		printk("Bluetooth init failed (err %d)\n", err);
33 		return 0;
34 	}
35 
36 	printk("Bluetooth initialized\n");
37 
38 	do {
39 		k_msleep(1000);
40 
41 		printk("Sending advertising data: 0x%02X\n", mfg_data[2]);
42 
43 		/* Start advertising */
44 		err = bt_le_adv_start(BT_LE_ADV_NCONN, ad, ARRAY_SIZE(ad),
45 				      NULL, 0);
46 		if (err) {
47 			printk("Advertising failed to start (err %d)\n", err);
48 			return 0;
49 		}
50 
51 		k_msleep(1000);
52 
53 		err = bt_le_adv_stop();
54 		if (err) {
55 			printk("Advertising failed to stop (err %d)\n", err);
56 			return 0;
57 		}
58 
59 		mfg_data[2]++;
60 
61 	} while (1);
62 	return 0;
63 }
64