blob: 363b9c09bd122370c82b285b975a4fc25488d7c1 [file] [log] [blame]
Chris Mantone0746b12023-05-14 18:31:47 -07001/******************************************************************************
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
Henri Chataing7bf239a2024-02-07 00:21:34 +000021#include <bluetooth/log.h>
Chris Mantone0746b12023-05-14 18:31:47 -070022
23#include <cstdint>
24
Hui Peng4b5f1bc2023-12-03 06:24:36 +000025#include "macros.h"
26
Chris Mantone0746b12023-05-14 18:31:47 -070027/*****************************************************************************
28 * Constants
29 ****************************************************************************/
30
31/* Success code and error codes */
Chris Mantond28b52e2024-07-12 18:04:44 -070032enum class tSDP_STATUS : uint16_t {
Chris Mantone0746b12023-05-14 18:31:47 -070033 SDP_SUCCESS = 0x0000,
34 SDP_INVALID_VERSION = 0x0001,
35 SDP_INVALID_SERV_REC_HDL = 0x0002,
36 SDP_INVALID_REQ_SYNTAX = 0x0003,
37 SDP_INVALID_PDU_SIZE = 0x0004,
38 SDP_INVALID_CONT_STATE = 0x0005,
39 SDP_NO_RESOURCES = 0x0006,
40 SDP_DI_REG_FAILED = 0x0007,
41 SDP_DI_DISC_FAILED = 0x0008,
42 SDP_NO_DI_RECORD_FOUND = 0x0009,
43 SDP_ERR_ATTR_NOT_PRESENT = 0x000A,
44 SDP_ILLEGAL_PARAMETER = 0x000B,
45
Chris Mantond28b52e2024-07-12 18:04:44 -070046 HID_SDP_NO_SERV_UUID = (tSDP_STATUS::SDP_ILLEGAL_PARAMETER + 1),
Chris Mantone0746b12023-05-14 18:31:47 -070047 HID_SDP_MANDATORY_MISSING,
48
49 SDP_NO_RECS_MATCH = 0xFFF0,
50 SDP_CONN_FAILED = 0xFFF1,
51 SDP_CFG_FAILED = 0xFFF2,
52 SDP_GENERIC_ERROR = 0xFFF3,
53 SDP_DB_FULL = 0xFFF4,
54 SDP_CANCEL = 0xFFF8,
Chris Mantond28b52e2024-07-12 18:04:44 -070055};
Chris Mantone0746b12023-05-14 18:31:47 -070056using tSDP_RESULT = tSDP_STATUS;
57using tSDP_REASON = tSDP_STATUS;
58
Chris Mantone0746b12023-05-14 18:31:47 -070059inline std::string sdp_status_text(const tSDP_STATUS& status) {
60 switch (status) {
Chris Mantond28b52e2024-07-12 18:04:44 -070061 CASE_RETURN_TEXT(tSDP_STATUS::SDP_SUCCESS);
62 CASE_RETURN_TEXT(tSDP_STATUS::SDP_INVALID_VERSION);
63 CASE_RETURN_TEXT(tSDP_STATUS::SDP_INVALID_SERV_REC_HDL);
64 CASE_RETURN_TEXT(tSDP_STATUS::SDP_INVALID_REQ_SYNTAX);
65 CASE_RETURN_TEXT(tSDP_STATUS::SDP_INVALID_PDU_SIZE);
66 CASE_RETURN_TEXT(tSDP_STATUS::SDP_INVALID_CONT_STATE);
67 CASE_RETURN_TEXT(tSDP_STATUS::SDP_NO_RESOURCES);
68 CASE_RETURN_TEXT(tSDP_STATUS::SDP_DI_REG_FAILED);
69 CASE_RETURN_TEXT(tSDP_STATUS::SDP_DI_DISC_FAILED);
70 CASE_RETURN_TEXT(tSDP_STATUS::SDP_NO_DI_RECORD_FOUND);
71 CASE_RETURN_TEXT(tSDP_STATUS::SDP_ERR_ATTR_NOT_PRESENT);
72 CASE_RETURN_TEXT(tSDP_STATUS::SDP_ILLEGAL_PARAMETER);
Chris Mantone0746b12023-05-14 18:31:47 -070073
Chris Mantond28b52e2024-07-12 18:04:44 -070074 CASE_RETURN_TEXT(tSDP_STATUS::HID_SDP_NO_SERV_UUID);
75 CASE_RETURN_TEXT(tSDP_STATUS::HID_SDP_MANDATORY_MISSING);
Chris Mantone0746b12023-05-14 18:31:47 -070076
Chris Mantond28b52e2024-07-12 18:04:44 -070077 CASE_RETURN_TEXT(tSDP_STATUS::SDP_NO_RECS_MATCH);
78 CASE_RETURN_TEXT(tSDP_STATUS::SDP_CONN_FAILED);
79 CASE_RETURN_TEXT(tSDP_STATUS::SDP_CFG_FAILED);
80 CASE_RETURN_TEXT(tSDP_STATUS::SDP_GENERIC_ERROR);
81 CASE_RETURN_TEXT(tSDP_STATUS::SDP_DB_FULL);
82 CASE_RETURN_TEXT(tSDP_STATUS::SDP_CANCEL);
Chris Mantone0746b12023-05-14 18:31:47 -070083 default:
Henri Chataing833941b2024-12-11 17:37:39 -080084 return std::format("UNKNOWN[{}]", static_cast<uint16_t>(status));
Chris Mantone0746b12023-05-14 18:31:47 -070085 }
86}
87const auto sdp_result_text = sdp_status_text;
Henri Chataing7bf239a2024-02-07 00:21:34 +000088
Henri Chataingb052e582024-11-13 01:18:45 +000089namespace std {
Henri Chataing7bf239a2024-02-07 00:21:34 +000090template <>
91struct formatter<tSDP_STATUS> : enum_formatter<tSDP_STATUS> {};
Henri Chataingb052e582024-11-13 01:18:45 +000092} // namespace std