当前位置:网站首页>树莓派连接蓝牙音箱
树莓派连接蓝牙音箱
2022-08-04 17:18:00 【ttyt1217】
安装依赖包
sudo apt-get update
sudo apt-get install pulseaudio pulseaudio-module-bluetooth
sudo apt-get install pi-bluetooth bluez bluez-firmware blueman
sudo apt install bluez bluez-firmware pulseaudio pulseaudio-module-bluetooth
sudo /etc/init.d/bluetooth restart
设置蓝牙配对连接音箱
bluetoothctl
show
power on
default-agent
scan on
pair 41:42:90:F3:9E:B5
trust 41:42:90:F3:9E:B5
connect 41:42:90:F3:9E:B5
info 41:42:90:F3:9E:B5
exit
树莓派每次开机后都要执行此脚本来连接蓝牙音箱/home/pi/myboot/startboot.sh
#!/bin/bash
sleep 1
pulseaudio --k
pulseaudio --start
bluetoothctl power on
bluetoothctl connect 41:42:90:F3:9E:B5
sleep 5
aplay /home/pi/myboot/startaudio.wav
echo 'audio OK~~~'
*下面这个蓝牙开机自连脚本其实是有问题的,开机自启后看似蓝牙音箱是已连接状态了,但是播放音乐还是无声,还需要在当前SSH连接终端手动执行一次上面startboot.sh
脚本才行。
开机启动用/etc/init.d/startboot
#!/bin/sh
#/etc/init.d/startboot
### BEGIN INIT INFO
# Provides:startboot
# Required-Start:$remote_fs $syslog
# Required-Stop:$remote_fs $syslog
# Default-Start:2 3 4 5
# Default-Stop:0 1 6
# Short-Description: startboot
# Description: This service is used to start my applaction
### END INIT INFO
case "$1" in
start)
echo "start your app here."
su pi -c "sh /home/pi/myboot/startboot.sh"
;;
stop)
echo "stop your app here."
;;
*)
echo "Usage: service startboot start|stop"
exit 1
;;
esac
exit 0
启动服务service startboot start
播放音频测试:
ffplay -nodisp -autoexit /home/pi/myboot/startaudio.wav
aplay /home/pi/myboot/startaudio.wav
边栏推荐
- 容器化 | 在 NFS 备份恢复 RadonDB MySQL 集群数据
- R语言ggplot2可视化:使用ggpubr包的ggbarplot函数可视化柱状图、color参数指定柱状图的边框的色彩
- 最小区间覆盖
- CF86D Powerful array
- (一)、线性表的顺序存储结构链式存储结构
- 【商家联盟】云平台—异业联盟,打造线上线下商业相结合的系统
- 如何模拟后台API调用场景,很细!
- codeforces每日5题(均1600)-第二十八天
- 并发编程原理学习-reentrantlock源码分析
- LeetCode Question of the Day - 1403. Minimum Subsequence in Non-Increasing Order
猜你喜欢
Copycat CNN: Stealing Knowledge by Persuading Confession with Random Non-Labeled Data阅读心得
【LeetCode每日一题】——540.有序数组中的单一元素
44. 通配符匹配 ●●● & HJ71 字符串通配符 ●●
Learning to Explore - Setting the Foreground Color for Fonts
shell脚本详解-------循环语句wuile循环和until循环
适配器模式
软件测试高频面试题真实分享/网上银行转账是怎么测的,设计一下测试用例。
【LeetCode Daily Question】——374. Guess the size of the number
What does the product system of a digital financial enterprise look like?
mysql学习笔记——利用动态SQL和Session变量实现一个公式或者计算器
随机推荐
消灭异步回调,还得是async-await
域名哪家便宜?怎么买便宜域名?
R语言缺失时间序列的填充及合并:补齐时间序列数据中所有缺失的时间索引、使用merge函数合并日期补齐之后的时间序列数据和另外一个时间序列数据(补齐左侧数据)
Catering Supply Chain Management System
JSP的Web监听器(Listener)
拼多多详情API接口深度解读
C# Sqlite database construction and use skills
抖音最重要的接口——item_search_video-根据关键词获取视频列表
自定义组件,并在组件中注入自定义组件实现多种场景的下的组件切换
正则过滤字符串中 script 标签
麒麟信安石勇博士荣获openEuler社区年度开源贡献之星
太一集团全资收购火币旗下社交产品火信
海报 | 夏季高温,危化品安全风险的注意事项必须get!
15 days to upgrade to fight monsters and become a virtual fashion creator
Boost library study notes (1) Installation and configuration
Learning and Exploration-Introducing Baidu Statistics to the Website
安装失败怎么办
荣耀发布开发者服务平台,智慧生态合作提速
88. (the home of cesium) cesium polymerization figure
适配器模式