Imported Upstream version 1.0.0
[platform/upstream/iotivity.git] / resource / csdk / connectivity / src / bt_le_adapter / linux / service.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_SERVICE_H
20 #define CA_BLE_LINUX_SERVICE_H
21
22 #include "bluez-glue.h"
23 #include "object_manager-glue.h"
24 #include "characteristic.h"
25
26
27 /**
28  * GATT Service Information
29  */
30 typedef struct CAGattService
31 {
32     /// D-Bus object path for the GattService1 object.
33     char * object_path;
34
35     /**
36      * OIC GATT service object_manager D-Bus interface skeleton
37      * object.
38      */
39     ObjectManager * object_manager;
40
41     /// OIC GATT service D-Bus interface skeleton object.
42     GattService1 * service;
43
44     /// OIC GATT request characteristic information.
45     CAGattCharacteristic request_characteristic;
46
47     /// OIC GATT response characteristic information.
48     CAGattCharacteristic response_characteristic;
49
50     /**
51      * org.bluez.GattManager1 object with which the service is
52      * registered.
53      */
54     GDBusProxy * gatt_manager;
55
56 } CAGattService;
57
58 /**
59  * Initialize GATT service fields.
60  *
61  * This function initializes the @c CAGattService object fields.
62  *
63  * @param[out] service  GATT service information to be initialized.
64  * @param[in]  context  Object containing the D-Bus connection to the
65  *                      bus on which the service will be exported.
66  * @param[in]  hci_name Name of the bluetooth adapter installed on the
67  *                      system, e.g. @c "hci0".
68  *
69  * @return @c true on success, @c false otherwise.
70  *
71  * @note This function does not allocate the @a service object
72  *       itself.  The caller is responsible for allocating that
73  *       memory.
74  */
75 bool CAGattServiceInitialize(CAGattService * service,
76                              CALEContext * context,
77                              char const * hci_name);
78
79 /**
80  * Destroy GATT service fields.
81  *
82  * This function finalizes the @c CAGattService object fields.
83  *
84  * @param[in] service GATT service information to be finalized.
85  *
86  * @note This function does not deallocate the @a service object
87  *       itself.  The caller is responsible for deallocating that
88  *       memory.
89  */
90 void CAGattServiceDestroy(CAGattService * service);
91
92
93 #endif  // CA_BLE_LINUX_SERVICE_H