1 /*
2  * Copyright Runtime.io 2018. All rights reserved.
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 /** @file
8  * @brief Bluetooth transport for the mcumgr SMP protocol.
9  */
10 
11 #ifndef ZEPHYR_INCLUDE_MGMT_SMP_BT_H_
12 #define ZEPHYR_INCLUDE_MGMT_SMP_BT_H_
13 
14 #include <zephyr/bluetooth/uuid.h>
15 #include <zephyr/types.h>
16 struct bt_conn;
17 
18 #ifdef __cplusplus
19 extern "C" {
20 #endif
21 
22 /** SMP service UUID value. */
23 #define SMP_BT_SVC_UUID_VAL \
24 	BT_UUID_128_ENCODE(0x8d53dc1d, 0x1db7, 0x4cd3, 0x868b, 0x8a527460aa84)
25 
26 /** SMP service UUID. */
27 #define SMP_BT_SVC_UUID \
28 	BT_UUID_DECLARE_128(SMP_BT_SVC_UUID_VAL)
29 
30 /** SMP characteristic UUID value. */
31 #define SMP_BT_CHR_UUID_VAL \
32 	BT_UUID_128_ENCODE(0xda2e7828, 0xfbce, 0x4e01, 0xae9e, 0x261174997c48)
33 
34 /** SMP characteristic UUID
35  *  Used for both requests and responses.
36  */
37 #define SMP_BT_CHR_UUID \
38 	BT_UUID_DECLARE_128(SMP_BT_CHR_UUID_VAL)
39 
40 /**
41  * @brief	Registers the SMP Bluetooth service. Should only be called if the Bluetooth
42  *		transport has been unregistered by calling smp_bt_unregister().
43  *
44  * @return	0 on success; negative error code on failure.
45  */
46 int smp_bt_register(void);
47 
48 /**
49  * @brief	Unregisters the SMP Bluetooth service.
50  *
51  * @return	0 on success; negative error code on failure.
52  */
53 int smp_bt_unregister(void);
54 
55 /**
56  * @brief	Transmits an SMP command/response over the specified Bluetooth connection as a
57  *		notification.
58  *
59  * @param conn	Connection object.
60  * @param data	Pointer to SMP message.
61  * @param len	data length.
62  *
63  * @return	0 in case of success or negative value in case of error.
64  */
65 int smp_bt_notify(struct bt_conn *conn, const void *data, uint16_t len);
66 
67 #ifdef __cplusplus
68 }
69 #endif
70 
71 #endif
72