Add current tx power read on hciops
Subsystems (2)
A message that is not in the archive (sent off-list or not yet received): 1308171784-24442-1-git-send-email-y
RFC 1/7 Add current tx power read on hciops
From: Claudio Takahasi <[email protected]>
Asynchronous read of the current transmission power of a given connection. Results are reported through events.
--- plugins/hciops.c | 43 +++++++++++++++++++++++++++++++++++++++++++ plugins/mgmtops.c | 11 +++++++++++ src/adapter.h | 1 + src/event.c | 8 ++++++++ src/event.h | 1 + 5 files changed, 64 insertions(+), 0 deletions(-)
plugins/hciops.c +43 -0
@@ -1773,6 +1773,22 @@ static inline void cc_le_set_scan_enable(int index, uint8_t status)set_state (index,DISCOV_SCAN ); } +static inline void read_txpower_complete (int index,void *ptr) +{ +struct dev_info *dev = &devs[index]; +read_transmit_power_level_rp *rp = ptr; +struct bt_conn *conn; + +if (rp->status) +return ; + + conn =find_conn_by_handle (dev, rp->handle); +if (conn ==NULL ) +return ; + +btd_event_txpower_read (&dev->bdaddr, &conn->bdaddr, rp->level); +} +static inline void cmd_complete (int index,void *ptr) {struct dev_info *dev = &devs[index];
@@ -1844,6 +1860,10 @@ static inline void cmd_complete(int index, void *ptr) ptr +=sizeof (evt_cmd_complete);read_local_oob_data_complete (index, status, ptr);break ; +case cmd_opcode_pack (OGF_HOST_CTL ,OCF_READ_TRANSMIT_POWER_LEVEL ): + ptr +=sizeof (evt_cmd_complete); +read_txpower_complete (index, ptr); +break ; }; }
@@ -3158,6 +3178,28 @@ static int hciops_read_clock(int index, bdaddr_t *bdaddr, int which,return 0 ; } +static int hciops_read_tx_power (int index,bdaddr_t *bdaddr) +{ +struct dev_info *dev = &devs[index]; +read_transmit_power_level_cp cp; +uint16_t handle; +int err; + + err =get_handle (index, bdaddr, &handle); +if (err <0 ) +return err; + +memset (&cp,0 ,sizeof (cp)); + cp.handle =htobs (handle); + cp.type =0x00 ;/* Current */ + +if (hci_send_cmd (dev->sk,OGF_HOST_CTL ,OCF_READ_TRANSMIT_POWER_LEVEL , +READ_TRANSMIT_POWER_LEVEL_CP_SIZE , &cp) <0 ) +return -errno; + +return 0 ; +} +static int hciops_read_bdaddr (int index,bdaddr_t *bdaddr) {struct dev_info *dev = &devs[index];
@@ -3664,6 +3706,7 @@ static struct btd_adapter_ops hci_ops = { .set_dev_class = hciops_set_dev_class, .set_fast_connectable = hciops_fast_connectable, .read_clock = hciops_read_clock, + .read_tx_power = hciops_read_tx_power, .read_bdaddr = hciops_read_bdaddr, .block_device = hciops_block_device, .unblock_device = hciops_unblock_device,
plugins/mgmtops.c +11 -0
@@ -1673,6 +1673,16 @@ static int mgmt_read_clock(int index, bdaddr_t *bdaddr, int which, int timeout,return -ENOSYS ; } +static int mgmt_read_tx_power (int index,bdaddr_t *bdaddr) +{ +char addr[18 ]; + +ba2str (bdaddr, addr); +DBG ("index %d addr %s read transmit power level" , index, addr); + +return -ENOSYS ; +} +static int mgmt_read_bdaddr (int index,bdaddr_t *bdaddr) {char addr[18 ];
@@ -2016,6 +2026,7 @@ static struct btd_adapter_ops mgmt_ops = { .set_dev_class = mgmt_set_dev_class, .set_fast_connectable = mgmt_fast_connectable, .read_clock = mgmt_read_clock, + .read_tx_power = mgmt_read_tx_power, .read_bdaddr = mgmt_read_bdaddr, .block_device = mgmt_block_device, .unblock_device = mgmt_unblock_device,
src/adapter.h +1 -0
@@ -182,6 +182,7 @@ struct btd_adapter_ops {int (*set_fast_connectable) (int index,gboolean enable);int (*read_clock) (int index,bdaddr_t *bdaddr,int which,int timeout,uint32_t *clock,uint16_t *accuracy); +int (*read_tx_power) (int index,bdaddr_t *bdaddr);int (*read_bdaddr) (int index,bdaddr_t *bdaddr);int (*block_device) (int index,bdaddr_t *bdaddr);int (*unblock_device) (int index,bdaddr_t *bdaddr);
src/event.c +8 -0
@@ -475,3 +475,11 @@ void btd_event_returned_link_key(bdaddr_t *local, bdaddr_t *peer)device_set_paired (device, TRUE); } + +void btd_event_txpower_read (bdaddr_t *local,bdaddr_t *peer,int8_t level) +{ +char peer_addr[18 ]; + +ba2str (peer, peer_addr); +DBG ("%s TX Power: %d" , peer_addr, level); +}
src/event.h +1 -0
@@ -40,3 +40,4 @@ int btd_event_user_passkey(bdaddr_t *sba, bdaddr_t *dba);int btd_event_user_notify (bdaddr_t *sba,bdaddr_t *dba,uint32_t passkey);int btd_event_link_key_notify (bdaddr_t *local,bdaddr_t *peer,uint8_t *key,uint8_t key_type,uint8_t pin_length); +void btd_event_txpower_read (bdaddr_t *local,bdaddr_t *peer,int8_t level);
Signature · 1 line
1.7.4.1
RFC 2/7 Add read RSSI on hciops
In reply to a message not in the archiveFrom: Sheldon Demario <[email protected]>
Extend adapter_ops adding a function to read the RSSI of an active connection asynchronously. This patch extends hciops only, mgmtops requires kernel changes to become functional.
--- plugins/hciops.c | 39 +++++++++++++++++++++++++++++++++++++++ plugins/mgmtops.c | 11 +++++++++++ src/adapter.h | 1 + src/event.c | 8 ++++++++ src/event.h | 1 + 5 files changed, 60 insertions(+), 0 deletions(-)
plugins/hciops.c +39 -0
@@ -1789,6 +1789,22 @@ static inline void read_txpower_complete(int index, void *ptr)btd_event_txpower_read (&dev->bdaddr, &conn->bdaddr, rp->level); } +static inline void read_rssi_complete (int index,void *ptr) +{ +struct dev_info *dev = &devs[index]; +read_rssi_rp *rp = ptr; +struct bt_conn *conn; + +if (rp->status) +return ; + + conn =find_conn_by_handle (dev, rp->handle); +if (conn ==NULL ) +return ; + +btd_event_rssi_read (&dev->bdaddr, &conn->bdaddr, rp->rssi); +} +static inline void cmd_complete (int index,void *ptr) {struct dev_info *dev = &devs[index];
@@ -1863,6 +1879,9 @@ static inline void cmd_complete(int index, void *ptr)case cmd_opcode_pack (OGF_HOST_CTL ,OCF_READ_TRANSMIT_POWER_LEVEL ): ptr +=sizeof (evt_cmd_complete);read_txpower_complete (index, ptr); +case cmd_opcode_pack (OGF_STATUS_PARAM ,OCF_READ_RSSI ): + ptr +=sizeof (evt_cmd_complete); +read_rssi_complete (index, ptr);break ; }; }
@@ -3178,6 +3197,25 @@ static int hciops_read_clock(int index, bdaddr_t *bdaddr, int which,return 0 ; } +static int hciops_read_rssi (int index,bdaddr_t *bdaddr) +{ +struct dev_info *dev = &devs[index]; +uint16_t handle; +int err; + + err =get_handle (index, bdaddr, &handle); +if (err <0 ) +return err; + + err =hci_send_cmd (dev->sk,OGF_STATUS_PARAM ,OCF_READ_RSSI , +sizeof (handle), &handle); + +if (err <0 ) +return -errno; + +return 0 ; +} +static int hciops_read_tx_power (int index,bdaddr_t *bdaddr) {struct dev_info *dev = &devs[index];
@@ -3706,6 +3744,7 @@ static struct btd_adapter_ops hci_ops = { .set_dev_class = hciops_set_dev_class, .set_fast_connectable = hciops_fast_connectable, .read_clock = hciops_read_clock, + .read_rssi = hciops_read_rssi, .read_tx_power = hciops_read_tx_power, .read_bdaddr = hciops_read_bdaddr, .block_device = hciops_block_device,
plugins/mgmtops.c +11 -0
@@ -1673,6 +1673,16 @@ static int mgmt_read_clock(int index, bdaddr_t *bdaddr, int which, int timeout,return -ENOSYS ; } +static int mgmt_read_rssi (int index,bdaddr_t *bdaddr) +{ +char addr[18 ]; + +ba2str (bdaddr, addr); +DBG ("index %d addr %s" , index, addr); + +return -ENOSYS ; +} +static int mgmt_read_tx_power (int index,bdaddr_t *bdaddr) {char addr[18 ];
@@ -2026,6 +2036,7 @@ static struct btd_adapter_ops mgmt_ops = { .set_dev_class = mgmt_set_dev_class, .set_fast_connectable = mgmt_fast_connectable, .read_clock = mgmt_read_clock, + .read_rssi = mgmt_read_rssi, .read_tx_power = mgmt_read_tx_power, .read_bdaddr = mgmt_read_bdaddr, .block_device = mgmt_block_device,
src/adapter.h +1 -0
@@ -182,6 +182,7 @@ struct btd_adapter_ops {int (*set_fast_connectable) (int index,gboolean enable);int (*read_clock) (int index,bdaddr_t *bdaddr,int which,int timeout,uint32_t *clock,uint16_t *accuracy); +int (*read_rssi) (int index,bdaddr_t *bdaddr);int (*read_tx_power) (int index,bdaddr_t *bdaddr);int (*read_bdaddr) (int index,bdaddr_t *bdaddr);int (*block_device) (int index,bdaddr_t *bdaddr);
src/event.c +8 -0
@@ -483,3 +483,11 @@ void btd_event_txpower_read(bdaddr_t *local, bdaddr_t *peer, int8_t level)ba2str (peer, peer_addr);DBG ("%s TX Power: %d" , peer_addr, level); } + +void btd_event_rssi_read (bdaddr_t *local,bdaddr_t *peer,int8_t rssi) +{ +char peer_addr[18 ]; + +ba2str (peer, peer_addr); +DBG ("%s RSSI: %d" , peer_addr, rssi); +}
src/event.h +1 -0
@@ -41,3 +41,4 @@ int btd_event_user_notify(bdaddr_t *sba, bdaddr_t *dba, uint32_t passkey);int btd_event_link_key_notify (bdaddr_t *local,bdaddr_t *peer,uint8_t *key,uint8_t key_type,uint8_t pin_length);void btd_event_txpower_read (bdaddr_t *local,bdaddr_t *peer,int8_t level); +void btd_event_rssi_read (bdaddr_t *local,bdaddr_t *peer,int8_t rssi);
Signature · 1 line
1.7.4.1
RFC 3/7 Add RSSI read callbacks
In reply to a message not in the archiveFrom: Claudio Takahasi <[email protected]>
Implements the adapter callback registration to allow asynchronous tracking of the RSSI of an active connection.
--- src/adapter.c | 105 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/adapter.h | 13 +++++++ src/event.c | 9 +++-- 3 files changed, 124 insertions(+), 3 deletions(-)
src/adapter.c +105 -0
@@ -79,6 +79,8 @@#define OFF_TIMER 3 +#define READ_RSSI_INTERVAL 2 +static DBusConnection *connection =NULL ;static GSList *adapter_drivers =NULL ;
@@ -104,6 +106,13 @@ struct service_auth {struct btd_adapter *adapter; }; +struct rssi_callback { +guint id; +btd_adapter_rssi_cb cb; +bdaddr_t bdaddr; +gpointer user_data; +}; +struct btd_adapter {uint16_t dev_id;int up;
@@ -151,6 +160,9 @@ struct btd_adapter {gboolean name_stored;GSList *loaded_drivers; + +GSList *rssi_callbacks; +gint rssi_id; }; static void adapter_set_pairable_timeout(struct btd_adapter *adapter,
@@ -2663,6 +2675,13 @@ void adapter_remove(struct btd_adapter *adapter)/* Return adapter to down state if it was not up on init */ adapter_ops->restore_powered (adapter->dev_id); +g_slist_free (adapter->rssi_callbacks); + +if (adapter->rssi_id) { +g_source_remove (adapter->rssi_id); + adapter->rssi_id =0 ; + } +btd_adapter_unref (adapter); }
@@ -3573,6 +3592,92 @@ void btd_adapter_unregister_powered_callback(struct btd_adapter *adapter,g_slist_remove (adapter->powered_callbacks, cb); } +static gint rssi_id_cmp (gconstpointer a,gconstpointer b) +{ +const struct rssi_callback *rssicb = a; +guint id =GPOINTER_TO_UINT (b); + +return rssicb->id - id; +} + +void adapter_read_rssi_complete (struct btd_adapter *adapter,bdaddr_t *dba, +int8_t rssi) +{ +struct rssi_callback *rssicb; +GSList *list; + +for (list = adapter->rssi_callbacks; list; list = list->next) { + rssicb = list->data; + +if (bacmp (&rssicb->bdaddr, dba)) +continue ; + + rssicb->cb (adapter, rssi, rssicb->user_data); + } +} + +static gboolean read_rssi (gpointer user_data) +{ +struct btd_adapter *adapter = user_data; +struct rssi_callback *rssicb; +GSList *list; + +for (list = adapter->rssi_callbacks; list; list = list->next) { + rssicb = list->data; + adapter_ops->read_rssi (adapter->dev_id, &rssicb->bdaddr); + } + +return TRUE; +} + +guint btd_adapter_register_rssi_callback (struct btd_adapter *adapter, +bdaddr_t *bda,btd_adapter_rssi_cb cb, +gpointer user_data) +{ +struct rssi_callback *rssicb; +static guint rssi_counter =0 ; + + rssicb = g_new0(struct rssi_callback, 1); + + rssicb->id = ++rssi_counter; + rssicb->cb = cb; +bacpy (&rssicb->bdaddr, bda); + rssicb->user_data = user_data; + +if (adapter->rssi_callbacks ==NULL ) + adapter->rssi_id =g_timeout_add_seconds (READ_RSSI_INTERVAL , + read_rssi, adapter); + + adapter->rssi_callbacks = +g_slist_append (adapter->rssi_callbacks, rssicb); + +return rssicb->id; +} + +gboolean btd_adapter_unregister_rssi_callback (struct btd_adapter *adapter,guint id) +{ +struct rssi_callback *rssicb; +GSList *list; + + list =g_slist_find_custom (adapter->rssi_callbacks, +GUINT_TO_POINTER (id), rssi_id_cmp); +if (!list) +return FALSE; + + rssicb = list->data; + + adapter->rssi_callbacks =g_slist_remove (adapter->rssi_callbacks, + rssicb); +g_free (rssicb); + +if (adapter->rssi_callbacks ==NULL ) { +g_source_remove (adapter->rssi_id); + adapter->rssi_id =0 ; + } + +return TRUE; +} +int btd_adapter_set_fast_connectable (struct btd_adapter *adapter,gboolean enable) {
src/adapter.h +13 -0
@@ -132,6 +132,9 @@ gboolean adapter_has_discov_sessions(struct btd_adapter *adapter);void adapter_suspend_discovery (struct btd_adapter *adapter);void adapter_resume_discovery (struct btd_adapter *adapter); +void adapter_read_rssi_complete (struct btd_adapter *adapter,bdaddr_t *dba, +int8_t rssi); +struct btd_adapter *btd_adapter_ref (struct btd_adapter *adapter);void btd_adapter_unref (struct btd_adapter *adapter);
@@ -220,11 +223,21 @@ int adapter_ops_setup(void);typedef void (*btd_adapter_powered_cb ) (struct btd_adapter *adapter,gboolean powered); + +typedef void (*btd_adapter_rssi_cb ) (struct btd_adapter *adapter, +int8_t rssi,gpointer user_data); +void btd_adapter_register_powered_callback (struct btd_adapter *adapter,btd_adapter_powered_cb cb);void btd_adapter_unregister_powered_callback (struct btd_adapter *adapter,btd_adapter_powered_cb cb); +guint btd_adapter_register_rssi_callback (struct btd_adapter *adapter, +bdaddr_t *dba,btd_adapter_rssi_cb cb, +gpointer user_data); + +gboolean btd_adapter_unregister_rssi_callback (struct btd_adapter *adapter, +guint id);/* If TRUE, enables fast connectabe, i.e. reduces page scan interval and changes * type. If FALSE, disables fast connectable, i.e. sets page scan interval and * type to default values. Valid for both connectable and discoverable modes. */
src/event.c +6 -3
@@ -486,8 +486,11 @@ void btd_event_txpower_read(bdaddr_t *local, bdaddr_t *peer, int8_t level)void btd_event_rssi_read (bdaddr_t *local,bdaddr_t *peer,int8_t rssi) { -char peer_addr[18 ]; +struct btd_adapter *adapter; -ba2str (peer, peer_addr); -DBG ("%s RSSI: %d" , peer_addr, rssi); + adapter =manager_find_adapter (local); +if (!adapter) +return ; + +adapter_read_rssi_complete (adapter, peer, rssi); }
Signature · 1 line
1.7.4.1
RFC 4/7 Add transmission power callbacks
In reply to a message not in the archiveFrom: Claudio Takahasi <[email protected]>
Implements the adapter TX power reading for active connections.
--- src/adapter.c | 125 +++++++++++++++++++++++++++++++++++++++++++++++++++------ src/adapter.h | 16 ++++++- src/event.c | 7 +++ 3 files changed, 132 insertions(+), 16 deletions(-)
src/adapter.c +112 -13
@@ -80,6 +80,7 @@#define OFF_TIMER 3#define READ_RSSI_INTERVAL 2 +#define READ_TXPOWER_INTERVAL 2static DBusConnection *connection =NULL ;static GSList *adapter_drivers =NULL ;
@@ -106,9 +107,9 @@ struct service_auth {struct btd_adapter *adapter; }; -struct rssi_callback { +struct read_callback {guint id; -btd_adapter_rssi_cb cb; +btd_adapter_read_cb cb;bdaddr_t bdaddr;gpointer user_data; };
@@ -163,6 +164,9 @@ struct btd_adapter {GSList *rssi_callbacks;gint rssi_id; + +GSList *txpower_callbacks; +gint txpower_id; }; static void adapter_set_pairable_timeout(struct btd_adapter *adapter,
@@ -2676,12 +2680,18 @@ void adapter_remove(struct btd_adapter *adapter) adapter_ops->restore_powered (adapter->dev_id);g_slist_free (adapter->rssi_callbacks); +g_slist_free (adapter->txpower_callbacks);if (adapter->rssi_id) {g_source_remove (adapter->rssi_id); adapter->rssi_id =0 ; } +if (adapter->txpower_id) { +g_source_remove (adapter->txpower_id); + adapter->txpower_id =0 ; + } +btd_adapter_unref (adapter); }
@@ -3592,23 +3602,22 @@ void btd_adapter_unregister_powered_callback(struct btd_adapter *adapter,g_slist_remove (adapter->powered_callbacks, cb); } -static gint rssi_id_cmp (gconstpointer a,gconstpointer b) +static gint callback_id_cmp (gconstpointer a,gconstpointer b) { -const struct rssi_callback *rssicb = a; +const struct read_callback *cb = a;guint id =GPOINTER_TO_UINT (b); -return rssicb->id - id; +return cb->id - id; }void adapter_read_rssi_complete (struct btd_adapter *adapter,bdaddr_t *dba,int8_t rssi) { -struct rssi_callback *rssicb; +struct read_callback *rssicb;GSList *list;for (list = adapter->rssi_callbacks; list; list = list->next) { rssicb = list->data; -if (bacmp (&rssicb->bdaddr, dba))continue ;
@@ -3616,10 +3625,26 @@ void adapter_read_rssi_complete(struct btd_adapter *adapter, bdaddr_t *dba, } } +void adapter_read_txpower_complete (struct btd_adapter *adapter,bdaddr_t *dba, +int8_t level) +{ +struct read_callback *txpowercb; +GSList *list; + +for (list = adapter->txpower_callbacks; list; list = list->next) { + txpowercb = list->data; + +if (bacmp (&txpowercb->bdaddr, dba)) +continue ; + + txpowercb->cb (adapter, level, txpowercb->user_data); + } +} +static gboolean read_rssi (gpointer user_data) {struct btd_adapter *adapter = user_data; -struct rssi_callback *rssicb; +struct read_callback *rssicb;GSList *list;for (list = adapter->rssi_callbacks; list; list = list->next) {
@@ -3631,13 +3656,13 @@ static gboolean read_rssi(gpointer user_data) }guint btd_adapter_register_rssi_callback (struct btd_adapter *adapter, -bdaddr_t *bda,btd_adapter_rssi_cb cb, +bdaddr_t *bda,btd_adapter_read_cb cb,gpointer user_data) { -struct rssi_callback *rssicb; +struct read_callback *rssicb;static guint rssi_counter =0 ; - rssicb = g_new0(struct rssi_callback, 1); + rssicb = g_new0(struct read_callback, 1); rssicb->id = ++rssi_counter; rssicb->cb = cb;
@@ -3656,11 +3681,11 @@ guint btd_adapter_register_rssi_callback(struct btd_adapter *adapter,gboolean btd_adapter_unregister_rssi_callback (struct btd_adapter *adapter,guint id) { -struct rssi_callback *rssicb; +struct read_callback *rssicb;GSList *list; list =g_slist_find_custom (adapter->rssi_callbacks, -GUINT_TO_POINTER (id), rssi_id_cmp); +GUINT_TO_POINTER (id), callback_id_cmp);if (!list)return FALSE;
@@ -3678,6 +3703,80 @@ gboolean btd_adapter_unregister_rssi_callback(struct btd_adapter *adapter, guintreturn TRUE; } +static gboolean read_txpower (gpointer user_data) +{ +struct btd_adapter *adapter = user_data; +struct read_callback *txpowercb; +GSList *list; + +for (list = adapter->txpower_callbacks; list; list = list->next) { + txpowercb = list->data; + adapter_ops->read_tx_power (adapter->dev_id, + &txpowercb->bdaddr); + } + +return TRUE; +} + +guint btd_adapter_register_txpower_callback (struct btd_adapter *adapter, +bdaddr_t *bda, +btd_adapter_read_cb cb, +gpointer user_data) +{ +struct read_callback *txpowercb; +static guint txpower_counter =0 ; + + txpowercb = g_new0(struct read_callback, 1); + + txpowercb->id = ++txpower_counter; + txpowercb->cb = cb; +bacpy (&txpowercb->bdaddr, bda); + txpowercb->user_data = user_data; + +if (adapter->txpower_callbacks ==NULL ) + adapter->txpower_id =g_timeout_add_seconds ( +READ_TXPOWER_INTERVAL , + read_txpower, adapter); + + adapter->txpower_callbacks = +g_slist_append (adapter->txpower_callbacks, txpowercb); + +return txpowercb->id; +} + +static gint txpower_id_cmp (gconstpointer a,gconstpointer b) +{ +const struct read_callback *txpowercb = a; +guint id =GPOINTER_TO_UINT (b); + +return txpowercb->id - id; +} + +gboolean btd_adapter_unregister_txpower_callback (struct btd_adapter *adapter, +guint id) +{ +struct read_callback *txpowercb; +GSList *list; + + list =g_slist_find_custom (adapter->txpower_callbacks, +GUINT_TO_POINTER (id), txpower_id_cmp); +if (!list) +return FALSE; + + txpowercb = list->data; + + adapter->txpower_callbacks =g_slist_remove (adapter->txpower_callbacks, + txpowercb); +g_free (txpowercb); + +if (adapter->txpower_callbacks ==NULL ) { +g_source_remove (adapter->txpower_id); + adapter->txpower_id =0 ; + } + +return TRUE; +} +int btd_adapter_set_fast_connectable (struct btd_adapter *adapter,gboolean enable) {
src/adapter.h +13 -3
@@ -134,6 +134,8 @@ void adapter_resume_discovery(struct btd_adapter *adapter);void adapter_read_rssi_complete (struct btd_adapter *adapter,bdaddr_t *dba,int8_t rssi); +void adapter_read_txpower_complete (struct btd_adapter *adapter,bdaddr_t *dba, +int8_t level);struct btd_adapter *btd_adapter_ref (struct btd_adapter *adapter);void btd_adapter_unref (struct btd_adapter *adapter);
@@ -224,8 +226,8 @@ int adapter_ops_setup(void);typedef void (*btd_adapter_powered_cb ) (struct btd_adapter *adapter,gboolean powered); -typedef void (*btd_adapter_rssi_cb ) (struct btd_adapter *adapter, -int8_t rssi,gpointer user_data); +typedef void (*btd_adapter_read_cb ) (struct btd_adapter *adapter, +int8_t level,gpointer user_data);void btd_adapter_register_powered_callback (struct btd_adapter *adapter,btd_adapter_powered_cb cb);
@@ -233,11 +235,19 @@ void btd_adapter_unregister_powered_callback(struct btd_adapter *adapter, btd_adapter_powered_cb cb);guint btd_adapter_register_rssi_callback (struct btd_adapter *adapter, -bdaddr_t *dba,btd_adapter_rssi_cb cb, +bdaddr_t *dba,btd_adapter_read_cb cb,gpointer user_data);gboolean btd_adapter_unregister_rssi_callback (struct btd_adapter *adapter,guint id); + +guint btd_adapter_register_txpower_callback (struct btd_adapter *adapter, +bdaddr_t *dba, +btd_adapter_read_cb cb, +gpointer user_data); +gboolean btd_adapter_unregister_txpower_callback (struct btd_adapter *adapter, +guint id); +/* If TRUE, enables fast connectabe, i.e. reduces page scan interval and changes * type. If FALSE, disables fast connectable, i.e. sets page scan interval and * type to default values. Valid for both connectable and discoverable modes. */
src/event.c +7 -0
@@ -478,10 +478,17 @@ void btd_event_returned_link_key(bdaddr_t *local, bdaddr_t *peer)void btd_event_txpower_read (bdaddr_t *local,bdaddr_t *peer,int8_t level) { +struct btd_adapter *adapter;char peer_addr[18 ];ba2str (peer, peer_addr);DBG ("%s TX Power: %d" , peer_addr, level); + + adapter =manager_find_adapter (local); +if (!adapter) +return ; + +adapter_read_txpower_complete (adapter, peer, level); }void btd_event_rssi_read (bdaddr_t *local,bdaddr_t *peer,int8_t rssi)
Signature · 1 line
1.7.4.1
RFC 5/7 Implement mgmt_read_rssi command
In reply to a message not in the archiveFrom: Anderson Briglia <[email protected]>
This patch implements Read RSSI command in management interface.
--- lib/mgmt.h | 10 ++++++++++ plugins/mgmtops.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 56 insertions(+), 4 deletions(-)
lib/mgmt.h +10 -0
@@ -205,6 +205,16 @@ struct mgmt_cp_remove_remote_oob_data {#define MGMT_OP_STOP_DISCOVERY 0x001C +#define MGMT_OP_READ_RSSI 0x001D +struct mgmt_cp_read_rssi { +bdaddr_t bdaddr; +} __packed; +struct mgmt_rp_read_rssi { +uint8_t status; +bdaddr_t bdaddr; +int8_t rssi; +} __packed; +#define MGMT_EV_CMD_COMPLETE 0x0001struct mgmt_ev_cmd_complete {uint16_t opcode;
plugins/mgmtops.c +46 -4
70 lines not on this page · raw message
Signature · 1 line
1.7.4.1
RFC 6/7 Implement mgmt_read_tx_power command
In reply to a message not in the archiveFrom: Bruna Moreira <[email protected]>
This patch implements a new command to read the TX power of an active connection asynchronously in the management interface.
--- lib/mgmt.h | 10 ++++++++++ plugins/mgmtops.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 56 insertions(+), 4 deletions(-)
lib/mgmt.h +10 -0
@@ -215,6 +215,16 @@ struct mgmt_rp_read_rssi {int8_t rssi; } __packed; +#define MGMT_OP_READ_TX_POWER_LEVEL 0x001E +struct mgmt_cp_read_tx_power_level { +bdaddr_t bdaddr; +} __packed; +struct mgmt_rp_read_tx_power_level { +uint8_t status; +bdaddr_t bdaddr; +int8_t level; +} __packed; +#define MGMT_EV_CMD_COMPLETE 0x0001struct mgmt_ev_cmd_complete {uint16_t opcode;
plugins/mgmtops.c +46 -4
70 lines not on this page · raw message
Signature · 1 line
1.7.4.1
RFC 7/7 Update Management API documentation
In reply to a message not in the archiveFrom: Bruna Moreira <[email protected]>
Add Read RSSI and Read TX Power level commands in Management API documentation.
--- doc/mgmt-api.txt | 20 ++++++++++++++++++++ 1 files changed, 20 insertions(+), 0 deletions(-)
doc/mgmt-api.txt +20 -0
@@ -319,6 +319,26 @@ Stop Discovery Command Command Parameters: Return Parameters: +Read RSSI Command +================= + + Command Code: 0x001D + Controller Index: <controller id> + Command Parameters: Address (6 Octets) + Return Parameters: Status (1 Octet) + Address (6 Octets) + RSSI (1 Octet) + +Read TX Power Level Command +=========================== + + Command Code: 0x001E + Controller Index: <controller id> + Command Parameters: Address (6 Octets) + Return Parameters: Address (6 Octets) + Status (1 Octet) + Level (1 Octet) + Read Tracing Buffer Size Command ================================
Signature · 1 line
1.7.4.1
Marcel Holtmann
maintainerRe: [RFC 7/7] Update Management API documentation
Hi Anderson,
Quoted 24 lines
Add Read RSSI and Read TX Power level commands in Management API documentation.
--- doc/mgmt-api.txt | 20 ++++++++++++++++++++ 1 files changed, 20 insertions(+), 0 deletions(-)doc/mgmt-api.txt +10
-0@@ -319,6 +319,26 @@ Stop Discovery Command Command Parameters: Return Parameters: +Read RSSI Command +================= + + Command Code: 0x001D + Controller Index: <controller id> + Command Parameters: Address (6 Octets) + Return Parameters: Status (1 Octet) + Address (6 Octets) + RSSI (1 Octet) +
doc/mgmt-api.txt Stop Discovery Command · line 341
Quoted 10 lines
doc/mgmt-api.txt +10
-0+Read TX Power Level Command +=========================== + + Command Code: 0x001E + Controller Index: <controller id> + Command Parameters: Address (6 Octets) + Return Parameters: Address (6 Octets) + Status (1 Octet) + Level (1 Octet) +
so why are these two separate commands. Just reading them in one kernel call might be a lot better. Including everything else you need to know about the connection. Also TX power can be local and remote TX power if I remember this correctly.
Regards
Marcel
Re: [RFC 7/7] Update Management API documentation
Hi Marcel,
Quoted 4 lines · Marcel Holtmann
so why are these two separate commands. Just reading them in one kernel call might be a lot better. Including everything else you need to know about the connection. Also TX power can be local and remote TX power if I remember this correctly.
The issue I see with your proposal is that for Proximity (currently the only user of this information) we read TX power from server (reporter) using GATT, while RSSI is read on client (monitor) side. By reading both, we would need to issue two separate HCI commands (and wait for both responses), but will always use only one value, depending on local BlueZ role.
Also note that on latest Proximity profile drafts, it is mentioned that the TX power on reporter will never change during a connection, and thus it should be read only once when the connection is established. RSSI (which is read "locally" on monitor side), on the other hand, should be read periodically for path loss calculation.
Regards,
Signature · 3 lines
Anderson Lizardo Instituto Nokia de Tecnologia - INdT Manaus - Brazil
Marcel Holtmann
maintainerRe: [RFC 7/7] Update Management API documentation
Hi Anderson,
Quoted 12 lines
Quoted 4 lines
so why are these two separate commands. Just reading them in one kernel call might be a lot better. Including everything else you need to know about the connection. Also TX power can be local and remote TX power if I remember this correctly.
The issue I see with your proposal is that for Proximity (currently the only user of this information) we read TX power from server (reporter) using GATT, while RSSI is read on client (monitor) side. By reading both, we would need to issue two separate HCI commands (and wait for both responses), but will always use only one value, depending on local BlueZ role.
Quoted 5 lines
Also note that on latest Proximity profile drafts, it is mentioned that the TX power on reporter will never change during a connection, and thus it should be read only once when the connection is established. RSSI (which is read "locally" on monitor side), on the other hand, should be read periodically for path loss calculation.
if TX power is only read once than the kernel should just do it once and be done with it.
And for RSSI, it would be better if the kernel read this periodically based on current sniff mode etc. Userspace can not trigger this with proper timing anyway. And it will potentially at some point start blocking the controller. Only the kernel really knows when it is acceptable to read the RSSI value.
Regards
Marcel
RE: [RFC 7/7] Update Management API documentation
PiAtLS0tLU9yaWdpbmFsIE1lc3NhZ2UtLS0tLQ0KPiBGcm9tOiBsaW51eC1ibHVldG9vdGgtb3du ZXJAdmdlci5rZXJuZWwub3JnIFttYWlsdG86bGludXgtYmx1ZXRvb3RoLQ0KPiBvd25lckB2Z2Vy Lmtlcm5lbC5vcmddIE9uIEJlaGFsZiBPZiBNYXJjZWwgSG9sdG1hbm4NCj4gU2VudDogVGh1cnNk YXksIEp1bmUgMTYsIDIwMTEgNToyOSBBTQ0KPiBUbzogQW5kZXJzb24gTGl6YXJkbw0KPiBDYzog YW5kZXJzb24uYnJpZ2xpYUBvcGVuYm9zc2Eub3JnOyBsaW51eC1ibHVldG9vdGhAdmdlci5rZXJu ZWwub3JnOw0KPiBCcnVuYSBNb3JlaXJhDQo+IFN1YmplY3Q6IFJlOiBbUkZDIDcvN10gVXBkYXRl IE1hbmFnZW1lbnQgQVBJIGRvY3VtZW50YXRpb24NCj4gDQo+IEhpIEFuZGVyc29uLA0KPiANCj4g PiA+IHNvIHdoeSBhcmUgdGhlc2UgdHdvIHNlcGFyYXRlIGNvbW1hbmRzLiBKdXN0IHJlYWRpbmcg dGhlbSBpbiBvbmUNCj4ga2VybmVsDQo+ID4gPiBjYWxsIG1pZ2h0IGJlIGEgbG90IGJldHRlci4g SW5jbHVkaW5nIGV2ZXJ5dGhpbmcgZWxzZSB5b3UgbmVlZCB0bw0KPiBrbm93DQo+ID4gPiBhYm91 dCB0aGUgY29ubmVjdGlvbi4gQWxzbyBUWCBwb3dlciBjYW4gYmUgbG9jYWwgYW5kIHJlbW90ZSBU WA0KPiBwb3dlciBpZg0KPiA+ID4gSSByZW1lbWJlciB0aGlzIGNvcnJlY3RseS4NCj4gPg0KPiA+ IFRoZSBpc3N1ZSBJIHNlZSB3aXRoIHlvdXIgcHJvcG9zYWwgaXMgdGhhdCBmb3IgUHJveGltaXR5 IChjdXJyZW50bHkNCj4gPiB0aGUgb25seSB1c2VyIG9mIHRoaXMgaW5mb3JtYXRpb24pIHdlIHJl YWQgVFggcG93ZXIgZnJvbSBzZXJ2ZXINCj4gPiAocmVwb3J0ZXIpIHVzaW5nIEdBVFQsIHdoaWxl IFJTU0kgaXMgcmVhZCBvbiBjbGllbnQgKG1vbml0b3IpIHNpZGUuDQo+IEJ5DQo+ID4gcmVhZGlu ZyBib3RoLCB3ZSB3b3VsZCBuZWVkIHRvIGlzc3VlIHR3byBzZXBhcmF0ZSBIQ0kgY29tbWFuZHMg KGFuZA0KPiA+IHdhaXQgZm9yIGJvdGggcmVzcG9uc2VzKSwgYnV0IHdpbGwgYWx3YXlzIHVzZSBv bmx5IG9uZSB2YWx1ZSwNCj4gPiBkZXBlbmRpbmcgb24gbG9jYWwgQmx1ZVogcm9sZS4NCj4gPg0K PiA+IEFsc28gbm90ZSB0aGF0IG9uIGxhdGVzdCBQcm94aW1pdHkgcHJvZmlsZSBkcmFmdHMsIGl0 IGlzIG1lbnRpb25lZA0KPiA+IHRoYXQgdGhlIFRYIHBvd2VyIG9uIHJlcG9ydGVyIHdpbGwgbmV2 ZXIgY2hhbmdlIGR1cmluZyBhIGNvbm5lY3Rpb24sDQo+ID4gYW5kIHRodXMgaXQgc2hvdWxkIGJl IHJlYWQgb25seSBvbmNlIHdoZW4gdGhlIGNvbm5lY3Rpb24gaXMNCj4gPiBlc3RhYmxpc2hlZC4g UlNTSSAod2hpY2ggaXMgcmVhZCAibG9jYWxseSIgb24gbW9uaXRvciBzaWRlKSwgb24gdGhlDQo+ ID4gb3RoZXIgaGFuZCwgc2hvdWxkIGJlIHJlYWQgcGVyaW9kaWNhbGx5IGZvciBwYXRoIGxvc3Mg Y2FsY3VsYXRpb24uDQo+IA0KPiBpZiBUWCBwb3dlciBpcyBvbmx5IHJlYWQgb25jZSB0aGFuIHRo ZSBrZXJuZWwgc2hvdWxkIGp1c3QgZG8gaXQgb25jZQ0KPiBhbmQNCj4gYmUgZG9uZSB3aXRoIGl0 Lg0KPiANCj4gQW5kIGZvciBSU1NJLCBpdCB3b3VsZCBiZSBiZXR0ZXIgaWYgdGhlIGtlcm5lbCBy ZWFkIHRoaXMgcGVyaW9kaWNhbGx5DQo+IGJhc2VkIG9uIGN1cnJlbnQgc25pZmYgbW9kZSBldGMu IFVzZXJzcGFjZSBjYW4gbm90IHRyaWdnZXIgdGhpcyB3aXRoDQo+IHByb3BlciB0aW1pbmcgYW55 d2F5LiBBbmQgaXQgd2lsbCBwb3RlbnRpYWxseSBhdCBzb21lIHBvaW50IHN0YXJ0DQo+IGJsb2Nr aW5nIHRoZSBjb250cm9sbGVyLiBPbmx5IHRoZSBrZXJuZWwgcmVhbGx5IGtub3dzIHdoZW4gaXQg aXMNCj4gYWNjZXB0YWJsZSB0byByZWFkIHRoZSBSU1NJIHZhbHVlLg0KPiANCj4gUmVnYXJkcw0K PiANCj4gTWFyY2VsDQo+IA0KPiANCg0KTWFyY2VsLA0KDQpSZWFkaW5nIHRoZSBSU1NJIGJ5IHRo ZSBrZXJuZWwsIHdpbGwgZm9yY2UgYSBjZXJ0YWluIGxpbWl0YXRpb24gb24gdGhlIA0KY3VycmVu dCBhbmQgZnV0dXJlIFByb2ZpbGVzLiBJIGJlbGlldmUgc2V0dGluZyB0aGUgdGltaW5nIHNob3Vs ZCBiZSBkb25lIA0KYnkgdGhlIHByb2ZpbGUgaXRzZWxmLCBub3QgdGhlIGJsdWV6IHVzZXIgc3Bh Y2UgY29kZSBvciB0aGUga2VybmVsLiBJdCANCmlzIHRoZSByZXNwb25zaWJpbGl0eSBvZiB0aGUg cHJvZmlsZSB0byBwZXJpb2RpY2FsbHkgcG9sbCB0aGUgUlNTSSBMZXZlbC4NCkZvciBzb21lIGNh c2VzLCBwb2xsaW5nIGl0IGV2ZXJ5IDUgc2Vjb25kcyB3b3VsZCBiZSBvaywgYW5kIGZvciBzb21l IA0KT3RoZXJzLCBpdCBtYXkgYmUgYmV0dGVyIHRvIHJlYWQgaXQgZXZlcnkgc2Vjb25kLiBJIGJl bGlldmUgd2UgbXVzdCBub3QgDQppbXBvc2UgYW55IGxpbWl0YXRpb24gaGVyZS4NCg0KSW4gYWRk aXRpb24sIFJTU0kgbGV2ZWxzIG1heSBub3QgYWx3YXlzIGJlIHJlcXVpcmVkIC0gc28gd2h5IHNo b3VsZCB0aGUgDQpLZXJuZWwgcmVhZCB0aG9zZSB2YWx1ZXMgYW5kIHdhc3RlIGJhbmR3aWR0aD8N Cg0KVGhhbmtzLA0KQ2hlbiBHYW5pci4NCg0K
Luiz Augusto von Dentz
maintainerRe: [RFC 7/7] Update Management API documentation
Hi,
Quoted 19 lines · Chen
Quoted 11 lines
if TX power is only read once than the kernel should just do it once and
be done with it.And for RSSI, it would be better if the kernel read this periodically based on current sniff mode etc. Userspace can not trigger this with proper timing anyway. And it will potentially at some point start blocking the controller. Only the kernel really knows when it is acceptable to read the RSSI value.
Quoted 5 lines
Regards
Marcel
Marcel,
Quoted 7 lines
Reading the RSSI by the kernel, will force a certain limitation on the current and future Profiles. I believe setting the timing should be done by the profile itself, not the bluez user space code or the kernel. It is the responsibility of the profile to periodically poll the RSSI Level. For some cases, polling it every 5 seconds would be ok, and for some Others, it may be better to read it every second. I believe we must not impose any limitation here.
You probably forgot that besides bluetoothd there should be no other application holding the mgmt socket, so not you can't really do it in poll in the application side and doing it over D-Bus is overkill. Also I notice that from some parties, you include, there is some tendency to have the profiles split from the bluetoothd, IMO this will only add fragmentation with each and every platform using BlueZ having their own implementation of each profile and not sharing much, making the IOP a complete mess.
Signature · 1 line
Luiz Augusto von Dentz
Re: [RFC 7/7] Update Management API documentation
Hi,
Quoted 40 lines · Luiz Augusto von Dentz
Hi,
Quoted 19 lines · Chen
Quoted 11 lines
if TX power is only read once than the kernel should just do it once and
be done with it.And for RSSI, it would be better if the kernel read this periodically based on current sniff mode etc. Userspace can not trigger this with proper timing anyway. And it will potentially at some point start blocking the controller. Only the kernel really knows when it is acceptable to read the RSSI value.
Quoted 5 lines
Regards
Marcel
Marcel,
Quoted 7 lines
Reading the RSSI by the kernel, will force a certain limitation on the current and future Profiles. I believe setting the timing should be done by the profile itself, not the bluez user space code or the kernel. It is the responsibility of the profile to periodically poll the RSSI Level. For some cases, polling it every 5 seconds would be ok, and for some Others, it may be better to read it every second. I believe we must not impose any limitation here.
You probably forgot that besides bluetoothd there should be no other application holding the mgmt socket, so not you can't really do it in poll in the application side and doing it over D-Bus is overkill. Also I notice that from some parties, you include, there is some tendency to have the profiles split from the bluetoothd, IMO this will only add fragmentation with each and every platform using BlueZ having their own implementation of each profile and not sharing much, making the IOP a complete mess.
Quoted 3 lines
--
Luiz Augusto von Dentz
--
Some additional comments...
Health plugin will need a similar approach to read the clock. It will be good to implement the same approach.
In our suggested implementation the adapter controls when to send the command to read the RSSI, keeping the same logic for both: hciops and mgmtops. If the adapter is managing when to send the commands, repeated commands can be avoided, multiple callbacks can be registered by the profiles, but only one command to read the RSSI will be sent. The cover letter of the userspace patches contains more details how we implemented it.
Reading the RSSI directly by the kernel will break hciops. These are the arguments that I have to support our decision.
BR,
Claudio.
Marcel Holtmann
maintainerRe: [RFC 7/7] Update Management API documentation
Hi Claudio,
Quoted 40 lines
Quoted 18 lines
Quoted 10 lines
Quoted 9 lines
if TX power is only read once than the kernel should just do it once and
be done with it.And for RSSI, it would be better if the kernel read this periodically based on current sniff mode etc. Userspace can not trigger this with proper timing anyway. And it will potentially at some point start blocking the controller. Only the kernel really knows when it is acceptable to read the RSSI value.
Quoted 7 lines
Reading the RSSI by the kernel, will force a certain limitation on the current and future Profiles. I believe setting the timing should be done by the profile itself, not the bluez user space code or the kernel. It is the responsibility of the profile to periodically poll the RSSI Level. For some cases, polling it every 5 seconds would be ok, and for some Others, it may be better to read it every second. I believe we must not impose any limitation here.
Quoted 9 lines
You probably forgot that besides bluetoothd there should be no other application holding the mgmt socket, so not you can't really do it in poll in the application side and doing it over D-Bus is overkill. Also I notice that from some parties, you include, there is some tendency to have the profiles split from the bluetoothd, IMO this will only add fragmentation with each and every platform using BlueZ having their own implementation of each profile and not sharing much, making the IOP a complete mess.
Some additional comments...
Health plugin will need a similar approach to read the clock. It will be good to implement the same approach.
In our suggested implementation the adapter controls when to send the command to read the RSSI, keeping the same logic for both: hciops and mgmtops. If the adapter is managing when to send the commands, repeated commands can be avoided, multiple callbacks can be registered by the profiles, but only one command to read the RSSI will be sent. The cover letter of the userspace patches contains more details how we implemented it.
Quoted 2 lines
Reading the RSSI directly by the kernel will break hciops. These are the arguments that I have to support our decision.
what I am hearing is that we want the kernel to poll for certain information if userspace needs them. And either it is a one-shot poll or it is on a regular interval.
The management interface will be primarily used by bluetoothd, but it is open for other users as well. Mainly some low-level system tools or more important qualification tools.
So triggering certain actions from userspace is always tricky and then we need to have bluetoothd sync with itself, its plugins etc. So I rather prefer that we tell the kernel which pollable information to read at which interval and then just get a notification if they have changed. Let the kernel do its job without having to wakeup half of userspace to make a simple decision to poll a value.
And don't get me wrong, the stupid Bluetooth chip should be able to poll this value with an interval natively. The best we can do is emulate that in the kernel.
Regards
Marcel
Re: [RFC 7/7] Update Management API documentation
Hi Marcel,
Quoted 42 lines · Marcel Holtmann
Hi Claudio,
Quoted 40 lines
Quoted 18 lines
Quoted 10 lines
Quoted 9 lines
if TX power is only read once than the kernel should just do it once and
be done with it.And for RSSI, it would be better if the kernel read this periodically based on current sniff mode etc. Userspace can not trigger this with proper timing anyway. And it will potentially at some point start blocking the controller. Only the kernel really knows when it is acceptable to read the RSSI value.
Quoted 7 lines
Reading the RSSI by the kernel, will force a certain limitation on the current and future Profiles. I believe setting the timing should be done by the profile itself, not the bluez user space code or the kernel. It is the responsibility of the profile to periodically poll the RSSI Level. For some cases, polling it every 5 seconds would be ok, and for some Others, it may be better to read it every second. I believe we must not impose any limitation here.
Quoted 9 lines
You probably forgot that besides bluetoothd there should be no other application holding the mgmt socket, so not you can't really do it in poll in the application side and doing it over D-Bus is overkill. Also I notice that from some parties, you include, there is some tendency to have the profiles split from the bluetoothd, IMO this will only add fragmentation with each and every platform using BlueZ having their own implementation of each profile and not sharing much, making the IOP a complete mess.
Some additional comments...
Health plugin will need a similar approach to read the clock. It will be good to implement the same approach.
In our suggested implementation the adapter controls when to send the command to read the RSSI, keeping the same logic for both: hciops and mgmtops. If the adapter is managing when to send the commands, repeated commands can be avoided, multiple callbacks can be registered by the profiles, but only one command to read the RSSI will be sent. The cover letter of the userspace patches contains more details how we implemented it.
Quoted 6 lines
Quoted 2 lines
Reading the RSSI directly by the kernel will break hciops. These are the arguments that I have to support our decision.
what I am hearing is that we want the kernel to poll for certain information if userspace needs them. And either it is a one-shot poll or it is on a regular interval.
If everybody agree we can do it. Our objective is to have the patches upstream. To keep the Proximity Monitor functional on both adapter_ops plugins we can move part of the logic from the adapter.c to the hciops. The polling to read the RSSI can be moved to hciops, in the management the polling will be in the kernel. The remaining code to register the callbacks doesn't need to be changed.
Do you agree?
Quoted 12 lines
The management interface will be primarily used by bluetoothd, but it is open for other users as well. Mainly some low-level system tools or more important qualification tools.
So triggering certain actions from userspace is always tricky and then we need to have bluetoothd sync with itself, its plugins etc. So I rather prefer that we tell the kernel which pollable information to read at which interval and then just get a notification if they have changed. Let the kernel do its job without having to wakeup half of userspace to make a simple decision to poll a value.
Quoted 3 lines
And don't get me wrong, the stupid Bluetooth chip should be able to poll this value with an interval natively. The best we can do is emulate that in the kernel.
No problem. We will change the code and send another RFC. Do you want another channel in the BTPROTO_HCI socket or keep everything inside HCI_CHANNEL_CONTROL?
BR,
Claudio.
Quoted 5 lines
Regards
Marcel
Marcel Holtmann
maintainerRe: [RFC 7/7] Update Management API documentation
Hi Claudio,
Quoted 47 lines
Quoted 40 lines
Quoted 40 lines
Quoted 18 lines
Quoted 10 lines
Quoted 9 lines
if TX power is only read once than the kernel should just do it once and
be done with it.And for RSSI, it would be better if the kernel read this periodically based on current sniff mode etc. Userspace can not trigger this with proper timing anyway. And it will potentially at some point start blocking the controller. Only the kernel really knows when it is acceptable to read the RSSI value.
Quoted 7 lines
Reading the RSSI by the kernel, will force a certain limitation on the current and future Profiles. I believe setting the timing should be done by the profile itself, not the bluez user space code or the kernel. It is the responsibility of the profile to periodically poll the RSSI Level. For some cases, polling it every 5 seconds would be ok, and for some Others, it may be better to read it every second. I believe we must not impose any limitation here.
Quoted 9 lines
You probably forgot that besides bluetoothd there should be no other application holding the mgmt socket, so not you can't really do it in poll in the application side and doing it over D-Bus is overkill. Also I notice that from some parties, you include, there is some tendency to have the profiles split from the bluetoothd, IMO this will only add fragmentation with each and every platform using BlueZ having their own implementation of each profile and not sharing much, making the IOP a complete mess.
Some additional comments...
Health plugin will need a similar approach to read the clock. It will be good to implement the same approach.
In our suggested implementation the adapter controls when to send the command to read the RSSI, keeping the same logic for both: hciops and mgmtops. If the adapter is managing when to send the commands, repeated commands can be avoided, multiple callbacks can be registered by the profiles, but only one command to read the RSSI will be sent. The cover letter of the userspace patches contains more details how we implemented it.Quoted 6 lines
Quoted 2 lines
Reading the RSSI directly by the kernel will break hciops. These are the arguments that I have to support our decision.
what I am hearing is that we want the kernel to poll for certain information if userspace needs them. And either it is a one-shot poll or it is on a regular interval.
Quoted 7 lines
If everybody agree we can do it. Our objective is to have the patches upstream. To keep the Proximity Monitor functional on both
adapter_opsplugins we can move part of the logic from theadapter.cto the hciops. The polling to read the RSSI can be moved to hciops, in the management the polling will be in the kernel. The remaining code to register the callbacks doesn't need to be changed.
Do you agree?
I am really open for suggestion, but just duplicating HCI is not going to cut it. We have to be a lot smarter with the kernel mgmt interface.
So lets give this approach and go and see how it works out. And btw. I do not care about the hciops that much anymore. If you wanna do the hard work to make it work, fine with me.
Quoted 11 lines
Quoted 11 lines
The management interface will be primarily used by bluetoothd, but it is open for other users as well. Mainly some low-level system tools or more important qualification tools.
So triggering certain actions from userspace is always tricky and then we need to have bluetoothd sync with itself, its plugins etc. So I rather prefer that we tell the kernel which pollable information to read at which interval and then just get a notification if they have changed. Let the kernel do its job without having to wakeup half of userspace to make a simple decision to poll a value.
Quoted 7 lines
Quoted 3 lines
And don't get me wrong, the stupid Bluetooth chip should be able to poll this value with an interval natively. The best we can do is emulate that in the kernel.
No problem. We will change the code and send another RFC. Do you want another channel in the
BTPROTO_HCIsocket or keep everything insideHCI_CHANNEL_CONTROL?
It is an async event on HCI_CHANNEL_CONTROL. That is good enough for me.
Regards
Marcel
Re: [RFC 7/7] Update Management API documentation
In reply to Claudio TakahasiQuoted 52 lines · Claudio Takahasi
Hi Marcel,
Quoted 42 lines · Marcel Holtmann
Hi Claudio,
Quoted 40 lines
Quoted 18 lines
Quoted 10 lines
Quoted 9 lines
if TX power is only read once than the kernel should just do it once and
be done with it.And for RSSI, it would be better if the kernel read this periodically based on current sniff mode etc. Userspace can not trigger this with proper timing anyway. And it will potentially at some point start blocking the controller. Only the kernel really knows when it is acceptable to read the RSSI value.
Quoted 7 lines
Reading the RSSI by the kernel, will force a certain limitation on the current and future Profiles. I believe setting the timing should be done by the profile itself, not the bluez user space code or the kernel. It is the responsibility of the profile to periodically poll the RSSI Level. For some cases, polling it every 5 seconds would be ok, and for some Others, it may be better to read it every second. I believe we must not impose any limitation here.
Quoted 9 lines
You probably forgot that besides bluetoothd there should be no other application holding the mgmt socket, so not you can't really do it in poll in the application side and doing it over D-Bus is overkill. Also I notice that from some parties, you include, there is some tendency to have the profiles split from the bluetoothd, IMO this will only add fragmentation with each and every platform using BlueZ having their own implementation of each profile and not sharing much, making the IOP a complete mess.
Some additional comments...
Health plugin will need a similar approach to read the clock. It will be good to implement the same approach.
In our suggested implementation the adapter controls when to send the command to read the RSSI, keeping the same logic for both: hciops and mgmtops. If the adapter is managing when to send the commands, repeated commands can be avoided, multiple callbacks can be registered by the profiles, but only one command to read the RSSI will be sent. The cover letter of the userspace patches contains more details how we implemented it.Quoted 6 lines
Quoted 2 lines
Reading the RSSI directly by the kernel will break hciops. These are the arguments that I have to support our decision.
what I am hearing is that we want the kernel to poll for certain information if userspace needs them. And either it is a one-shot poll or it is on a regular interval.
Quoted 6 lines
If everybody agree we can do it. Our objective is to have the patches upstream. To keep the Proximity Monitor functional on both
adapter_opsplugins we can move part of the logic from theadapter.cto the hciops. The polling to read the RSSI can be moved to hciops, in the management the polling will be in the kernel. The remaining code to register the callbacks doesn't need to be changed.
Do we have a really good reason to implement this both for hciops and mgmtops? We wrote mgmt interface to solve our problems. So why do we still care about put new stuff on hciops? And then we maintain two pieces of code instead of one.
Gustavo
Re: [RFC 7/7] Update Management API documentation
Hi,
Quoted 1 line · Gustavo F. Padovan
* Claudio Takahasi <[email protected]> [2011-06-16 12:12:53 =
-0300]:
Quoted 4 lines
Quoted 4 lines
Hi Marcel,
On Thu, Jun 16, 2011 at 11:47 AM, Marcel Holtmann <[email protected]> =
Quoted 3 lines · wrote:
Quoted 3 lines
Quoted 3 lines
Hi Claudio,
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
if TX power is only read once than the kernel should just do it o=
nce
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
and
be done with it.And for RSSI, it would be better if the kernel read this periodic=
ally
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
based on current sniff mode etc. Userspace can not trigger this w=
ith
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 3 lines
proper timing anyway. And it will potentially at some point start blocking the controller. Only the kernel really knows when it is acceptable to read the RSSI value.
Reading the RSSI by the kernel, will force a certain limitation on=
the
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
current and future Profiles. I believe setting the timing should b=
e done
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
by the profile itself, not the bluez user space code or the kernel=
. It
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
is the responsibility of the profile to periodically poll the RSSI=
Level.
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
For some cases, polling it every 5 seconds would be ok, and for so=
me
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Others, it may be better to read it every second. I believe we mus=
t not
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line
impose any limitation here.
You probably forgot that besides bluetoothd there should be no othe=
r
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
application holding the mgmt socket, so not you can't really do it =
in
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
poll in the application side and doing it over D-Bus is overkill. A=
lso
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
I notice that from some parties, you include, there is some tendenc=
y
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
to have the profiles split from the bluetoothd, IMO this will only =
add
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
fragmentation with each and every platform using BlueZ having their own implementation of each profile and not sharing much, making the IOP a complete mess.
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Some additional comments...
Health plugin will need a similar approach to read the clock. It will be good to implement the same approach.
In our suggested implementation the adapter controls when to send the command to read the RSSI, keeping the same logic for both: hciops and mgmtops. If the adapter is managing when to send the commands, repeated commands can be avoided, multiple callbacks can be registere=
d
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
by the profiles, but only one command to read the RSSI will be sent. The cover letter of the userspace patches contains more details how w=
e
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 4 lines
implemented it.
Reading the RSSI directly by the kernel will break hciops. These are the arguments that I have to support our decision.
what I am hearing is that we want the kernel to poll for certain information if userspace needs them. And either it is a one-shot poll =
or
Quoted 3 lines
Quoted 3 lines
Quoted 1 line
it is on a regular interval.
If everybody agree we can do it. Our objective is to have the patches up=
stream.
Quoted 7 lines
Quoted 5 lines
To keep the Proximity Monitor functional on both
adapter_opsplugins we can move part of the logic from theadapter.cto the hciops. The polling to read the RSSI can be moved to hciops, in the management the polling will be in the kernel. The remaining code to register the callbacks doesn't need to be changed.Do we have a really good reason to implement this both for hciops and mgm=
tops?
Quoted 1 line
We wrote mgmt interface to solve our problems. So why do we still care ab=
out
Quoted 5 lines
put new stuff on hciops? And then we maintain two pieces of code instead of one.
=A0 =A0 =A0 =A0Gustavo
Ok, we could implement it just for mgmtops. But, I need some opinions before start coding. We was thinking about the architecture needed into the kernel and we have some ideas:
- Add a new Management command called MGMT_ADD_LISTENER or something like that, which has two arguments at least: command op code and timer interval.
- A callback called by the expired timer for each monitored command will be responsible to send the result (e.g.: Read RSSI or Read Clock), to the userspace.
As you could notice, we should have one timer for each command. What do you think about this approach?
Regards,
Anderson Briglia
--=20
INdT - Instituto Nokia de tecnologia
+55 2126 1122
Marcel Holtmann
maintainerRe: [RFC 7/7] Update Management API documentation
Hi Anderson,
Quoted 73 lines
Quoted 54 lines
Quoted 47 lines
Quoted 40 lines
Quoted 40 lines
Quoted 18 lines
Quoted 10 lines
Quoted 9 lines
if TX power is only read once than the kernel should just do it once and
be done with it.And for RSSI, it would be better if the kernel read this periodically based on current sniff mode etc. Userspace can not trigger this with proper timing anyway. And it will potentially at some point start blocking the controller. Only the kernel really knows when it is acceptable to read the RSSI value.
Quoted 7 lines
Reading the RSSI by the kernel, will force a certain limitation on the current and future Profiles. I believe setting the timing should be done by the profile itself, not the bluez user space code or the kernel. It is the responsibility of the profile to periodically poll the RSSI Level. For some cases, polling it every 5 seconds would be ok, and for some Others, it may be better to read it every second. I believe we must not impose any limitation here.
Quoted 9 lines
You probably forgot that besides bluetoothd there should be no other application holding the mgmt socket, so not you can't really do it in poll in the application side and doing it over D-Bus is overkill. Also I notice that from some parties, you include, there is some tendency to have the profiles split from the bluetoothd, IMO this will only add fragmentation with each and every platform using BlueZ having their own implementation of each profile and not sharing much, making the IOP a complete mess.
Some additional comments...
Health plugin will need a similar approach to read the clock. It will be good to implement the same approach.
In our suggested implementation the adapter controls when to send the command to read the RSSI, keeping the same logic for both: hciops and mgmtops. If the adapter is managing when to send the commands, repeated commands can be avoided, multiple callbacks can be registered by the profiles, but only one command to read the RSSI will be sent. The cover letter of the userspace patches contains more details how we implemented it.Quoted 6 lines
Quoted 2 lines
Reading the RSSI directly by the kernel will break hciops. These are the arguments that I have to support our decision.
what I am hearing is that we want the kernel to poll for certain information if userspace needs them. And either it is a one-shot poll or it is on a regular interval.
Quoted 6 lines
If everybody agree we can do it. Our objective is to have the patches upstream. To keep the Proximity Monitor functional on both
adapter_opsplugins we can move part of the logic from theadapter.cto the hciops. The polling to read the RSSI can be moved to hciops, in the management the polling will be in the kernel. The remaining code to register the callbacks doesn't need to be changed.Quoted 7 lines
Do we have a really good reason to implement this both for hciops and mgmtops? We wrote mgmt interface to solve our problems. So why do we still care about put new stuff on hciops? And then we maintain two pieces of code instead of one.
Gustavo
Ok, we could implement it just for mgmtops. But, I need some opinions before start coding. We was thinking about the architecture needed into the kernel and we have some ideas:
- Add a new Management command called
MGMT_ADD_LISTENERor something like that, which has two arguments at least: command op code and timer interval.
- A callback called by the expired timer for each monitored command will be responsible to send the result (e.g.: Read RSSI or Read Clock), to the userspace.
Quoted 2 lines
As you could notice, we should have one timer for each command. What do you think about this approach?
what you want is an mgmt event that notifies you about changes and that could be well one event per type. And then you need one mgmt command to set the trigger here.
Also you might wanna look at the SIG closely. I think they are trying to fix this on the HCI controller side. So we get at least RSSI updates when they change and don't have to poll them.
In theory it is always better to define a threshold instead of fixed poll interval. Even if the threshold is implement as a poll on older chips, at least for future ones you get this right.
Regards
Marcel
Re: [RFC 7/7] Update Management API documentation
In reply to Luiz Augusto von DentzHi,
Quoted 8 lines · Luiz Augusto von Dentz
You probably forgot that besides bluetoothd there should be no other application holding the mgmt socket, so not you can't really do it in poll in the application side and doing it over D-Bus is overkill. Also I notice that from some parties, you include, there is some tendency to have the profiles split from the bluetoothd, IMO this will only add fragmentation with each and every platform using BlueZ having their own implementation of each profile and not sharing much, making the IOP a complete mess.
I would like to bring attention to a thread I attempted to start some time ago, named "D-Bus GATT API for external/proprietary profiles". If anyone is really willing to implement external profiles over D-Bus, please voice your points that would support this. Note that this attempt never happened before, AFAIK all bluez supported profiles are implemented internally on bluez source code, usually as plugins.
Regards,
Signature · 3 lines
Anderson Lizardo Instituto Nokia de Tecnologia - INdT Manaus - Brazil
Re: [RFC 7/7] Update Management API documentation
Hi Lizardo,
Quoted 11 lines · Anderson Lizardo
Quoted 8 lines · Luiz Augusto von Dentz
You probably forgot that besides bluetoothd there should be no other application holding the mgmt socket, so not you can't really do it in poll in the application side and doing it over D-Bus is overkill. Also I notice that from some parties, you include, there is some tendency to have the profiles split from the bluetoothd, IMO this will only add fragmentation with each and every platform using BlueZ having their own implementation of each profile and not sharing much, making the IOP a complete mess.
Quoted 6 lines
I would like to bring attention to a thread I attempted to start some time ago, named "D-Bus GATT API for external/proprietary profiles". If anyone is really willing to implement external profiles over D-Bus, please voice your points that would support this. Note that this attempt never happened before, AFAIK all bluez supported profiles are implemented internally on bluez source code, usually as plugins.
Not all profiles. There's e.g. the OBEX profiles provided by obexd. The main reason for that separation is that practically everything handled by obexd is user data which doesn't belong in a system level daemon like bluetoothd. The same system-user separation could be a reason for other profiles to exist in separate processes. Then there's also partial splits like that for HFP where audio is handled by an audio subsystem like PulseAudio and signaling by a cellular subsystem like oFono.
Johan
Re: [RFC 7/7] Update Management API documentation
Hi Johan,
Quoted 7 lines · Johan Hedberg
Quoted 6 lines
I would like to bring attention to a thread I attempted to start some time ago, named "D-Bus GATT API for external/proprietary profiles". If anyone is really willing to implement external profiles over D-Bus, please voice your points that would support this. Note that this attempt never happened before, AFAIK all bluez supported profiles are implemented internally on bluez source code, usually as plugins.
Quoted 7 lines
Not all profiles. There's e.g. the OBEX profiles provided by obexd. The main reason for that separation is that practically everything handled by obexd is user data which doesn't belong in a system level daemon like bluetoothd. The same system-user separation could be a reason for other profiles to exist in separate processes. Then there's also partial splits like that for HFP where audio is handled by an audio subsystem like PulseAudio and signaling by a cellular subsystem like oFono.
Thanks for the clarification. I completely forgot about these cases (also I don't actually know how obexd integrates with bluetoothd, blame on me). But looks like the decision to whether to implement a profile fully inside or outside (partially or not) bluez is per profile, right? I think GATT profiles are so diverse that we would have to make the decision on a profile basis. In this case, it helps each profile having its own D-Bus API and plugin.
Proximity, for instance, is so attached to the connection state (and depending on RSSI and TX power) that it would be an example of one profile that is best implemented next to BlueZ.
Future GATT profiles which might need to read a lot of user information might need a split from bluetoothd process.
Regards,
Signature · 3 lines
Anderson Lizardo Instituto Nokia de Tecnologia - INdT Manaus - Brazil
GATT and GATT based Profiles architecture - Query
In reply to Marcel HoltmannSGksDQoNCkkgaGF2ZSBiZWVuIHJlYWRpbmcgc29tZSBwb3N0cyB3aGVyZSB0 aGUgR0FUVCBwcm9maWxlcyB3ZXJlIHJlZmVycmVkIHRvIGFzICJwbHVnaW5z Ii4NCg0KQ291bGQgeW91IHRlbGwgbWUgd2hhdCBpcyBhICJwbHVnaW4iIGlu IHRoaXMgY29udGV4dD8NCkFyZSB0aGVzZSBwcm9maWxlcyBydW5uaW5nIGlu IGEgc2VwYXJhdGUgcHJvY2VzcyBzcGFjZSAodG8gcmVzdCBvZiBCbHVlWiBo YXZpbmcgR0FUVCAvQVRUKT8NCkNhbiB0aGVzZSBwcm9maWxlcyBiZSBicm91 Z2h0IHVwIGFuZCBkb3duIGF0IHJ1biB0aW1lPw0KQ2FuIG5vbnN0YW5kYXJk IHVzZWNhc2VzIGJlIGltcGxlbWVudGVkIGFuZCBwbHVnZ2VkIGluIHRvIHVz ZSBHQVRUIGZyb20gQmx1ZVo/DQoNCkkgYW0gaGFwcHkgdG8gaGF2ZSBzb21l IGNvZGUgcmVmZXJlbmNlcyB0aGF0IGNhbiBzaG93IG1lIHRoZSBhbnN3ZXIg dG8gdGhlc2UuDQoNClRoYW5rIHlvdQ0KYWpheQ0KCgpNZW1iZXIgb2YgdGhl IENTUiBwbGMgZ3JvdXAgb2YgY29tcGFuaWVzLiBDU1IgcGxjIHJlZ2lzdGVy ZWQgaW4gRW5nbGFuZCBhbmQgV2FsZXMsIHJlZ2lzdGVyZWQgbnVtYmVyIDQx ODczNDYsIHJlZ2lzdGVyZWQgb2ZmaWNlIENodXJjaGlsbCBIb3VzZSwgQ2Ft YnJpZGdlIEJ1c2luZXNzIFBhcmssIENvd2xleSBSb2FkLCBDYW1icmlkZ2Us IENCNCAwV1osIFVuaXRlZCBLaW5nZG9tCk1vcmUgaW5mb3JtYXRpb24gY2Fu IGJlIGZvdW5kIGF0IHd3dy5jc3IuY29tLiBGb2xsb3cgQ1NSIG9uIFR3aXR0 ZXIgYXQgaHR0cDovL3R3aXR0ZXIuY29tL0NTUl9QTEMgYW5kIHJlYWQgb3Vy IGJsb2cgYXQgd3d3LmNzci5jb20vYmxvZwo=
Re: GATT and GATT based Profiles architecture - Query
Hi Ajay,
Quoted 3 lines · Ajay Pillai
I have been reading some posts where the GATT profiles were referred to as "plugins".
Could you tell me what is a "plugin" in this context?
It is a BlueZ plugin. See the plugins/ directory on BlueZ sources for example of simple (non-GATT) plugins. There are other plugins dedicated directories as well, run "grep -R BLUETOOTH_PLUGIN_DEFINE *" on source to find them.
Quoted 1 line
Are these profiles running in a separate process space (to rest of BlueZ having GATT /ATT)?
Same process. They are usually builtin (statically linked with bluetoothd binary), but can be also .so files loaded when bluetoothd is started.
Quoted 1 line
Can these profiles be brought up and down at run time?
Not really. But they can be prevented from being started, if you pass the -P <pluginname> option.
Quoted 1 line
Can nonstandard usecases be implemented and plugged in to use GATT from BlueZ?
If you implement your own BlueZ plugin, yes. But be sure to check the BlueZ license, I don't know if standalone plugins would have to follow the same license as BlueZ itself (I assume yes, as there is no "exception" to GPL like on kernel).
Quoted 1 line
I am happy to have some code references that can show me the answer to these.
Be sure to follow the latest LE related patches which are being sent to the list, and the ones which are going to be sent in the next days. We are trying to submit upstream the infrastructure necessary for implementing LE profiles ASAP. They will be probably sent as RFC, as they add new infrastructure which we would like to get some feedback first.
Regards,
Signature · 3 lines
Anderson Lizardo Instituto Nokia de Tecnologia - INdT Manaus - Brazil
RE: GATT and GATT based Profiles architecture - Query
Hi Anderson,
I saw another post from you which seemed to indicate that the GATT DBUS API is not meant to be used extensively in systems for implementing profiles or for general App integration. (Please correct me if I interpreted wrong)
However this information coupled with the tightly coupled nature of the GATT based profiles (as derived from your reply) in BlueZ, is giving me an impression that the current development direction in BlueZ can severely curb the freedom of device implementers
to use the capability of GATT. (not sure if you have discussed this before an concluded, in which case I would be interested to be pointed to another post)
The way I see it is that the pace of profile spec ratification in the SIG or the pace of development of profiles in BlueZ will probably be too slow
for the larger community of device manufacturers and Application developers for platforms like Android.
Besides, the usecases being addressed by the profiles in pipeline would probably be only a fraction of the real potential of GATT, which device manufacturers might want to tap into.
This makes me think that more focus needs to be given to the GATT DBUS API, than what is implied by your earlier post.
Do you have plans for making the GATT DBUS API more feature complete?
Do you see problems in including GATT Servers too in it?
Are you open to stronger contributions to the GATT DBUS API? ( I am interested to do that)
You posted earlier:
Quoted 8 lines
To be able to implement a full GATT profile externally (client role), we would need to expose the full GATT (or even ATT) stack over D-Bus. For instance, have methods for each GATT operation, and signals for notifications/indications.
Is that really what we want? If yes, the Attribute API could have to be severely redesigned. It was not (and currently still not is) intended for that.
Could you elaborate what is the scope of this redesign?
I am interested to know if system integrators can have a mutually exclusive choice between external profiles using BlueZ GATT and BlueZ built-in profiles.
Thank you
ajay
Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom More information can be found at www.csr.com. Follow CSR on Twitter at http://twitter.com/CSR_PLC and read our blog at www.csr.com/blog
Re: GATT and GATT based Profiles architecture - Query
Hi Ajay,
Quoted 3 lines · Ajay Pillai
I saw another post from you which seemed to indicate that the GATT DBUS API is not meant to be used extensively in systems for implementing profiles or for general App integration. (Please correct me if I interpreted wrong)
The current API implementation (documented in doc/attribute-api.txt) is not suitable for implementing external profiles, correct.
Quoted 3 lines
However this information coupled with the tightly coupled nature of the GATT based profiles (as derived from your reply) in BlueZ, is giving me an impression that the current development direction in BlueZ can severely curb the freedom of device implementers
to use the capability of GATT. (not sure if you have discussed this before an concluded, in which case I would be interested to be pointed to another post)
If these implementers create a BlueZ plugin (in C), they have the full power of BlueZ GATT stack. Of course, there are the licensing requirements (I suppose).
Quoted 3 lines
The way I see it is that the pace of profile spec ratification in the SIG or the pace of development of profiles in BlueZ will probably be too slow
for the larger community of device manufacturers and Application developers for platforms like Android.
Besides, the usecases being addressed by the profiles in pipeline would probably be only a fraction of the real potential of GATT, which device manufacturers might want to tap into.
I agree. But note that currently we lack use cases which justify a complete GATT API over D-Bus. Feel free to discuss your own use cases, and propose an API for them.
Quoted 1 line
This makes me think that more focus needs to be given to the GATT DBUS API, than what is implied by your earlier post.
So far we have been focusing on implementing officially adopted profiles, the current D-Bus API was proposed and implemented at a time when there were no actual GATT profiles, and so far it has been used for testing purposes.
Quoted 1 line
Do you have plans for making the GATT DBUS API more feature complete?
At least on the team I work, there are no plans for that. But I wanted to bring up the discussion anyway, thus my e-mail.
Quoted 2 lines
Do you see problems in including GATT Servers too in it?
Are you open to stronger contributions to the GATT DBUS API? ( I am interested to do that)
I believe we are always open to discussions and contributions :). But before you begin implementing your proposal, I'd suggest discussing a draft API first on this list. I'm sure there are other parties interested on helping on that as well.
Quoted 10 lines
You posted earlier:
Quoted 8 lines
To be able to implement a full GATT profile externally (client role), we would need to expose the full GATT (or even ATT) stack over D-Bus. For instance, have methods for each GATT operation, and signals for notifications/indications.
Is that really what we want? If yes, the Attribute API could have to be severely redesigned. It was not (and currently still not is) intended for that.
Could you elaborate what is the scope of this redesign?
If you take a look on doc/attribute-api.txt on BlueZ source, you might identify some limitations already (assuming you already have some use cases in mind):
* There are no way to access custom characteristic descriptors (only presentation format and user description descriptors are currently exposed). This is a major limitation if you want to access custom descriptors.
* No D-Bus API e.g. the server side (only client side) for managing the Attribute server
* Notifications/indications are registered per server, not per characteristic (this might be a limitation or not)
* Currently no way to handle cases where new services/characteristics are added "on the fly" on the server side (i.e. suport for the "Service Changed" GATT characteristic). Idea: new services or characteristics could be announced as D-Bus signals.
Quoted 1 line
I am interested to know if system integrators can have a mutually exclusive choice between external profiles using BlueZ GATT and BlueZ built-in profiles.
They could coexist just fine. But for that to work, the attribute server database needs to be managed by BlueZ, which would allocate attribute handles as necessary. Also note that UUIDs would need to be allocated for proprietary profiles (not sure how BT SIG handles that).
Also consider contributing to the officially adopted profiles (once they are actually adopted). I really hope we don't see multiple implementations of an adopted GATT profile.
Regards,
Signature · 3 lines
Anderson Lizardo Instituto Nokia de Tecnologia - INdT Manaus - Brazil
Re: GATT and GATT based Profiles architecture - Query
Hi,
2011/6/17 Anderson Lizardo <[email protected]>:
Quoted 76 lines
Hi Ajay,
Quoted 3 lines · Ajay Pillai
I saw another post from you which seemed to indicate that the GATT DBUS API is not meant to be used extensively in systems for implementing profiles or for general App integration. (Please correct me if I interpreted wrong)
The current API implementation (documented in
doc/attribute-api.txt) is not suitable for implementing external profiles, correct.Quoted 3 lines
However this information coupled with the tightly coupled nature of the GATT based profiles (as derived from your reply) in BlueZ, is giving me an impression that the current development direction in BlueZ can severely curb the freedom of device implementers
to use the capability of GATT. (not sure if you have discussed this before an concluded, in which case I would be interested to be pointed to another post)If these implementers create a BlueZ plugin (in C), they have the full power of BlueZ GATT stack. Of course, there are the licensing requirements (I suppose).
Quoted 3 lines
The way I see it is that the pace of profile spec ratification in the SIG or the pace of development of profiles in BlueZ will probably be too slow
for the larger community of device manufacturers and Application developers for platforms like Android.
Besides, the usecases being addressed by the profiles in pipeline would probably be only a fraction of the real potential of GATT, which device manufacturers might want to tap into.I agree. But note that currently we lack use cases which justify a complete GATT API over D-Bus. Feel free to discuss your own use cases, and propose an API for them.
Quoted 1 line
This makes me think that more focus needs to be given to the GATT DBUS API, than what is implied by your earlier post.
So far we have been focusing on implementing officially adopted profiles, the current D-Bus API was proposed and implemented at a time when there were no actual GATT profiles, and so far it has been used for testing purposes.
Quoted 1 line
Do you have plans for making the GATT DBUS API more feature complete?
At least on the team I work, there are no plans for that. But I wanted to bring up the discussion anyway, thus my e-mail.
Quoted 2 lines
Do you see problems in including GATT Servers too in it?
Are you open to stronger contributions to the GATT DBUS API? ( I am interested to do that)I believe we are always open to discussions and contributions :). But before you begin implementing your proposal, I'd suggest discussing a draft API first on this list. I'm sure there are other parties interested on helping on that as well.
Quoted 10 lines
You posted earlier:
Quoted 8 lines
To be able to implement a full GATT profile externally (client role), we would need to expose the full GATT (or even ATT) stack over D-Bus. For instance, have methods for each GATT operation, and signals for notifications/indications.
Is that really what we want? If yes, the Attribute API could have to be severely redesigned. It was not (and currently still not is) intended for that.
Could you elaborate what is the scope of this redesign?
If you take a look on
doc/attribute-api.txton BlueZ source, you might identify some limitations already (assuming you already have some use cases in mind):* There are no way to access custom characteristic descriptors (only presentation format and user description descriptors are currently exposed). This is a major limitation if you want to access custom descriptors.
* No D-Bus API e.g. the server side (only client side) for managing the Attribute server
* Notifications/indications are registered per server, not per characteristic (this might be a limitation or not)
* Currently no way to handle cases where new services/characteristics are added "on the fly" on the server side (i.e. suport for the "Service Changed" GATT characteristic). Idea: new services or characteristics could be announced as D-Bus signals.Quoted 1 line
I am interested to know if system integrators can have a mutually exclusive choice between external profiles using BlueZ GATT and BlueZ built-in profiles.
Quoted 9 lines
They could coexist just fine. But for that to work, the attribute server database needs to be managed by BlueZ, which would allocate attribute handles as necessary. Also note that UUIDs would need to be allocated for proprietary profiles (not sure how BT SIG handles that).
Also consider contributing to the officially adopted profiles (once they are actually adopted). I really hope we don't see multiple implementations of an adopted GATT profile.
Just a note. If there is a full GATT API and we do BlueZ plugins over GATT (wich have their own D-Bus API as usual in BlueZ). The GATT API may be in conflict with those APIs exposed by those plugins because Applications will be able to use Attribute D-Bus one avoiding those APIs exposed by plugins. Do not?
Regards
Re: GATT and GATT based Profiles architecture - Query
Hi,
Quoted 5 lines · Santiago Carot
Just a note. If there is a full GATT API and we do BlueZ plugins over GATT (wich have their own D-Bus API as usual in BlueZ). The GATT API may be in conflict with those APIs exposed by those plugins because Applications will be able to use Attribute D-Bus one avoiding those APIs exposed by plugins. Do not?
As long as all APIs use the same stack, there is no issue AFAIK. For instance, if someone uses the Proximity D-Bus API and another application does the same operation over the "generic" Attribute API, both operations will be processed the same way inside the BlueZ GATT stack (because they use the same functions internally). At least this is the intended behavior, we don't do much testing like that :)
Regards,
Signature · 3 lines
Anderson Lizardo Instituto Nokia de Tecnologia - INdT Manaus - Brazil
Re: GATT and GATT based Profiles architecture - Query
Hi
2011/6/17 Anderson Lizardo <[email protected]>:
Quoted 9 lines
Hi,
Quoted 5 lines · Santiago Carot
Just a note. If there is a full GATT API and we do BlueZ plugins over GATT (wich have their own D-Bus API as usual in BlueZ). The GATT API may be in conflict with those APIs exposed by those plugins because Applications will be able to use Attribute D-Bus one avoiding those APIs exposed by plugins. Do not?
Quoted 7 lines
As long as all APIs use the same stack, there is no issue AFAIK. For instance, if someone uses the Proximity D-Bus API and another application does the same operation over the "generic" Attribute API, both operations will be processed the same way inside the BlueZ GATT stack (because they use the same functions internally). At least this is the intended behavior, we don't do much testing like that :)
Yes, sure. the GATT API will allow applications to avoid use API provided for GATT based plugins. In this scenario there will be two ways to doing things. A) Using the plugin API and B)Through the GATT API. ... or in the worst case, an Application may use both.
Quoted 6 lines
Regards,
--
Anderson Lizardo
Instituto Nokia de Tecnologia - INdT
Manaus - Brazil
RE: GATT and GATT based Profiles architecture - Query
In reply to Anderson LizardoHi Anderson,
Quoted 7 lines
Quoted 3 lines
The way I see it is that the pace of profile spec ratification in the SIG or the pace of development of profiles in BlueZ will probably be too slow
for the larger community of device manufacturers and Application developers for platforms like Android.
Besides, the usecases being addressed by the profiles in pipeline would probably be only a fraction of the real potential of GATT, which device manufacturers might want to tap into.I agree. But note that currently we lack use cases which justify a complete GATT API over D-Bus. Feel free to discuss your own use cases, and propose an API for them.
The point that I was trying to make is that you or me trying to figure out the possible usecases over GATT and then trying to cater to them may prove to be inadequate quite soon after widespread Ble deployment. I thought the usecases over GATT beyond those that are thought over by the SIG are best left to the imagination of the users of GATT which could be the peripheral device manufacturers. Giving BlueZ a comprehensive GATT API will enable any of these usecases and would pave the way for widespread and faster usage of Ble/GATT, at the same time giving freedom to the user to decide what usecases he/she wants in his/her BlueZ powered device. I do not have any specific usecase in mind (or it could be that I have just too many of them), but the system of interest to me is Android.
Quoted 7 lines
Quoted 2 lines
Do you see problems in including GATT Servers too in it?
Are you open to stronger contributions to the GATT DBUS API? ( I am interested to do that)I believe we are always open to discussions and contributions :). But before you begin implementing your proposal, I'd suggest discussing a draft API first on this list. I'm sure there are other parties interested on helping on that as well.
Sure. I shall send out an API RFC before I start on it.
Thank you,
ajay
Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom More information can be found at www.csr.com. Follow CSR on Twitter at http://twitter.com/CSR_PLC and read our blog at www.csr.com/blog
RE: [RFC 7/7] Update Management API documentation
In reply to Anderson LizardoQuoted 20 lines
-----Original Message-----
From: [email protected] [mailto:linux-bluetooth- [email protected]] On Behalf Of Anderson Lizardo
Sent: Thursday, June 16, 2011 2:48 AM
To: Marcel Holtmann
Cc: [email protected]; [email protected]; Bruna Moreira
Subject: Re: [RFC 7/7] Update Management API documentation =20
Hi Marcel,
=20Quoted 1 line · Marcel Holtmann
so why are these two separate commands. Just reading them in one
kernel
Quoted 1 line
call might be a lot better. Including everything else you need to
know
Quoted 1 line
about the connection. Also TX power can be local and remote TX power
if
Quoted 1 line
I remember this correctly.
Quoted 13 lines
=20
The issue I see with your proposal is that for Proximity (currently the only user of this information) we read TX power from server (reporter) using GATT, while RSSI is read on client (monitor) side. By reading both, we would need to issue two separate HCI commands (and wait for both responses), but will always use only one value, depending on local BlueZ role.
=20
Also note that on latest Proximity profile drafts, it is mentioned that the TX power on reporter will never change during a connection, and thus it should be read only once when the connection is established. RSSI (which is read "locally" on monitor side), on the other hand, should be read periodically for path loss calculation.
Anderson,
Please note that this is currently true for LE connection, but may change=20 in the future. In addition, TX Power for BR/EDR may change during the=20 connection (by the controller, depending on LMP commands), so reading it=20 periodically and updating the GATT server must be implemented.
Chen Ganir.
Re: [RFC 7/7] Update Management API documentation
Hi Chen,
Quoted 2 lines · Chen
Please note that this is currently true for LE connection, but may change in the future.
If you read the latest Proximity draft (not from bluetooth.org, from the mailing lists), you will see that the recommendation to read TX power once on LE is to conserve power (specially on the single mode device, I suppose, but it would waste power on the BlueZ side as well). Unfortunately, if they change the recommendation again (in this case they would be returning to a previous decision), we would inevitably have to change implementation anyway.
Quoted 3 lines
In addition, TX Power for BR/EDR may change during the connection (by the controller, depending on LMP commands), so reading it periodically and updating the GATT server must be implemented.
I don't really feel comfortable on discussing things which are not adopted on BT-SIG yet but... Are you aware of any latest GATT profiles which support BR/EDR? Be sure to check the latest drafts from BT-SIG mailing lists.
I'm not saying it will *never* happen, but I think we should make development decisions on what we know at the moment, not on what might be possibly added to a future (not yet existing) profile. Otherwise we risk doing unnecessary things for current profiles, like reading TX Power periodically when a GATT profile would recommend reading once.
My two cents,
Signature · 3 lines
Anderson Lizardo Instituto Nokia de Tecnologia - INdT Manaus - Brazil
RE: [RFC 7/7] Update Management API documentation
Quoted 15 lines
-----Original Message-----
From: Anderson Lizardo [mailto:[email protected]]
Sent: Thursday, June 16, 2011 4:45 PM
To: Ganir, Chen
Cc: Marcel Holtmann; [email protected]; linux- [email protected]; Bruna Moreira
Subject: Re: [RFC 7/7] Update Management API documentation =20
Hi Chen,
=20Quoted 1 line · Chen
Please note that this is currently true for LE connection, but may
change
Quoted 1 line
in the future.
Quoted 8 lines
=20
If you read the latest Proximity draft (not from bluetooth.org, from the mailing lists), you will see that the recommendation to read TX power once on LE is to conserve power (specially on the single mode device, I suppose, but it would waste power on the BlueZ side as well). Unfortunately, if they change the recommendation again (in this case they would be returning to a previous decision), we would inevitably have to change implementation anyway.
Anderson,
Quoted 1 line
From the version I have (d10), it is clearly seen that it can support both
BR/EDR and LE as well (service discovery for example is explained for both BR/EDR and LE). In addition, it is stated in this version of the spec that The TX power characteristic should return the current TX power level. This means that if there is any chance that this level changes, it must be updat= ed
periodically, or read each time the characteristic is accessed for reading (with the suggested GATT server callback mechanism).Furthermore, it is clea= rly=20
specified that on BR/EDR, when the TX Power level changes, the reporter=20 should notify the monitor about the change, if it's registered for these=20 notifications.
I see no reason to implement different behavior or logic for BE/EDR or LE.= =20
In addition, I do not believe it is the responsibility of the bluez stack=20 (adapter in this case) to set the intervals for getting this info - it is=20 the responsibility of the profile, whether it is implemented as a bluez plu= gin=20
(so the plugin initiates the RSSI/TX Power readings according to its own=20 timing) or by an external profile (if future bluez implementation allows th= is).
Thanks,
Chen Ganir