123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593 |
- #ifndef ZEPHYR_INCLUDE_BLUETOOTH_ISO_H_
- #define ZEPHYR_INCLUDE_BLUETOOTH_ISO_H_
- #ifdef __cplusplus
- extern "C" {
- #endif
- #include <sys/atomic.h>
- #include <bluetooth/buf.h>
- #include <bluetooth/conn.h>
- #include <bluetooth/hci.h>
- #define BT_ISO_CHAN_SEND_RESERVE (CONFIG_BT_HCI_RESERVE + \
- BT_HCI_ISO_HDR_SIZE + \
- BT_HCI_ISO_DATA_HDR_SIZE)
- #define BT_ISO_DATA_PATH_HCI 0x00
- #define BT_ISO_INTERVAL_MIN 0x0000FF
- #define BT_ISO_INTERVAL_MAX 0x0FFFFF
- #define BT_ISO_LATENCY_MIN 0x0005
- #define BT_ISO_LATENCY_MAX 0x0FA0
- #define BT_ISO_PACKING_SEQUENTIAL 0x00
- #define BT_ISO_PACKING_INTERLEAVED 0x01
- #define BT_ISO_FRAMING_UNFRAMED 0x00
- #define BT_ISO_FRAMING_FRAMED 0x01
- #define BT_ISO_MAX_GROUP_ISO_COUNT 0x1F
- #define BT_ISO_MAX_SDU 0x0FFF
- #define BT_ISO_SYNC_TIMEOUT_MIN 0x000A
- #define BT_ISO_SYNC_TIMEOUT_MAX 0x4000
- #define BT_ISO_SYNC_MSE_ANY 0x00
- #define BT_ISO_SYNC_MSE_MIN 0x01
- #define BT_ISO_SYNC_MSE_MAX 0x1F
- #define BT_ISO_CONNECTED_RTN_MAX 0xFF
- #define BT_ISO_BROADCAST_RTN_MAX 0x1E
- #define BT_ISO_BROADCAST_CODE_SIZE 16
- enum {
-
- BT_ISO_DISCONNECTED,
-
- BT_ISO_CONNECT,
-
- BT_ISO_CONNECTED,
-
- BT_ISO_DISCONNECT,
- };
- struct bt_iso_chan {
-
- struct bt_conn *iso;
-
- struct bt_iso_chan_ops *ops;
-
- struct bt_iso_chan_qos *qos;
- uint8_t state;
- bt_security_t required_sec_level;
- };
- struct bt_iso_chan_io_qos {
-
- uint16_t sdu;
-
- uint8_t phy;
-
- uint8_t rtn;
-
- struct bt_iso_chan_path *path;
- };
- struct bt_iso_chan_qos {
-
- struct bt_iso_chan_io_qos *rx;
-
- struct bt_iso_chan_io_qos *tx;
- };
- struct bt_iso_chan_path {
-
- uint8_t pid;
-
- uint8_t format;
-
- uint16_t cid;
-
- uint16_t vid;
-
- uint32_t delay;
-
- uint8_t cc_len;
-
- uint8_t cc[0];
- };
- enum {
-
- BT_ISO_FLAGS_VALID,
-
- BT_ISO_FLAGS_ERROR,
-
- BT_ISO_FLAGS_LOST
- };
- struct bt_iso_recv_info {
-
- uint32_t ts;
-
- uint16_t sn;
-
- uint8_t flags;
- };
- struct bt_iso_cig;
- struct bt_iso_cig_create_param {
-
- struct bt_iso_chan **cis_channels;
-
- uint8_t num_cis;
-
- uint32_t interval;
-
- uint16_t latency;
-
- uint8_t sca;
-
- uint8_t packing;
-
- uint8_t framing;
- };
- struct bt_iso_connect_param {
-
- struct bt_iso_chan *iso_chan;
-
- struct bt_conn *acl;
- };
- struct bt_iso_big;
- struct bt_iso_big_create_param {
-
- struct bt_iso_chan **bis_channels;
-
- uint8_t num_bis;
-
- uint32_t interval;
-
- uint16_t latency;
-
- uint8_t packing;
-
- uint8_t framing;
-
- bool encryption;
-
- uint8_t bcode[BT_ISO_BROADCAST_CODE_SIZE];
- };
- struct bt_iso_big_sync_param {
-
- struct bt_iso_chan **bis_channels;
-
- uint8_t num_bis;
-
- uint32_t bis_bitfield;
-
- uint32_t mse;
-
- uint16_t sync_timeout;
-
- bool encryption;
-
- uint8_t bcode[BT_ISO_BROADCAST_CODE_SIZE];
- };
- struct bt_iso_biginfo {
-
- const bt_addr_le_t *addr;
-
- uint8_t sid;
-
- uint8_t num_bis;
-
- uint8_t sub_evt_count;
-
- uint16_t iso_interval;
-
- uint8_t burst_number;
-
- uint8_t offset;
-
- uint8_t rep_count;
-
- uint16_t max_pdu;
-
- uint32_t sdu_interval;
-
- uint16_t max_sdu;
-
- uint8_t phy;
-
- uint8_t framing;
-
- bool encryption;
- };
- struct bt_iso_chan_ops {
-
- void (*connected)(struct bt_iso_chan *chan);
-
- void (*disconnected)(struct bt_iso_chan *chan, uint8_t reason);
-
- struct net_buf *(*alloc_buf)(struct bt_iso_chan *chan);
-
- void (*recv)(struct bt_iso_chan *chan, const struct bt_iso_recv_info *info,
- struct net_buf *buf);
-
- void (*sent)(struct bt_iso_chan *chan);
- };
- struct bt_iso_server {
-
- bt_security_t sec_level;
-
- int (*accept)(struct bt_conn *acl, struct bt_iso_chan **chan);
- };
- int bt_iso_server_register(struct bt_iso_server *server);
- int bt_iso_cig_create(const struct bt_iso_cig_create_param *param,
- struct bt_iso_cig **out_cig);
- int bt_iso_cig_terminate(struct bt_iso_cig *cig);
- int bt_iso_chan_connect(const struct bt_iso_connect_param *param, size_t count);
- int bt_iso_chan_disconnect(struct bt_iso_chan *chan);
- int bt_iso_chan_send(struct bt_iso_chan *chan, struct net_buf *buf);
- int bt_iso_big_create(struct bt_le_ext_adv *padv, struct bt_iso_big_create_param *param,
- struct bt_iso_big **out_big);
- int bt_iso_big_terminate(struct bt_iso_big *big);
- int bt_iso_big_sync(struct bt_le_per_adv_sync *sync, struct bt_iso_big_sync_param *param,
- struct bt_iso_big **out_big);
- #ifdef __cplusplus
- }
- #endif
- #endif
|