Read the statement by Michael Teeuw here.
Automatically wake bluetooth speaker from sleep/suspend
-
@stinger0815 start here
https://linuxcommand.org/lc3_wss0010.phpbut one point the filename does NOT NEED the .sh extension
The leap from this topic to my idea is that your ‘script’ can be named the same as the program u wish to run and no one could tell it was your script instead!
and your script can call the original program so you don’t have to recreate everything it doespath is an important topic here. covered in the linked topic
most of this works in windows too
-
@sdetweil said in Automatically wake bluetooth speaker from sleep/suspend:
@stinger0815 start here
https://linuxcommand.org/lc3_wss0010.phpbut one point the filename does NOT NEED the .sh extension
The leap from this topic to my idea is that your ‘script’ can be named the same as the program u wish to run and no one could tell it was your script instead!
and your script can call the original program so you don’t have to recreate everything it doespath is an important topic here. covered in the linked topic
most of this works in windows too
Hey thank you very much! I’ve in the meantime started to look for a hack to get it to work:
in the node_helper of the detector module I’ve changed the function that sends the notification once the trigger command is received and added a child_process (from nodejs) there:
onDetected: function (from, detected) { this.deactivate() let ble = require('child_process'); ble.exec('sh bluetooth_connector.sh', function (error, stdout, stderr) { console.log('stdout: ' + stdout); console.log('stderr: ' + stderr); if (error !== null) { console.log('exec error: ' + error); } }); this.sendSocketNotification("DETECTED", { from: from, key: detected } ) },
The script that is called by exec “bluetooth_connector” only contains:
#!/bin/bash bluetoothctl \ connect <<BLE ADDRESS>> exit
pretty hacky but does the job for now. I’ll now try to figure out whether this is actually decoupled enough so that the exec does not block the rest of the application. As I can tell from the logs it looks like the script is decoupled and runs in the background - what is good.
So as this is running now I’ll look into the solution you gave.
-
(if you think that is the better solution… I will engage you for coding :D)
-
@bugsounet said in Automatically wake bluetooth speaker from sleep/suspend:
(if you think that is the better solution… I will engage you for coding :D)
:face_with_hand_over_mouth:
It’s certainly not a perfect solution - I have to add that every time there is an update in the detector helper - ohh, surprise, there is an update in the detector module :D
-
humm…
i’m so kind today … so try v3.0.4 of GA with this recipe:var recipe = { commands: { "Bluetooth": { shellExec: { exec: (params) => { if (params.notification == "GA_ACTIVATE") return "bluetooth_connector.sh" else return null } } } }, plugins: { onNotificationReceived: "Bluetooth" }, } exports.recipe = recipe
Note maybe you have to add path in the return value example
/home/pi/bla/bla/bluetooth_connector.sh
-
@bugsounet said in Automatically wake bluetooth speaker from sleep/suspend:
humm…
i’m so kind today … so try v3.0.4 of GA with this recipe:var recipe = { commands: { [...] Note maybe you have to add path in the return value example `/home/pi/bla/bla/bluetooth_connector.sh`
That’s pretty sweet and works fine :) Thank you very much!
-
that i says:
i’m so kind today
because i offer no help there, so today you have a lot of chance :)
-
@stinger0815 : I am so sorry to “hijack” your thread. But do you perhaps have the correct steps to follow to install and get GA to work on the rpi? I have tried numerous threads, but all are out-dated and different from Google’s current developer screens - So I get to a spot where things are no longer working.
Google does not really help either, as I have raised questions, that gets not answered.Thank you and I apologize again.
-