I just finished to build a new script with the help of this page
https://www.domoticz.com/wiki/Presence_ ... Beacon%29
All is ok if I run the service manually but after every reboot the service is failed!
I built the file check_beacon_presence.service as is
Code: Select all
Description=check_beacon_presence Service
After=multi-user.target
[Service]
User=root
Type=idle
ExecStart=python /usr/local/bin/check_beacon_presence.py
[Install]
WantedBy=multi-user.target
Code: Select all
sudo systemctl enable check_beacon_presence.service
Code: Select all
sudo systemctl start check_beacon_presence.service
Code: Select all
pi@raspberrypi4:~ $ sudo systemctl status check_beacon_presence.service -l
● check_beacon_presence.service
Loaded: loaded (/etc/systemd/system/check_beacon_presence.service; enabled; vendor preset: enabled)
Active: active (running) since Sat 2020-04-18 19:30:22 CEST; 1min 7s ago
Main PID: 7213 (python)
Tasks: 2 (limit: 3911)
Memory: 12.0M
CGroup: /system.slice/check_beacon_presence.service
└─7213 /usr/bin/python /usr/local/bin/check_beacon_presence.py
avril 18 19:30:22 raspberrypi4 systemd[1]: Started check_beacon_presence.service.
avril 18 19:30:22 raspberrypi4 sudo[7219]: root : TTY=unknown ; PWD=/ ; USER=root ; COMMAND=/bin/hciconfig hci1 down
avril 18 19:30:22 raspberrypi4 sudo[7219]: pam_unix(sudo:session): session opened for user root by (uid=0)
avril 18 19:30:22 raspberrypi4 sudo[7219]: pam_unix(sudo:session): session closed for user root
avril 18 19:30:22 raspberrypi4 sudo[7229]: root : TTY=unknown ; PWD=/ ; USER=root ; COMMAND=/bin/hciconfig hci1 up
avril 18 19:30:22 raspberrypi4 sudo[7229]: pam_unix(sudo:session): session opened for user root by (uid=0)
avril 18 19:30:22 raspberrypi4 sudo[7229]: pam_unix(sudo:session): session closed for user root
avril 18 19:30:22 raspberrypi4 sudo[7239]: root : TTY=unknown ; PWD=/ ; USER=root ; COMMAND=/bin/hciconfig
avril 18 19:30:22 raspberrypi4 sudo[7239]: pam_unix(sudo:session): session opened for user root by (uid=0)
avril 18 19:30:22 raspberrypi4 sudo[7239]: pam_unix(sudo:session): session closed for user root
Code: Select all
pi@raspberrypi4:~ $ sudo systemctl status check_beacon_presence.service -l
● check_beacon_presence.service
Loaded: loaded (/etc/systemd/system/check_beacon_presence.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Sat 2020-04-18 19:25:09 CEST; 1s ago
Process: 4777 ExecStart=/usr/bin/python /usr/local/bin/check_beacon_presence.py (code=exited, status=1/FAILURE)
Main PID: 4777 (code=exited, status=1/FAILURE)
avril 18 19:25:09 raspberrypi4 sudo[4803]: pam_unix(sudo:session): session opened for user root by (uid=0)
avril 18 19:25:09 raspberrypi4 sudo[4803]: pam_unix(sudo:session): session closed for user root
avril 18 19:25:09 raspberrypi4 python[4777]: Traceback (most recent call last):
avril 18 19:25:09 raspberrypi4 python[4777]: File "/usr/local/bin/check_beacon_presence.py", line 182, in <module>
avril 18 19:25:09 raspberrypi4 python[4777]: hci_toggle_le_scan(sock, 0x01)
avril 18 19:25:09 raspberrypi4 python[4777]: File "/usr/local/bin/check_beacon_presence.py", line 102, in hci_toggle_le_scan
avril 18 19:25:09 raspberrypi4 python[4777]: bluez.hci_send_cmd(sock, OGF_LE_CTL, OCF_LE_SET_SCAN_ENABLE, cmd_pkt)
avril 18 19:25:09 raspberrypi4 python[4777]: _bluetooth.error: (1, 'Operation not permitted')
avril 18 19:25:09 raspberrypi4 systemd[1]: check_beacon_presence.service: Main process exited, code=exited, status=1/FAILURE
avril 18 19:25:09 raspberrypi4 systemd[1]: check_beacon_presence.service: Failed with result 'exit-code'.
So I ran this command
Code: Select all
pi@raspberrypi4:~ $ sudo su
root@raspberrypi4:/home/pi# python /usr/local/bin/check_beacon_presence.py
So manually od ok but after rebbot no!
I am using RPI4 and buster
I can't understand where is my mistake
Any help or advice very appreciated
Have a good day