1 /*
2  * Copyright (C) 2015 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef __BT_SDP_H__
18 #define __BT_SDP_H__
19 
20 #include <stdint.h>
21 // #include "bluetooth.h"
22 #include "common/bt_defs.h"
23 #include "esp_bt_defs.h"
24 
25 #define SDP_OPP_SUPPORTED_FORMATS_MAX_LENGTH 15
26 
27 /**
28  * These events are handled by the state machine
29  */
30 typedef enum {
31     SDP_TYPE_RAW,        // Used to carry raw SDP search data for unknown UUIDs
32     SDP_TYPE_MAP_MAS,    // Message Access Profile - Server
33     SDP_TYPE_MAP_MNS,    // Message Access Profile - Client (Notification Server)
34     SDP_TYPE_PBAP_PSE,   // Phone Book Profile - Server
35     SDP_TYPE_PBAP_PCE,   // Phone Book Profile - Client
36     SDP_TYPE_OPP_SERVER, // Object Push Profile
37     SDP_TYPE_SAP_SERVER, // SIM Access Profile
38 } bluetooth_sdp_types;
39 
40 /**
41  * Some signals need additional pointers, hence we introduce a
42  * generic way to handle these pointers.
43  */
44 typedef struct _bluetooth_sdp_hdr_overlay {
45     bluetooth_sdp_types type;
46     esp_bt_uuid_t       uuid;
47     uint32_t            service_name_length;
48     char               *service_name;
49     int32_t             rfcomm_channel_number;
50     int32_t             l2cap_psm;
51     int32_t             profile_version;
52     int                 user1_ptr_len;
53     uint8_t            *user1_ptr;
54     int                 user2_ptr_len; // not used
55     uint8_t            *user2_ptr;     // not used
56 } bluetooth_sdp_hdr_overlay;
57 
58 typedef struct _bluetooth_sdp_mas_record {
59     bluetooth_sdp_hdr_overlay hdr;
60     uint32_t                  mas_instance_id;
61     uint32_t                  supported_features;
62     uint32_t                  supported_message_types;
63 } bluetooth_sdp_mas_record;
64 
65 typedef struct _bluetooth_sdp_mns_record {
66     bluetooth_sdp_hdr_overlay hdr;
67     uint32_t                  supported_features;
68 } bluetooth_sdp_mns_record;
69 
70 typedef struct _bluetooth_sdp_pse_record {
71     bluetooth_sdp_hdr_overlay hdr;
72     uint32_t                  supported_features;
73     uint32_t                  supported_repositories;
74 } bluetooth_sdp_pse_record;
75 
76 typedef struct _bluetooth_sdp_pce_record {
77     bluetooth_sdp_hdr_overlay hdr;
78 } bluetooth_sdp_pce_record;
79 
80 typedef struct _bluetooth_sdp_ops_record {
81     bluetooth_sdp_hdr_overlay hdr;
82     int                       supported_formats_list_len;
83     uint8_t                   supported_formats_list[SDP_OPP_SUPPORTED_FORMATS_MAX_LENGTH];
84 } bluetooth_sdp_ops_record;
85 
86 typedef struct _bluetooth_sdp_sap_record {
87     bluetooth_sdp_hdr_overlay hdr;
88 } bluetooth_sdp_sap_record;
89 
90 typedef union {
91     bluetooth_sdp_hdr_overlay hdr;
92     bluetooth_sdp_mas_record  mas;
93     bluetooth_sdp_mns_record  mns;
94     bluetooth_sdp_pse_record  pse;
95     bluetooth_sdp_pce_record  pce;
96     bluetooth_sdp_ops_record  ops;
97     bluetooth_sdp_sap_record  sap;
98 } bluetooth_sdp_record;
99 
100 #endif /* __BT_SDP_H__ */
101