tizen 2.3.1 release
[framework/connectivity/bluez.git] / attrib / gattrib.h
1 /*
2  *
3  *  BlueZ - Bluetooth protocol stack for Linux
4  *
5  *  Copyright (C) 2010  Nokia Corporation
6  *  Copyright (C) 2010  Marcel Holtmann <marcel@holtmann.org>
7  *
8  *
9  *  This program is free software; you can redistribute it and/or modify
10  *  it under the terms of the GNU General Public License as published by
11  *  the Free Software Foundation; either version 2 of the License, or
12  *  (at your option) any later version.
13  *
14  *  This program is distributed in the hope that it will be useful,
15  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  *  GNU General Public License for more details.
18  *
19  *  You should have received a copy of the GNU General Public License
20  *  along with this program; if not, write to the Free Software
21  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
22  *
23  */
24 #ifndef __GATTRIB_H
25 #define __GATTRIB_H
26
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30
31 #define GATTRIB_ALL_REQS 0xFE
32 #define GATTRIB_ALL_HANDLES 0x0000
33
34 struct bt_att;  /* Forward declaration for compatibility */
35 struct _GAttrib;
36 typedef struct _GAttrib GAttrib;
37
38 typedef void (*GAttribResultFunc) (guint8 status, const guint8 *pdu,
39                                         guint16 len, gpointer user_data);
40 typedef void (*GAttribDisconnectFunc)(gpointer user_data);
41 typedef void (*GAttribDebugFunc)(const char *str, gpointer user_data);
42 typedef void (*GAttribNotifyFunc)(const guint8 *pdu, guint16 len,
43                                                         gpointer user_data);
44
45 GAttrib *g_attrib_new(GIOChannel *io, guint16 mtu);
46 GAttrib *g_attrib_ref(GAttrib *attrib);
47 void g_attrib_unref(GAttrib *attrib);
48
49 GIOChannel *g_attrib_get_channel(GAttrib *attrib);
50
51 #ifdef __TIZEN_PATCH__
52 void g_attrib_channel_unref(GAttrib *attrib);
53 struct bt_att *g_attrib_get_att(GAttrib *attrib);
54 #endif
55
56 gboolean g_attrib_set_destroy_function(GAttrib *attrib,
57                 GDestroyNotify destroy, gpointer user_data);
58
59 guint g_attrib_send(GAttrib *attrib, guint id, const guint8 *pdu, guint16 len,
60                         GAttribResultFunc func, gpointer user_data,
61                         GDestroyNotify notify);
62
63 gboolean g_attrib_cancel(GAttrib *attrib, guint id);
64 gboolean g_attrib_cancel_all(GAttrib *attrib);
65
66 guint g_attrib_register(GAttrib *attrib, guint8 opcode, guint16 handle,
67                                 GAttribNotifyFunc func, gpointer user_data,
68                                 GDestroyNotify notify);
69
70 uint8_t *g_attrib_get_buffer(GAttrib *attrib, size_t *len);
71 gboolean g_attrib_set_mtu(GAttrib *attrib, int mtu);
72
73 gboolean g_attrib_unregister(GAttrib *attrib, guint id);
74 gboolean g_attrib_unregister_all(GAttrib *attrib);
75
76 #ifdef __cplusplus
77 }
78 #endif
79 #endif