billthefarmer / sig-gen

Android Signal Generator

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Feature request: allow controlling via intents

teemue opened this issue · comments

Title says it: for example, macrodroid script sends and intent to this app to change frequency generated.

I looked at this, it's doable. I looked at the docs to find out what MacroDroid can put in an intent and got an empty answer in the wiki...

Screenshot 2022-06-22 at 16-46-32 Action Send Intent - MacroDroid Wiki

So unless you can come up with some better docs my implementing this may be wasted effort as macrodroid may not be able to send a suitable intent. There's also no link to the sources, so I assume I can't look at that to find out.

I couldn't find better documentation myself, but attached are screenshots of the parameters macrodroid allows. Hope this is useful 😀Screenshot_20220623-102012.jpgScreenshot_20220623-102007.jpgScreenshot_20220623-101955.jpg

I installed Macrodroid to test this but could not find Send Intent. I assume it must need the paid version.

I have implemented this, excerpt from README:

External Control

The app may be started, the frequency, level, waveform and mute set externally by sending a suitable Intent from an automation app. The app package/activity is org.billthefarmer.siggen/.Main. The parameters may be:

Parameter Action/Category/Extra Type Value
Action android.intent.action.MAIN
android.intent.action.DEFAULT
Category android.intent.category.LAUNCHER
android.intent.category.DEFAULT
Extras org.billthefarmer.siggen.SET_FREQ int, float 0.1 – 25000
org.billthefarmer.siggen.SET_LEVEL int, float -80 – 0
org.billthefarmer.siggen.SET_WAVE int 0 = Sine
1 = Square
2 = Sawtooth
org.billthefarmer.siggen.SET_MUTE boolean true, false

Any combination of extras or none may be sent. Subsequent intents sent will update the parameters from the included extras.

This may be tested using the Android Debug Bridge.

$ adb shell am start --ef org.billthefarmer.siggen.SET_FREQ 257.3 --ef org.billthefarmer.siggen.SET_LEVEL -25.2 org.billthefarmer.siggen/.Main
Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=org.billthefarmer.siggen/.Main (has extras) }
$ adb shell am start --ez org.billthefarmer.siggen.SET_MUTE true org.billthefarmer.siggen/.Main
Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=org.billthefarmer.siggen/.Main (has extras) }
Warning: Activity not started, its current task has been brought to the front

Thanks for quick response :-)

For some reason, If I fire those adb commands, the device opens just siggen but with default values, not commanded ones

Thanks for quick response :-)

For some reason, If I fire those adb commands, the device opens just siggen but with default values, not commanded ones

Sorry. I guess I have to wait for a new build containing the newest implementations ;D

I have found Send Intent under Connectivity. However it doesn't work because the dialog doesn't include a category which appears to be required. You can start the app using Launch Application, but that allows no parameters.

Screenshot_20220624-183242 1

Actually I just built the newest apk myself and installed. Got intents working via macrodroid.

Type org.billthefarmer.siggen.Main in Class and it works :-)

Would it be possible to control siggen when it's running background though?

Further intents sent after the app is started will update parameters and bring the app to the front. As it works I have pushed a new version which will get built and appear on F-Droid in a few days, depending on their schedule.

There is an automation app on F-Droid – Automation which makes it easier to set up an intent with extras...

Screenshot_20220625-102409 1

This app' was already great, but with this feature it's become absolutely awesome!
Thanks a lot !