Providing build option to disable BLE server
[platform/upstream/iotivity.git] / resource / csdk / connectivity / src / bt_le_adapter / linux / characteristic.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_CHARACTERISTIC_H
20 #define CA_BLE_LINUX_CHARACTERISTIC_H
21
22 #include "bluez-glue.h"
23 #include "descriptor.h"
24 #include "recv.h"
25 #include "context.h"
26
27
28 /**
29  * OIC GATT Characteristic Information
30  *
31  * OIC GATT characteristics contain one user description descriptor.
32  *
33  * @note The response characteristic should also have a client
34  *       characteristic configuration descriptor.  However, BlueZ
35  *       implicitly adds that descriptor to the characteristic when
36  *       the characteristic "notify" property is set.  There is no
37  *       need to explicitly add that descriptor.
38  */
39 typedef struct CAGattCharacteristic
40 {
41
42     /**
43      * Object containing the D-Bus connection list of connected
44      * devices.
45      */
46     CALEContext * context;
47
48     /**
49      * IoTivity OIC GATT service information.
50      *
51      * @note This is currently only used by the response
52      *       characteristic to gain access to the request
53      *       characteristic @c client endpoint field.
54      *
55      * @todo It seems somewhat wasteful have a field available to both
56      *       response and request characteristics, but used by only
57      *       one of them.
58      */
59     struct CAGattService * service;
60
61     /// D-Bus object path for the GattCharacteristic1 object.
62     char * object_path;
63
64     /// OIC GATT service D-Bus interface skeleton object.
65     GattCharacteristic1 * characteristic;
66
67     /// OIC GATT user description descriptor information.
68     CAGattDescriptor descriptor;
69
70     /**
71      * Information used to keep track of received data fragments.
72      *
73      * @note This is only used by the OIC GATT request characteristic
74      *       skeleton implementation.  It is not needed by the
75      *       response characteristic skeleton.
76      *
77      * @todo It seems somewhat wasteful have a field available to both
78      *       response and request characteristics, but used by only
79      *       one of them.
80      */
81     CAGattRecvInfo recv_info;
82
83 } CAGattCharacteristic;
84
85 /**
86  * Initialize GATT request characteristic fields.
87  *
88  * This function initializes the request @c CAGattCharacteristic
89  * object fields.
90  *
91  * @param[in,out] s       Information about GATT service to which the
92  *                        characteristic belongs.
93  * @param[in]     context Object containing the D-Bus connection to
94  *                        the bus on which the characteristic will be
95  *                        exported, as well as the list of connected
96  *                        devices.
97  *
98  * @return @c true on success, @c false otherwise.
99  */
100 bool CAGattRequestCharacteristicInitialize(struct CAGattService * s,
101                                            CALEContext * context);
102
103 /**
104  * Initialize GATT response characteristic fields.
105  *
106  * This function initializes the response @c CAGattCharacteristic
107  * object fields.
108  *
109  * @param[in,out] s        Information about GATT service to which the
110  *                         characteristic belongs.
111  * @param[in]     context  Object containing the D-Bus connection to
112  *                         the bus on which the characteristic will be
113  *                         exported, as well as the list of connected
114  *                         devices.
115  *
116  * @return @c true on success, @c false otherwise.
117  */
118 bool CAGattResponseCharacteristicInitialize(struct CAGattService * s,
119                                             CALEContext * context);
120
121 /**
122  * Destroy GATT characteristic fields.
123  *
124  * This function finalizes the @c CAGattCharacteristic object fields.
125  *
126  * @param[in] characteristic GATT characteristic information to be
127  *                           finalized.
128  */
129 void CAGattCharacteristicDestroy(CAGattCharacteristic * characteristic);
130
131 /**
132  * Get all characteristic properties.
133  *
134  * @param[in] characteristic The D-Bus skeleton object from which the
135  *                           characteristic properties will be extracted.
136  * @return A variant of the form a{sa{sv}}, suitable for use in the
137  *         result of the
138  *         @c org.freedesktop.DBus.ObjectManager.GetManagedObjects()
139  *         method provided by the IoTivity the
140  *         @c org.bluez.GattService1 implementation.
141  */
142 GVariant * CAGattCharacteristicGetProperties(
143     GattCharacteristic1 * characteristic);
144
145
146 #endif  // CA_BLE_LINUX_CHARACTERISTIC_H