1、执行
> /home/firefly/.config/lxsession/Lubuntu/autostart
2、执行
crontab -e
修改
10 * * * * /bin/bash /opt/restart_bluetoothdemo.sh &> /dev/null
为
10 * * * * /bin/systemctl restart ble-gw
3、执行
vim /etc/systemd/system/ble-gw.service
复制下面文本
[Unit]
Description=Start Bluetooth Gateway Application after Network
After=network.target,systemd-resolved.service
Wants=network.target,systemd-resolved.service
[Service]
Environment=DISPLAY=:0
Environment=XDG_RUNTIME_DIR=/run/user/1000
Environment=PULSE_RUNTIME_PATH=/run/user/1000/pulse/
Environment = LD_LIBRARY_PATH=/opt/Qt/5.15.14_armhf/lib:/usr/local/lib
Environment = QT_PLUGIN_PATH=/opt/Qt/5.15.14_armhf/plugins
Environment = PATH=$PATH:/opt/Qt/5.15.14_armhf/bin
ExecStartPre=/bin/sleep 15
ExecStart=/home/firefly/Downloads/build-bluetoothdemo-unknown-Release/bluetoothdemo
WorkingDirectory=/home/firefly/Downloads/build-bluetoothdemo-unknown-Release/
Restart=always
User=firefly
[Install]
WantedBy=multi-user.target
按键盘字母i,然后鼠标右键粘贴
然后按键盘输入冒号,再输入小写wq,回车
4、设置ble-gw开机自启
systemctl enable ble-gw
5、关闭系统日志服务
systemctl disable --now systemd-journald.service
systemctl disable --now syslog.socket rsyslog.service
6、开启dhcp自动续约:在配置文件中,添加或修改以下行:
vim /etc/dhcp/dhclient.conf
# 启用自动续约
request-renewal-time=60