diff --git a/profiles/audio/manager.c b/profiles/audio/manager.c
index f9c0ca6..ff4590e 100644
--- a/profiles/audio/manager.c
+++ b/profiles/audio/manager.c
#include "../src/adapter.h"
#include "../src/device.h"
#include "../src/profile.h"
+#include "../src/service.h"
#include "log.h"
#include "device.h"
return NULL;
}
-static void audio_remove(struct btd_profile *p, struct btd_device *device)
+static void audio_remove(struct btd_service *service)
{
+ struct btd_device *device = btd_service_get_device(service);
struct audio_device *dev;
dev = manager_find_device(device);
audio_device_unregister(dev);
}
-static int a2dp_source_probe(struct btd_profile *p, struct btd_device *device)
+static int a2dp_source_probe(struct btd_service *service)
{
+ struct btd_device *device = btd_service_get_device(service);
struct audio_device *audio_dev;
audio_dev = get_audio_dev(device);
return 0;
}
-static int a2dp_sink_probe(struct btd_profile *p, struct btd_device *device)
+static int a2dp_sink_probe(struct btd_service *service)
{
+ struct btd_device *device = btd_service_get_device(service);
struct audio_device *audio_dev;
audio_dev = get_audio_dev(device);
return 0;
}
-static int avrcp_probe(struct btd_profile *p, struct btd_device *device)
+static int avrcp_probe(struct btd_service *service)
{
+ struct btd_device *device = btd_service_get_device(service);
+ struct btd_profile *p = btd_service_get_profile(service);
struct audio_device *audio_dev;
audio_dev = get_audio_dev(device);
diff --git a/profiles/cyclingspeed/cyclingspeed.c b/profiles/cyclingspeed/cyclingspeed.c
index 744bd4b..6080f09 100644
--- a/profiles/cyclingspeed/cyclingspeed.c
+++ b/profiles/cyclingspeed/cyclingspeed.c
#include "adapter.h"
#include "device.h"
#include "profile.h"
+#include "service.h"
#include "dbus-common.h"
#include "error.h"
#include "attrib/gattrib.h"
{ }
};
-static int csc_device_probe(struct btd_profile *p, struct btd_device *device)
+static int csc_device_probe(struct btd_service *service)
{
+ struct btd_device *device = btd_service_get_device(service);
struct btd_adapter *adapter;
struct csc_adapter *cadapter;
struct csc *csc;
return 0;
}
-static void csc_device_remove(struct btd_profile *p,
- struct btd_device *device)
+static void csc_device_remove(struct btd_service *service)
{
+ struct btd_device *device = btd_service_get_device(service);
struct btd_adapter *adapter;
struct csc_adapter *cadapter;
struct csc *csc;
diff --git a/profiles/deviceinfo/deviceinfo.c b/profiles/deviceinfo/deviceinfo.c
index 08f53b3..fc8babd 100644
--- a/profiles/deviceinfo/deviceinfo.c
+++ b/profiles/deviceinfo/deviceinfo.c
#include "adapter.h"
#include "device.h"
#include "profile.h"
+#include "service.h"
#include "attrib/gattrib.h"
#include "attio.h"
#include "attrib/att.h"
deviceinfo_free(d);
}
-static int deviceinfo_driver_probe(struct btd_profile *p,
- struct btd_device *device)
+static int deviceinfo_driver_probe(struct btd_service *service)
{
+ struct btd_device *device = btd_service_get_device(service);
struct gatt_primary *prim;
prim = btd_device_get_primary(device, DEVICE_INFORMATION_UUID);
return deviceinfo_register(device, prim);
}
-static void deviceinfo_driver_remove(struct btd_profile *p,
- struct btd_device *device)
+static void deviceinfo_driver_remove(struct btd_service *service)
{
+ struct btd_device *device = btd_service_get_device(service);
+
deviceinfo_unregister(device);
}
diff --git a/profiles/gatt/gas.c b/profiles/gatt/gas.c
index 4c7af4b..33a680f 100644
--- a/profiles/gatt/gas.c
+++ b/profiles/gatt/gas.c
#include "adapter.h"
#include "device.h"
#include "profile.h"
+#include "service.h"
#include "attrib/att.h"
#include "attrib/gattrib.h"
#include "attio.h"
gas_free(gas);
}
-static int gatt_driver_probe(struct btd_profile *p, struct btd_device *device)
+static int gatt_driver_probe(struct btd_service *service)
{
+ struct btd_device *device = btd_service_get_device(service);
struct gatt_primary *gap, *gatt;
gap = btd_device_get_primary(device, GAP_UUID);
return gas_register(device, &gap->range, &gatt->range);
}
-static void gatt_driver_remove(struct btd_profile *p,
- struct btd_device *device)
+static void gatt_driver_remove(struct btd_service *service)
{
+ struct btd_device *device = btd_service_get_device(service);
+
gas_unregister(device);
}
diff --git a/profiles/health/hdp_manager.c b/profiles/health/hdp_manager.c
index 3777fd4..1bb6007 100644
--- a/profiles/health/hdp_manager.c
+++ b/profiles/health/hdp_manager.c
#include <adapter.h>
#include <device.h>
#include <profile.h>
+#include <service.h>
#include <glib-helper.h>
#include <log.h>
hdp_adapter_unregister(adapter);
}
-static int hdp_driver_probe(struct btd_profile *p, struct btd_device *device)
+static int hdp_driver_probe(struct btd_service *service)
{
+ struct btd_device *device = btd_service_get_device(service);
+
return hdp_device_register(device);
}
-static void hdp_driver_remove(struct btd_profile *p, struct btd_device *device)
+static void hdp_driver_remove(struct btd_service *service)
{
+ struct btd_device *device = btd_service_get_device(service);
+
hdp_device_unregister(device);
}
diff --git a/profiles/heartrate/heartrate.c b/profiles/heartrate/heartrate.c
index 18a9448..3a2d419 100644
--- a/profiles/heartrate/heartrate.c
+++ b/profiles/heartrate/heartrate.c
#include "dbus-common.h"
#include "device.h"
#include "profile.h"
+#include "service.h"
#include "error.h"
#include "attrib/gattrib.h"
#include "attrib/att.h"
heartrate_adapter_unregister(adapter);
}
-static int heartrate_device_probe(struct btd_profile *p,
- struct btd_device *device)
+static int heartrate_device_probe(struct btd_service *service)
{
+ struct btd_device *device = btd_service_get_device(service);
struct gatt_primary *prim;
prim = btd_device_get_primary(device, HEART_RATE_UUID);
return heartrate_device_register(device, prim);
}
-static void heartrate_device_remove(struct btd_profile *p,
- struct btd_device *device)
+static void heartrate_device_remove(struct btd_service *service)
{
+ struct btd_device *device = btd_service_get_device(service);
+
heartrate_device_unregister(device);
}
diff --git a/profiles/input/device.c b/profiles/input/device.c
index ad1d930..741f27c 100644
--- a/profiles/input/device.c
+++ b/profiles/input/device.c
#include "../src/adapter.h"
#include "../src/device.h"
#include "../src/profile.h"
+#include "../src/service.h"
#include "../src/storage.h"
#include "../src/dbus-common.h"
hid_reconnection_mode(reconnect_initiate, normally_connectable);
}
-static struct input_device *input_device_new(struct btd_device *device,
- struct btd_profile *p)
+static struct input_device *input_device_new(struct btd_service *service)
{
+ struct btd_device *device = btd_service_get_device(service);
+ struct btd_profile *p = btd_service_get_profile(service);
const char *path = device_get_path(device);
const sdp_record_t *rec = btd_device_get_record(device, p->remote_uuid);
struct btd_adapter *adapter = device_get_adapter(device);
{ }
};
-int input_device_register(struct btd_profile *p, struct btd_device *device)
+int input_device_register(struct btd_service *service)
{
+ struct btd_device *device = btd_service_get_device(service);
const char *path = device_get_path(device);
struct input_device *idev;
if (idev)
return -EEXIST;
- idev = input_device_new(device, p);
+ idev = input_device_new(service);
if (!idev)
return -EINVAL;
return NULL;
}
-void input_device_unregister(struct btd_profile *p, struct btd_device *device)
+void input_device_unregister(struct btd_service *service)
{
+ struct btd_device *device = btd_service_get_device(service);
const char *path = device_get_path(device);
struct input_device *idev;
diff --git a/profiles/input/device.h b/profiles/input/device.h
index 1c237fc..fd7f847 100644
--- a/profiles/input/device.h
+++ b/profiles/input/device.h
void input_set_idle_timeout(int timeout);
-int input_device_register(struct btd_profile *p, struct btd_device *device);
-void input_device_unregister(struct btd_profile *p, struct btd_device *device);
+int input_device_register(struct btd_service *service);
+void input_device_unregister(struct btd_service *service);
int input_device_set_channel(const bdaddr_t *src, const bdaddr_t *dst, int psm,
GIOChannel *io);
diff --git a/profiles/input/hog.c b/profiles/input/hog.c
index eec0eee..c092875 100644
--- a/profiles/input/hog.c
+++ b/profiles/input/hog.c
#include "src/adapter.h"
#include "src/device.h"
#include "src/profile.h"
+#include "src/service.h"
#include "plugin.h"
#include "suspend.h"
g_slist_foreach(devices, set_suspend, GINT_TO_POINTER(suspend));
}
-static int hog_probe(struct btd_profile *p, struct btd_device *device)
+static int hog_probe(struct btd_service *service)
{
+ struct btd_device *device = btd_service_get_device(service);
const char *path = device_get_path(device);
GSList *primaries, *l;
hog_unregister_device(hogdev);
}
-static void hog_remove(struct btd_profile *p, struct btd_device *device)
+static void hog_remove(struct btd_service *service)
{
+ struct btd_device *device = btd_service_get_device(service);
const char *path = device_get_path(device);
DBG("path %s", path);
diff --git a/profiles/input/manager.c b/profiles/input/manager.c
index 51cd4cf..dc771a6 100644
--- a/profiles/input/manager.c
+++ b/profiles/input/manager.c
#include "../src/adapter.h"
#include "../src/device.h"
#include "../src/profile.h"
+#include "../src/service.h"
#include "device.h"
#include "server.h"
diff --git a/profiles/network/connection.c b/profiles/network/connection.c
index 84359c0..cc7c5ce 100644
--- a/profiles/network/connection.c
+++ b/profiles/network/connection.c
#include "adapter.h"
#include "device.h"
#include "profile.h"
+#include "service.h"
#include "error.h"
#include "common.h"
{ }
};
-void connection_unregister(struct btd_profile *p, struct btd_device *device)
+void connection_unregister(struct btd_service *service)
{
+ struct btd_device *device = btd_service_get_device(service);
+ struct btd_profile *p = btd_service_get_profile(service);
struct network_peer *peer;
uint16_t id = bnep_service_id(p->remote_uuid);
return peer;
}
-int connection_register(struct btd_profile *p, struct btd_device *device)
+int connection_register(struct btd_service *service)
{
+ struct btd_device *device = btd_service_get_device(service);
+ struct btd_profile *p = btd_service_get_profile(service);
struct network_peer *peer;
struct network_conn *nc;
uint16_t id = bnep_service_id(p->remote_uuid);
diff --git a/profiles/network/connection.h b/profiles/network/connection.h
index 5daead0..1e7eedb 100644
--- a/profiles/network/connection.h
+++ b/profiles/network/connection.h
*
*/
-int connection_register(struct btd_profile *p, struct btd_device *device);
-void connection_unregister(struct btd_profile *p, struct btd_device *device);
+int connection_register(struct btd_service *service);
+void connection_unregister(struct btd_service *service);
int connection_connect(struct btd_device *device, uint16_t id);
int connection_disconnect(struct btd_device *device, uint16_t id);
diff --git a/profiles/network/manager.c b/profiles/network/manager.c
index df79351..f37954a 100644
--- a/profiles/network/manager.c
+++ b/profiles/network/manager.c
#include "adapter.h"
#include "device.h"
#include "profile.h"
+#include "service.h"
#include "manager.h"
#include "common.h"
#include "connection.h"
diff --git a/profiles/proximity/manager.c b/profiles/proximity/manager.c
index f24428b..7dab23f 100644
--- a/profiles/proximity/manager.c
+++ b/profiles/proximity/manager.c
#include "adapter.h"
#include "device.h"
#include "profile.h"
+#include "service.h"
#include "attrib/att.h"
#include "attrib/gattrib.h"
#include "attrib/gatt.h"
.findme = TRUE,
};
-static int monitor_linkloss_probe(struct btd_profile *p,
- struct btd_device *device)
+static int monitor_linkloss_probe(struct btd_service *service)
{
+ struct btd_device *device = btd_service_get_device(service);
struct gatt_primary *linkloss;
linkloss = btd_device_get_primary(device, LINK_LOSS_UUID);
return monitor_register_linkloss(device, &enabled, linkloss);
}
-static int monitor_immediate_probe(struct btd_profile *p,
- struct btd_device *device)
+static int monitor_immediate_probe(struct btd_service *service)
{
+ struct btd_device *device = btd_service_get_device(service);
struct gatt_primary *immediate;
immediate = btd_device_get_primary(device, IMMEDIATE_ALERT_UUID);
return monitor_register_immediate(device, &enabled, immediate);
}
-static int monitor_txpower_probe(struct btd_profile *p,
- struct btd_device *device)
+static int monitor_txpower_probe(struct btd_service *service)
{
+ struct btd_device *device = btd_service_get_device(service);
struct gatt_primary *txpower;
txpower = btd_device_get_primary(device, TX_POWER_UUID);
return monitor_register_txpower(device, &enabled, txpower);
}
-static void monitor_linkloss_remove(struct btd_profile *p,
- struct btd_device *device)
+static void monitor_linkloss_remove(struct btd_service *service)
{
+ struct btd_device *device = btd_service_get_device(service);
+
monitor_unregister_linkloss(device);
}
-static void monitor_immediate_remove(struct btd_profile *p,
- struct btd_device *device)
+static void monitor_immediate_remove(struct btd_service *service)
{
+ struct btd_device *device = btd_service_get_device(service);
+
monitor_unregister_immediate(device);
}
-static void monitor_txpower_remove(struct btd_profile *p,
- struct btd_device *device)
+static void monitor_txpower_remove(struct btd_service *service)
{
+ struct btd_device *device = btd_service_get_device(service);
+
monitor_unregister_txpower(device);
}
diff --git a/profiles/proximity/reporter.c b/profiles/proximity/reporter.c
index 66f52fe..dbb593a 100644
--- a/profiles/proximity/reporter.c
+++ b/profiles/proximity/reporter.c
#include "error.h"
#include "device.h"
#include "profile.h"
+#include "service.h"
#include "hcid.h"
#include "attrib/gattrib.h"
#include "attrib/att.h"
radapter->devices = g_slist_prepend(radapter->devices, device);
}
-int reporter_device_probe(struct btd_profile *p, struct btd_device *device)
+int reporter_device_probe(struct btd_service *service)
{
+ struct btd_device *device = btd_service_get_device(service);
struct reporter_adapter *radapter;
struct btd_adapter *adapter = device_get_adapter(device);
return 0;
}
-void reporter_device_remove(struct btd_profile *p, struct btd_device *device)
+void reporter_device_remove(struct btd_service *service)
{
+ struct btd_device *device = btd_service_get_device(service);
struct reporter_adapter *radapter;
struct btd_adapter *adapter = device_get_adapter(device);
diff --git a/profiles/proximity/reporter.h b/profiles/proximity/reporter.h
index b02ae9c..a8e1aac 100644
--- a/profiles/proximity/reporter.h
+++ b/profiles/proximity/reporter.h
HIGH_ALERT = 0x02,
};
-void reporter_device_remove(struct btd_profile *p, struct btd_device *device);
-int reporter_device_probe(struct btd_profile *p, struct btd_device *device);
+void reporter_device_remove(struct btd_service *service);
+int reporter_device_probe(struct btd_service *service);
int reporter_adapter_probe(struct btd_profile *p, struct btd_adapter *adapter);
void reporter_adapter_remove(struct btd_profile *p,
diff --git a/profiles/sap/manager.c b/profiles/sap/manager.c
index fddd7aa..24b73e7 100644
--- a/profiles/sap/manager.c
+++ b/profiles/sap/manager.c
#include "adapter.h"
#include "device.h"
#include "profile.h"
+#include "service.h"
#include "manager.h"
#include "server.h"
diff --git a/profiles/scanparam/scan.c b/profiles/scanparam/scan.c
index deb0653..dbbb4ea 100644
--- a/profiles/scanparam/scan.c
+++ b/profiles/scanparam/scan.c
#include "adapter.h"
#include "device.h"
#include "profile.h"
+#include "service.h"
#include "attrib/att.h"
#include "attrib/gattrib.h"
#include "attrib/gatt.h"
g_free(scan);
}
-static int scan_param_probe(struct btd_profile *p, struct btd_device *device)
+static int scan_param_probe(struct btd_service *service)
{
+ struct btd_device *device = btd_service_get_device(service);
struct gatt_primary *prim;
DBG("Probing Scan Parameters");
return scan_register(device, prim);
}
-static void scan_param_remove(struct btd_profile *p, struct btd_device *device)
+static void scan_param_remove(struct btd_service *service)
{
+ struct btd_device *device = btd_service_get_device(service);
+
scan_unregister(device);
}
diff --git a/profiles/thermometer/thermometer.c b/profiles/thermometer/thermometer.c
index ae8ccb2..3757b25 100644
--- a/profiles/thermometer/thermometer.c
+++ b/profiles/thermometer/thermometer.c
#include "adapter.h"
#include "device.h"
#include "profile.h"
+#include "service.h"
#include "error.h"
#include "log.h"
#include "attrib/gattrib.h"
THERMOMETER_MANAGER_INTERFACE);
}
-static int thermometer_device_probe(struct btd_profile *p,
- struct btd_device *device)
+static int thermometer_device_probe(struct btd_service *service)
{
+ struct btd_device *device = btd_service_get_device(service);
struct gatt_primary *tattr;
tattr = btd_device_get_primary(device, HEALTH_THERMOMETER_UUID);
return thermometer_register(device, tattr);
}
-static void thermometer_device_remove(struct btd_profile *p,
- struct btd_device *device)
+static void thermometer_device_remove(struct btd_service *service)
{
+ struct btd_device *device = btd_service_get_device(service);
+
thermometer_unregister(device);
}
diff --git a/src/profile.c b/src/profile.c
index 7bd7970..b2c5ebf 100644
--- a/src/profile.c
+++ b/src/profile.c
#include "adapter.h"
#include "device.h"
#include "profile.h"
+#include "service.h"
#define DUN_DEFAULT_CHANNEL 1
#define SPP_DEFAULT_CHANNEL 3
}
}
-static int ext_device_probe(struct btd_profile *p, struct btd_device *dev)
+static int ext_device_probe(struct btd_service *service)
{
+ struct btd_profile *p = btd_service_get_profile(service);
struct ext_profile *ext;
ext = find_ext(p);
return NULL;
}
-static void ext_device_remove(struct btd_profile *p, struct btd_device *dev)
+static void ext_device_remove(struct btd_service *service)
{
+ struct btd_profile *p = btd_service_get_profile(service);
+ struct btd_device *dev = btd_service_get_device(service);
struct ext_profile *ext;
struct ext_io *conn;
diff --git a/src/profile.h b/src/profile.h
index 5622f23..8daa358 100644
--- a/src/profile.h
+++ b/src/profile.h
#define BTD_PROFILE_PRIORITY_MEDIUM 1
#define BTD_PROFILE_PRIORITY_HIGH 2
+struct btd_service;
+
struct btd_profile {
const char *name;
int priority;
bool auto_connect;
- int (*device_probe) (struct btd_profile *p, struct btd_device *device);
- void (*device_remove) (struct btd_profile *p,
- struct btd_device *device);
+ int (*device_probe) (struct btd_service *service);
+ void (*device_remove) (struct btd_service *service);
int (*connect) (struct btd_device *device,
struct btd_profile *profile);
diff --git a/src/service.c b/src/service.c
index 298d600..a10138d 100644
--- a/src/service.c
+++ b/src/service.c
assert(service->state == BTD_SERVICE_STATE_UNAVAILABLE);
- err = service->profile->device_probe(service->profile, service->device);
+ err = service->profile->device_probe(service);
if (err == 0) {
change_state(service, BTD_SERVICE_STATE_DISCONNECTED, 0);
return 0;
void service_shutdown(struct btd_service *service)
{
change_state(service, BTD_SERVICE_STATE_UNAVAILABLE, 0);
- service->profile->device_remove(service->profile, service->device);
+ service->profile->device_remove(service);
service->device = NULL;
service->profile = NULL;
}