summaryrefslogtreecommitdiff
path: root/health/hdp_types.h
blob: 7d232931761617aaff342db16d407fe3af92c673 (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
/*
 *
 *  BlueZ - Bluetooth protocol stack for Linux
 *
 *  Copyright (C) 2010 GSyC/LibreSoft, Universidad Rey Juan Carlos.
 *  Authors:
 *  Santiago Carot Nemesio <sancane at gmail.com>
 *  Jose Antonio Santos-Cadenas <santoscadenas at gmail.com>
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 *
 */

#ifndef __HDP_TYPES_H__
#define __HDP_TYPES_H__

#define HDP_UUID		"00001400-0000-1000-8000-00805F9B34FB"
#define HDP_SOURCE_UUID		"00001401-0000-1000-8000-00805F9B34FB"
#define HDP_SINK_UUID		"00001402-0000-1000-8000-00805F9B34FB"

#define MANAGER_PATH		"/org/bluez"

#define HEALTH_MANAGER		"org.bluez.HealthManager"
#define HEALTH_DEVICE		"org.bluez.HealthDevice"
#define HEALTH_CHANNEL		"org.bluez.HealthChannel"

#define HDP_VERSION		0x0100

#define HDP_SERVICE_NAME	"Bluez HDP"
#define HDP_SERVICE_DSC		"A Bluez health device profile implementation"
#define HDP_SERVICE_PROVIDER	"Bluez"

#define HDP_MDEP_ECHO		0x00
#define HDP_MDEP_INITIAL	0x01
#define HDP_MDEP_FINAL		0x7F

#define HDP_ERROR		g_quark_from_static_string("hdp-error-quark")

#define HDP_NO_PREFERENCE_DC	0x00
#define HDP_RELIABLE_DC		0x01
#define HDP_STREAMING_DC	0x02

#define HDP_SINK_ROLE_AS_STRING		"sink"
#define HDP_SOURCE_ROLE_AS_STRING	"source"

typedef enum {
	HDP_SOURCE = 0x00,
	HDP_SINK = 0x01
} HdpRole;

typedef enum {
	HDP_DIC_PARSE_ERROR,
	HDP_DIC_ENTRY_PARSE_ERROR,
	HDP_CONNECTION_ERROR,
	HDP_UNSPECIFIED_ERROR,
	HDP_UNKNOWN_ERROR
} HdpError;

enum data_specs {
	DATA_EXCHANGE_SPEC_11073 = 0x01
};

struct hdp_application {
	DBusConnection		*conn;		/* For dbus watcher */
	char			*path;		/* The path of the application */
	uint16_t		data_type;	/* Data type handled for this application */
	gboolean		data_type_set;	/* Flag for dictionary parsing */
	uint8_t			role;		/* Role of this application */
	gboolean		role_set;	/* Flag for dictionary parsing */
	uint8_t			chan_type;	/* QoS preferred by source applications */
	gboolean		chan_type_set;	/* Flag for dictionary parsing */
	char			*description;	/* Options description for SDP record */
	uint8_t			id;		/* The identification is also the mdepid */
	char			*oname;		/* Name of the owner application */
	int			dbus_watcher;	/* Watch for clients disconnection */
	gint			ref;		/* Reference counter */
};

struct hdp_adapter {
	struct btd_adapter	*btd_adapter;	/* Bluetooth adapter */
	struct mcap_instance	*mi;		/* Mcap instance in */
	uint16_t		ccpsm;		/* Control channel psm */
	uint16_t		dcpsm;		/* Data channel psm */
	uint32_t		sdp_handler;	/* SDP record handler */
	uint32_t		record_state;	/* Service record state */
};

struct hdp_device {
	DBusConnection		*conn;		/* For name listener handling */
	struct btd_device	*dev;		/* Device reference */
	struct hdp_adapter	*hdp_adapter;	/* hdp_adapater */
	struct mcap_mcl		*mcl;		/* The mcap control channel */
	gboolean		mcl_conn;	/* Mcl status */
	gboolean		sdp_present;	/* Has an sdp record */
	GSList			*channels;	/* Data Channel list */
	struct hdp_channel	*ndc;		/* Data channel being negotiated */
	struct hdp_channel	*fr;		/* First reliable data channel */
	gint			ref;		/* Reference counting */
};

struct hdp_echo_data;

struct hdp_channel {
	struct hdp_device	*dev;		/* Device where this channel belongs */
	struct hdp_application	*app;		/* Application */
	struct mcap_mdl		*mdl;		/* The data channel reference */
	char			*path;		/* The path of the channel */
	uint8_t			config;		/* Channel configuration */
	uint8_t			mdep;		/* Remote MDEP */
	uint16_t		mdlid;		/* Data channel Id */
	uint16_t		imtu;		/* Channel incoming MTU */
	uint16_t		omtu;		/* Channel outgoing MTU */
	struct hdp_echo_data	*edata;		/* private data used by echo channels */
	gint			ref;		/* Reference counter */
};

#endif /* __HDP_TYPES_H__ */