* [PATCH] build: Add missing documentation files to EXTRA_DIST
From: Andrzej Kaczmarek @ 2012-10-09 13:51 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Andrzej Kaczmarek
This patch adds missing documentation files to EXTRA_DIST variable so they
are included when creating tarball.
---
Makefile.am | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/Makefile.am b/Makefile.am
index 3b08f9a..dbbd794 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -401,7 +401,9 @@ EXTRA_DIST += doc/manager-api.txt \
doc/network-api.txt doc/input-api.txt doc/audio-api.txt \
doc/control-api.txt doc/hfp-api.txt doc/health-api.txt \
doc/sap-api.txt doc/media-api.txt doc/assigned-numbers.txt \
- doc/supported-features.txt doc/alert-api.txt
+ doc/supported-features.txt doc/alert-api.txt doc/mgmt-api.txt \
+ doc/oob-api.txt doc/proximity-api.txt doc/heartrate-api.txt \
+ doc/thermometer-api.txt
AM_YFLAGS = -d
--
1.7.11.3
^ permalink raw reply related
* [PATCH 9/9] device: Remove not used device_set_class function
From: Szymon Janc @ 2012-10-09 12:12 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1349784722-14578-1-git-send-email-szymon.janc@tieto.com>
With mgmt interface CoD cannot change as it is only received in EIR when
device is discovered or connected. Was only used in
btd_event_remote_class which is now removed.
---
src/device.c | 12 ------------
src/device.h | 1 -
2 files changed, 13 deletions(-)
diff --git a/src/device.c b/src/device.c
index e94b222..71bfea5 100644
--- a/src/device.c
+++ b/src/device.c
@@ -3475,18 +3475,6 @@ void btd_device_unref(struct btd_device *device)
g_free(path);
}
-void device_set_class(struct btd_device *device, uint32_t value)
-{
- const char *icon = class_to_icon(value);
-
- g_dbus_emit_property_changed(btd_get_dbus_connection(), device->path,
- DEVICE_INTERFACE, "Class");
-
- if (icon)
- g_dbus_emit_property_changed(btd_get_dbus_connection(),
- device->path, DEVICE_INTERFACE, "Icon");
-}
-
int device_get_appearance(struct btd_device *device, uint16_t *value)
{
uint16_t app;
diff --git a/src/device.h b/src/device.h
index d23f40d..46cecb4 100644
--- a/src/device.h
+++ b/src/device.h
@@ -102,7 +102,6 @@ guint device_add_disconnect_watch(struct btd_device *device,
disconnect_watch watch, void *user_data,
GDestroyNotify destroy);
void device_remove_disconnect_watch(struct btd_device *device, guint id);
-void device_set_class(struct btd_device *device, uint32_t value);
int device_get_appearance(struct btd_device *device, uint16_t *value);
void device_set_appearance(struct btd_device *device, uint16_t value);
--
1.7.9.5
^ permalink raw reply related
* [PATCH 8/9] adapter: Remove not used btd_adapter_switch_{online,offline} functions
From: Szymon Janc @ 2012-10-09 12:12 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1349784722-14578-1-git-send-email-szymon.janc@tieto.com>
Were used only in Maemo plugin which is now removed.
---
src/adapter.c | 43 -------------------------------------------
src/adapter.h | 2 --
2 files changed, 45 deletions(-)
diff --git a/src/adapter.c b/src/adapter.c
index f3e381b..e6cb3e9 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -3582,49 +3582,6 @@ int btd_adapter_restore_powered(struct btd_adapter *adapter)
return mgmt_set_powered(adapter->dev_id, TRUE);
}
-static gboolean switch_off_timeout(gpointer user_data)
-{
- struct btd_adapter *adapter = user_data;
-
- mgmt_set_powered(adapter->dev_id, FALSE);
- adapter->off_timer = 0;
-
- return FALSE;
-}
-
-int btd_adapter_switch_online(struct btd_adapter *adapter)
-{
- if (adapter->up)
- return -EALREADY;
-
- if (adapter->off_timer)
- off_timer_remove(adapter);
-
- return mgmt_set_powered(adapter->dev_id, TRUE);
-}
-
-int btd_adapter_switch_offline(struct btd_adapter *adapter)
-{
- if (!adapter->up)
- return -EALREADY;
-
- if (adapter->off_timer)
- return 0;
-
- adapter->global_mode = MODE_OFF;
-
- if (adapter->connections == NULL)
- return mgmt_set_powered(adapter->dev_id, FALSE);
-
- g_slist_foreach(adapter->connections,
- (GFunc) device_request_disconnect, NULL);
-
- adapter->off_timer = g_timeout_add_seconds(OFF_TIMER,
- switch_off_timeout, adapter);
-
- return 0;
-}
-
static gboolean disable_auto(gpointer user_data)
{
struct btd_adapter *adapter = user_data;
diff --git a/src/adapter.h b/src/adapter.h
index 9fd034d..cef59d2 100644
--- a/src/adapter.h
+++ b/src/adapter.h
@@ -178,8 +178,6 @@ void btd_adapter_any_release_path(void);
gboolean adapter_powering_down(struct btd_adapter *adapter);
int btd_adapter_restore_powered(struct btd_adapter *adapter);
-int btd_adapter_switch_online(struct btd_adapter *adapter);
-int btd_adapter_switch_offline(struct btd_adapter *adapter);
void btd_adapter_enable_auto_connect(struct btd_adapter *adapter);
typedef ssize_t (*btd_adapter_pin_cb_t) (struct btd_adapter *adapter,
--
1.7.9.5
^ permalink raw reply related
* [PATCH 7/9] storage: Remove not used read_remote_features
From: Szymon Janc @ 2012-10-09 12:12 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1349784722-14578-1-git-send-email-szymon.janc@tieto.com>
It was only usefull with hciops.
---
src/storage.c | 45 ---------------------------------------------
src/storage.h | 2 --
2 files changed, 47 deletions(-)
diff --git a/src/storage.c b/src/storage.c
index 297aba7..ac66021 100644
--- a/src/storage.c
+++ b/src/storage.c
@@ -435,51 +435,6 @@ done:
return 0;
}
-static int decode_bytes(const char *str, unsigned char *bytes, size_t len)
-{
- unsigned int i;
-
- for (i = 0; i < len; i++) {
- if (sscanf(str + (i * 2), "%02hhX", &bytes[i]) != 1)
- return -EINVAL;
- }
-
- return 0;
-}
-
-int read_remote_features(const bdaddr_t *local, const bdaddr_t *peer,
- unsigned char *page1, unsigned char *page2)
-{
- char filename[PATH_MAX + 1], addr[18], *str;
- size_t len;
- int err;
-
- if (page1 == NULL && page2 == NULL)
- return -EINVAL;
-
- create_filename(filename, PATH_MAX, local, "features");
-
- ba2str(peer, addr);
-
- str = textfile_get(filename, addr);
- if (!str)
- return -ENOENT;
-
- len = strlen(str);
-
- err = -ENOENT;
-
- if (page1 && len >= 16)
- err = decode_bytes(str, page1, 8);
-
- if (page2 && len >= 33)
- err = decode_bytes(str + 17, page2, 8);
-
- free(str);
-
- return err;
-}
-
int write_lastseen_info(const bdaddr_t *local, const bdaddr_t *peer,
uint8_t peer_type, struct tm *tm)
{
diff --git a/src/storage.h b/src/storage.h
index 8293ba8..e334828 100644
--- a/src/storage.h
+++ b/src/storage.h
@@ -50,8 +50,6 @@ int write_device_name(const bdaddr_t *local, const bdaddr_t *peer,
uint8_t peer_type, const char *name);
int read_device_name(const char *src, const char *dst, uint8_t dst_type,
char *name);
-int read_remote_features(const bdaddr_t *local, const bdaddr_t *peer,
- unsigned char *page1, unsigned char *page2);
int write_lastseen_info(const bdaddr_t *local, const bdaddr_t *peer,
uint8_t peer_type, struct tm *tm);
int write_lastused_info(const bdaddr_t *local, const bdaddr_t *peer,
--
1.7.9.5
^ permalink raw reply related
* [PATCH 6/9] storage: Remove not used write_features_info
From: Szymon Janc @ 2012-10-09 12:11 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1349784722-14578-1-git-send-email-szymon.janc@tieto.com>
This was used in hciops.
---
src/storage.c | 32 --------------------------------
src/storage.h | 2 --
2 files changed, 34 deletions(-)
diff --git a/src/storage.c b/src/storage.c
index 4dc2d17..297aba7 100644
--- a/src/storage.c
+++ b/src/storage.c
@@ -435,38 +435,6 @@ done:
return 0;
}
-int write_features_info(const bdaddr_t *local, const bdaddr_t *peer,
- unsigned char *page1, unsigned char *page2)
-{
- char filename[PATH_MAX + 1], addr[18];
- char str[] = "0000000000000000 0000000000000000";
- char *old_value;
- int i;
-
- ba2str(peer, addr);
-
- create_filename(filename, PATH_MAX, local, "features");
- create_file(filename, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
-
- old_value = textfile_get(filename, addr);
-
- if (page1)
- for (i = 0; i < 8; i++)
- sprintf(str + (i * 2), "%2.2X", page1[i]);
- else if (old_value && strlen(old_value) >= 16)
- strncpy(str, old_value, 16);
-
- if (page2)
- for (i = 0; i < 8; i++)
- sprintf(str + 17 + (i * 2), "%2.2X", page2[i]);
- else if (old_value && strlen(old_value) >= 33)
- strncpy(str + 17, old_value + 17, 16);
-
- free(old_value);
-
- return textfile_put(filename, addr, str);
-}
-
static int decode_bytes(const char *str, unsigned char *bytes, size_t len)
{
unsigned int i;
diff --git a/src/storage.h b/src/storage.h
index e19e67f..8293ba8 100644
--- a/src/storage.h
+++ b/src/storage.h
@@ -50,8 +50,6 @@ int write_device_name(const bdaddr_t *local, const bdaddr_t *peer,
uint8_t peer_type, const char *name);
int read_device_name(const char *src, const char *dst, uint8_t dst_type,
char *name);
-int write_features_info(const bdaddr_t *local, const bdaddr_t *peer,
- unsigned char *page1, unsigned char *page2);
int read_remote_features(const bdaddr_t *local, const bdaddr_t *peer,
unsigned char *page1, unsigned char *page2);
int write_lastseen_info(const bdaddr_t *local, const bdaddr_t *peer,
--
1.7.9.5
^ permalink raw reply related
* [PATCH 5/9] storage: Remove not used write_version_info
From: Szymon Janc @ 2012-10-09 12:11 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1349784722-14578-1-git-send-email-szymon.janc@tieto.com>
This was used in hciops only.
---
src/storage.c | 17 -----------------
src/storage.h | 3 ---
2 files changed, 20 deletions(-)
diff --git a/src/storage.c b/src/storage.c
index d4189c5..4dc2d17 100644
--- a/src/storage.c
+++ b/src/storage.c
@@ -435,23 +435,6 @@ done:
return 0;
}
-int write_version_info(const bdaddr_t *local, const bdaddr_t *peer,
- uint16_t manufacturer, uint8_t lmp_ver,
- uint16_t lmp_subver)
-{
- char filename[PATH_MAX + 1], addr[18], str[16];
-
- memset(str, 0, sizeof(str));
- sprintf(str, "%d %d %d", manufacturer, lmp_ver, lmp_subver);
-
- create_filename(filename, PATH_MAX, local, "manufacturers");
-
- create_file(filename, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
-
- ba2str(peer, addr);
- return textfile_put(filename, addr, str);
-}
-
int write_features_info(const bdaddr_t *local, const bdaddr_t *peer,
unsigned char *page1, unsigned char *page2)
{
diff --git a/src/storage.h b/src/storage.h
index 0a91d47..e19e67f 100644
--- a/src/storage.h
+++ b/src/storage.h
@@ -50,9 +50,6 @@ int write_device_name(const bdaddr_t *local, const bdaddr_t *peer,
uint8_t peer_type, const char *name);
int read_device_name(const char *src, const char *dst, uint8_t dst_type,
char *name);
-int write_version_info(const bdaddr_t *local, const bdaddr_t *peer,
- uint16_t manufacturer, uint8_t lmp_ver,
- uint16_t lmp_subver);
int write_features_info(const bdaddr_t *local, const bdaddr_t *peer,
unsigned char *page1, unsigned char *page2);
int read_remote_features(const bdaddr_t *local, const bdaddr_t *peer,
--
1.7.9.5
^ permalink raw reply related
* [PATCH 4/9] storage: Remove not used read_remote_eir
From: Szymon Janc @ 2012-10-09 12:11 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1349784722-14578-1-git-send-email-szymon.janc@tieto.com>
This function is not used. Previously it was used to determine if
remote device is legacy or not.
---
src/storage.c | 41 -----------------------------------------
src/storage.h | 2 --
2 files changed, 43 deletions(-)
diff --git a/src/storage.c b/src/storage.c
index 55dc591..d4189c5 100644
--- a/src/storage.c
+++ b/src/storage.c
@@ -435,47 +435,6 @@ done:
return 0;
}
-int read_remote_eir(const bdaddr_t *local, const bdaddr_t *peer,
- uint8_t peer_type, uint8_t *data)
-{
- char filename[PATH_MAX + 1], key[18], *str;
- int i;
-
- create_filename(filename, PATH_MAX, local, "eir");
-
- ba2str(peer, key);
- sprintf(&key[17], "#%hhu", peer_type);
-
- str = textfile_get(filename, key);
- if (str != NULL)
- goto done;
-
- /* Try old format (address only) */
- key[17] = '\0';
-
- str = textfile_get(filename, key);
- if (!str)
- return -ENOENT;
-
-done:
- if (!data) {
- free(str);
- return 0;
- }
-
- if (strlen(str) < 480) {
- free(str);
- return -EIO;
- }
-
- for (i = 0; i < HCI_MAX_EIR_LENGTH; i++)
- sscanf(str + (i * 2), "%02hhX", &data[i]);
-
- free(str);
-
- return 0;
-}
-
int write_version_info(const bdaddr_t *local, const bdaddr_t *peer,
uint16_t manufacturer, uint8_t lmp_ver,
uint16_t lmp_subver)
diff --git a/src/storage.h b/src/storage.h
index d6aa8ec..0a91d47 100644
--- a/src/storage.h
+++ b/src/storage.h
@@ -50,8 +50,6 @@ int write_device_name(const bdaddr_t *local, const bdaddr_t *peer,
uint8_t peer_type, const char *name);
int read_device_name(const char *src, const char *dst, uint8_t dst_type,
char *name);
-int read_remote_eir(const bdaddr_t *local, const bdaddr_t *peer,
- uint8_t peer_type, uint8_t *data);
int write_version_info(const bdaddr_t *local, const bdaddr_t *peer,
uint16_t manufacturer, uint8_t lmp_ver,
uint16_t lmp_subver);
--
1.7.9.5
^ permalink raw reply related
* [PATCH 3/9] event: Don't store EIR in btd_event_device_found
From: Szymon Janc @ 2012-10-09 12:11 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1349784722-14578-1-git-send-email-szymon.janc@tieto.com>
It is never read and was usefull only to gather EIR data for testing
which can also be done with hcidump etc.
---
src/event.c | 3 ---
src/storage.c | 21 ---------------------
src/storage.h | 2 --
3 files changed, 26 deletions(-)
diff --git a/src/event.c b/src/event.c
index ac7140c..bd5ee1e 100644
--- a/src/event.c
+++ b/src/event.c
@@ -257,9 +257,6 @@ void btd_event_device_found(bdaddr_t *local, bdaddr_t *peer, uint8_t bdaddr_type
update_lastseen(local, peer, bdaddr_type);
- if (data)
- write_remote_eir(local, peer, bdaddr_type, data, data_len);
-
adapter_update_found_devices(adapter, peer, bdaddr_type, rssi,
confirm_name, legacy, data, data_len);
}
diff --git a/src/storage.c b/src/storage.c
index df6b0aa..55dc591 100644
--- a/src/storage.c
+++ b/src/storage.c
@@ -435,27 +435,6 @@ done:
return 0;
}
-int write_remote_eir(const bdaddr_t *local, const bdaddr_t *peer,
- uint8_t peer_type, uint8_t *data,
- uint8_t data_len)
-{
- char filename[PATH_MAX + 1], key[20], str[481];
- int i;
-
- memset(str, 0, sizeof(str));
- for (i = 0; i < data_len; i++)
- sprintf(str + (i * 2), "%2.2X", data[i]);
-
- create_filename(filename, PATH_MAX, local, "eir");
-
- create_file(filename, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
-
- ba2str(peer, key);
- sprintf(&key[17], "#%hhu", peer_type);
-
- return textfile_put(filename, key, str);
-}
-
int read_remote_eir(const bdaddr_t *local, const bdaddr_t *peer,
uint8_t peer_type, uint8_t *data)
{
diff --git a/src/storage.h b/src/storage.h
index 741b8a7..d6aa8ec 100644
--- a/src/storage.h
+++ b/src/storage.h
@@ -50,8 +50,6 @@ int write_device_name(const bdaddr_t *local, const bdaddr_t *peer,
uint8_t peer_type, const char *name);
int read_device_name(const char *src, const char *dst, uint8_t dst_type,
char *name);
-int write_remote_eir(const bdaddr_t *local, const bdaddr_t *peer,
- uint8_t peer_type, uint8_t *data, uint8_t data_len);
int read_remote_eir(const bdaddr_t *local, const bdaddr_t *peer,
uint8_t peer_type, uint8_t *data);
int write_version_info(const bdaddr_t *local, const bdaddr_t *peer,
--
1.7.9.5
^ permalink raw reply related
* [PATCH 2/9] Pass confirm name as gboolean value
From: Szymon Janc @ 2012-10-09 12:11 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1349784722-14578-1-git-send-email-szymon.janc@tieto.com>
confirm_name is a boolean value and can be pass as such instead of
uint8_t.
---
src/adapter.c | 2 +-
src/adapter.h | 2 +-
src/event.c | 2 +-
src/event.h | 2 +-
src/mgmt.c | 2 +-
5 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/src/adapter.c b/src/adapter.c
index abb9691..f3e381b 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -3141,7 +3141,7 @@ static gboolean connect_pending_cb(gpointer user_data)
void adapter_update_found_devices(struct btd_adapter *adapter,
const bdaddr_t *bdaddr,
uint8_t bdaddr_type, int8_t rssi,
- uint8_t confirm_name, gboolean legacy,
+ gboolean confirm_name, gboolean legacy,
uint8_t *data, uint8_t data_len)
{
struct remote_dev_info *dev;
diff --git a/src/adapter.h b/src/adapter.h
index a089075..9fd034d 100644
--- a/src/adapter.h
+++ b/src/adapter.h
@@ -128,7 +128,7 @@ struct remote_dev_info *adapter_search_found_devices(struct btd_adapter *adapter
void adapter_update_found_devices(struct btd_adapter *adapter,
const bdaddr_t *bdaddr,
uint8_t bdaddr_type, int8_t rssi,
- uint8_t confirm_name, gboolean legacy,
+ gboolean confirm_name, gboolean legacy,
uint8_t *data, uint8_t data_len);
void adapter_emit_device_found(struct btd_adapter *adapter,
struct remote_dev_info *dev);
diff --git a/src/event.c b/src/event.c
index d552a0f..ac7140c 100644
--- a/src/event.c
+++ b/src/event.c
@@ -243,7 +243,7 @@ static void update_lastused(bdaddr_t *sba, bdaddr_t *dba, uint8_t dba_type)
}
void btd_event_device_found(bdaddr_t *local, bdaddr_t *peer, uint8_t bdaddr_type,
- int8_t rssi, uint8_t confirm_name,
+ int8_t rssi, gboolean confirm_name,
gboolean legacy, uint8_t *data,
uint8_t data_len)
{
diff --git a/src/event.h b/src/event.h
index a9afa1e..a7c3ce2 100644
--- a/src/event.h
+++ b/src/event.h
@@ -24,7 +24,7 @@
int btd_event_request_pin(bdaddr_t *sba, bdaddr_t *dba, gboolean secure);
void btd_event_device_found(bdaddr_t *local, bdaddr_t *peer, uint8_t bdaddr_type,
- int8_t rssi, uint8_t confirm_name,
+ int8_t rssi, gboolean confirm_name,
gboolean legacy, uint8_t *data,
uint8_t data_len);
void btd_event_remote_name(bdaddr_t *local, bdaddr_t *peer, char *name);
diff --git a/src/mgmt.c b/src/mgmt.c
index 9353c7d..719af06 100644
--- a/src/mgmt.c
+++ b/src/mgmt.c
@@ -1667,7 +1667,7 @@ static void mgmt_device_found(int sk, uint16_t index, void *buf, size_t len)
DBG("hci%u addr %s, rssi %d flags 0x%04x eir_len %u",
index, addr, ev->rssi, flags, eir_len);
- confirm_name = (flags & MGMT_DEV_FOUND_CONFIRM_NAME);
+ confirm_name = (flags & MGMT_DEV_FOUND_CONFIRM_NAME) ? TRUE : FALSE;
legacy = (flags & MGMT_DEV_FOUND_LEGACY_PAIRING) ? TRUE : FALSE;
btd_event_device_found(&info->bdaddr, &ev->addr.bdaddr,
--
1.7.9.5
^ permalink raw reply related
* [PATCH 1/9] Simplify checking if found device is legacy
From: Szymon Janc @ 2012-10-09 12:11 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1349784722-14578-1-git-send-email-szymon.janc@tieto.com>
This simplify code by removing pairing_is_legacy() function which was
always returning FALSE due to EIR being always present with mgmt
interface (this also fix small issue when first DeviceFound signal
emitted for legacy device was having LegacyPairing set to false).
Instead of using btd_event_set_legacy_pairing to set legacy pairing in
remote_dev_info handle it in similar way to rssi.
---
src/adapter.c | 52 ++++++++++++----------------------------------------
src/adapter.h | 6 +++---
src/event.c | 22 +++-------------------
src/event.h | 4 ++--
src/mgmt.c | 11 +++--------
5 files changed, 23 insertions(+), 72 deletions(-)
diff --git a/src/adapter.c b/src/adapter.c
index 6b28651..abb9691 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -2947,6 +2947,7 @@ void adapter_emit_device_found(struct btd_adapter *adapter,
const char *icon, *paddr = peer_addr;
dbus_bool_t paired = FALSE, trusted = FALSE;
dbus_int16_t rssi = dev->rssi;
+ dbus_bool_t legacy = dev->legacy;
char *alias;
size_t uuid_count;
@@ -2985,8 +2986,6 @@ void adapter_emit_device_found(struct btd_adapter *adapter,
return;
}
- dev->legacy = FALSE;
-
if (read_remote_appearance(&adapter->bdaddr, &dev->bdaddr,
dev->bdaddr_type, &app) == 0)
icon = gap_appearance_to_icon(app);
@@ -3002,7 +3001,7 @@ void adapter_emit_device_found(struct btd_adapter *adapter,
"RSSI", DBUS_TYPE_INT16, &rssi,
"Name", DBUS_TYPE_STRING, &dev->name,
"Alias", DBUS_TYPE_STRING, &alias,
- "LegacyPairing", DBUS_TYPE_BOOLEAN, &dev->legacy,
+ "LegacyPairing", DBUS_TYPE_BOOLEAN, &legacy,
"Paired", DBUS_TYPE_BOOLEAN, &paired,
"UUIDs", DBUS_TYPE_ARRAY, &dev->uuids, uuid_count,
NULL);
@@ -3016,7 +3015,7 @@ void adapter_emit_device_found(struct btd_adapter *adapter,
"RSSI", DBUS_TYPE_INT16, &rssi,
"Name", DBUS_TYPE_STRING, &dev->name,
"Alias", DBUS_TYPE_STRING, &alias,
- "LegacyPairing", DBUS_TYPE_BOOLEAN, &dev->legacy,
+ "LegacyPairing", DBUS_TYPE_BOOLEAN, &legacy,
"Paired", DBUS_TYPE_BOOLEAN, &paired,
"Trusted", DBUS_TYPE_BOOLEAN, &trusted,
"UUIDs", DBUS_TYPE_ARRAY, &dev->uuids, uuid_count,
@@ -3071,26 +3070,6 @@ static void dev_prepend_uuid(gpointer data, gpointer user_data)
dev->services = g_slist_prepend(dev->services, g_strdup(new_uuid));
}
-static gboolean pairing_is_legacy(const bdaddr_t *local, const bdaddr_t *peer,
- const uint8_t *eir, const char *name)
-{
- unsigned char features[8];
-
- if (eir)
- return FALSE;
-
- if (name == NULL)
- return TRUE;
-
- if (read_remote_features(local, peer, NULL, features) < 0)
- return TRUE;
-
- if (features[0] & 0x01)
- return FALSE;
- else
- return TRUE;
-}
-
static char *read_stored_data(const bdaddr_t *local, const bdaddr_t *peer,
uint8_t peer_type, const char *file)
{
@@ -3162,13 +3141,13 @@ static gboolean connect_pending_cb(gpointer user_data)
void adapter_update_found_devices(struct btd_adapter *adapter,
const bdaddr_t *bdaddr,
uint8_t bdaddr_type, int8_t rssi,
- uint8_t confirm_name, uint8_t *data,
- uint8_t data_len)
+ uint8_t confirm_name, gboolean legacy,
+ uint8_t *data, uint8_t data_len)
{
struct remote_dev_info *dev;
struct eir_data eir_data;
char *alias, *name;
- gboolean legacy, name_known;
+ gboolean name_known;
int err;
GSList *l;
@@ -3203,7 +3182,7 @@ void adapter_update_found_devices(struct btd_adapter *adapter,
goto done;
}
- if (dev->rssi != rssi)
+ if (dev->rssi != rssi || dev->legacy != legacy)
goto done;
eir_data_free(&eir_data);
@@ -3215,19 +3194,11 @@ void adapter_update_found_devices(struct btd_adapter *adapter,
name = read_stored_data(&adapter->bdaddr, bdaddr, bdaddr_type, "names");
- if (bdaddr_type == BDADDR_BREDR) {
- legacy = pairing_is_legacy(&adapter->bdaddr, bdaddr, data,
- name);
-
- if (!name && main_opts.name_resolv &&
- adapter_has_discov_sessions(adapter))
- name_known = FALSE;
- else
- name_known = TRUE;
- } else {
- legacy = FALSE;
+ if (bdaddr_type == BDADDR_BREDR && !name && main_opts.name_resolv &&
+ adapter_has_discov_sessions(adapter))
+ name_known = FALSE;
+ else
name_known = TRUE;
- }
if (confirm_name)
mgmt_confirm_name(adapter->dev_id, bdaddr, bdaddr_type,
@@ -3262,6 +3233,7 @@ void adapter_update_found_devices(struct btd_adapter *adapter,
done:
dev->rssi = rssi;
+ dev->legacy = legacy;
adapter->found_devices = g_slist_sort(adapter->found_devices,
(GCompareFunc) dev_rssi_cmp);
diff --git a/src/adapter.h b/src/adapter.h
index 72a9988..a089075 100644
--- a/src/adapter.h
+++ b/src/adapter.h
@@ -82,7 +82,7 @@ struct remote_dev_info {
uint32_t class;
char *name;
char *alias;
- dbus_bool_t legacy;
+ gboolean legacy;
char **uuids;
size_t uuid_count;
GSList *services;
@@ -128,8 +128,8 @@ struct remote_dev_info *adapter_search_found_devices(struct btd_adapter *adapter
void adapter_update_found_devices(struct btd_adapter *adapter,
const bdaddr_t *bdaddr,
uint8_t bdaddr_type, int8_t rssi,
- uint8_t confirm_name, uint8_t *data,
- uint8_t data_len);
+ uint8_t confirm_name, gboolean legacy,
+ uint8_t *data, uint8_t data_len);
void adapter_emit_device_found(struct btd_adapter *adapter,
struct remote_dev_info *dev);
void adapter_mode_changed(struct btd_adapter *adapter, uint8_t scan_mode);
diff --git a/src/event.c b/src/event.c
index 0ebab19..d552a0f 100644
--- a/src/event.c
+++ b/src/event.c
@@ -244,7 +244,8 @@ static void update_lastused(bdaddr_t *sba, bdaddr_t *dba, uint8_t dba_type)
void btd_event_device_found(bdaddr_t *local, bdaddr_t *peer, uint8_t bdaddr_type,
int8_t rssi, uint8_t confirm_name,
- uint8_t *data, uint8_t data_len)
+ gboolean legacy, uint8_t *data,
+ uint8_t data_len)
{
struct btd_adapter *adapter;
@@ -260,24 +261,7 @@ void btd_event_device_found(bdaddr_t *local, bdaddr_t *peer, uint8_t bdaddr_type
write_remote_eir(local, peer, bdaddr_type, data, data_len);
adapter_update_found_devices(adapter, peer, bdaddr_type, rssi,
- confirm_name, data, data_len);
-}
-
-void btd_event_set_legacy_pairing(bdaddr_t *local, bdaddr_t *peer,
- gboolean legacy)
-{
- struct btd_adapter *adapter;
- struct remote_dev_info *dev;
-
- adapter = manager_find_adapter(local);
- if (!adapter) {
- error("No matching adapter found");
- return;
- }
-
- dev = adapter_search_found_devices(adapter, peer);
- if (dev)
- dev->legacy = legacy;
+ confirm_name, legacy, data, data_len);
}
void btd_event_remote_name(bdaddr_t *local, bdaddr_t *peer, char *name)
diff --git a/src/event.h b/src/event.h
index 6adf1f5..a9afa1e 100644
--- a/src/event.h
+++ b/src/event.h
@@ -25,8 +25,8 @@
int btd_event_request_pin(bdaddr_t *sba, bdaddr_t *dba, gboolean secure);
void btd_event_device_found(bdaddr_t *local, bdaddr_t *peer, uint8_t bdaddr_type,
int8_t rssi, uint8_t confirm_name,
- uint8_t *data, uint8_t data_len);
-void btd_event_set_legacy_pairing(bdaddr_t *local, bdaddr_t *peer, gboolean legacy);
+ gboolean legacy, uint8_t *data,
+ uint8_t data_len);
void btd_event_remote_name(bdaddr_t *local, bdaddr_t *peer, char *name);
void btd_event_conn_complete(bdaddr_t *local, bdaddr_t *peer, uint8_t bdaddr_type,
char *name, uint32_t class);
diff --git a/src/mgmt.c b/src/mgmt.c
index d3f7809..9353c7d 100644
--- a/src/mgmt.c
+++ b/src/mgmt.c
@@ -1635,6 +1635,7 @@ static void mgmt_device_found(int sk, uint16_t index, void *buf, size_t len)
uint16_t eir_len;
uint8_t *eir;
gboolean confirm_name;
+ gboolean legacy;
if (len < sizeof(*ev)) {
error("mgmt_device_found too short (%zu bytes)", len);
@@ -1666,19 +1667,13 @@ static void mgmt_device_found(int sk, uint16_t index, void *buf, size_t len)
DBG("hci%u addr %s, rssi %d flags 0x%04x eir_len %u",
index, addr, ev->rssi, flags, eir_len);
- if (flags & MGMT_DEV_FOUND_LEGACY_PAIRING)
- btd_event_set_legacy_pairing(&info->bdaddr, &ev->addr.bdaddr,
- TRUE);
- else
- btd_event_set_legacy_pairing(&info->bdaddr, &ev->addr.bdaddr,
- FALSE);
-
confirm_name = (flags & MGMT_DEV_FOUND_CONFIRM_NAME);
+ legacy = (flags & MGMT_DEV_FOUND_LEGACY_PAIRING) ? TRUE : FALSE;
btd_event_device_found(&info->bdaddr, &ev->addr.bdaddr,
ev->addr.type,
ev->rssi, confirm_name,
- eir, eir_len);
+ legacy, eir, eir_len);
}
static void mgmt_discovering(int sk, uint16_t index, void *buf, size_t len)
--
1.7.9.5
^ permalink raw reply related
* [PATCH 0/9] Remove some old code
From: Szymon Janc @ 2012-10-09 12:11 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
This removes some unused or not needed old code.
Szymon Janc (9):
Simplify checking if found device is legacy
Pass confirm name as gboolean value
event: Don't store EIR in btd_event_device_found
storage: Remove not used read_remote_eir
storage: Remove not used write_version_info
storage: Remove not used write_features_info
storage: Remove not used read_remote_features
adapter: Remove not used btd_adapter_switch_{online,offline}
functions
device: Remove not used device_set_class function
src/adapter.c | 95 +++++------------------------------
src/adapter.h | 8 ++-
src/device.c | 12 -----
src/device.h | 1 -
src/event.c | 27 ++--------
src/event.h | 6 +--
src/mgmt.c | 13 ++---
src/storage.c | 156 ---------------------------------------------------------
src/storage.h | 11 ----
9 files changed, 26 insertions(+), 303 deletions(-)
--
1.7.9.5
^ permalink raw reply
* [PATCH v3 5/5] audio: Remove redundant procedure when a2dp connect
From: chanyeol.park @ 2012-10-09 11:35 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1349782548-27923-1-git-send-email-chanyeol.park@samsung.com>
From: Chan-yeol Park <chanyeol.park@samsung.com>
This patch fixes the bug that when remote host is down a2dp connection failure
is handled like XCASE
---
audio/avdtp.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/audio/avdtp.c b/audio/avdtp.c
index d905db3..ae1ab7b 100644
--- a/audio/avdtp.c
+++ b/audio/avdtp.c
@@ -2411,9 +2411,10 @@ static void avdtp_connect_cb(GIOChannel *chan, GError *err, gpointer user_data)
{
struct avdtp *session = user_data;
char address[18];
- GError *gerr = NULL;
+ int err_no = EIO;
if (err) {
+ err_no = err->code;
error("%s", err->message);
goto failed;
}
@@ -2421,13 +2422,13 @@ static void avdtp_connect_cb(GIOChannel *chan, GError *err, gpointer user_data)
if (!session->io)
session->io = g_io_channel_ref(chan);
- bt_io_get(chan, &gerr,
+ bt_io_get(chan, &err,
BT_IO_OPT_OMTU, &session->omtu,
BT_IO_OPT_IMTU, &session->imtu,
BT_IO_OPT_INVALID);
- if (gerr) {
- error("%s", gerr->message);
- g_error_free(gerr);
+ if (err) {
+ err_no = err->code;
+ error("%s", err->message);
goto failed;
}
@@ -2481,7 +2482,7 @@ failed:
avdtp_sep_set_state(session, stream->lsep,
AVDTP_STATE_IDLE);
} else
- connection_lost(session, EIO);
+ connection_lost(session, err_no);
}
static void auth_cb(DBusError *derr, void *user_data)
--
1.7.9.5
^ permalink raw reply related
* [PATCH v3 4/5] audio: Fix audio driver is not probed
From: chanyeol.park @ 2012-10-09 11:35 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1349782548-27923-1-git-send-email-chanyeol.park@samsung.com>
From: Chan-yeol Park <chanyeol.park@samsung.com>
This patch fix the bugs that when handling an AVDTP incoming connection,
audio-a2dp driver is not probed because advanced audio UUID is missed.
---
audio/manager.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/audio/manager.c b/audio/manager.c
index 26cd9bf..b052009 100644
--- a/audio/manager.c
+++ b/audio/manager.c
@@ -1093,7 +1093,8 @@ static struct btd_profile gateway_profile = {
static struct btd_profile a2dp_profile = {
.name = "audio-a2dp",
- .remote_uuids = BTD_UUIDS(A2DP_SOURCE_UUID, A2DP_SINK_UUID),
+ .remote_uuids = BTD_UUIDS(A2DP_SOURCE_UUID, A2DP_SINK_UUID,
+ ADVANCED_AUDIO_UUID),
.device_probe = a2dp_probe,
.device_remove = audio_remove,
--
1.7.9.5
^ permalink raw reply related
* [PATCH v3 3/5] avinfo: Print a2dp vendor codec info
From: chanyeol.park @ 2012-10-09 11:35 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1349782548-27923-1-git-send-email-chanyeol.park@samsung.com>
From: Chan-yeol Park <chanyeol.park@samsung.com>
---
tools/avinfo.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/tools/avinfo.c b/tools/avinfo.c
index 78a1544..f036cf8 100644
--- a/tools/avinfo.c
+++ b/tools/avinfo.c
@@ -158,6 +158,18 @@ struct getcap_resp {
uint8_t caps[0];
} __attribute__ ((packed));
+static void print_vendor(a2dp_vendor_codec_t *vendor)
+{
+ printf("\tMedia Codec: Vendor Specific A2DP Codec");
+
+ printf("\n\t\tVendor ID 0x%02x%02x%02x%02x", vendor->vendor_id[0],
+ vendor->vendor_id[1], vendor->vendor_id[2],
+ vendor->vendor_id[3]);
+
+ printf("\n\t\tVendor Specific Codec ID 0x%02x%02x\n",
+ vendor->codec_id[0], vendor->codec_id[1]);
+}
+
static void print_mpeg12(a2dp_mpeg_t *mpeg)
{
@@ -292,6 +304,9 @@ static void print_media_codec(struct avdtp_media_codec_capability *cap)
case A2DP_CODEC_MPEG12:
print_mpeg12((void *) cap->data);
break;
+ case A2DP_CODEC_VENDOR:
+ print_vendor((void *) cap->data);
+ break;
default:
printf("\tMedia Codec: Unknown\n");
}
--
1.7.9.5
^ permalink raw reply related
* [PATCH v3 2/5] avinfo: Replace definitions with a2dp-codecs.h's
From: chanyeol.park @ 2012-10-09 11:35 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1349782548-27923-1-git-send-email-chanyeol.park@samsung.com>
From: Chan-yeol Park <chanyeol.park@samsung.com>
---
audio/a2dp-codecs.h | 21 +++++++++-
tools/avinfo.c | 113 +++------------------------------------------------
2 files changed, 25 insertions(+), 109 deletions(-)
diff --git a/audio/a2dp-codecs.h b/audio/a2dp-codecs.h
index 2afafa5..3dc31cb 100644
--- a/audio/a2dp-codecs.h
+++ b/audio/a2dp-codecs.h
@@ -49,6 +49,9 @@
#define SBC_ALLOCATION_SNR (1 << 1)
#define SBC_ALLOCATION_LOUDNESS 1
+#define MAX_BITPOOL 64
+#define MIN_BITPOOL 2
+
#define MPEG_CHANNEL_MODE_MONO (1 << 3)
#define MPEG_CHANNEL_MODE_DUAL_CHANNEL (1 << 2)
#define MPEG_CHANNEL_MODE_STEREO (1 << 1)
@@ -65,8 +68,22 @@
#define MPEG_SAMPLING_FREQ_44100 (1 << 1)
#define MPEG_SAMPLING_FREQ_48000 1
-#define MAX_BITPOOL 64
-#define MIN_BITPOOL 2
+#define MPEG_BIT_RATE_VBR 0x8000
+#define MPEG_BIT_RATE_320000 0x4000
+#define MPEG_BIT_RATE_256000 0x2000
+#define MPEG_BIT_RATE_224000 0x1000
+#define MPEG_BIT_RATE_192000 0x0800
+#define MPEG_BIT_RATE_160000 0x0400
+#define MPEG_BIT_RATE_128000 0x0200
+#define MPEG_BIT_RATE_112000 0x0100
+#define MPEG_BIT_RATE_96000 0x0080
+#define MPEG_BIT_RATE_80000 0x0040
+#define MPEG_BIT_RATE_64000 0x0020
+#define MPEG_BIT_RATE_56000 0x0010
+#define MPEG_BIT_RATE_48000 0x0008
+#define MPEG_BIT_RATE_40000 0x0004
+#define MPEG_BIT_RATE_32000 0x0002
+#define MPEG_BIT_RATE_FREE 0x0001
#if __BYTE_ORDER == __LITTLE_ENDIAN
diff --git a/tools/avinfo.c b/tools/avinfo.c
index 63b0da6..78a1544 100644
--- a/tools/avinfo.c
+++ b/tools/avinfo.c
@@ -39,6 +39,8 @@
#include <sys/ioctl.h>
#include <sys/socket.h>
+#include <a2dp-codecs.h>
+
#include <bluetooth/bluetooth.h>
#include <bluetooth/hci.h>
#include <bluetooth/hci_lib.h>
@@ -72,65 +74,6 @@
#define AVDTP_MEDIA_TYPE_VIDEO 0x01
#define AVDTP_MEDIA_TYPE_MULTIMEDIA 0x02
-#define A2DP_CODEC_SBC 0x00
-#define A2DP_CODEC_MPEG12 0x01
-#define A2DP_CODEC_MPEG24 0x02
-#define A2DP_CODEC_ATRAC 0x03
-
-#define SBC_SAMPLING_FREQ_16000 (1 << 3)
-#define SBC_SAMPLING_FREQ_32000 (1 << 2)
-#define SBC_SAMPLING_FREQ_44100 (1 << 1)
-#define SBC_SAMPLING_FREQ_48000 (1 << 0)
-
-#define SBC_CHANNEL_MODE_MONO (1 << 3)
-#define SBC_CHANNEL_MODE_DUAL_CHANNEL (1 << 2)
-#define SBC_CHANNEL_MODE_STEREO (1 << 1)
-#define SBC_CHANNEL_MODE_JOINT_STEREO (1 << 0)
-
-#define SBC_BLOCK_LENGTH_4 (1 << 3)
-#define SBC_BLOCK_LENGTH_8 (1 << 2)
-#define SBC_BLOCK_LENGTH_12 (1 << 1)
-#define SBC_BLOCK_LENGTH_16 (1 << 0)
-
-#define SBC_SUBBANDS_4 (1 << 1)
-#define SBC_SUBBANDS_8 (1 << 0)
-
-#define SBC_ALLOCATION_SNR (1 << 1)
-#define SBC_ALLOCATION_LOUDNESS (1 << 0)
-
-#define MPEG_CHANNEL_MODE_MONO (1 << 3)
-#define MPEG_CHANNEL_MODE_DUAL_CHANNEL (1 << 2)
-#define MPEG_CHANNEL_MODE_STEREO (1 << 1)
-#define MPEG_CHANNEL_MODE_JOINT_STEREO (1 << 0)
-
-#define MPEG_LAYER_MP1 (1 << 2)
-#define MPEG_LAYER_MP2 (1 << 1)
-#define MPEG_LAYER_MP3 (1 << 0)
-
-#define MPEG_SAMPLING_FREQ_16000 (1 << 5)
-#define MPEG_SAMPLING_FREQ_22050 (1 << 4)
-#define MPEG_SAMPLING_FREQ_24000 (1 << 3)
-#define MPEG_SAMPLING_FREQ_32000 (1 << 2)
-#define MPEG_SAMPLING_FREQ_44100 (1 << 1)
-#define MPEG_SAMPLING_FREQ_48000 (1 << 0)
-
-#define MPEG_BIT_RATE_VBR 0x8000
-#define MPEG_BIT_RATE_320000 0x4000
-#define MPEG_BIT_RATE_256000 0x2000
-#define MPEG_BIT_RATE_224000 0x1000
-#define MPEG_BIT_RATE_192000 0x0800
-#define MPEG_BIT_RATE_160000 0x0400
-#define MPEG_BIT_RATE_128000 0x0200
-#define MPEG_BIT_RATE_112000 0x0100
-#define MPEG_BIT_RATE_96000 0x0080
-#define MPEG_BIT_RATE_80000 0x0040
-#define MPEG_BIT_RATE_64000 0x0020
-#define MPEG_BIT_RATE_56000 0x0010
-#define MPEG_BIT_RATE_48000 0x0008
-#define MPEG_BIT_RATE_40000 0x0004
-#define MPEG_BIT_RATE_32000 0x0002
-#define MPEG_BIT_RATE_FREE 0x0001
-
struct avdtp_service_capability {
uint8_t category;
uint8_t length;
@@ -169,28 +112,6 @@ struct avdtp_media_codec_capability {
uint8_t data[0];
} __attribute__ ((packed));
-struct sbc_codec_cap {
- struct avdtp_media_codec_capability cap;
- uint8_t channel_mode:4;
- uint8_t frequency:4;
- uint8_t allocation_method:2;
- uint8_t subbands:2;
- uint8_t block_length:4;
- uint8_t min_bitpool;
- uint8_t max_bitpool;
-} __attribute__ ((packed));
-
-struct mpeg_codec_cap {
- struct avdtp_media_codec_capability cap;
- uint8_t channel_mode:4;
- uint8_t crc:1;
- uint8_t layer:3;
- uint8_t frequency:6;
- uint8_t mpf:1;
- uint8_t rfa:1;
- uint16_t bitrate;
-} __attribute__ ((packed));
-
#elif __BYTE_ORDER == __BIG_ENDIAN
struct avdtp_header {
@@ -223,28 +144,6 @@ struct avdtp_media_codec_capability {
uint8_t data[0];
} __attribute__ ((packed));
-struct sbc_codec_cap {
- struct avdtp_media_codec_capability cap;
- uint8_t frequency:4;
- uint8_t channel_mode:4;
- uint8_t block_length:4;
- uint8_t subbands:2;
- uint8_t allocation_method:2;
- uint8_t min_bitpool;
- uint8_t max_bitpool;
-} __attribute__ ((packed));
-
-struct mpeg_codec_cap {
- struct avdtp_media_codec_capability cap;
- uint8_t layer:3;
- uint8_t crc:1;
- uint8_t channel_mode:4;
- uint8_t rfa:1;
- uint8_t mpf:1;
- uint8_t frequency:6;
- uint16_t bitrate;
-} __attribute__ ((packed));
-
#else
#error "Unknown byte order"
#endif
@@ -260,7 +159,7 @@ struct getcap_resp {
} __attribute__ ((packed));
-static void print_mpeg12(struct mpeg_codec_cap *mpeg)
+static void print_mpeg12(a2dp_mpeg_t *mpeg)
{
printf("\tMedia Codec: MPEG12\n\t\tChannel Modes: ");
@@ -341,7 +240,7 @@ static void print_mpeg12(struct mpeg_codec_cap *mpeg)
printf("RFC-2250\n");
}
-static void print_sbc(struct sbc_codec_cap *sbc)
+static void print_sbc(a2dp_sbc_t *sbc)
{
printf("\tMedia Codec: SBC\n\t\tChannel Modes: ");
@@ -388,10 +287,10 @@ static void print_media_codec(struct avdtp_media_codec_capability *cap)
{
switch (cap->media_codec_type) {
case A2DP_CODEC_SBC:
- print_sbc((void *) cap);
+ print_sbc((void *) cap->data);
break;
case A2DP_CODEC_MPEG12:
- print_mpeg12((void *) cap);
+ print_mpeg12((void *) cap->data);
break;
default:
printf("\tMedia Codec: Unknown\n");
--
1.7.9.5
^ permalink raw reply related
* [PATCH v3 1/5] audio: Add check for vendor specific A2DP codec
From: chanyeol.park @ 2012-10-09 11:35 UTC (permalink / raw)
To: linux-bluetooth
From: Chan-yeol Park <chanyeol.park@samsung.com>
This patch adds checks(vendor ID, vendor specific codec ID) to make sure of
vendor specific A2DP codec selection.
---
audio/a2dp-codecs.h | 6 +++++
audio/a2dp.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 69 insertions(+), 1 deletion(-)
diff --git a/audio/a2dp-codecs.h b/audio/a2dp-codecs.h
index 51c796a..2afafa5 100644
--- a/audio/a2dp-codecs.h
+++ b/audio/a2dp-codecs.h
@@ -26,6 +26,7 @@
#define A2DP_CODEC_MPEG12 0x01
#define A2DP_CODEC_MPEG24 0x02
#define A2DP_CODEC_ATRAC 0x03
+#define A2DP_CODEC_VENDOR 0xFF
#define SBC_SAMPLING_FREQ_16000 (1 << 3)
#define SBC_SAMPLING_FREQ_32000 (1 << 2)
@@ -114,3 +115,8 @@ typedef struct {
#else
#error "Unknown byte order"
#endif
+
+typedef struct {
+ uint8_t vendor_id[4];
+ uint8_t codec_id[2];
+} __attribute__ ((packed)) a2dp_vendor_codec_t;
diff --git a/audio/a2dp.c b/audio/a2dp.c
index fd1c494..2c9251a 100644
--- a/audio/a2dp.c
+++ b/audio/a2dp.c
@@ -44,6 +44,7 @@
#include "sink.h"
#include "source.h"
#include "a2dp.h"
+#include "a2dp-codecs.h"
#include "sdpd.h"
/* The duration that streams without users are allowed to stay in
@@ -1427,11 +1428,62 @@ done:
finalize_select(setup);
}
+static gboolean vendor_codec_is_matched(uint8_t *remote_cap,
+ size_t remote_cap_len, struct a2dp_sep *sep)
+{
+ uint8_t *capabilities;
+ size_t length;
+
+ a2dp_vendor_codec_t *local_codec;
+ a2dp_vendor_codec_t *remote_codec;
+
+ if (remote_cap_len < sizeof(a2dp_vendor_codec_t))
+ return FALSE;
+
+ remote_codec = (a2dp_vendor_codec_t *) remote_cap;
+
+ DBG("Remote vendor 0x%02x%02x%02x%02x codec 0x%02x%02x",
+ remote_codec->vendor_id[0], remote_codec->vendor_id[1],
+ remote_codec->vendor_id[2], remote_codec->vendor_id[3],
+ remote_codec->codec_id[0], remote_codec->codec_id[1]);
+
+ if (sep->endpoint == NULL)
+ return FALSE;
+
+ length = sep->endpoint->get_capabilities(sep,
+ &capabilities, sep->user_data);
+
+ if (length < sizeof(a2dp_vendor_codec_t))
+ return FALSE;
+
+ local_codec = (a2dp_vendor_codec_t *) capabilities;
+
+ DBG("Registered vendor 0x%02x%02x%02x%02x codec 0x%02x%02x",
+ local_codec->vendor_id[0], local_codec->vendor_id[1],
+ local_codec->vendor_id[2], local_codec->vendor_id[3],
+ local_codec->codec_id[0], local_codec->codec_id[1]);
+
+ if (memcmp(remote_codec->vendor_id, local_codec->vendor_id,
+ sizeof(local_codec->vendor_id)))
+ return FALSE;
+
+ if (memcmp(remote_codec->codec_id, local_codec->codec_id,
+ sizeof(local_codec->codec_id)))
+ return FALSE;
+
+ DBG("Vendor Codec info is matched");
+
+ return TRUE;
+}
+
static struct a2dp_sep *a2dp_find_sep(struct avdtp *session, GSList *list,
const char *sender)
{
for (; list; list = list->next) {
struct a2dp_sep *sep = list->data;
+ struct avdtp_remote_sep *rsep;
+ struct avdtp_media_codec_capability *rsep_codec;
+ struct avdtp_service_capability *service;
/* Use sender's endpoint if available */
if (sender) {
@@ -1445,7 +1497,17 @@ static struct a2dp_sep *a2dp_find_sep(struct avdtp *session, GSList *list,
continue;
}
- if (avdtp_find_remote_sep(session, sep->lsep) == NULL)
+ rsep = avdtp_find_remote_sep(session, sep->lsep);
+ if (rsep == NULL)
+ continue;
+
+ service = avdtp_get_codec(rsep);
+ rsep_codec = (struct avdtp_media_codec_capability *)
+ service->data;
+
+ if (rsep_codec->media_codec_type == A2DP_CODEC_VENDOR &&
+ !vendor_codec_is_matched(rsep_codec->data,
+ service->length - sizeof(*rsep_codec), sep))
continue;
return sep;
--
1.7.9.5
^ permalink raw reply related
* [PATCH v3 15/15] thermometer: Fix missing braces
From: Andrzej Kaczmarek @ 2012-10-09 11:19 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Andrzej Kaczmarek
In-Reply-To: <1349781598-22580-1-git-send-email-andrzej.kaczmarek@tieto.com>
---
profiles/thermometer/thermometer.c | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/profiles/thermometer/thermometer.c b/profiles/thermometer/thermometer.c
index ae4081e..3e71ede 100644
--- a/profiles/thermometer/thermometer.c
+++ b/profiles/thermometer/thermometer.c
@@ -335,8 +335,9 @@ static void change_property(struct thermometer *t, const char *name,
emit_property_changed(device_get_path(t->dev),
THERMOMETER_INTERFACE, name,
DBUS_TYPE_UINT16, &t->min);
- } else
+ } else {
DBG("%s is not a thermometer property", name);
+ }
}
static void valid_range_desc_cb(guint8 status, const guint8 *pdu, guint16 len,
@@ -421,8 +422,9 @@ static void process_thermometer_desc(struct descriptor *desc)
val = GATT_CLIENT_CHARAC_CFG_IND_BIT;
msg = g_strdup("Enable Measurement Interval "
"indication");
- } else
+ } else {
goto done;
+ }
att_put_u16(val, atval);
gatt_write_char(ch->t->attrib, desc->handle, atval, 2,
@@ -548,12 +550,13 @@ static void process_thermometer_char(struct characteristic *ch)
gboolean intermediate = TRUE;
change_property(ch->t, "Intermediate", &intermediate);
return;
- } else if (g_strcmp0(ch->attr.uuid, TEMPERATURE_TYPE_UUID) == 0)
+ } else if (g_strcmp0(ch->attr.uuid, TEMPERATURE_TYPE_UUID) == 0) {
gatt_read_char(ch->t->attrib, ch->attr.value_handle,
read_temp_type_cb, ch);
- else if (g_strcmp0(ch->attr.uuid, MEASUREMENT_INTERVAL_UUID) == 0)
+ } else if (g_strcmp0(ch->attr.uuid, MEASUREMENT_INTERVAL_UUID) == 0) {
gatt_read_char(ch->t->attrib, ch->attr.value_handle,
read_interval_cb, ch);
+ }
}
static void configure_thermometer_cb(GSList *characteristics, guint8 status,
@@ -591,10 +594,11 @@ static void configure_thermometer_cb(GSList *characteristics, guint8 status,
if (start == c->handle)
continue;
end = c->handle - 1;
- } else if (c->value_handle != t->svc_range->end)
+ } else if (c->value_handle != t->svc_range->end) {
end = t->svc_range->end;
- else
+ } else {
continue;
+ }
gatt_find_info(t->attrib, start, end, discover_desc_cb, ch);
}
--
1.7.11.3
^ permalink raw reply related
* [PATCH v3 14/15] thermometer: Fix indentation
From: Andrzej Kaczmarek @ 2012-10-09 11:19 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Andrzej Kaczmarek
In-Reply-To: <1349781598-22580-1-git-send-email-andrzej.kaczmarek@tieto.com>
---
profiles/thermometer/thermometer.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/profiles/thermometer/thermometer.c b/profiles/thermometer/thermometer.c
index 684cd60..ae4081e 100644
--- a/profiles/thermometer/thermometer.c
+++ b/profiles/thermometer/thermometer.c
@@ -83,7 +83,7 @@ struct thermometer {
};
struct characteristic {
- struct gatt_char attr; /* Characteristic */
+ struct gatt_char attr; /* Characteristic */
GSList *desc; /* Descriptors */
struct thermometer *t; /* Thermometer where the char belongs */
};
--
1.7.11.3
^ permalink raw reply related
* [PATCH v3 13/15] thermometer: Fix whitespace
From: Andrzej Kaczmarek @ 2012-10-09 11:19 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Andrzej Kaczmarek
In-Reply-To: <1349781598-22580-1-git-send-email-andrzej.kaczmarek@tieto.com>
---
profiles/thermometer/thermometer.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/profiles/thermometer/thermometer.c b/profiles/thermometer/thermometer.c
index 530fed2..684cd60 100644
--- a/profiles/thermometer/thermometer.c
+++ b/profiles/thermometer/thermometer.c
@@ -634,7 +634,7 @@ static DBusMessage *get_properties(DBusConnection *conn, DBusMessage *msg,
return reply;
}
-static void write_interval_cb (guint8 status, const guint8 *pdu, guint16 len,
+static void write_interval_cb(guint8 status, const guint8 *pdu, guint16 len,
gpointer user_data)
{
struct tmp_interval_data *data = user_data;
--
1.7.11.3
^ permalink raw reply related
* [PATCH v3 12/15] thermometer: Refactor processing of measurement characteristic value
From: Andrzej Kaczmarek @ 2012-10-09 11:19 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Andrzej Kaczmarek
In-Reply-To: <1349781598-22580-1-git-send-email-andrzej.kaczmarek@tieto.com>
Data buffer is read by simply moving buffer pointer instead of calculating
indexes of consecutive fields. This makes function flow easier to follow
as there's no need to care about presence of fields prior to current when
reading data.
---
profiles/thermometer/thermometer.c | 66 +++++++++++++++++++++-----------------
1 file changed, 37 insertions(+), 29 deletions(-)
diff --git a/profiles/thermometer/thermometer.c b/profiles/thermometer/thermometer.c
index 72cdc79..530fed2 100644
--- a/profiles/thermometer/thermometer.c
+++ b/profiles/thermometer/thermometer.c
@@ -1021,27 +1021,37 @@ static void proc_measurement(struct thermometer *t, const uint8_t *pdu,
uint16_t len, gboolean final)
{
struct measurement m;
- const char *type;
+ const char *type = NULL;
uint8_t flags;
uint32_t raw;
- if (len < 4) {
+ /* skip opcode and handle */
+ pdu += 3;
+ len -= 3;
+
+ if (len < 1) {
DBG("Mandatory flags are not provided");
return;
}
- flags = pdu[3];
+ memset(&m, 0, sizeof(m));
+
+ flags = *pdu;
+
if (flags & TEMP_UNITS)
m.unit = "fahrenheit";
else
m.unit = "celsius";
- if (len < 8) {
- DBG("Temperature measurement value is not provided");
+ pdu++;
+ len--;
+
+ if (len < 4) {
+ DBG("Mandatory temperature measurement value is not provided");
return;
}
- raw = att_get_u32(&pdu[4]);
+ raw = att_get_u32(pdu);
m.mant = raw & 0x00FFFFFF;
m.exp = ((int32_t) raw) >> 24;
@@ -1050,48 +1060,46 @@ static void proc_measurement(struct thermometer *t, const uint8_t *pdu,
m.mant = m.mant - FLOAT_MAX_MANTISSA;
}
+ pdu += 4;
+ len -= 4;
+
if (flags & TEMP_TIME_STAMP) {
struct tm ts;
time_t time;
- if (len < 15) {
- DBG("Can't get time stamp value");
+ if (len < 7) {
+ DBG("Time stamp is not provided");
return;
}
- ts.tm_year = att_get_u16(&pdu[8]) - 1900;
- ts.tm_mon = pdu[10] - 1;
- ts.tm_mday = pdu[11];
- ts.tm_hour = pdu[12];
- ts.tm_min = pdu[13];
- ts.tm_sec = pdu[14];
+ ts.tm_year = att_get_u16(pdu) - 1900;
+ ts.tm_mon = *(pdu + 2) - 1;
+ ts.tm_mday = *(pdu + 3);
+ ts.tm_hour = *(pdu + 4);
+ ts.tm_min = *(pdu + 5);
+ ts.tm_sec = *(pdu + 6);
ts.tm_isdst = -1;
time = mktime(&ts);
m.time = (uint64_t) time;
m.suptime = TRUE;
- } else
- m.suptime = FALSE;
+
+ pdu += 7;
+ len -= 7;
+ }
if (flags & TEMP_TYPE) {
- uint8_t index;
-
- if (m.suptime && len >= 16)
- index = 15;
- else if (!m.suptime && len >= 9)
- index = 9;
- else {
- DBG("Can't get temperature type");
+ if (len < 1) {
+ DBG("Temperature type is not provided");
return;
}
- type = temptype2str(pdu[index]);
- } else if (t->has_type)
+ type = temptype2str(*pdu);
+ } else if (t->has_type) {
type = temptype2str(t->type);
- else
- type = NULL;
+ }
- m.type = type ? g_strdup(type) : NULL;
+ m.type = g_strdup(type);
m.value = final ? "final" : "intermediate";
recv_measurement(t, &m);
--
1.7.11.3
^ permalink raw reply related
* [PATCH v3 11/15] thermometer: Add common function to write characteristics CCC
From: Andrzej Kaczmarek @ 2012-10-09 11:19 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Andrzej Kaczmarek
In-Reply-To: <1349781598-22580-1-git-send-email-andrzej.kaczmarek@tieto.com>
There are now few separate functions to write CCC for measurement
characteristics which looks similar. This patch adds common function
to write given value into CCC for given characteristics and leaves
dedicated functions to act only as simple wrappers.
---
profiles/thermometer/thermometer.c | 108 ++++++++-----------------------------
1 file changed, 23 insertions(+), 85 deletions(-)
diff --git a/profiles/thermometer/thermometer.c b/profiles/thermometer/thermometer.c
index b39fd9b..72cdc79 100644
--- a/profiles/thermometer/thermometer.c
+++ b/profiles/thermometer/thermometer.c
@@ -376,7 +376,7 @@ static void valid_range_desc_cb(guint8 status, const guint8 *pdu, guint16 len,
change_property(desc->ch->t, "Minimum", &min);
}
-static void measurement_cb(guint8 status, const guint8 *pdu,
+static void write_ccc_cb(guint8 status, const guint8 *pdu,
guint16 len, gpointer user_data)
{
char *msg = user_data;
@@ -426,7 +426,7 @@ static void process_thermometer_desc(struct descriptor *desc)
att_put_u16(val, atval);
gatt_write_char(ch->t->attrib, desc->handle, atval, 2,
- measurement_cb, msg);
+ write_ccc_cb, msg);
return;
}
@@ -720,9 +720,8 @@ static DBusMessage *set_property(DBusConnection *conn, DBusMessage *msg,
return write_attr_interval(t, msg, value);
}
-static void enable_final_measurement(gpointer data, gpointer user_data)
+static void write_ccc(struct thermometer *t, const char *uuid, uint16_t value)
{
- struct thermometer *t = data;
struct characteristic *ch;
struct descriptor *desc;
bt_uuid_t btuuid;
@@ -732,116 +731,55 @@ static void enable_final_measurement(gpointer data, gpointer user_data)
if (t->attrib == NULL)
return;
- ch = get_characteristic(t, TEMPERATURE_MEASUREMENT_UUID);
+ ch = get_characteristic(t, uuid);
if (ch == NULL) {
- DBG("Temperature measurement characteristic not found");
+ DBG("Characteristic %s not found", uuid);
return;
}
bt_uuid16_create(&btuuid, GATT_CLIENT_CHARAC_CFG_UUID);
desc = get_descriptor(ch, &btuuid);
if (desc == NULL) {
- DBG("Client characteristic configuration descriptor not found");
+ DBG("CCC descriptor for %s not found", uuid);
return;
}
- atval[0] = 0x02;
- atval[1] = 0x00;
- msg = g_strdup("Enable final measurement");
- gatt_write_char(t->attrib, desc->handle, atval, 2, measurement_cb, msg);
+ att_put_u16(value, atval);
+
+ msg = g_strdup_printf("Write CCC: %04x for %s", value, uuid);
+
+ gatt_write_char(t->attrib, desc->handle, atval, sizeof(atval),
+ write_ccc_cb, msg);
}
-static void enable_intermediate_measurement(gpointer data, gpointer user_data)
+static void enable_final_measurement(gpointer data, gpointer user_data)
{
struct thermometer *t = data;
- struct characteristic *ch;
- struct descriptor *desc;
- bt_uuid_t btuuid;
- uint8_t atval[2];
- char *msg;
-
- if (t->attrib == NULL || !t->intermediate)
- return;
- ch = get_characteristic(t, INTERMEDIATE_TEMPERATURE_UUID);
- if (ch == NULL) {
- DBG("Intermediate measurement characteristic not found");
- return;
- }
+ write_ccc(t, TEMPERATURE_MEASUREMENT_UUID,
+ GATT_CLIENT_CHARAC_CFG_IND_BIT);
+}
- bt_uuid16_create(&btuuid, GATT_CLIENT_CHARAC_CFG_UUID);
- desc = get_descriptor(ch, &btuuid);
- if (desc == NULL) {
- DBG("Client characteristic configuration descriptor not found");
- return;
- }
+static void enable_intermediate_measurement(gpointer data, gpointer user_data)
+{
+ struct thermometer *t = data;
- atval[0] = 0x01;
- atval[1] = 0x00;
- msg = g_strdup("Enable intermediate measurement");
- gatt_write_char(t->attrib, desc->handle, atval, 2, measurement_cb, msg);
+ write_ccc(t, INTERMEDIATE_TEMPERATURE_UUID,
+ GATT_CLIENT_CHARAC_CFG_NOTIF_BIT);
}
static void disable_final_measurement(gpointer data, gpointer user_data)
{
struct thermometer *t = data;
- struct characteristic *ch;
- struct descriptor *desc;
- bt_uuid_t btuuid;
- uint8_t atval[2];
- char *msg;
- if (t->attrib == NULL)
- return;
-
- ch = get_characteristic(t, TEMPERATURE_MEASUREMENT_UUID);
- if (ch == NULL) {
- DBG("Temperature measurement characteristic not found");
- return;
- }
-
- bt_uuid16_create(&btuuid, GATT_CLIENT_CHARAC_CFG_UUID);
- desc = get_descriptor(ch, &btuuid);
- if (desc == NULL) {
- DBG("Client characteristic configuration descriptor not found");
- return;
- }
-
- atval[0] = 0x00;
- atval[1] = 0x00;
- msg = g_strdup("Disable final measurement");
- gatt_write_char(t->attrib, desc->handle, atval, 2, measurement_cb, msg);
+ write_ccc(t, TEMPERATURE_MEASUREMENT_UUID, 0x0000);
}
static void disable_intermediate_measurement(gpointer data, gpointer user_data)
{
struct thermometer *t = data;
- struct characteristic *ch;
- struct descriptor *desc;
- bt_uuid_t btuuid;
- uint8_t atval[2];
- char *msg;
-
- if (t->attrib == NULL)
- return;
-
- ch = get_characteristic(t, INTERMEDIATE_TEMPERATURE_UUID);
- if (ch == NULL) {
- DBG("Intermediate measurement characteristic not found");
- return;
- }
-
- bt_uuid16_create(&btuuid, GATT_CLIENT_CHARAC_CFG_UUID);
- desc = get_descriptor(ch, &btuuid);
- if (desc == NULL) {
- DBG("Client characteristic configuration descriptor not found");
- return;
- }
- atval[0] = 0x00;
- atval[1] = 0x00;
- msg = g_strdup("Disable intermediate measurement");
- gatt_write_char(t->attrib, desc->handle, atval, 2, measurement_cb, msg);
+ write_ccc(t, INTERMEDIATE_TEMPERATURE_UUID, 0x0000);
}
static void remove_int_watcher(struct thermometer_adapter *tadapter,
--
1.7.11.3
^ permalink raw reply related
* [PATCH v3 10/15] thermometer: Add constant definition for watcher interface name
From: Andrzej Kaczmarek @ 2012-10-09 11:19 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Andrzej Kaczmarek
In-Reply-To: <1349781598-22580-1-git-send-email-andrzej.kaczmarek@tieto.com>
---
profiles/thermometer/thermometer.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/profiles/thermometer/thermometer.c b/profiles/thermometer/thermometer.c
index dc716b4..b39fd9b 100644
--- a/profiles/thermometer/thermometer.c
+++ b/profiles/thermometer/thermometer.c
@@ -44,6 +44,7 @@
#define THERMOMETER_INTERFACE "org.bluez.Thermometer"
#define THERMOMETER_MANAGER_INTERFACE "org.bluez.ThermometerManager"
+#define THERMOMETER_WATCHER_INTERFACE "org.bluez.ThermometerWatcher"
/* Temperature measurement flag fields */
#define TEMP_UNITS 0x01
@@ -1034,7 +1035,7 @@ static void update_watcher(gpointer data, gpointer user_data)
DBusMessage *msg;
msg = dbus_message_new_method_call(w->srv, w->path,
- "org.bluez.ThermometerWatcher",
+ THERMOMETER_WATCHER_INTERFACE,
"MeasurementReceived");
if (msg == NULL)
return;
--
1.7.11.3
^ permalink raw reply related
* [PATCH v3 09/15] thermometer: Update driver naming style
From: Andrzej Kaczmarek @ 2012-10-09 11:19 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Andrzej Kaczmarek
In-Reply-To: <1349781598-22580-1-git-send-email-andrzej.kaczmarek@tieto.com>
This patch changes device probe and remove functions name to include
'device' rather than 'driver' name as it better describes what both
do.
Also profile driver name is changed to better describe that it's now
profile driver rather than device driver only.
---
profiles/thermometer/manager.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/profiles/thermometer/manager.c b/profiles/thermometer/manager.c
index 86e3a0f..6057633 100644
--- a/profiles/thermometer/manager.c
+++ b/profiles/thermometer/manager.c
@@ -41,7 +41,7 @@ static gint primary_uuid_cmp(gconstpointer a, gconstpointer b)
return g_strcmp0(prim->uuid, uuid);
}
-static int thermometer_driver_probe(struct btd_profile *p,
+static int thermometer_device_probe(struct btd_profile *p,
struct btd_device *device,
GSList *uuids)
{
@@ -60,7 +60,7 @@ static int thermometer_driver_probe(struct btd_profile *p,
return thermometer_register(device, tattr);
}
-static void thermometer_driver_remove(struct btd_profile *p,
+static void thermometer_device_remove(struct btd_profile *p,
struct btd_device *device)
{
thermometer_unregister(device);
@@ -79,10 +79,10 @@ static void thermometer_adapter_remove(struct btd_profile *p,
}
static struct btd_profile thermometer_profile = {
- .name = "thermometer-device-driver",
+ .name = "Health Thermometer GATT driver",
.remote_uuids = BTD_UUIDS(HEALTH_THERMOMETER_UUID),
- .device_probe = thermometer_driver_probe,
- .device_remove = thermometer_driver_remove,
+ .device_probe = thermometer_device_probe,
+ .device_remove = thermometer_device_remove,
.adapter_probe = thermometer_adapter_probe,
.adapter_remove = thermometer_adapter_remove
};
--
1.7.11.3
^ permalink raw reply related
* [PATCH v3 08/15] thermometer: Change string properties to lower-case
From: Andrzej Kaczmarek @ 2012-10-09 11:19 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Andrzej Kaczmarek
In-Reply-To: <1349781598-22580-1-git-send-email-andrzej.kaczmarek@tieto.com>
---
doc/thermometer-api.txt | 10 +++++-----
profiles/thermometer/thermometer.c | 26 +++++++++++++-------------
2 files changed, 18 insertions(+), 18 deletions(-)
diff --git a/doc/thermometer-api.txt b/doc/thermometer-api.txt
index a1da2e6..5bbd4bf 100644
--- a/doc/thermometer-api.txt
+++ b/doc/thermometer-api.txt
@@ -125,7 +125,7 @@ Methods void MeasurementReceived(dict measurement)
string Unit:
- Possible values: "Celsius" or "Fahrenheit"
+ Possible values: "celsius" or "fahrenheit"
uint64 Time (optional):
@@ -136,10 +136,10 @@ Methods void MeasurementReceived(dict measurement)
Only present if measurement type is known.
- Possible values: "Armpit", "Body", "Ear",
- "Finger", "Intestines", "Mouth",
- "Rectum", "Toe", "Tympanum"
+ Possible values: "armpit", "body", "ear",
+ "finger", "intestines", "mouth",
+ "rectum", "toe", "tympanum"
string Measurement:
- Possible values: "Final" or "Intermediate"
+ Possible values: "final" or "intermediate"
diff --git a/profiles/thermometer/thermometer.c b/profiles/thermometer/thermometer.c
index 64029b2..dc716b4 100644
--- a/profiles/thermometer/thermometer.c
+++ b/profiles/thermometer/thermometer.c
@@ -120,15 +120,15 @@ static GSList *thermometer_adapters = NULL;
const char *temp_type[] = {
"<reserved>",
- "Armpit",
- "Body",
- "Ear",
- "Finger",
- "Intestines",
- "Mouth",
- "Rectum",
- "Toe",
- "Tympanum"
+ "armpit",
+ "body",
+ "ear",
+ "finger",
+ "intestines",
+ "mouth",
+ "rectum",
+ "toe",
+ "tympanum"
};
static const gchar *temptype2str(uint8_t value)
@@ -1070,7 +1070,7 @@ static void recv_measurement(struct thermometer *t, struct measurement *m)
m->t = t;
- if (g_strcmp0(m->value, "Intermediate") == 0)
+ if (g_strcmp0(m->value, "intermediate") == 0)
wlist = t->tadapter->iwatchers;
else
wlist = t->tadapter->fwatchers;
@@ -1093,9 +1093,9 @@ static void proc_measurement(struct thermometer *t, const uint8_t *pdu,
flags = pdu[3];
if (flags & TEMP_UNITS)
- m.unit = "Fahrenheit";
+ m.unit = "fahrenheit";
else
- m.unit = "Celsius";
+ m.unit = "celsius";
if (len < 8) {
DBG("Temperature measurement value is not provided");
@@ -1153,7 +1153,7 @@ static void proc_measurement(struct thermometer *t, const uint8_t *pdu,
type = NULL;
m.type = type ? g_strdup(type) : NULL;
- m.value = final ? "Final" : "Intermediate";
+ m.value = final ? "final" : "intermediate";
recv_measurement(t, &m);
g_free(m.type);
--
1.7.11.3
^ permalink raw reply related
* [PATCH v3 07/15] thermometer: Reformat MeasurementReceived description
From: Andrzej Kaczmarek @ 2012-10-09 11:19 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Andrzej Kaczmarek
In-Reply-To: <1349781598-22580-1-git-send-email-andrzej.kaczmarek@tieto.com>
MeasurementReceived method description is reformatted to be more
readable and consistent with other API documents.
Special values for Exponent and Mantissa fields specify now only NaN
value as this is only special value defined by HTS specification for
measurement.
---
doc/thermometer-api.txt | 76 ++++++++++++++++++++++++++++++-------------------
1 file changed, 46 insertions(+), 30 deletions(-)
diff --git a/doc/thermometer-api.txt b/doc/thermometer-api.txt
index 1828811..a1da2e6 100644
--- a/doc/thermometer-api.txt
+++ b/doc/thermometer-api.txt
@@ -97,33 +97,49 @@ Service unique name
Interface org.bluez.ThermometerWatcher
Object path freely definable
-Methods void MeasurementReceived(dict measure)
-
- This callback gets called when a measure has been
- scanned in the thermometer. The Time entry in the dict
- will be only present if the device supports storing of
- data. The time value is expressed in seconds since epoch.
- The value represented is (mantissa) x (10**exponent)
- See foot note for special values when treating with
- health devices. The Type entry is only present if the
- measurement type is known. Otherwise, it is undefined.
-
- Dict is defined as below:
- {
- "Exponent" : int8,
- "Mantissa" : int32,
- "Unit" : ("Celsius" or "Fahrenheit"),
- "Time" : uint64,
- "Type" : ("Armpit", "Body", "Ear", "Finger",
- "Intestines", "Mouth", "Rectum", "Toe",
- "Tympanum"),
- "Measurement" : ("Final" or "Intermediate"),
- }
-
- For special cases, the exponent shall always be zero and
- the mantissa should be one of following values:
-
- NRes = -(2**23)
- NaN = +(2**23-1)
- INFINITY = (2**23-2)
- -INFINITY = -(2**23-2)
+Methods void MeasurementReceived(dict measurement)
+
+ This callback gets called when a measurement has been
+ scanned in the thermometer.
+
+ Measurement:
+
+ int16 Exponent:
+ int32 Mantissa:
+
+ Exponent and Mantissa values as
+ extracted from float value defined by
+ IEEE-11073-20601.
+
+ Measurement value is calculated as
+ (Mantissa) * (10^Exponent)
+
+ For special cases Exponent is set to 0
+ and Mantissa is set to one of following
+ values:
+
+ +(2^23 - 1) NaN (invalid or missing data)
+ -(2^23) NRes
+ +(2^23 - 2) +Infinity
+ -(2^23 - 2) -Infinity
+
+ string Unit:
+
+ Possible values: "Celsius" or "Fahrenheit"
+
+ uint64 Time (optional):
+
+ Time of measurement, if supported by device.
+ Expressed in seconds since epoch.
+
+ string Type (optional):
+
+ Only present if measurement type is known.
+
+ Possible values: "Armpit", "Body", "Ear",
+ "Finger", "Intestines", "Mouth",
+ "Rectum", "Toe", "Tympanum"
+
+ string Measurement:
+
+ Possible values: "Final" or "Intermediate"
--
1.7.11.3
^ permalink raw reply related
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox