1 /******************************************************************
3 * Copyright 2015 Intel Corporation All Rights Reserved.
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
9 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 ******************************************************************/
19 #ifndef CA_BLE_LINUX_SERVICE_H
20 #define CA_BLE_LINUX_SERVICE_H
22 #include "bluez-glue.h"
23 #include "object_manager-glue.h"
24 #include "characteristic.h"
28 * GATT Service Information
30 typedef struct CAGattService
32 /// D-Bus object path for the GattService1 object.
36 * OIC GATT service object_manager D-Bus interface skeleton
39 ObjectManager * object_manager;
41 /// OIC GATT service D-Bus interface skeleton object.
42 GattService1 * service;
44 /// OIC GATT request characteristic information.
45 CAGattCharacteristic request_characteristic;
47 /// OIC GATT response characteristic information.
48 CAGattCharacteristic response_characteristic;
51 * org.bluez.GattManager1 object with which the service is
54 GDBusProxy * gatt_manager;
59 * Make the pseudo-address for the peer connected to the service.
61 * @param[in] c Information about GATT service for which the
62 * peer (client) address is being created.
64 * @return @c String containing an encoded address associated with the
65 * peer connected to the peripheral on which the service
66 * implementation resides, or @c NULL on error.
68 char * CAGattServiceMakePeerAddress(CAGattService * s);
71 * Decode @c CAGattService pointer from peer @c address.
73 * @param[in] address String containing a client/peer pseudo-address
74 * corresponding to the GATT service through which
75 * communication is performed.
77 * @return Pointer to ::CAGattService object corresponding to the
80 CAGattService * CAGattServiceDecodeAddress(char const * address);
83 * Initialize GATT service fields.
85 * This function initializes the @c CAGattService object fields.
87 * @param[out] service GATT service information to be initialized.
88 * @param[in] hci_name Name of the bluetooth adapter installed on the
89 * system, e.g. @c "hci0".
90 * @param[in] context Object containing the D-Bus connection to the
91 * bus on which the service will be exported, as
92 * well as an address-to-characteristic map.
94 * @return @c true on success, @c false otherwise.
96 * @note This function does not allocate the @a service object
97 * itself. The caller is responsible for allocating that
100 bool CAGattServiceInitialize(CAGattService * service,
101 char const * hci_name,
102 CALEContext * context);
105 * Destroy GATT service fields.
107 * This function finalizes the @c CAGattService object fields.
109 * @param[in] service GATT service information to be finalized.
111 * @note This function does not deallocate the @a service object
112 * itself. The caller is responsible for deallocating that
115 void CAGattServiceDestroy(CAGattService * service);
117 #endif // CA_BLE_LINUX_SERVICE_H