Bluetooth: Implement SMP error response
Add bt_smp_create_pdu() helper and implement send_err_rsp for an unknown SMP command. Change-Id: Iaed0811f3323f62aaa56eb531fb383cf15396ef8 Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
This commit is contained in:
parent
69f94f2484
commit
3750a7eb36
2 changed files with 30 additions and 2 deletions
|
@ -44,11 +44,34 @@
|
|||
#include "l2cap.h"
|
||||
#include "smp.h"
|
||||
|
||||
struct bt_buf *bt_smp_create_pdu(struct bt_conn *conn, uint8_t op, size_t len)
|
||||
{
|
||||
struct bt_smp_hdr *hdr;
|
||||
struct bt_buf *buf;
|
||||
|
||||
buf = bt_l2cap_create_pdu(conn, BT_L2CAP_CID_SMP, sizeof(*hdr) + len);
|
||||
if (!buf)
|
||||
return NULL;
|
||||
|
||||
hdr = (void *)bt_buf_add(buf, sizeof(*hdr));
|
||||
hdr->code = op;
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
static void send_err_rsp(struct bt_conn *conn, uint8_t reason)
|
||||
{
|
||||
/* TODO: implement err response */
|
||||
struct bt_smp_pairing_fail *rsp;
|
||||
struct bt_buf *buf;
|
||||
|
||||
return;
|
||||
buf = bt_smp_create_pdu(conn, BT_SMP_CMD_PAIRING_FAIL, sizeof(*rsp));
|
||||
if (!buf)
|
||||
return;
|
||||
|
||||
rsp = (void *)bt_buf_add(buf, sizeof(*rsp));
|
||||
rsp->reason = reason;
|
||||
|
||||
bt_conn_send(conn, buf);
|
||||
}
|
||||
|
||||
void bt_smp_recv(struct bt_conn *conn, struct bt_buf *buf)
|
||||
|
|
|
@ -52,4 +52,9 @@ struct bt_smp_hdr {
|
|||
#define BT_SMP_ERR_BREDR_PAIRING_IN_PROGRESS 0x0d
|
||||
#define BT_SMP_ERR_CROSS_TRANSP_NOT_ALLOWED 0x0e
|
||||
|
||||
#define BT_SMP_CMD_PAIRING_FAIL 0x05
|
||||
struct bt_smp_pairing_fail {
|
||||
uint8_t reason;
|
||||
} PACK_STRUCT;
|
||||
|
||||
void bt_smp_recv(struct bt_conn *conn, struct bt_buf *buf);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue