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 ******************************************************************/
28 static char const TAG[] = "BLE_SERVER";
30 // ---------------------------------------------------------------------
31 // GATT Request Handling
32 // ---------------------------------------------------------------------
33 void CAGattServerHandleRequestData()
37 // ---------------------------------------------------------------------
38 // GATT Response Handling
39 // ---------------------------------------------------------------------
41 * Send response data to the GATT client.
43 * Respone data will be sent to the client through the given response
44 * @a characteristic proxy as a GATT characteristic notification.
46 * @param[in] characteristic The D-Bus proxy for the response
47 * characteristic through which the
48 * notification will be sent.
49 * @param[in] data The byte array to be sent.
50 * @param[in] length The number of elements in the byte
53 static bool CAGattServerSendResponseNotification(
54 GattCharacteristic1 * characteristic,
58 if (!gatt_characteristic1_get_notifying(characteristic))
62 "Attempt to send response with notifications "
64 "Client must enable notifications. "
65 "No response was sent.");
70 GVariant * const value =
71 g_variant_new_fixed_array(G_VARIANT_TYPE_BYTE,
77 * Send the response fragment by setting the "Value" property on
78 * the response characteristic, and emitting the
79 * @c org.freedesktop.Dbus.Properties.PropertiesChanged signal,
82 * @todo Do we need to explicitly emit the @c GObject @c notify or
83 * @c org.freedesktop.Dbus.Properties.PropertiesChanged
86 gatt_characteristic1_set_value(characteristic, value);
91 bool CAGattServerSendResponse(void const * method_info,
95 assert(method_info != NULL);
97 CAGattResponseInfo const * const info = method_info;
99 GattCharacteristic1 * const characteristic =
100 info->characteristic;
102 if (!CAGattServerSendResponseNotification(characteristic,