1 /* IEEE 802.15.4 settings code */
2 
3 /*
4  * Copyright (c) 2017 Intel Corporation.
5  *
6  * SPDX-License-Identifier: Apache-2.0
7  */
8 
9 #include <logging/log.h>
10 LOG_MODULE_DECLARE(net_config, CONFIG_NET_CONFIG_LOG_LEVEL);
11 
12 #include <zephyr.h>
13 #include <errno.h>
14 
15 #include <net/net_if.h>
16 #include <net/net_core.h>
17 #include <net/net_mgmt.h>
18 #include <net/bt.h>
19 
20 #include <bluetooth/bluetooth.h>
21 #include <bluetooth/uuid.h>
22 #include <bluetooth/gatt.h>
23 
24 #if defined(CONFIG_NET_CONFIG_BT_NODE)
25 #define ADV_STR "on"
26 
27 BT_GATT_SERVICE_DEFINE(ipss_svc,
28 	/* IP Support Service Declaration */
29 	BT_GATT_PRIMARY_SERVICE(BT_UUID_IPSS),
30 );
31 #endif
32 
z_net_config_bt_setup(void)33 int z_net_config_bt_setup(void)
34 {
35 	struct net_if *iface;
36 	const struct device *dev;
37 	int err;
38 
39 	err = bt_enable(NULL);
40 	if (err < 0 && err != -EALREADY) {
41 		return err;
42 	}
43 
44 	dev = device_get_binding("net_bt");
45 	if (!dev) {
46 		return -ENODEV;
47 	}
48 
49 	iface = net_if_lookup_by_dev(dev);
50 	if (!iface) {
51 		return -EINVAL;
52 	}
53 
54 #if defined(CONFIG_NET_CONFIG_BT_NODE)
55 	if (net_mgmt(NET_REQUEST_BT_ADVERTISE, iface, ADV_STR,
56 		     sizeof(ADV_STR))) {
57 		return -EINVAL;
58 	}
59 #endif
60 
61 	return 0;
62 }
63