Return-Path: From: Szymon Janc To: linux-bluetooth@vger.kernel.org Cc: Szymon Janc Subject: [PATCH 1/4] android/bluetooth: Add support for timestamp device property Date: Fri, 20 Dec 2013 19:30:07 +0100 Message-Id: <1387564210-6102-1-git-send-email-szymon.janc@tieto.com> Sender: linux-bluetooth-owner@vger.kernel.org List-ID: This allows to handle timestamp property request. Also this will be usefull for devices info cache (clearing old devices). --- android/bluetooth.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/android/bluetooth.c b/android/bluetooth.c index e534fc1..2e75864 100644 --- a/android/bluetooth.c +++ b/android/bluetooth.c @@ -80,6 +80,8 @@ struct device { uint32_t class; int32_t rssi; + uint32_t timestamp; + GSList *uuids; }; @@ -227,6 +229,8 @@ static void store_device_info(struct device *dev) else g_key_file_remove_key(key_file, addr, "Class", NULL); + g_key_file_set_integer(key_file, addr, "Timestamp", dev->timestamp); + if (dev->uuids) { GSList *l; int i; @@ -291,6 +295,7 @@ static struct device *create_device(const bdaddr_t *bdaddr, uint8_t type) bacpy(&dev->bdaddr, bdaddr); dev->bdaddr_type = type; dev->bond_state = HAL_BOND_STATE_NONE; + dev->timestamp = time(NULL); /* use address for name, will be change if one is present * eg. in EIR or set by set_property. */ @@ -1004,6 +1009,8 @@ static void update_found_device(const bdaddr_t *bdaddr, uint8_t bdaddr_type, ev->status = HAL_STATUS_SUCCESS; bdaddr2android(bdaddr, ev->bdaddr); + + dev->timestamp = time(NULL); } if (eir.class) { @@ -1607,6 +1614,9 @@ static void create_device_from_info(GKeyFile *key_file, const char *peer) dev->class = g_key_file_get_integer(key_file, peer, "Class", NULL); + dev->timestamp = g_key_file_get_integer(key_file, peer, "Timestamp", + NULL); + uuids = g_key_file_get_string_list(key_file, peer, "Services", NULL, NULL); if (uuids) { @@ -2647,11 +2657,10 @@ static uint8_t get_device_version_info(struct device *dev) static uint8_t get_device_timestamp(struct device *dev) { - DBG("Not implemented"); - - /* TODO */ + send_device_property(&dev->bdaddr, HAL_PROP_DEVICE_TIMESTAMP, + sizeof(dev->timestamp), &dev->timestamp); - return HAL_STATUS_FAILED; + return HAL_STATUS_SUCCESS; } static void handle_get_remote_device_props_cmd(const void *buf, uint16_t len) -- 1.8.3.2