Soletta™ Framework
Framework for making IoT devices

Full online documentation | C API Index
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
sol-gatt.h
Go to the documentation of this file.
1 /*
2  * This file is part of the Soletta (TM) Project
3  *
4  * Copyright (C) 2016 Intel Corporation. All rights reserved.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */
18 
19 #pragma once
20 
21 #include <sol-bluetooth.h>
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
61 };
62 
99 };
100 
123 };
124 
134 struct sol_gatt_pending;
136 
145  const struct sol_gatt_pending *op);
146 
150 typedef struct sol_gatt_attr {
153  uint16_t flags;
158  int (*read)(struct sol_gatt_pending *op,
159  uint16_t offset);
172  int (*write)(struct sol_gatt_pending *op,
173  struct sol_buffer *buf,
174  uint16_t offset);
175 
176  void *user_data;
177 
178  void *_priv;
179 } sol_gatt_attr;
180 
195  int error,
196  struct sol_buffer *buf);
197 
203 #define SOL_GATT_SERVICE_UUID_16(service_uuid) \
204  { .type = SOL_GATT_ATTR_TYPE_SERVICE, \
205  .uuid = { .type = SOL_BT_UUID_TYPE_16, \
206  .val16 = (service_uuid) } }
207 
213 #define SOL_GATT_CHARACTERISTIC_UUID_16(_uuid, _flags, ...) \
214  { .type = SOL_GATT_ATTR_TYPE_CHARACTERISTIC, \
215  .uuid = { .type = SOL_BT_UUID_TYPE_16, \
216  .val16 = (_uuid) }, \
217  .flags = (_flags), \
218  __VA_ARGS__ }
219 
225 #define SOL_GATT_DESCRIPTOR_UUID_16(_uuid, _flags, ...) \
226  { .type = SOL_GATT_ATTR_TYPE_DESCRIPTOR, \
227  .uuid = { .type = SOL_BT_UUID_TYPE_16, \
228  .val16 = (_uuid) }, \
229  .flags = (_flags), \
230  __VA_ARGS__ }
231 
237 #define SOL_GATT_ATTR_INVALID { .type = SOL_GATT_ATTR_TYPE_INVALID }
238 
247 
256 
270 int sol_gatt_read_attr(struct sol_bt_conn *conn, struct sol_gatt_attr *attr,
271  void (*cb)(void *user_data, bool success,
272  const struct sol_gatt_attr *attr,
273  const struct sol_buffer *buf),
274  const void *user_data);
275 
290 int sol_gatt_write_attr(struct sol_bt_conn *conn, struct sol_gatt_attr *attr,
291  struct sol_buffer *buf,
292  void (*cb)(void *user_data, bool success,
293  const struct sol_gatt_attr *attr),
294  const void *user_data);
295 
314 int sol_gatt_discover(struct sol_bt_conn *conn, enum sol_gatt_attr_type type,
315  const struct sol_gatt_attr *parent,
316  const struct sol_bt_uuid *uuid,
317  bool (*cb)(void *user_data, struct sol_bt_conn *conn,
318  const struct sol_gatt_attr *attr),
319  const void *user_data);
320 
335 int sol_gatt_subscribe(struct sol_bt_conn *conn, const struct sol_gatt_attr *attr,
336  bool (*cb)(void *user_data, const struct sol_gatt_attr *attr,
337  const struct sol_buffer *buffer),
338  const void *user_data);
339 
348 int sol_gatt_unsubscribe(bool (*cb)(void *user_data, const struct sol_gatt_attr *attr,
349  const struct sol_buffer *buffer),
350  const void *user_data);
351 
365 int sol_gatt_indicate(struct sol_bt_conn *conn, const struct sol_gatt_attr *attr);
366 
380 int sol_gatt_notify(struct sol_bt_conn *conn, const struct sol_gatt_attr *attr);
381 
386 #ifdef __cplusplus
387 }
388 #endif
struct sol_http_client_connection * pending
Definition: download.c:29
enum sol_gatt_attr_type type
Definition: sol-gatt.h:152
uint16_t flags
Definition: sol-gatt.h:153
int sol_gatt_indicate(struct sol_bt_conn *conn, const struct sol_gatt_attr *attr)
Sends an indication to the device represented by conn.
sol_gatt_attr_type
Set of types of Attributes.
Definition: sol-gatt.h:56
const struct sol_gatt_attr * sol_gatt_pending_get_attr(const struct sol_gatt_pending *op)
Returns the attribute referenced by a pending operation.
Definition: sol-gatt.h:59
Allows notifications for the characteristic value.
Definition: sol-gatt.h:78
int sol_gatt_pending_reply(struct sol_gatt_pending *pending, int error, struct sol_buffer *buf)
Returns a response to an asynchronous operation.
Only allows encrypted and authenticated write operations against the characteristic value...
Definition: sol-gatt.h:98
Representation of a Bluetooth UUID.
Definition: sol-bluetooth.h:77
Allows write operation against the descriptors associated with this characteristic.
Definition: sol-gatt.h:86
Routines to handle common Bluetooth communications.
Definition: sol-gatt.h:58
Allows the descriptor value to be read.
Definition: sol-gatt.h:106
struct sol_bt_conn sol_bt_conn
Represents an active connection to a Bluetooth device.
Definition: sol-bluetooth.h:128
Only allows encrypted and authenticated write operations against the descriptor value.
Definition: sol-gatt.h:122
struct sol_bt_uuid uuid
Definition: sol-gatt.h:151
int(* read)(struct sol_gatt_pending *op, uint16_t offset)
The response for this operation will be returned by calling sol_gatt_pending_reply() passing a valid ...
Definition: sol-gatt.h:158
int sol_gatt_notify(struct sol_bt_conn *conn, const struct sol_gatt_attr *attr)
Sends a notificatiion to the device represented by conn.
int sol_gatt_register_attributes(struct sol_gatt_attr *attrs)
Registers attributes into the GATT database.
Allows the characteristic value to be read.
Definition: sol-gatt.h:72
int sol_gatt_read_attr(struct sol_bt_conn *conn, struct sol_gatt_attr *attr, void(*cb)(void *user_data, bool success, const struct sol_gatt_attr *attr, const struct sol_buffer *buf), const void *user_data)
Reads the value from a attribute.
int sol_gatt_write_attr(struct sol_bt_conn *conn, struct sol_gatt_attr *attr, struct sol_buffer *buf, void(*cb)(void *user_data, bool success, const struct sol_gatt_attr *attr), const void *user_data)
Writes the value to a attribute.
int sol_gatt_subscribe(struct sol_bt_conn *conn, const struct sol_gatt_attr *attr, bool(*cb)(void *user_data, const struct sol_gatt_attr *attr, const struct sol_buffer *buffer), const void *user_data)
Registers a callback to be called when a notification/indication is received.
Only allows encrypted read operations against the descriptor value.
Definition: sol-gatt.h:110
Only allows encrypted read operations against the characteristic value.
Definition: sol-gatt.h:88
Definition: sol-gatt.h:57
Allows the characteristic value to be written.
Definition: sol-gatt.h:76
void * _priv
Definition: sol-gatt.h:178
int sol_gatt_unregister_attributes(struct sol_gatt_attr *attrs)
Unregisters attributes from the GATT database.
Allows the reliable write procedure against the characteristic value.
Definition: sol-gatt.h:84
int sol_gatt_unsubscribe(bool(*cb)(void *user_data, const struct sol_gatt_attr *attr, const struct sol_buffer *buffer), const void *user_data)
Unregisters from receiving notifications indications.
Representation of a GATT Attribute.
Definition: sol-gatt.h:150
static struct sol_gatt_attr attrs[]
Definition: heartbeat.c:57
int(* write)(struct sol_gatt_pending *op, struct sol_buffer *buf, uint16_t offset)
The response for this operation will be returned by calling sol_gatt_pending_reply(), the buf parameter will be ignored.
Definition: sol-gatt.h:172
Allows the descriptor value to be written.
Definition: sol-gatt.h:108
struct sol_gatt_pending sol_gatt_pending
Represents a pending request.
Definition: sol-gatt.h:135
Only allows encrypted and authenticated read operations against the characteristic value...
Definition: sol-gatt.h:94
sol_gatt_chr_flags
Set of flags for Charateristic attributes.
Definition: sol-gatt.h:68
Allows the write without response procedure against the characteristic value.
Definition: sol-gatt.h:74
int sol_gatt_discover(struct sol_bt_conn *conn, enum sol_gatt_attr_type type, const struct sol_gatt_attr *parent, const struct sol_bt_uuid *uuid, bool(*cb)(void *user_data, struct sol_bt_conn *conn, const struct sol_gatt_attr *attr), const void *user_data)
Discover attributes by type, restricted by UUID and parent attribute.
Allows the authenticated signed write procedure against the characteristic value. ...
Definition: sol-gatt.h:82
Only allows encrypted write operations against the descriptor value.
Definition: sol-gatt.h:112
Allows indications for the characteristic value.
Definition: sol-gatt.h:80
Only allows encrypted and authenticated read operations against the descriptor value.
Definition: sol-gatt.h:117
struct sol_gatt_attr sol_gatt_attr
Representation of a GATT Attribute.
Definition: sol-gatt.h:60
A sol_buffer is a dynamic array, that can be resized if needed.
Definition: sol-buffer.h:130
Only allows encrypted write operations against the characteristic value.
Definition: sol-gatt.h:90
When set allows the characteristic value to be broadcast.
Definition: sol-gatt.h:70
sol_gatt_desc_flags
Set of flags for Descriptor attributes.
Definition: sol-gatt.h:104
void * user_data
Definition: sol-gatt.h:176