01-08-2019, 07:11 PM
That code doesn't detect the presense of the adapter but rather it assumes the adapter is present and then starts the Bluetooth services.
Ideally we would want to know whether an adapter exists before deciding whether to start Bluetooth. For example with a BT dongle inserted, the function startBt() will most likely succeed and we will have a MAC address established in /var/lib/bluetooth. If the adapter is subsequently removed the MAC address will remain and thus it can't be used to reliably detect the presense of the adapter.
I think that simply starting hciuart would be a reliable test but it takes almost 2 minutes to timeout when no adapter :-0 This makes it unsuitable.
-Tim
Ideally we would want to know whether an adapter exists before deciding whether to start Bluetooth. For example with a BT dongle inserted, the function startBt() will most likely succeed and we will have a MAC address established in /var/lib/bluetooth. If the adapter is subsequently removed the MAC address will remain and thus it can't be used to reliably detect the presense of the adapter.
I think that simply starting hciuart would be a reliable test but it takes almost 2 minutes to timeout when no adapter :-0 This makes it unsuitable.
Code:
Jan 08 13:56:07 rp4 polkitd(authority=local)[608]: Registered Authentication Agent for unix-process:6454:1004991 (system bus name :1.10 [/usr/bin/pkttyagent --notify-fd 5 --fallback], object path /org
Jan 08 13:56:16 rp4 polkitd(authority=local)[608]: Unregistered Authentication Agent for unix-process:6454:1004991 (system bus name :1.10, object path /org/freedesktop/PolicyKit1/AuthenticationAgent,
Jan 08 13:56:16 rp4 polkitd(authority=local)[608]: Operator of unix-process:6454:1004991 FAILED to authenticate to gain authorization for action org.freedesktop.systemd1.manage-units for system-bus-na
Jan 08 13:56:19 rp4 sudo[6467]: pi : TTY=pts/0 ; PWD=/home/pi ; USER=root ; COMMAND=/bin/systemctl start hciuart
Jan 08 13:56:19 rp4 sudo[6467]: pam_unix(sudo:session): session opened for user root by pi(uid=0)
Jan 08 13:57:49 rp4 systemd[1]: dev-serial1.device: Job dev-serial1.device/start timed out.
Jan 08 13:57:49 rp4 systemd[1]: Timed out waiting for device dev-serial1.device.
-Tim