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 /**
17  * @addtogroup Bluetooth
18  * @{
19  *
20  * @brief Defines a bluetooth system that provides basic blurtooth connection and profile functions,
21  *        including A2DP, AVRCP, BLE, GATT, HFP, MAP, PBAP, and SPP, etc.
22  *
23  * @since 6
24  */
25 
26 /**
27  * @file bluetooth_socket_outputstream.h
28  *
29  * @brief Declares spp inputstream framework functions, including basic functions.
30  *
31  * @since 6
32  */
33 
34 #ifndef BLUETOOTH_OUTPUTSTREAM_H
35 #define BLUETOOTH_OUTPUTSTREAM_H
36 
37 #include "bluetooth_def.h"
38 #include "bluetooth_types.h"
39 
40 namespace OHOS {
41 namespace Bluetooth {
42 /**
43  * @brief Class for spp output stream functions.
44  *
45  * @since 6
46  */
47 class BLUETOOTH_API OutputStream {
48 public:
49     /**
50      * @brief A constructor used to create an OutputStream instance.
51      *
52      * @param socketFd Socket fd.
53      * @since 6
54      */
55     explicit OutputStream(int socketFd);
56 
57     /**
58      * @brief Destroy the OutputStream object.
59      *
60      * @since 6
61      */
62     virtual ~OutputStream();
63 
64     /**
65      * @brief Socket write.
66      *
67      * @param buf Data to be written.
68      * @param length The length of data to be written.
69      * @return Returns <b> >0 </b> operation succeeded.The return value is length of the written data.
70      *         Returns <b> 0 </b> operation succeeded,but the data length is 0.
71      *         Returns <b> -1 </b> operation failed.
72      * @since 6
73      */
74     int Write(const uint8_t *buf, size_t length);
75 
76 private:
77     int socketFd_;
78     OutputStream() = delete;
79 };
80 } // namespace Bluetooth
81 } // namespace OHOS
82 #endif  // BLUETOOTH_OUTPUTSTREAM_H