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 TRANSPORT_DEF_H 17 #define TRANSPORT_DEF_H 18 19 #include "dispatcher.h" 20 #include "transport.h" 21 22 namespace OHOS { 23 namespace bluetooth { 24 // Transport event declarations 25 // The event is triggered when connection failed. 26 static const int CONNECT_FAIL = 0x0001; 27 // The event is triggered when the disconnection process is successful. 28 static const int DISCONNECT_SUCCESS = 0x0002; 29 // The event is triggered when the disconnection process fails. 30 static const int DISCONNECT_FAIL = 0x0003; 31 // The event is triggered when peer or RFCOMM/L2CAP is available to receive data. 32 static const int EV_FC_ON = 0x0004; 33 // The event is triggered when peer or RFCOMM/L2CAP is not available to receive data. 34 static const int EV_FC_OFF = 0x0005; 35 // The event is triggered when L2CAP channel is on a collision. 36 static const int CONNECT_COLLISION = 0x0006; 37 38 static const int L2CAP_SEND_CONFIG_REQ = 0x01; 39 static const int L2CAP_RECV_CONFIG_RSP = 0x02; 40 static const int L2CAP_RECV_CONFIG_REQ = 0x04; 41 static const int L2CAP_CONFIG_COMPLETE = (L2CAP_SEND_CONFIG_REQ | L2CAP_RECV_CONFIG_RSP | L2CAP_RECV_CONFIG_REQ); 42 43 static const int L2CAP_CONFIG_FLUSHTTIMEOUT = 0xFFFF; 44 static const int L2CAP_CONFIG_FCS = 0x01; 45 static const int L2CAP_CONFIG_RFC_MODE = 0x03; 46 47 /** 48 * @brief L2cap transport information. 49 */ 50 typedef struct { 51 const RawAddress *addr; 52 uint16_t lpsm; 53 uint16_t rpsm; 54 uint16_t mtu; 55 DataTransportObserver &observer; 56 utility::Dispatcher &dispatcher; 57 } L2capTransportInfo; 58 } // namespace bluetooth 59 } // namespace OHOS 60 #endif // TRANSPORT_DEF_H