Ubuntu22.04之获取蓝牙键盘、蓝牙鼠标电量(二百七十七)

简介: CSDN博客专家、《Android系统多媒体进阶实战》一书作者

新书发布:《Android系统多媒体进阶实战》🚀
优质专栏: Audio工程师进阶系列原创干货持续更新中……】🚀
优质专栏: 多媒体系统工程师系列原创干货持续更新中……】🚀
优质视频课程:AAOS车载系统+AOSP14系统攻城狮入门视频实战课 🚀

人生格言: 人生从来没有捷径,只有行动才是治疗恐惧和懒惰的唯一良药.

更多原创,欢迎关注:Android系统攻城狮

欢迎关注Android系统攻城狮

🌻1.前言

本篇目的:Ubuntu22.04之获取蓝牙键盘、蓝牙鼠标电量

🌻2.开发需求

通过命令获取蓝牙鼠标、蓝牙键盘电池电量

🌻3.解决方案

🐓3.1 方式一

  • bluetoothctl命令
  • 1.获取蓝牙设备的Mac地址(用它获取电量)
# bluetoothctl devices
Device 00:xx:xx:xx:xx:11 Bluetooth Keyboard
Device xx:xx:xx:xx:xx:22 Mouse BT3.0
  • 2.获取蓝牙鼠标和键盘电量
# bluetoothctl

获取蓝牙键盘电量
# info 00:xx:xx:xx:xx:11
  • 3.获取蓝牙鼠标电量
# 00:xx:xx:xx:xx:22

搜索:Battery关键字
  • 注意:如果以上没有:Battery关键字,请继续看下面第二种方式。

🐓3.2 方式二

  • upower命令
  • 1.获取设备
# upower -e
/org/freedesktop/UPower/devices/battery_Mouse
/org/freedesktop/UPower/devices/keyboard_battery

2.获取蓝牙键盘电池电量:

# upower -i /org/freedesktop/UPower/devices/keyboard_battery
native-path:          hid-00:xx:xx:xx:xx:xx-battery
  model:                xxx Keyboard
  power supply:         no  
  has history:          yes
  has statistics:       yes
  keyboard
    present:             yes
    rechargeable:        yes
    state:               discharging
    warning-level:       none
    percentage:          66%
    icon-name:          'battery-full-symbolic'
  • 注意:蓝牙键盘电量剩余:66%

3.获取蓝牙鼠标电池电量:

# upower -i /org/freedesktop/UPower/devices/battery_Mouse
native-path:          hid-00:xx:xx:xx:xx:22-battery
  model:                xxx Mouse
  power supply:         no  
  has history:          yes
  has statistics:       yes
  keyboard
    present:             yes
    rechargeable:        yes
    state:               discharging
    warning-level:       none
    percentage:          88%
    icon-name:          'battery-full-symbolic'
  • 注意:蓝牙鼠标电量剩余:88%

4.dump所有蓝牙设备电量信息

# upower -d
native-path:          hid-00:xx:xx:xx:xx:22-battery
  model:                xxx Mouse
  power supply:         no  
  has history:          yes
  has statistics:       yes
  keyboard
    present:             yes
    rechargeable:        yes
    state:               discharging
    warning-level:       none
    percentage:          88%
    icon-name:          'battery-full-symbolic'
native-path:          hid-00:xx:xx:xx:xx:xx-battery
  model:                xxx Keyboard
  power supply:         no  
  has history:          yes
  has statistics:       yes
  keyboard
    present:             yes
    rechargeable:        yes
    state:               discharging
    warning-level:       none
    percentage:          66%
    icon-name:          'battery-full-symbolic' 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Android系统攻城狮

你的鼓励将是我创作的最大动力!

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值