Providing build option to disable BLE server
[platform/upstream/iotivity.git] / resource / csdk / connectivity / src / bt_le_adapter / linux / recv.h
1 /******************************************************************
2  *
3  * Copyright 2015 Intel Corporation All Rights Reserved.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  ******************************************************************/
18
19 #ifndef CA_BLE_LINUX_RECV_H
20 #define CA_BLE_LINUX_RECV_H
21
22 #include "context.h"
23
24 #include "caleinterface.h"
25
26 #include <stdint.h>
27 #include <stdlib.h>
28
29
30 /**
31  * Information used to keep track of received data fragments.
32  */
33 typedef struct _CAGattRecvInfo
34 {
35
36     /**
37      * @name Peer Connection-specific Fields
38      *
39      * These fields are valid only as long as the peer is connected.
40      */
41     //@{
42     /// Peer address.
43     char * peer;
44
45     /// Callback invoked upon receiving all data from GATT peer.
46     CABLEDataReceivedCallback on_packet_received;
47
48     /**
49      * Context object containing lock used for synchronized access to
50      * the @c on_packet_received callback since that callback is actually
51      * owned by it.
52      */
53     CALEContext * context;
54     //@}
55
56 } CAGattRecvInfo;
57
58 /**
59  * Initialize a @c CAGattRecvInfo object.
60  *
61  * @param[in] info Pointer to @c CAGattRecvInfo object being
62  *                 initialized.  No memory is allocated by this
63  *                 function.  The caller is responsible for
64  *                 instantiating the object prior to calling this
65  *                 function.
66  */
67 void CAGattRecvInfoInitialize(CAGattRecvInfo * info);
68
69 /**
70  * Destroy a @c CAGattRecvInfo object.
71  *
72  * Destruction of @a info involves deallocating and clearing out all
73  * fields, as necessary.
74  *
75  * @param[in] info Pointer to @c CAGattRecvInfo object being
76  *                 destroyed.  Only the @a info fields are finalized.
77  *                 Memory of @a info itself is retained by the
78  *                 caller.
79  */
80 void CAGattRecvInfoDestroy(CAGattRecvInfo * info);
81
82 /**
83  * Handle data received from GATT a peer.
84  *
85  * @param[in] info        Information required to complete the receive
86  *                        operation.
87  * @param[in] data        Octet array containing received data
88  *                        fragment.
89  * @param[in] length      Length of the @a data array.
90  *
91  * @return @c true on success, @c false otherwise.
92  */
93 bool CAGattRecv(CAGattRecvInfo * info,
94                 uint8_t const * data,
95                 uint32_t length);
96
97
98 #endif  /* CA_BLE_LINUX_RECV_H */