1 /* 2 * Copyright (C) 2021 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef OBEX_TYPES_H 17 #define OBEX_TYPES_H 18 19 #include <cstdint> 20 21 namespace OHOS { 22 namespace bluetooth { 23 #define OBEX_LOG_DEBUG(fmt, ...) LOG_DEBUG("[OBEX]:" fmt, ##__VA_ARGS__) 24 #define OBEX_LOG_INFO(fmt, ...) LOG_INFO("[OBEX]:" fmt, ##__VA_ARGS__) 25 #define OBEX_LOG_ERROR(fmt, ...) LOG_ERROR("[OBEX]:" fmt, ##__VA_ARGS__) 26 27 const uint8_t OBEX_VERSION = 0x10; 28 const uint8_t OBEX_FINAL_BIT_MASK = 0x80; 29 // Min, Max and default transport MTU 30 const uint16_t OBEX_DEFAULT_MTU = 1024; 31 const uint16_t OBEX_MINIMUM_MTU = 255; 32 const uint16_t OBEX_MAXIMUM_MTU = 65535; 33 // The value of 0xffffffff indicates a timeout of infinity 34 const uint32_t OBEX_SESSION_MAX_TIMEOUT_SEC = 0xFFFFFFFF; 35 // backup a level before applying name (equivalent to ../ on many systems) 36 const uint8_t OBEX_SETPATH_BACKUP = 0x01; 37 // Don’t create folder if it does not exist, return an error instead. 38 const uint8_t OBEX_SETPATH_NOCREATE = 0x02; 39 40 enum class ObexOpeId : uint8_t { 41 CONNECT = 0x80, 42 DISCONNECT = 0x81, 43 PUT = 0x02, 44 PUT_FINAL = 0x82, 45 GET = 0x03, 46 GET_FINAL = 0x83, 47 SETPATH = 0x85, 48 ACTION = 0x86, 49 SESSION = 0x87, 50 ABORT = 0xFF 51 }; 52 enum class ObexRspCode : uint8_t { 53 CONTINUE = 0x90, // 100 Continue 54 SUCCESS = 0xA0, // 200 OK, Success 55 CREATED = 0xA1, // 201 Created 56 ACCEPTED = 0xA2, // 202 Accepted 57 NON_AUTH = 0xA3, // 203 Non-Authoritative Information 58 NO_CONTENT = 0xA4, // 204 No Content 59 RESET_CONTENT = 0xA5, // 205 Reset Content 60 PARTIAL_CONTENT = 0xA6, // 206 Partial Content 61 MULTIPLE_CHOICES = 0xB0, // 300 Multiple Choices 62 MOVED_PERMANENTLY = 0xB1, // 301 Moved Permanently 63 MOVED_TEMPORARILY = 0xB2, // 302 Moved temporarily 64 SEE_OTHER = 0xB3, // 303 See Other 65 NOT_MODIFIED = 0xB4, // 304 Not modified 66 USE_PROXY = 0xB5, // 305 Use Proxy 67 BAD_REQUEST = 0xC0, // 400 Bad Request - server couldn’t understand request 68 UNAUTHORIZED = 0xC1, // 401 Unauthorized 69 PAYMENT_REQUIRED = 0xC2, // 402 Payment required 70 FORBIDDEN = 0xC3, // 403 Forbidden - operation is understood but refused 71 NOT_FOUND = 0xC4, // 404 Not Found 72 METHOD_NOT_ALLOWED = 0xC5, // 405 Method not allowed 73 NOT_ACCEPTABLE = 0xC6, // 406 Not Acceptable 74 PROXY_AUTH_REQUIRED = 0xC7, // 407 Proxy Authentication required 75 REQUEST_TIME_OUT = 0xC8, // 408 Request Time Out 76 CONFLICT = 0xC9, // 409 Conflict 77 GONE = 0xCA, // 410 Gone 78 LENGTH_REQUIRED = 0xCB, // 411 Length Required 79 PRECONDITION_FAILED = 0xCC, // 412 Precondition failed 80 REQUESTED_ENTITY_TOO_LARGE = 0xCD, // 413 Requested entity too large 81 REQUEST_URL_TOO_LARGE = 0xCE, // 414 Request URL too large 82 UNSUPPORTED_MEDIA_TYPE = 0xCF, // 415 Unsupported media type 83 INTERNAL_SERVER_ERROR = 0xD0, // 500 Internal Server Error 84 NOT_IMPLEMENTED = 0xD1, // 501 Not Implemented 85 BAD_GATEWAY = 0xD2, // 502 Bad Gateway 86 SERVICE_UNAVAILABLE = 0xD3, // 503 Service Unavailable 87 GATEWAY_TIMEOUT = 0xD4, // 504 Gateway Timeout 88 HTTP_VERSION_NOT_SUPPORTED = 0xD5, // 505 HTTP version not supported 89 DATABASE_FULL = 0xE0, // Database Full 90 DATABASE_LOCKED = 0xE1 // Database Locked 91 }; 92 } // namespace bluetooth 93 } // namespace OHOS 94 #endif // OBEX_TYPES_H 95