-
Notifications
You must be signed in to change notification settings - Fork 0
/
BluetoothServer.h
63 lines (50 loc) · 2.26 KB
/
BluetoothServer.h
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
#ifndef BLUETOOTH_SERVER_H
#define BLUETOOTH_SERVER_H
#include <gio/gio.h>
#include <string>
class BluetoothServer {
public:
BluetoothServer();
~BluetoothServer();
void init();
void makeDiscoverable();
void makePairable();
void setAlias(const std::string& alias);
void registerAgent();
void powerOnAdapter();
void startAdvertising();
private:
GDBusConnection* connection;
guint registration_id; // Keep track of the registration ID for cleanup
static GDBusNodeInfo *introspection_data;
static GDBusInterfaceVTable interface_vtable;
static void onMethodCall(GDBusConnection* connection,
const gchar* sender,
const gchar* object_path,
const gchar* interface_name,
const gchar* method_name,
GVariant* parameters,
GDBusMethodInvocation* invocation,
gpointer user_data);
static GVariant* onGetProperty(GDBusConnection* connection,
const gchar* sender,
const gchar* object_path,
const gchar* interface_name,
const gchar* property_name,
GError** error,
gpointer user_data);
static gboolean onSetProperty(GDBusConnection* connection,
const gchar* sender,
const gchar* object_path,
const gchar* interface_name,
const gchar* property_name,
GVariant* value,
GError** error,
gpointer user_data);
void handleRequestPinCode(GDBusMethodInvocation* invocation, GVariant* parameters);
void handleRequestPasskey(GDBusMethodInvocation* invocation, GVariant* parameters);
void handleRequestConfirmation(GDBusMethodInvocation* invocation, GVariant* parameters);
int bluezAdapterSetProperty(const char *prop, GVariant *value);
int bluezAgentCallMethod(const gchar *method, GVariant *param);
};
#endif // BLUETOOTH_SERVER_H