nRF Connect SDK API 0.1.0
Loading...
Searching...
No Matches
dfu_smp.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2019 Nordic Semiconductor ASA
3 *
4 * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5 */
6
7#ifndef BT_DFU_SMP_H_
8#define BT_DFU_SMP_H_
9
17#ifdef __cplusplus
18extern "C" {
19#endif
20
21#include <stdbool.h>
22#include <zephyr/bluetooth/gatt.h>
23#include <zephyr/bluetooth/conn.h>
24#include <bluetooth/gatt_dm.h>
25
26
31#define BT_UUID_DFU_SMP_SERVICE_VAL \
32 BT_UUID_128_ENCODE(0x8D53DC1D, 0x1DB7, 0x4CD3, 0x868B, 0x8A527460AA84)
33
34#define BT_UUID_DFU_SMP_SERVICE BT_UUID_DECLARE_128(BT_UUID_DFU_SMP_SERVICE_VAL)
35
41#define BT_UUID_DFU_SMP_CHAR_VAL \
42 BT_UUID_128_ENCODE(0xDA2E7828, 0xFBCE, 0x4E01, 0xAE9E, 0x261174997C48)
43
44
45#define BT_UUID_DFU_SMP_CHAR BT_UUID_DECLARE_128(BT_UUID_DFU_SMP_CHAR_VAL)
46
47/* Forward declaration required for function handlers. */
48struct bt_dfu_smp;
49
54 uint8_t op;
56 uint8_t flags;
58 uint8_t len_h8;
60 uint8_t len_l8;
62 uint8_t group_h8;
64 uint8_t group_l8;
66 uint8_t seq;
68 uint8_t id;
69};
70
80 size_t total_size;
82 size_t offset;
84 size_t chunk_size;
86 const uint8_t *data;
87};
88
93typedef void (*bt_dfu_smp_rsp_part_cb)(struct bt_dfu_smp *dfu_smp);
94
100typedef void (*bt_dfu_smp_error_cb)(struct bt_dfu_smp *dfu_smp,
101 int err);
102
112};
113
119 struct bt_conn *conn;
123 uint16_t smp;
125 uint16_t smp_ccc;
151 struct bt_gatt_subscribe_params notification_params;
152};
153
162int bt_dfu_smp_init(struct bt_dfu_smp *dfu_smp,
163 const struct bt_dfu_smp_init_params *params);
164
175int bt_dfu_smp_handles_assign(struct bt_gatt_dm *dm,
176 struct bt_dfu_smp *dfu_smp);
177
188int bt_dfu_smp_command(struct bt_dfu_smp *dfu_smp,
190 size_t cmd_size, const void *cmd_data);
191
198struct bt_conn *bt_dfu_smp_conn(const struct bt_dfu_smp *dfu_smp);
199
211 const struct bt_dfu_smp *dfu_smp);
212
227bool bt_dfu_smp_rsp_total_check(const struct bt_dfu_smp *dfu_smp);
228
229
230#ifdef __cplusplus
231}
232#endif
233
238#endif /* BT_DFU_SMP_H_ */
void(* bt_dfu_smp_error_cb)(struct bt_dfu_smp *dfu_smp, int err)
Global function that is called when an error occurs.
Definition: dfu_smp.h:100
bool bt_dfu_smp_rsp_total_check(const struct bt_dfu_smp *dfu_smp)
Check if all response parts have been received.
int bt_dfu_smp_init(struct bt_dfu_smp *dfu_smp, const struct bt_dfu_smp_init_params *params)
Initialize the DFU SMP Client module.
int bt_dfu_smp_command(struct bt_dfu_smp *dfu_smp, bt_dfu_smp_rsp_part_cb rsp_cb, size_t cmd_size, const void *cmd_data)
Execute a command.
struct bt_conn * bt_dfu_smp_conn(const struct bt_dfu_smp *dfu_smp)
Get the connection object that is used with the DFU SMP Client.
void(* bt_dfu_smp_rsp_part_cb)(struct bt_dfu_smp *dfu_smp)
Handle part of the response.
Definition: dfu_smp.h:93
int bt_dfu_smp_handles_assign(struct bt_gatt_dm *dm, struct bt_dfu_smp *dfu_smp)
Assign handles to the DFU SMP Client instance.
bt_dfu_smp_rsp_part_cb rsp_part
Callback pointer for receiving the response.
Definition: dfu_smp.h:141
bt_dfu_smp_error_cb error_cb
Callback pointer for global error.
Definition: dfu_smp.h:135
Definition: dfu_smp.h:130
uint16_t smp
Definition: dfu_smp.h:123
uint16_t smp_ccc
Definition: dfu_smp.h:125
Definition: dfu_smp.h:121
uint8_t len_h8
Definition: dfu_smp.h:58
uint8_t group_h8
Definition: dfu_smp.h:62
uint8_t op
Definition: dfu_smp.h:54
uint8_t flags
Definition: dfu_smp.h:56
uint8_t len_l8
Definition: dfu_smp.h:60
uint8_t id
Definition: dfu_smp.h:68
uint8_t seq
Definition: dfu_smp.h:66
uint8_t group_l8
Definition: dfu_smp.h:64
Header used internally by dfu_smp.
Definition: dfu_smp.h:52
bt_dfu_smp_error_cb error_cb
Callback pointer for error handler.
Definition: dfu_smp.h:111
DFU SMP Client parameters for the initialization function.
Definition: dfu_smp.h:106
size_t total_size
Total size of the response.
Definition: dfu_smp.h:80
size_t offset
Current data chunk offset.
Definition: dfu_smp.h:82
size_t chunk_size
The size of the data chunk.
Definition: dfu_smp.h:84
const uint8_t * data
Pointer to the data.
Definition: dfu_smp.h:86
Current response state.
Definition: dfu_smp.h:73
struct bt_dfu_smp::bt_dfu_smp_cbs cbs
struct bt_dfu_smp_rsp_state rsp_state
Definition: dfu_smp.h:128
struct bt_gatt_subscribe_params notification_params
Response notification parameters.
Definition: dfu_smp.h:151
struct bt_dfu_smp::bt_dfu_smp_handles handles
struct bt_conn * conn
Definition: dfu_smp.h:119
DFU SMP Client structure.
Definition: dfu_smp.h:117