![]() |
#1 |
Connoisseur
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 55
Karma: 78045
Join Date: Oct 2023
Location: Ontario, Canada
Device: Kobo Aura Edition 2, Kobo Clara 2E
|
![]()
Hello folks,
I'm trying to turn on Bluetooth programmatically without needing Nickel for alternative readers on my Kobo Clara 2E. I wrote the patch to turn Bluetooth on and off using NickelMenu, and it works perfectly fine, but when I try to run the services that get triggered when Nickel is used, I get unreliable behavior. I need some help in making sense of all the programs that are running. Here's what I've found out: ps dump changes after turning Bluetooth on via Nickel: Code:
[root@kobo ~]# ps PID USER TIME COMMAND ...... 5173 root 0:00 /bin/bluealsa -S -i hci0 5170 root 0:00 /sbin/getty -L ttymxc0 (or ttymxc1) 115200 vt100 ...... # this is where I turn on bluetooth 3431 root 0:00 /sbin/hciattach -n ttymxc1 any 1500000 flow -t 20 3434 root 0:00 [hci0] 3435 root 0:00 [hci0] 3440 root 0:00 /libexec/bluetooth/bluetoothd Here's my script: Code:
# cat on.sh #!/bin/bash cd "$(dirname "$0")" # Check if bluetoothd is running if ! pgrep bluetoothd > /dev/null then echo "bluetoothd is not running." echo "Killing getty and bluealsa" # An experiment pkill bluealsa & pkill getty & sleep 1 echo "bluealsastuff" # Content: # /bin/bluealsa -S -i hci0 & # pkill bluetoothd sh bluealsastuff.sh > /dev/null 2>&1 & echo "Adding uhid.ko.." # load the kernel patch for the device recognition sh ./adduhid.sh echo "hci services.." sh ./runhci.sh # nohup /sbin/hciattach -n ttymxc1 any 1500000 flow -t 20 & echo "Starting bluetoothd.." /libexec/bluetooth/bluetoothd > /dev/null 2>&1 & echo "Sleep 1" sleep 1 bluetoothctl power on echo "HCI0 up..." hciconfig hci0 up echo "Success.." else echo "bluetoothd is already running. No action taken." fi exit 0 Code:
# hciconfig hci0 hci0: Type: Primary Bus: UART BD Address: A4:3C:D7:10:62:44 ACL MTU: 1016:5 SCO MTU: 60:12 DOWN RX bytes:1711 acl:29 sco:0 events:95 errors:0 TX bytes:1597 acl:29 sco:0 commands:56 errors:0 Code:
hciconfig hci0 up If I run Bluetooth once from Nickel and then go run the script, I see that my chances are better. It's also a must to have WiFi running for Bluetooth to be turned on for Nickel btpt to run. After doing this once, it's not necessary for the script to have wifi on. Any help in making this process a bit more reliable is appreciated. For what it's worth, this is how I turn off Bluetooth: Code:
cat off.sh #!/bin/bash cd "$(dirname "$0")" # Check if bluetoothd is running if pgrep bluetoothd > /dev/null then echo "bluetoothd is running." echo "Turning off Bluetooth and killing bluetoothd." # bluetoothctl power off pkill bluetoothd echo "Remove uhid.ko.." sh ./removeuhid.sh echo "Killing hciattach.." pkill hciattach echo "Success.." else echo "bluetoothd is not running. No action taken." fi The killing of bluealsa and getty (I have no idea what they do) was an experiment as they seem to be using the ttymxc1 sometimes and I thought maybe isn't making the device busy or something. I haven't been able to verify this 100%. Thank you |
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Unexpected behaviour of the Calibre "e-book editor" | WalterWalter | Editor | 2 | 02-18-2022 05:24 AM |
Calibre 4/4.1 "Metadata Edit" (HTML-view) changed behaviour | ajki | Library Management | 1 | 10-16-2019 09:10 PM |
Strange behaviour with "not referenced" files | Phssthpok | Editor | 4 | 10-21-2015 10:43 AM |
iPad Evernote and Adonit team up for Bluetooth fine-point "Jot Script" stylus | Jessica Lares | Apple Devices | 31 | 10-11-2013 11:17 PM |
Alter Double-click behaviour to "edit metadata" instead of "open ebook?" | Feather_Qwill | Library Management | 5 | 09-15-2013 11:20 AM |