diff options
| author | jacqueline <me@jacqueline.id.au> | 2025-07-25 13:33:07 +1000 |
|---|---|---|
| committer | jacqueline <me@jacqueline.id.au> | 2025-07-25 13:33:07 +1000 |
| commit | c8e79a926620e48830778714cfe4b2ea2453fcaf (patch) | |
| tree | 8c756e08e01b8e147cf72bec128026f46bd854c5 /lib/bt/host/bluedroid/stack/obex/include | |
| parent | 237136f3e93cb6b5be24670d7520adb17cc0fa36 (diff) | |
| download | tangara-fw-c8e79a926620e48830778714cfe4b2ea2453fcaf.tar.gz | |
Update forked idf components
Diffstat (limited to 'lib/bt/host/bluedroid/stack/obex/include')
4 files changed, 209 insertions, 0 deletions
diff --git a/lib/bt/host/bluedroid/stack/obex/include/obex_int.h b/lib/bt/host/bluedroid/stack/obex/include/obex_int.h new file mode 100644 index 00000000..28c4eab4 --- /dev/null +++ b/lib/bt/host/bluedroid/stack/obex/include/obex_int.h @@ -0,0 +1,76 @@ +/* + * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#pragma once + +#include "common/bt_target.h" + +#include "stack/obex_api.h" +#include "obex_tl.h" +#include "obex_tl_l2cap.h" + +#if (OBEX_INCLUDED == TRUE) + +#if (RFCOMM_INCLUDED == TRUE) +#define OBEX_BT_HDR_MIN_OFFSET OBEX_TL_RFCOMM_BT_HDR_MIN_OFFSET /* should set to max value of all transport layer */ +#define OBEX_BT_HDR_RESERVE_LEN OBEX_TL_RFCOMM_BT_HDR_RESERVE_LEN /* should set to max value of all transport layer */ +#else +#define OBEX_BT_HDR_MIN_OFFSET OBEX_TL_L2CAP_BT_HDR_OFFSET_MIN +#define OBEX_BT_HDR_RESERVE_LEN OBEX_TL_L2CAP_BT_HDR_RESERVE_LEN +#endif + +#define OBEX_ROLE_CLIENT 0x01 +#define OBEX_ROLE_SERVER 0x02 + +/* OBEX connection state */ +#define OBEX_STATE_IDLE 0 /* No connection */ +#define OBEX_STATE_OPENING 1 /* Starting to open a connection */ +#define OBEX_STATE_OPENED 2 /* Connection opened */ + +/* OBEX Connection Control block */ +typedef struct { + tOBEX_MSG_CBACK *callback; /* Connection msg callback function */ + UINT16 tl_hdl; /* Transport layer non-zeros connection handle*/ + UINT16 tl_peer_mtu; /* Transport layer peer mtu */ + UINT16 tl_our_mtu; /* Transport layer our mtu */ + UINT8 tl_cong; /* 1 if transport layer congestion, otherwise 0 */ + UINT8 tl; /* OBEX_OVER_L2CAP or OBEX_OVER_RFCOMM */ + UINT8 allocated; /* 0, not allocated. index+1, otherwise. equal to api handle */ + UINT8 state; /* This OBEX connection state */ + UINT8 role; /* This OBEX connection role */ +} tOBEX_CCB; + +/* OBEX Server Control block */ +typedef struct { + tOBEX_MSG_CBACK *callback; /* Connection msg callback function */ + UINT16 tl_hdl; /* Transport layer non-zeros server handle*/ + UINT8 tl; /* OBEX_OVER_L2CAP or OBEX_OVER_RFCOMM */ + UINT8 allocated; /* 0, not allocated. index+1, otherwise. */ +} tOBEX_SCB; + +/* OBEX Control block */ +typedef struct { + tOBEX_CCB ccb[OBEX_MAX_CONNECTION]; /* connection control blocks */ + tOBEX_SCB scb[OBEX_MAX_SERVER]; /* server control blocks */ + tOBEX_TL_OPS *tl_ops[OBEX_NUM_TL]; /* transport operation function pointer */ + UINT8 trace_level; /* trace level */ +} tOBEX_CB; + +#if OBEX_DYNAMIC_MEMORY == FALSE +extern tOBEX_CB obex_cb; +#else +extern tOBEX_CB *obex_cb_ptr; +#define obex_cb (*obex_cb_ptr) +#endif + +void obex_tl_l2cap_callback(tOBEX_TL_EVT evt, tOBEX_TL_MSG *msg); +void obex_tl_rfcomm_callback(tOBEX_TL_EVT evt, tOBEX_TL_MSG *msg); +tOBEX_CCB *obex_allocate_ccb(void); +tOBEX_SCB *obex_allocate_scb(void); +void obex_free_ccb(tOBEX_CCB *p_ccb); +void obex_free_scb(tOBEX_SCB *p_scb); + +#endif /* #if (OBEX_INCLUDED == TRUE) */ diff --git a/lib/bt/host/bluedroid/stack/obex/include/obex_tl.h b/lib/bt/host/bluedroid/stack/obex/include/obex_tl.h new file mode 100644 index 00000000..9211b9b0 --- /dev/null +++ b/lib/bt/host/bluedroid/stack/obex/include/obex_tl.h @@ -0,0 +1,97 @@ +/* + * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#pragma once + +#include "common/bt_target.h" + +#if (OBEX_INCLUDED == TRUE) + +/* Return code of obex_tl_send_data */ +#define OBEX_TL_FAILED FALSE +#define OBEX_TL_SUCCESS TRUE +#define OBEX_TL_CONGESTED 2 + +typedef enum { + OBEX_TL_CONN_OPEN_EVT, + OBEX_TL_CONN_INCOME_EVT, + OBEX_TL_DIS_CONN_EVT, + OBEX_TL_CONGEST_EVT, + OBEX_TL_UNCONGEST_EVT, + OBEX_TL_MTU_CHANGE_EVT, + OBEX_TL_DATA_EVT +} tOBEX_TL_EVT; + +typedef union { + /* general struct, used to retrieve handle */ + struct { + UINT16 hdl; + } any; + + /* struct for OBEX_TL_CONN_OPEN_EVT */ + struct { + UINT16 hdl; + UINT16 peer_mtu; + UINT16 our_mtu; + } conn_open; + + /* struct for OBEX_TL_CONN_INCOME_EVT */ + struct { + UINT16 hdl; + UINT16 peer_mtu; + UINT16 our_mtu; + UINT16 svr_hdl; + } conn_income; + + /* struct for OBEX_TL_MTU_CHANGE_EVT */ + struct { + UINT16 hdl; + UINT16 peer_mtu; + UINT16 our_mtu; + } mtu_chg; + + /* struct for OBEX_TL_DATA_EVT */ + struct { + UINT16 hdl; + BT_HDR *p_buf; + } data; +} tOBEX_TL_MSG; + +typedef struct +{ + UINT16 psm; /* l2cap psm */ + UINT16 sec_mask; /* security mask */ + UINT16 pref_mtu; /* preferred mtu, limited by L2CAP_MTU_SIZE */ + BD_ADDR addr; /* peer bluetooth device address */ +} tOBEX_TL_L2CAP_SVR; + +typedef struct +{ + UINT8 scn; /* service channel number */ + UINT16 sec_mask; /* security mask */ + UINT16 pref_mtu; /* preferred mtu, limited by rfcomm mtu */ + BD_ADDR addr; /* peer bluetooth device address */ +} tOBEX_TL_RFCOMM_SVR; + +typedef union +{ + tOBEX_TL_L2CAP_SVR l2cap; + tOBEX_TL_RFCOMM_SVR rfcomm; +} tOBEX_TL_SVR_INFO; + +typedef void (tOBEX_TL_CBACK)(tOBEX_TL_EVT evt, tOBEX_TL_MSG *msg); + +typedef struct { + void (*init)(tOBEX_TL_CBACK *callback); + void (*deinit)(void); + UINT16 (*connect)(tOBEX_TL_SVR_INFO *server); + void (*disconnect)(UINT16 tl_hdl); + UINT16 (*send)(UINT16 tl_hdl, BT_HDR *p_buf); + UINT16 (*bind)(tOBEX_TL_SVR_INFO *server); + void (*unbind)(UINT16 tl_hdl); +} tOBEX_TL_OPS; + +#endif /* #if (OBEX_INCLUDED == TRUE) */ diff --git a/lib/bt/host/bluedroid/stack/obex/include/obex_tl_l2cap.h b/lib/bt/host/bluedroid/stack/obex/include/obex_tl_l2cap.h new file mode 100644 index 00000000..32667766 --- /dev/null +++ b/lib/bt/host/bluedroid/stack/obex/include/obex_tl_l2cap.h @@ -0,0 +1,18 @@ +/* + * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#pragma once + +#include "obex_tl.h" + +#if (OBEX_INCLUDED == TRUE) + +#define OBEX_TL_L2CAP_BT_HDR_MIN_OFFSET 13 /* equal to L2CAP_MIN_OFFSET */ +#define OBEX_TL_L2CAP_BT_HDR_RESERVE_LEN 0 /* not require any additional byte */ + +tOBEX_TL_OPS *obex_tl_l2cap_ops_get(void); + +#endif /* #if (OBEX_INCLUDED == TRUE) */ diff --git a/lib/bt/host/bluedroid/stack/obex/include/obex_tl_rfcomm.h b/lib/bt/host/bluedroid/stack/obex/include/obex_tl_rfcomm.h new file mode 100644 index 00000000..61b9d295 --- /dev/null +++ b/lib/bt/host/bluedroid/stack/obex/include/obex_tl_rfcomm.h @@ -0,0 +1,18 @@ +/* + * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#pragma once + +#include "obex_tl.h" + +#if (OBEX_INCLUDED == TRUE && RFCOMM_INCLUDED == TRUE) + +#define OBEX_TL_RFCOMM_BT_HDR_MIN_OFFSET 18 /* RFCOMM_MIN_OFFSET + L2CAP_MIN_OFFSET */ +#define OBEX_TL_RFCOMM_BT_HDR_RESERVE_LEN 1 /* reserve 1 byte for rfcomm fcs */ + +tOBEX_TL_OPS *obex_tl_rfcomm_ops_get(void); + +#endif /* #if (OBEX_INCLUDED == TRUE && RFCOMM_INCLUDED == TRUE) */ |
