1 /******************************************************************************
2 *
3 * Copyright 1999-2012 Broadcom Corporation
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at:
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 ******************************************************************************/
18
19 #pragma once
20
21 #include <base/strings/stringprintf.h>
22 #include <bluetooth/log.h>
23
24 #include <cstdint>
25
26 #include "macros.h"
27
28 /*****************************************************************************
29 * Constants
30 ****************************************************************************/
31
32 /* Success code and error codes */
33 typedef enum : uint16_t {
34 SDP_SUCCESS = 0x0000,
35 SDP_INVALID_VERSION = 0x0001,
36 SDP_INVALID_SERV_REC_HDL = 0x0002,
37 SDP_INVALID_REQ_SYNTAX = 0x0003,
38 SDP_INVALID_PDU_SIZE = 0x0004,
39 SDP_INVALID_CONT_STATE = 0x0005,
40 SDP_NO_RESOURCES = 0x0006,
41 SDP_DI_REG_FAILED = 0x0007,
42 SDP_DI_DISC_FAILED = 0x0008,
43 SDP_NO_DI_RECORD_FOUND = 0x0009,
44 SDP_ERR_ATTR_NOT_PRESENT = 0x000A,
45 SDP_ILLEGAL_PARAMETER = 0x000B,
46
47 HID_SDP_NO_SERV_UUID = (SDP_ILLEGAL_PARAMETER + 1),
48 HID_SDP_MANDATORY_MISSING,
49
50 SDP_NO_RECS_MATCH = 0xFFF0,
51 SDP_CONN_FAILED = 0xFFF1,
52 SDP_CFG_FAILED = 0xFFF2,
53 SDP_GENERIC_ERROR = 0xFFF3,
54 SDP_DB_FULL = 0xFFF4,
55 SDP_CANCEL = 0xFFF8,
56 } tSDP_STATUS;
57 using tSDP_RESULT = tSDP_STATUS;
58 using tSDP_REASON = tSDP_STATUS;
59
sdp_status_text(const tSDP_STATUS & status)60 inline std::string sdp_status_text(const tSDP_STATUS& status) {
61 switch (status) {
62 CASE_RETURN_TEXT(SDP_SUCCESS);
63 CASE_RETURN_TEXT(SDP_INVALID_VERSION);
64 CASE_RETURN_TEXT(SDP_INVALID_SERV_REC_HDL);
65 CASE_RETURN_TEXT(SDP_INVALID_REQ_SYNTAX);
66 CASE_RETURN_TEXT(SDP_INVALID_PDU_SIZE);
67 CASE_RETURN_TEXT(SDP_INVALID_CONT_STATE);
68 CASE_RETURN_TEXT(SDP_NO_RESOURCES);
69 CASE_RETURN_TEXT(SDP_DI_REG_FAILED);
70 CASE_RETURN_TEXT(SDP_DI_DISC_FAILED);
71 CASE_RETURN_TEXT(SDP_NO_DI_RECORD_FOUND);
72 CASE_RETURN_TEXT(SDP_ERR_ATTR_NOT_PRESENT);
73 CASE_RETURN_TEXT(SDP_ILLEGAL_PARAMETER);
74
75 CASE_RETURN_TEXT(HID_SDP_NO_SERV_UUID);
76 CASE_RETURN_TEXT(HID_SDP_MANDATORY_MISSING);
77
78 CASE_RETURN_TEXT(SDP_NO_RECS_MATCH);
79 CASE_RETURN_TEXT(SDP_CONN_FAILED);
80 CASE_RETURN_TEXT(SDP_CFG_FAILED);
81 CASE_RETURN_TEXT(SDP_GENERIC_ERROR);
82 CASE_RETURN_TEXT(SDP_DB_FULL);
83 CASE_RETURN_TEXT(SDP_CANCEL);
84 default:
85 return base::StringPrintf("UNKNOWN[%hu]", status);
86 }
87 }
88 const auto sdp_result_text = sdp_status_text;
89
90 namespace fmt {
91 template <>
92 struct formatter<tSDP_STATUS> : enum_formatter<tSDP_STATUS> {};
93 } // namespace fmt
94