Home | History | Annotate | Download | only in health
      1 /*
      2  *
      3  *  BlueZ - Bluetooth protocol stack for Linux
      4  *
      5  *  Copyright (C) 2010 GSyC/LibreSoft, Universidad Rey Juan Carlos.
      6  *  Authors:
      7  *  Santiago Carot Nemesio <sancane at gmail.com>
      8  *  Jose Antonio Santos-Cadenas <santoscadenas at gmail.com>
      9  *
     10  *  This program is free software; you can redistribute it and/or modify
     11  *  it under the terms of the GNU General Public License as published by
     12  *  the Free Software Foundation; either version 2 of the License, or
     13  *  (at your option) any later version.
     14  *
     15  *  This program is distributed in the hope that it will be useful,
     16  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
     17  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     18  *  GNU General Public License for more details.
     19  *
     20  *  You should have received a copy of the GNU General Public License
     21  *  along with this program; if not, write to the Free Software
     22  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
     23  *
     24  */
     25 
     26 #ifndef __HDP_TYPES_H__
     27 #define __HDP_TYPES_H__
     28 
     29 #define HDP_UUID		"00001400-0000-1000-8000-00805F9B34FB"
     30 #define HDP_SOURCE_UUID		"00001401-0000-1000-8000-00805F9B34FB"
     31 #define HDP_SINK_UUID		"00001402-0000-1000-8000-00805F9B34FB"
     32 
     33 #define MANAGER_PATH		"/org/bluez"
     34 
     35 #define HEALTH_MANAGER		"org.bluez.HealthManager"
     36 #define HEALTH_DEVICE		"org.bluez.HealthDevice"
     37 #define HEALTH_CHANNEL		"org.bluez.HealthChannel"
     38 
     39 #define HDP_VERSION		0x0100
     40 
     41 #define HDP_SERVICE_NAME	"Bluez HDP"
     42 #define HDP_SERVICE_DSC		"A Bluez health device profile implementation"
     43 #define HDP_SERVICE_PROVIDER	"Bluez"
     44 
     45 #define HDP_MDEP_ECHO		0x00
     46 #define HDP_MDEP_INITIAL	0x01
     47 #define HDP_MDEP_FINAL		0x7F
     48 
     49 #define HDP_ERROR		g_quark_from_static_string("hdp-error-quark")
     50 
     51 #define HDP_NO_PREFERENCE_DC	0x00
     52 #define HDP_RELIABLE_DC		0x01
     53 #define HDP_STREAMING_DC	0x02
     54 
     55 #define HDP_SINK_ROLE_AS_STRING		"sink"
     56 #define HDP_SOURCE_ROLE_AS_STRING	"source"
     57 
     58 typedef enum {
     59 	HDP_SOURCE = 0x00,
     60 	HDP_SINK = 0x01
     61 } HdpRole;
     62 
     63 typedef enum {
     64 	HDP_DIC_PARSE_ERROR,
     65 	HDP_DIC_ENTRY_PARSE_ERROR,
     66 	HDP_CONNECTION_ERROR,
     67 	HDP_UNSPECIFIED_ERROR,
     68 	HDP_UNKNOWN_ERROR
     69 } HdpError;
     70 
     71 enum data_specs {
     72 	DATA_EXCHANGE_SPEC_11073 = 0x01
     73 };
     74 
     75 struct hdp_application {
     76 	DBusConnection		*conn;		/* For dbus watcher */
     77 	char			*path;		/* The path of the application */
     78 	uint16_t		data_type;	/* Data type handled for this application */
     79 	gboolean		data_type_set;	/* Flag for dictionary parsing */
     80 	uint8_t			role;		/* Role of this application */
     81 	gboolean		role_set;	/* Flag for dictionary parsing */
     82 	uint8_t			chan_type;	/* QoS preferred by source applications */
     83 	gboolean		chan_type_set;	/* Flag for dictionary parsing */
     84 	char			*description;	/* Options description for SDP record */
     85 	uint8_t			id;		/* The identification is also the mdepid */
     86 	char			*oname;		/* Name of the owner application */
     87 	int			dbus_watcher;	/* Watch for clients disconnection */
     88 	gint			ref;		/* Reference counter */
     89 };
     90 
     91 struct hdp_adapter {
     92 	struct btd_adapter	*btd_adapter;	/* Bluetooth adapter */
     93 	struct mcap_instance	*mi;		/* Mcap instance in */
     94 	uint16_t		ccpsm;		/* Control channel psm */
     95 	uint16_t		dcpsm;		/* Data channel psm */
     96 	uint32_t		sdp_handler;	/* SDP record handler */
     97 	uint32_t		record_state;	/* Service record state */
     98 };
     99 
    100 struct hdp_device {
    101 	DBusConnection		*conn;		/* For name listener handling */
    102 	struct btd_device	*dev;		/* Device reference */
    103 	struct hdp_adapter	*hdp_adapter;	/* hdp_adapater */
    104 	struct mcap_mcl		*mcl;		/* The mcap control channel */
    105 	gboolean		mcl_conn;	/* Mcl status */
    106 	gboolean		sdp_present;	/* Has an sdp record */
    107 	GSList			*channels;	/* Data Channel list */
    108 	struct hdp_channel	*ndc;		/* Data channel being negotiated */
    109 	struct hdp_channel	*fr;		/* First reliable data channel */
    110 	gint			ref;		/* Reference counting */
    111 };
    112 
    113 struct hdp_echo_data;
    114 
    115 struct hdp_channel {
    116 	struct hdp_device	*dev;		/* Device where this channel belongs */
    117 	struct hdp_application	*app;		/* Application */
    118 	struct mcap_mdl		*mdl;		/* The data channel reference */
    119 	char			*path;		/* The path of the channel */
    120 	uint8_t			config;		/* Channel configuration */
    121 	uint8_t			mdep;		/* Remote MDEP */
    122 	uint16_t		mdlid;		/* Data channel Id */
    123 	uint16_t		imtu;		/* Channel incoming MTU */
    124 	uint16_t		omtu;		/* Channel outgoing MTU */
    125 	struct hdp_echo_data	*edata;		/* private data used by echo channels */
    126 	gint			ref;		/* Reference counter */
    127 };
    128 
    129 #endif /* __HDP_TYPES_H__ */
    130