1 // Copyright 2020 Google LLC
2 //
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 //     https://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 #ifndef CORE_INTERNAL_BLUETOOTH_ENDPOINT_CHANNEL_H_
16 #define CORE_INTERNAL_BLUETOOTH_ENDPOINT_CHANNEL_H_
17 
18 #include <string>
19 
20 #include "core/internal/base_endpoint_channel.h"
21 #include "platform/public/bluetooth_classic.h"
22 #include "proto/connections_enums.pb.h"
23 
24 namespace location {
25 namespace nearby {
26 namespace connections {
27 
28 class BluetoothEndpointChannel final : public BaseEndpointChannel {
29  public:
30   // Creates both outgoing and incoming BT channels.
31   BluetoothEndpointChannel(const std::string& channel_name,
32                            BluetoothSocket bluetooth_socket);
33 
34   proto::connections::Medium GetMedium() const override;
35 
36   int GetMaxTransmitPacketSize() const override;
37 
38  private:
39   static constexpr int kDefaultBTMaxTransmitPacketSize = 1980;  // 990 * 2 Bytes
40 
41   void CloseImpl() override;
42 
43   BluetoothSocket bluetooth_socket_;
44 };
45 
46 }  // namespace connections
47 }  // namespace nearby
48 }  // namespace location
49 
50 #endif  // CORE_INTERNAL_BLUETOOTH_ENDPOINT_CHANNEL_H_
51