summaryrefslogtreecommitdiffstats
path: root/include/bluez-glib.h
blob: 25abecb906fea7b857fd4ff139eccd06b5566d74 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
/*
 * Copyright 2021 Konsulko Group
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef BLUEZ_GLIB_H
#define BLUEZ_GLIB_H

#include <glib.h>

#ifdef __cplusplus
extern "C"
{
#endif

typedef enum {
	BLUEZ_LOG_LEVEL_ERROR,
	BLUEZ_LOG_LEVEL_WARNING,
	BLUEZ_LOG_LEVEL_INFO,
	BLUEZ_LOG_LEVEL_DEBUG
} bluez_log_level_t;

// Hook to allow users to override the default level
#ifndef BLUEZ_LOG_LEVEL_DEFAULT
#define BLUEZ_LOG_LEVEL_DEFAULT BLUEZ_LOG_LEVEL_ERROR
#endif

typedef enum {
	BLUEZ_EVENT_ADD,
	BLUEZ_EVENT_REMOVE,
	BLUEZ_EVENT_CHANGE
} bluez_event_t;

typedef enum {
	BLUEZ_AGENT_EVENT_REQUEST_CONFIRMATION,
	BLUEZ_AGENT_EVENT_AUTHORIZE_SERVICE,
	BLUEZ_AGENT_EVENT_CANCELLED_PAIRING
} bluez_agent_event_t;

typedef enum {
	BLUEZ_MEDIA_CONTROL_CONNECT,
	BLUEZ_MEDIA_CONTROL_DISCONNECT,
	BLUEZ_MEDIA_CONTROL_PLAY,
	BLUEZ_MEDIA_CONTROL_PAUSE,
	BLUEZ_MEDIA_CONTROL_STOP,
	BLUEZ_MEDIA_CONTROL_NEXT,
	BLUEZ_MEDIA_CONTROL_PREVIOUS,
	BLUEZ_MEDIA_CONTROL_FASTFORWARD,
	BLUEZ_MEDIA_CONTROL_REWIND
} bluez_media_control_t;

typedef void (*bluez_init_cb_t)(gchar *adapter, gboolean status, gpointer user_data);

typedef void (*bluez_adapter_event_cb_t)(gchar *adapter,
					 bluez_event_t event,
					 GVariant *properties,
					 gpointer user_data);

typedef void (*bluez_device_event_cb_t)(gchar *adapter,
					gchar *device,
					bluez_event_t event,
					GVariant *properties,
					gpointer user_data);

typedef void (*bluez_media_control_event_cb_t)(gchar *adapter,
					       gchar *device,
					       gchar *endpoint,
					       bluez_event_t event,
					       GVariant *properties,
					       gpointer user_data);

typedef void (*bluez_media_player_event_cb_t)(gchar *adapter,
					      gchar *device,
					      gchar *player,
					      bluez_event_t event,
					      GVariant *properties,
					      gpointer user_data);

typedef void (*bluez_agent_event_cb_t)(gchar *device,
				       bluez_agent_event_t event,
				       GVariant *properties,
				       gpointer user_data);

typedef void (*bluez_device_connect_cb_t)(gchar *device, gboolean status, gpointer user_data);

typedef void (*bluez_device_pair_cb_t)(gchar *device, gboolean status, gpointer user_data);

void bluez_add_adapter_event_callback(bluez_adapter_event_cb_t cb, gpointer user_data);

void bluez_add_device_event_callback(bluez_device_event_cb_t cb, gpointer user_data);

void bluez_add_media_control_event_callback(bluez_media_control_event_cb_t cb, gpointer user_data);

void bluez_add_media_player_event_callback(bluez_media_player_event_cb_t cb, gpointer user_data);

void bluez_add_agent_event_callback(bluez_agent_event_cb_t cb, gpointer user_data);

void bluez_set_log_level(bluez_log_level_t level);

gboolean bluez_init(gboolean register_agent,
		    gboolean autoconnect,
		    bluez_init_cb_t cb,
		    gpointer user_data);

char *bluez_get_default_adapter(void);

gboolean bluez_set_default_adapter(const char *adapter, char **adapter_new);

gboolean bluez_get_managed_objects(GVariant **reply);

gboolean bluez_get_adapters(GArray **reply);

gboolean bluez_adapter_get_state(const char *adapter, GVariant **reply);

gboolean bluez_adapter_get_devices(const char *adapter, GVariant **reply);

gboolean bluez_adapter_set_discovery(const char *adapter, gboolean scan);

gboolean bluez_adapter_set_discovery_filter(const char *adapter, gchar **uuids, gchar *transport);

gboolean bluez_adapter_set_discoverable(const char *adapter, gboolean discoverable);

gboolean bluez_adapter_set_powered(const char *adapter, gboolean powered);

gboolean bluez_device_connect(const char *device,
			      const char *uuid,
			      bluez_device_connect_cb_t cb,
			      gpointer user_data);

gboolean bluez_device_disconnect(const char *device, const char *uuid);

gboolean bluez_device_pair(const char *device,
			   bluez_device_pair_cb_t cb,
			   gpointer user_data);

gboolean bluez_cancel_pairing(void);

gboolean bluez_confirm_pairing(const char *pincode_str);

gboolean bluez_device_remove(const char *device);

gboolean bluez_device_avrcp_controls(const char *device, bluez_media_control_t action);

gboolean bluez_set_pincode(const char *pincode);

#ifdef __cplusplus
} // extern "C"
#endif

#endif /* BLUEZ_GLIB_H */