[go: nahoru, domu]

blob: 3c9fbf5b4b6fb1403b0266a3b9ad2f8128e14fba [file] [log] [blame]
Avi Drissman0db84842022-09-13 19:47:041// Copyright 2014 The Chromium Authors
isherman@chromium.org8696f572014-06-12 12:59:202// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef DEVICE_BLUETOOTH_BLUETOOTH_RFCOMM_CHANNEL_MAC_H_
6#define DEVICE_BLUETOOTH_BLUETOOTH_RFCOMM_CHANNEL_MAC_H_
7
8#import <IOBluetooth/IOBluetooth.h>
9#import <IOKit/IOReturn.h>
avi176e2692015-12-22 19:26:5210#include <stddef.h>
11#include <stdint.h>
isherman@chromium.org8696f572014-06-12 12:59:2012
thakis08c9d69b02016-04-11 04:37:2513#include <memory>
14
isherman@chromium.org8696f572014-06-12 12:59:2015#include "device/bluetooth/bluetooth_channel_mac.h"
16
17@class BluetoothRfcommChannelDelegate;
18
19namespace device {
20
21class BluetoothRfcommChannelMac : public BluetoothChannelMac {
22 public:
23 // Creates a new RFCOMM channel wrapper with the given |socket| and native
24 // |channel|.
isherman@chromium.org8696f572014-06-12 12:59:2025 BluetoothRfcommChannelMac(BluetoothSocketMac* socket,
26 IOBluetoothRFCOMMChannel* channel);
Peter Boströmec0e7662021-09-23 21:20:5727
28 BluetoothRfcommChannelMac(const BluetoothRfcommChannelMac&) = delete;
29 BluetoothRfcommChannelMac& operator=(const BluetoothRfcommChannelMac&) =
30 delete;
31
dchengb5aaf402014-10-22 23:07:5232 ~BluetoothRfcommChannelMac() override;
isherman@chromium.org8696f572014-06-12 12:59:2033
34 // Opens a new RFCOMM channel with Channel ID |channel_id| to the target
35 // |device|. Returns the opened channel and sets |status| to kIOReturnSuccess
36 // if the open process was successfully started (or if an existing RFCOMM
37 // channel was found). Otherwise, sets |status| to an error status.
thakis08c9d69b02016-04-11 04:37:2538 static std::unique_ptr<BluetoothRfcommChannelMac> OpenAsync(
isherman@chromium.org8696f572014-06-12 12:59:2039 BluetoothSocketMac* socket,
40 IOBluetoothDevice* device,
isherman@chromium.orgedc0de32014-06-14 19:31:4841 BluetoothRFCOMMChannelID channel_id,
isherman@chromium.org8696f572014-06-12 12:59:2042 IOReturn* status);
43
44 // BluetoothChannelMac:
dchengb5aaf402014-10-22 23:07:5245 void SetSocket(BluetoothSocketMac* socket) override;
46 IOBluetoothDevice* GetDevice() override;
47 uint16_t GetOutgoingMTU() override;
48 IOReturn WriteAsync(void* data, uint16_t length, void* refcon) override;
isherman@chromium.org8696f572014-06-12 12:59:2049
50 void OnChannelOpenComplete(IOBluetoothRFCOMMChannel* channel,
51 IOReturn status);
52 void OnChannelClosed(IOBluetoothRFCOMMChannel* channel);
53 void OnChannelDataReceived(IOBluetoothRFCOMMChannel* channel,
54 void* data,
55 size_t length);
56 void OnChannelWriteComplete(IOBluetoothRFCOMMChannel* channel,
57 void* refcon,
58 IOReturn status);
59
60 private:
61 // The wrapped native RFCOMM channel.
Avi Drissman36cfbd8d2023-06-13 19:37:2562 IOBluetoothRFCOMMChannel* __strong channel_;
isherman@chromium.orgedc0de32014-06-14 19:31:4863
64 // The delegate for the native channel.
Avi Drissman36cfbd8d2023-06-13 19:37:2565 BluetoothRfcommChannelDelegate* __strong delegate_;
isherman@chromium.org8696f572014-06-12 12:59:2066};
67
68} // namespace device
69
70#endif // DEVICE_BLUETOOTH_BLUETOOTH_RFCOMM_CHANNEL_MAC_H_