Skip to content

Commit

Permalink
Drop link quality
Browse files Browse the repository at this point in the history
This value is really pointless, especially as it is vendor specific. Also it's only available via libbluetooth, so BlueZ 6 will not have it anymore.

This is more or less a subset of blueman-project#1642.
  • Loading branch information
cschramm committed Sep 6, 2022
1 parent 2371a40 commit d2fe2e8
Show file tree
Hide file tree
Showing 18 changed files with 7 additions and 65 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
* Store network configuration in GSettings instead of /var/lib/blueman/network.state.
* Replace custom MessageArea widget with regular Gtk.InfoBar
* Drop auto-power feature. BlueZ now has the AutoEnable setting for even better auto-powering.
* Do not use pointless link quality value

### Bugs fixed

Expand Down
28 changes: 6 additions & 22 deletions blueman/gui/manager/ManagerDeviceList.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,6 @@ def __init__(self, adapter: Optional[str] = None, inst: Optional["Blueman"] = No
{"id": "rssi_pb", "type": GdkPixbuf.Pixbuf, "renderer": Gtk.CellRendererPixbuf(),
"render_attrs": {}, "view_props": {"spacing": 0},
"celldata_func": (self._set_cell_data, "rssi")},
{"id": "lq_pb", "type": GdkPixbuf.Pixbuf, "renderer": Gtk.CellRendererPixbuf(),
"render_attrs": {}, "view_props": {"spacing": 0},
"celldata_func": (self._set_cell_data, "lq")},
{"id": "tpl_pb", "type": GdkPixbuf.Pixbuf, "renderer": Gtk.CellRendererPixbuf(),
"render_attrs": {}, "view_props": {"spacing": 0},
"celldata_func": (self._set_cell_data, "tpl")},
Expand All @@ -61,7 +58,6 @@ def __init__(self, adapter: Optional[str] = None, inst: Optional["Blueman"] = No
{"id": "objpush", "type": bool}, # used to set Send File button
{"id": "battery", "type": float},
{"id": "rssi", "type": float},
{"id": "lq", "type": float},
{"id": "tpl", "type": float},
{"id": "icon_info", "type": Gtk.IconInfo},
{"id": "cell_fader", "type": CellFade},
Expand Down Expand Up @@ -474,22 +470,18 @@ def _update_power_levels(self, tree_iter: Gtk.TreeIter, device: Device, cinfo: c
# cinfo init may fail for bluetooth devices version 4 and up
# FIXME Workaround is horrible and we should show something better
if cinfo.failed:
bars.update({"rssi": 100.0, "tpl": 100.0, "lq": 100.0})
bars.update({"rssi": 100.0, "tpl": 100.0})
else:
try:
bars["rssi"] = max(50 + float(cinfo.get_rssi()) / 127 * 50, 10)
except ConnInfoReadError:
bars["rssi"] = 50
try:
bars["lq"] = max(float(cinfo.get_lq()) / 255 * 100, 10)
except ConnInfoReadError:
bars["lq"] = 10
try:
bars["tpl"] = max(50 + float(cinfo.get_tpl()) / 127 * 50, 10)
except ConnInfoReadError:
bars["tpl"] = 50

if row["battery"] == row["rssi"] == row["tpl"] == row["lq"] == 0:
if row["battery"] == row["rssi"] == row["tpl"] == 0:
self._prepare_fader(row["cell_fader"]).animate(start=0.0, end=1.0, duration=400)

w = 14 * self.get_scale_factor()
Expand All @@ -502,12 +494,12 @@ def _update_power_levels(self, tree_iter: Gtk.TreeIter, device: Device, cinfo: c
self.set(tree_iter, **{name: perc, f"{name}_pb": icon})

def _disable_power_levels(self, tree_iter: Gtk.TreeIter) -> None:
row = self.get(tree_iter, "cell_fader", "battery", "rssi", "lq", "tpl")
if row["battery"] == row["rssi"] == row["tpl"] == row["lq"] == 0:
row = self.get(tree_iter, "cell_fader", "battery", "rssi", "tpl")
if row["battery"] == row["rssi"] == row["tpl"] == 0:
return

self.set(tree_iter, battery=0, rssi=0, lq=0, tpl=0)
self._prepare_fader(row["cell_fader"], lambda: self.set(tree_iter, battery_pb=None, rssi_pb=None, lq_pb=None,
self.set(tree_iter, battery=0, rssi=0, tpl=0)
self._prepare_fader(row["cell_fader"], lambda: self.set(tree_iter, battery_pb=None, rssi_pb=None,
tpl_pb=None)).animate(start=1.0, end=0.0, duration=400)

def _prepare_fader(self, fader: AnimBase, callback: Optional[Callable[[], None]] = None) -> AnimBase:
Expand Down Expand Up @@ -559,7 +551,6 @@ def tooltip_query(self, _tw: Gtk.Widget, x: int, y: int, _kb: bool, tooltip: Gtk

elif path[1] == self.columns["battery_pb"] \
or path[1] == self.columns["tpl_pb"] \
or path[1] == self.columns["lq_pb"] \
or path[1] == self.columns["rssi_pb"]:
tree_iter = self.get_iter(path[0])
assert tree_iter is not None
Expand All @@ -572,7 +563,6 @@ def tooltip_query(self, _tw: Gtk.Widget, x: int, y: int, _kb: bool, tooltip: Gtk

battery = self.get(tree_iter, "battery")["battery"]
rssi = self.get(tree_iter, "rssi")["rssi"]
lq = self.get(tree_iter, "lq")["lq"]
tpl = self.get(tree_iter, "tpl")["tpl"]

if battery != 0:
Expand Down Expand Up @@ -600,12 +590,6 @@ def tooltip_query(self, _tw: Gtk.Widget, x: int, y: int, _kb: bool, tooltip: Gtk
lines.append(_("Received Signal Strength: %(rssi)u%% <i>(%(rssi_state)s)</i>") %
{"rssi": rssi, "rssi_state": rssi_state})

if lq != 0:
if path[1] == self.columns["lq_pb"]:
lines.append(_("<b>Link Quality: %(lq)u%%</b>") % {"lq": lq})
else:
lines.append(_("Link Quality: %(lq)u%%") % {"lq": lq})

if tpl != 0:
if tpl < 30:
tpl_state = _("Low")
Expand Down
10 changes: 0 additions & 10 deletions data/icons/pixmaps/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,6 @@ pixmaps_DATA = \
blueman-battery-80.png \
blueman-battery-90.png \
blueman-battery-100.png \
blueman-lq-10.png \
blueman-lq-20.png \
blueman-lq-30.png \
blueman-lq-40.png \
blueman-lq-50.png \
blueman-lq-60.png \
blueman-lq-70.png \
blueman-lq-80.png \
blueman-lq-90.png \
blueman-lq-100.png \
blueman-rssi-10.png \
blueman-rssi-20.png \
blueman-rssi-30.png \
Expand Down
Binary file removed data/icons/pixmaps/blueman-lq-10.png
Binary file not shown.
Binary file removed data/icons/pixmaps/blueman-lq-100.png
Binary file not shown.
Binary file removed data/icons/pixmaps/blueman-lq-20.png
Binary file not shown.
Binary file removed data/icons/pixmaps/blueman-lq-30.png
Binary file not shown.
Binary file removed data/icons/pixmaps/blueman-lq-40.png
Binary file not shown.
Binary file removed data/icons/pixmaps/blueman-lq-50.png
Binary file not shown.
Binary file removed data/icons/pixmaps/blueman-lq-60.png
Binary file not shown.
Binary file removed data/icons/pixmaps/blueman-lq-70.png
Binary file not shown.
Binary file removed data/icons/pixmaps/blueman-lq-80.png
Binary file not shown.
Binary file removed data/icons/pixmaps/blueman-lq-90.png
Binary file not shown.
10 changes: 0 additions & 10 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -100,16 +100,6 @@ install_data(
'data/icons/pixmaps/blueman-battery-80.png',
'data/icons/pixmaps/blueman-battery-90.png',
'data/icons/pixmaps/blueman-battery-100.png',
'data/icons/pixmaps/blueman-lq-10.png',
'data/icons/pixmaps/blueman-lq-20.png',
'data/icons/pixmaps/blueman-lq-30.png',
'data/icons/pixmaps/blueman-lq-40.png',
'data/icons/pixmaps/blueman-lq-50.png',
'data/icons/pixmaps/blueman-lq-60.png',
'data/icons/pixmaps/blueman-lq-70.png',
'data/icons/pixmaps/blueman-lq-80.png',
'data/icons/pixmaps/blueman-lq-90.png',
'data/icons/pixmaps/blueman-lq-100.png',
'data/icons/pixmaps/blueman-rssi-10.png',
'data/icons/pixmaps/blueman-rssi-20.png',
'data/icons/pixmaps/blueman-rssi-30.png',
Expand Down
10 changes: 0 additions & 10 deletions module/_blueman.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ cdef extern from "libblueman.h":

cdef int connection_init(int dev_id, char *addr, conn_info_handles *ci)
cdef int connection_get_rssi(conn_info_handles *ci, signed char *ret_rssi)
cdef int connection_get_lq(conn_info_handles *ci, unsigned char *ret_lq)
cdef int connection_get_tpl(conn_info_handles *ci, signed char *ret_tpl, unsigned char type)
cdef int connection_close(conn_info_handles *ci)
cdef int c_get_rfcomm_channel "get_rfcomm_channel" (unsigned short service_class, char* btd_addr)
Expand All @@ -100,7 +99,6 @@ ERR = {
-4:"Get connection info failed",
-5:"Read RSSI failed",
-6:"Read transmit power level request failed",
-7:"Read Link quality failed",
-8:"Getting rfcomm list failed",
-9:"ERR_SOCKET_FAILED",
-12: "Can't bind RFCOMM socket",
Expand Down Expand Up @@ -248,14 +246,6 @@ cdef class conn_info:

return rssi

def get_lq(self):
cdef unsigned char lq
res = connection_get_lq(&self.ci, &lq)
if res < 0:
raise ConnInfoReadError(ERR[res])

return lq

def get_tpl(self, tp=0):
cdef signed char tpl
res = connection_get_tpl(&self.ci, &tpl, tp)
Expand Down
10 changes: 0 additions & 10 deletions module/libblueman.c
Original file line number Diff line number Diff line change
Expand Up @@ -220,16 +220,6 @@ int connection_get_rssi(struct conn_info_handles *ci, int8_t *ret_rssi)

}

int connection_get_lq(struct conn_info_handles *ci, uint8_t *ret_lq)
{
uint8_t lq;
if (hci_read_link_quality(ci->dd, htobs(ci->handle), &lq, 1000) < 0) {
return ERR_READ_LQ_FAILED;
}
*ret_lq = lq;
return 1;
}

int connection_get_tpl(struct conn_info_handles *ci, int8_t *ret_tpl, uint8_t type)
{
int8_t level;
Expand Down
2 changes: 0 additions & 2 deletions module/libblueman.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#define ERR_GET_CONN_INFO_FAILED -4
#define ERR_READ_RSSI_FAILED -5
#define ERR_READ_TPL_FAILED -6
#define ERR_READ_LQ_FAILED -7
#define ERR_GET_RFCOMM_LIST_FAILED -8
#define ERR_SOCKET_FAILED -9
#define ERR_BIND_FAILED -12
Expand All @@ -20,7 +19,6 @@ struct conn_info_handles {

int connection_init(int dev_id, char *addr, struct conn_info_handles *ci);
int connection_get_rssi(struct conn_info_handles *ci, int8_t *ret_rssi);
int connection_get_lq(struct conn_info_handles *ci, uint8_t *ret_lq);
int connection_get_tpl(struct conn_info_handles *ci, int8_t *ret_tpl, uint8_t type);
int connection_close(struct conn_info_handles *ci);
int get_rfcomm_channel(uint16_t uuid, char* btd_addr);
Expand Down
1 change: 0 additions & 1 deletion stubs/_blueman.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ class conn_info:
failed: bool
def __init__(self, addr: str, hci_name: str) -> None: ...
def deinit(self) -> None: ...
def get_lq(self) -> int: ...
def get_rssi(self) -> int: ...
def get_tpl(self) -> int: ...
def init(self) -> None: ...
Expand Down

0 comments on commit d2fe2e8

Please sign in to comment.