123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632 |
- #ifndef ZEPHYR_INCLUDE_BLUETOOTH_SDP_H_
- #define ZEPHYR_INCLUDE_BLUETOOTH_SDP_H_
- #include <bluetooth/uuid.h>
- #include <bluetooth/conn.h>
- #ifdef __cplusplus
- extern "C" {
- #endif
- #define BT_SDP_SDP_SERVER_SVCLASS 0x1000
- #define BT_SDP_BROWSE_GRP_DESC_SVCLASS 0x1001
- #define BT_SDP_PUBLIC_BROWSE_GROUP 0x1002
- #define BT_SDP_SERIAL_PORT_SVCLASS 0x1101
- #define BT_SDP_LAN_ACCESS_SVCLASS 0x1102
- #define BT_SDP_DIALUP_NET_SVCLASS 0x1103
- #define BT_SDP_IRMC_SYNC_SVCLASS 0x1104
- #define BT_SDP_OBEX_OBJPUSH_SVCLASS 0x1105
- #define BT_SDP_OBEX_FILETRANS_SVCLASS 0x1106
- #define BT_SDP_IRMC_SYNC_CMD_SVCLASS 0x1107
- #define BT_SDP_HEADSET_SVCLASS 0x1108
- #define BT_SDP_CORDLESS_TELEPHONY_SVCLASS 0x1109
- #define BT_SDP_AUDIO_SOURCE_SVCLASS 0x110a
- #define BT_SDP_AUDIO_SINK_SVCLASS 0x110b
- #define BT_SDP_AV_REMOTE_TARGET_SVCLASS 0x110c
- #define BT_SDP_ADVANCED_AUDIO_SVCLASS 0x110d
- #define BT_SDP_AV_REMOTE_SVCLASS 0x110e
- #define BT_SDP_AV_REMOTE_CONTROLLER_SVCLASS 0x110f
- #define BT_SDP_INTERCOM_SVCLASS 0x1110
- #define BT_SDP_FAX_SVCLASS 0x1111
- #define BT_SDP_HEADSET_AGW_SVCLASS 0x1112
- #define BT_SDP_WAP_SVCLASS 0x1113
- #define BT_SDP_WAP_CLIENT_SVCLASS 0x1114
- #define BT_SDP_PANU_SVCLASS 0x1115
- #define BT_SDP_NAP_SVCLASS 0x1116
- #define BT_SDP_GN_SVCLASS 0x1117
- #define BT_SDP_DIRECT_PRINTING_SVCLASS 0x1118
- #define BT_SDP_REFERENCE_PRINTING_SVCLASS 0x1119
- #define BT_SDP_IMAGING_SVCLASS 0x111a
- #define BT_SDP_IMAGING_RESPONDER_SVCLASS 0x111b
- #define BT_SDP_IMAGING_ARCHIVE_SVCLASS 0x111c
- #define BT_SDP_IMAGING_REFOBJS_SVCLASS 0x111d
- #define BT_SDP_HANDSFREE_SVCLASS 0x111e
- #define BT_SDP_HANDSFREE_AGW_SVCLASS 0x111f
- #define BT_SDP_DIRECT_PRT_REFOBJS_SVCLASS 0x1120
- #define BT_SDP_REFLECTED_UI_SVCLASS 0x1121
- #define BT_SDP_BASIC_PRINTING_SVCLASS 0x1122
- #define BT_SDP_PRINTING_STATUS_SVCLASS 0x1123
- #define BT_SDP_HID_SVCLASS 0x1124
- #define BT_SDP_HCR_SVCLASS 0x1125
- #define BT_SDP_HCR_PRINT_SVCLASS 0x1126
- #define BT_SDP_HCR_SCAN_SVCLASS 0x1127
- #define BT_SDP_CIP_SVCLASS 0x1128
- #define BT_SDP_VIDEO_CONF_GW_SVCLASS 0x1129
- #define BT_SDP_UDI_MT_SVCLASS 0x112a
- #define BT_SDP_UDI_TA_SVCLASS 0x112b
- #define BT_SDP_AV_SVCLASS 0x112c
- #define BT_SDP_SAP_SVCLASS 0x112d
- #define BT_SDP_PBAP_PCE_SVCLASS 0x112e
- #define BT_SDP_PBAP_PSE_SVCLASS 0x112f
- #define BT_SDP_PBAP_SVCLASS 0x1130
- #define BT_SDP_MAP_MSE_SVCLASS 0x1132
- #define BT_SDP_MAP_MCE_SVCLASS 0x1133
- #define BT_SDP_MAP_SVCLASS 0x1134
- #define BT_SDP_GNSS_SVCLASS 0x1135
- #define BT_SDP_GNSS_SERVER_SVCLASS 0x1136
- #define BT_SDP_MPS_SC_SVCLASS 0x113a
- #define BT_SDP_MPS_SVCLASS 0x113b
- #define BT_SDP_PNP_INFO_SVCLASS 0x1200
- #define BT_SDP_GENERIC_NETWORKING_SVCLASS 0x1201
- #define BT_SDP_GENERIC_FILETRANS_SVCLASS 0x1202
- #define BT_SDP_GENERIC_AUDIO_SVCLASS 0x1203
- #define BT_SDP_GENERIC_TELEPHONY_SVCLASS 0x1204
- #define BT_SDP_UPNP_SVCLASS 0x1205
- #define BT_SDP_UPNP_IP_SVCLASS 0x1206
- #define BT_SDP_UPNP_PAN_SVCLASS 0x1300
- #define BT_SDP_UPNP_LAP_SVCLASS 0x1301
- #define BT_SDP_UPNP_L2CAP_SVCLASS 0x1302
- #define BT_SDP_VIDEO_SOURCE_SVCLASS 0x1303
- #define BT_SDP_VIDEO_SINK_SVCLASS 0x1304
- #define BT_SDP_VIDEO_DISTRIBUTION_SVCLASS 0x1305
- #define BT_SDP_HDP_SVCLASS 0x1400
- #define BT_SDP_HDP_SOURCE_SVCLASS 0x1401
- #define BT_SDP_HDP_SINK_SVCLASS 0x1402
- #define BT_SDP_GENERIC_ACCESS_SVCLASS 0x1800
- #define BT_SDP_GENERIC_ATTRIB_SVCLASS 0x1801
- #define BT_SDP_APPLE_AGENT_SVCLASS 0x2112
- #define BT_SDP_SERVER_RECORD_HANDLE 0x0000
- #define BT_SDP_ATTR_RECORD_HANDLE 0x0000
- #define BT_SDP_ATTR_SVCLASS_ID_LIST 0x0001
- #define BT_SDP_ATTR_RECORD_STATE 0x0002
- #define BT_SDP_ATTR_SERVICE_ID 0x0003
- #define BT_SDP_ATTR_PROTO_DESC_LIST 0x0004
- #define BT_SDP_ATTR_BROWSE_GRP_LIST 0x0005
- #define BT_SDP_ATTR_LANG_BASE_ATTR_ID_LIST 0x0006
- #define BT_SDP_ATTR_SVCINFO_TTL 0x0007
- #define BT_SDP_ATTR_SERVICE_AVAILABILITY 0x0008
- #define BT_SDP_ATTR_PROFILE_DESC_LIST 0x0009
- #define BT_SDP_ATTR_DOC_URL 0x000a
- #define BT_SDP_ATTR_CLNT_EXEC_URL 0x000b
- #define BT_SDP_ATTR_ICON_URL 0x000c
- #define BT_SDP_ATTR_ADD_PROTO_DESC_LIST 0x000d
- #define BT_SDP_ATTR_GROUP_ID 0x0200
- #define BT_SDP_ATTR_IP_SUBNET 0x0200
- #define BT_SDP_ATTR_VERSION_NUM_LIST 0x0200
- #define BT_SDP_ATTR_SUPPORTED_FEATURES_LIST 0x0200
- #define BT_SDP_ATTR_GOEP_L2CAP_PSM 0x0200
- #define BT_SDP_ATTR_SVCDB_STATE 0x0201
- #define BT_SDP_ATTR_MPSD_SCENARIOS 0x0200
- #define BT_SDP_ATTR_MPMD_SCENARIOS 0x0201
- #define BT_SDP_ATTR_MPS_DEPENDENCIES 0x0202
- #define BT_SDP_ATTR_SERVICE_VERSION 0x0300
- #define BT_SDP_ATTR_EXTERNAL_NETWORK 0x0301
- #define BT_SDP_ATTR_SUPPORTED_DATA_STORES_LIST 0x0301
- #define BT_SDP_ATTR_DATA_EXCHANGE_SPEC 0x0301
- #define BT_SDP_ATTR_NETWORK 0x0301
- #define BT_SDP_ATTR_FAX_CLASS1_SUPPORT 0x0302
- #define BT_SDP_ATTR_REMOTE_AUDIO_VOLUME_CONTROL 0x0302
- #define BT_SDP_ATTR_MCAP_SUPPORTED_PROCEDURES 0x0302
- #define BT_SDP_ATTR_FAX_CLASS20_SUPPORT 0x0303
- #define BT_SDP_ATTR_SUPPORTED_FORMATS_LIST 0x0303
- #define BT_SDP_ATTR_FAX_CLASS2_SUPPORT 0x0304
- #define BT_SDP_ATTR_AUDIO_FEEDBACK_SUPPORT 0x0305
- #define BT_SDP_ATTR_NETWORK_ADDRESS 0x0306
- #define BT_SDP_ATTR_WAP_GATEWAY 0x0307
- #define BT_SDP_ATTR_HOMEPAGE_URL 0x0308
- #define BT_SDP_ATTR_WAP_STACK_TYPE 0x0309
- #define BT_SDP_ATTR_SECURITY_DESC 0x030a
- #define BT_SDP_ATTR_NET_ACCESS_TYPE 0x030b
- #define BT_SDP_ATTR_MAX_NET_ACCESSRATE 0x030c
- #define BT_SDP_ATTR_IP4_SUBNET 0x030d
- #define BT_SDP_ATTR_IP6_SUBNET 0x030e
- #define BT_SDP_ATTR_SUPPORTED_CAPABILITIES 0x0310
- #define BT_SDP_ATTR_SUPPORTED_FEATURES 0x0311
- #define BT_SDP_ATTR_SUPPORTED_FUNCTIONS 0x0312
- #define BT_SDP_ATTR_TOTAL_IMAGING_DATA_CAPACITY 0x0313
- #define BT_SDP_ATTR_SUPPORTED_REPOSITORIES 0x0314
- #define BT_SDP_ATTR_MAS_INSTANCE_ID 0x0315
- #define BT_SDP_ATTR_SUPPORTED_MESSAGE_TYPES 0x0316
- #define BT_SDP_ATTR_PBAP_SUPPORTED_FEATURES 0x0317
- #define BT_SDP_ATTR_MAP_SUPPORTED_FEATURES 0x0317
- #define BT_SDP_ATTR_SPECIFICATION_ID 0x0200
- #define BT_SDP_ATTR_VENDOR_ID 0x0201
- #define BT_SDP_ATTR_PRODUCT_ID 0x0202
- #define BT_SDP_ATTR_VERSION 0x0203
- #define BT_SDP_ATTR_PRIMARY_RECORD 0x0204
- #define BT_SDP_ATTR_VENDOR_ID_SOURCE 0x0205
- #define BT_SDP_ATTR_HID_DEVICE_RELEASE_NUMBER 0x0200
- #define BT_SDP_ATTR_HID_PARSER_VERSION 0x0201
- #define BT_SDP_ATTR_HID_DEVICE_SUBCLASS 0x0202
- #define BT_SDP_ATTR_HID_COUNTRY_CODE 0x0203
- #define BT_SDP_ATTR_HID_VIRTUAL_CABLE 0x0204
- #define BT_SDP_ATTR_HID_RECONNECT_INITIATE 0x0205
- #define BT_SDP_ATTR_HID_DESCRIPTOR_LIST 0x0206
- #define BT_SDP_ATTR_HID_LANG_ID_BASE_LIST 0x0207
- #define BT_SDP_ATTR_HID_SDP_DISABLE 0x0208
- #define BT_SDP_ATTR_HID_BATTERY_POWER 0x0209
- #define BT_SDP_ATTR_HID_REMOTE_WAKEUP 0x020a
- #define BT_SDP_ATTR_HID_PROFILE_VERSION 0x020b
- #define BT_SDP_ATTR_HID_SUPERVISION_TIMEOUT 0x020c
- #define BT_SDP_ATTR_HID_NORMALLY_CONNECTABLE 0x020d
- #define BT_SDP_ATTR_HID_BOOT_DEVICE 0x020e
- #define BT_SDP_PRIMARY_LANG_BASE 0x0100
- #define BT_SDP_ATTR_SVCNAME_PRIMARY (0x0000 + BT_SDP_PRIMARY_LANG_BASE)
- #define BT_SDP_ATTR_SVCDESC_PRIMARY (0x0001 + BT_SDP_PRIMARY_LANG_BASE)
- #define BT_SDP_ATTR_PROVNAME_PRIMARY (0x0002 + BT_SDP_PRIMARY_LANG_BASE)
- #define BT_SDP_DATA_NIL 0x00
- #define BT_SDP_UINT8 0x08
- #define BT_SDP_UINT16 0x09
- #define BT_SDP_UINT32 0x0a
- #define BT_SDP_UINT64 0x0b
- #define BT_SDP_UINT128 0x0c
- #define BT_SDP_INT8 0x10
- #define BT_SDP_INT16 0x11
- #define BT_SDP_INT32 0x12
- #define BT_SDP_INT64 0x13
- #define BT_SDP_INT128 0x14
- #define BT_SDP_UUID_UNSPEC 0x18
- #define BT_SDP_UUID16 0x19
- #define BT_SDP_UUID32 0x1a
- #define BT_SDP_UUID128 0x1c
- #define BT_SDP_TEXT_STR_UNSPEC 0x20
- #define BT_SDP_TEXT_STR8 0x25
- #define BT_SDP_TEXT_STR16 0x26
- #define BT_SDP_TEXT_STR32 0x27
- #define BT_SDP_BOOL 0x28
- #define BT_SDP_SEQ_UNSPEC 0x30
- #define BT_SDP_SEQ8 0x35
- #define BT_SDP_SEQ16 0x36
- #define BT_SDP_SEQ32 0x37
- #define BT_SDP_ALT_UNSPEC 0x38
- #define BT_SDP_ALT8 0x3d
- #define BT_SDP_ALT16 0x3e
- #define BT_SDP_ALT32 0x3f
- #define BT_SDP_URL_STR_UNSPEC 0x40
- #define BT_SDP_URL_STR8 0x45
- #define BT_SDP_URL_STR16 0x46
- #define BT_SDP_URL_STR32 0x47
- #define BT_SDP_TYPE_DESC_MASK 0xf8
- #define BT_SDP_SIZE_DESC_MASK 0x07
- #define BT_SDP_SIZE_INDEX_OFFSET 5
- struct bt_sdp_data_elem {
- uint8_t type;
- uint32_t data_size;
- uint32_t total_size;
- const void *data;
- };
- struct bt_sdp_attribute {
- uint16_t id;
- struct bt_sdp_data_elem val;
- };
- struct bt_sdp_record {
- uint32_t handle;
- struct bt_sdp_attribute *attrs;
- size_t attr_count;
- uint8_t index;
- struct bt_sdp_record *next;
- };
- #define BT_SDP_ARRAY_8(...) ((uint8_t[]) {__VA_ARGS__})
- #define BT_SDP_ARRAY_16(...) ((uint16_t[]) {__VA_ARGS__})
- #define BT_SDP_ARRAY_32(...) ((uint32_t[]) {__VA_ARGS__})
- #define BT_SDP_TYPE_SIZE(_type) .type = _type, \
- .data_size = BIT(_type & BT_SDP_SIZE_DESC_MASK), \
- .total_size = BIT(_type & BT_SDP_SIZE_DESC_MASK) + 1
- #define BT_SDP_TYPE_SIZE_VAR(_type, _size) .type = _type, \
- .data_size = _size, \
- .total_size = BIT((_type & BT_SDP_SIZE_DESC_MASK) - \
- BT_SDP_SIZE_INDEX_OFFSET) + _size + 1
- #define BT_SDP_DATA_ELEM_LIST(...) ((struct bt_sdp_data_elem[]) {__VA_ARGS__})
- #define BT_SDP_NEW_SERVICE \
- { \
- BT_SDP_ATTR_RECORD_HANDLE, \
- { BT_SDP_TYPE_SIZE(BT_SDP_UINT32), BT_SDP_ARRAY_32(0) } \
- }, \
- { \
- BT_SDP_ATTR_RECORD_STATE, \
- { BT_SDP_TYPE_SIZE(BT_SDP_UINT32), BT_SDP_ARRAY_32(0) } \
- }, \
- { \
- BT_SDP_ATTR_LANG_BASE_ATTR_ID_LIST, \
- { BT_SDP_TYPE_SIZE_VAR(BT_SDP_SEQ8, 9), \
- BT_SDP_DATA_ELEM_LIST( \
- { BT_SDP_TYPE_SIZE(BT_SDP_UINT16), BT_SDP_ARRAY_8('n', 'e') }, \
- { BT_SDP_TYPE_SIZE(BT_SDP_UINT16), BT_SDP_ARRAY_16(106) }, \
- { BT_SDP_TYPE_SIZE(BT_SDP_UINT16), \
- BT_SDP_ARRAY_16(BT_SDP_PRIMARY_LANG_BASE) } \
- ), \
- } \
- }, \
- { \
- BT_SDP_ATTR_BROWSE_GRP_LIST, \
- { BT_SDP_TYPE_SIZE_VAR(BT_SDP_SEQ8, 3), \
- BT_SDP_DATA_ELEM_LIST( \
- { BT_SDP_TYPE_SIZE(BT_SDP_UUID16), \
- BT_SDP_ARRAY_16(BT_SDP_PUBLIC_BROWSE_GROUP) }, \
- ), \
- } \
- }
- #define BT_SDP_LIST(_att_id, _type_size, _data_elem_seq) \
- { \
- _att_id, { _type_size, _data_elem_seq } \
- }
- #define BT_SDP_SERVICE_ID(_uuid) \
- { \
- BT_SDP_ATTR_SERVICE_ID, \
- { BT_SDP_TYPE_SIZE(BT_SDP_UUID16), &((struct bt_uuid_16) _uuid) } \
- }
- #define BT_SDP_SERVICE_NAME(_name) \
- { \
- BT_SDP_ATTR_SVCNAME_PRIMARY, \
- { BT_SDP_TYPE_SIZE_VAR(BT_SDP_TEXT_STR8, (sizeof(_name)-1)), _name } \
- }
- #define BT_SDP_SUPPORTED_FEATURES(_features) \
- { \
- BT_SDP_ATTR_SUPPORTED_FEATURES, \
- { BT_SDP_TYPE_SIZE(BT_SDP_UINT16), BT_SDP_ARRAY_16(_features) } \
- }
- #define BT_SDP_RECORD(_attrs) \
- { \
- .attrs = _attrs, \
- .attr_count = ARRAY_SIZE((_attrs)), \
- }
- int bt_sdp_register_service(struct bt_sdp_record *service);
- struct bt_sdp_client_result {
-
- struct net_buf *resp_buf;
-
- bool next_record_hint;
-
- const struct bt_uuid *uuid;
- };
- enum {
- BT_SDP_DISCOVER_UUID_STOP = 0,
- BT_SDP_DISCOVER_UUID_CONTINUE,
- };
- typedef uint8_t (*bt_sdp_discover_func_t)
- (struct bt_conn *conn, struct bt_sdp_client_result *result);
- struct bt_sdp_discover_params {
- sys_snode_t _node;
-
- const struct bt_uuid *uuid;
-
- bt_sdp_discover_func_t func;
-
- struct net_buf_pool *pool;
- };
- int bt_sdp_discover(struct bt_conn *conn,
- const struct bt_sdp_discover_params *params);
- int bt_sdp_discover_cancel(struct bt_conn *conn,
- const struct bt_sdp_discover_params *params);
- enum bt_sdp_proto {
- BT_SDP_PROTO_RFCOMM = 0x0003,
- BT_SDP_PROTO_L2CAP = 0x0100,
- };
- int bt_sdp_get_proto_param(const struct net_buf *buf, enum bt_sdp_proto proto,
- uint16_t *param);
- int bt_sdp_get_addl_proto_param(const struct net_buf *buf, enum bt_sdp_proto proto,
- uint8_t param_index, uint16_t *param);
- int bt_sdp_get_profile_version(const struct net_buf *buf, uint16_t profile,
- uint16_t *version);
- int bt_sdp_get_features(const struct net_buf *buf, uint16_t *features);
- #ifdef __cplusplus
- }
- #endif
- #endif
|