Extension of the antenna switch for direct execution of shell scripts on the Kiwi
I did some tests with an antenna switch using a relay board with Tasmota firmware.
Unfortunately there is a problem in the Kiwi firmware that spaces are removed from the cURL arguments in the extension for the antenna switch. This means that direct control of the relay board via cURL argument is not possible.
I therefore take the diversions via an external HTTP server with stored scripts for switching, which also works so far.
It would be a little easier if you could execute direct shell scripts on the Kiwi instead of the cURL arguments.
Or have I overlooked the fact that there is such a possibility?
Regards, Steffen
Comments
It's not that spaces are removed. Spaces are the delimiter between multiple curl command invocations (see: http://kiwisdr.com/info/#id-antsw)
You can't use a space in a curl URL anyway without %-escaping it (i.e. %20), so I don't understand how this could have worked using space characters (e.g. curl 'kiwisdr.com/files/filename%20with%20spaces') Now if you're wanting to specify other curl arguments besides the URL that's a different story.
I'm not sure I like the idea of executing shell scripts (as root) from the server. Seems like too much of a vulnerability vector.
Oh, sorry. Then I've made a mistake.
The first time I inserted these lines with spaces in between
http://192.168.x.y/cm?cmnd=Power2%20Off
http://192.168.x.y/cm?cmnd=Power1%20Off
it did not work. I had read that spaces are removed and thought that this meant the escape sequence %20.
Now it works, for whatever reason.
And the other thing with the scripts is now also clear to me that this should not work with root rights.
One more question about the cURL commands.
If I set "Switch to default antenna when no users connected?" to Yes and define a default antenna, will the cURL commands also be executed?
Thanks.
Regards, Steffen
Ugh. I don't understand. That code doesn't work at all. I tested it with Glenn's V/UHF converter and it worked fine. I'm sure of it. But looking at it now there's no way. It does everything wrong.
Give me a bit to fix it. I'll have it for the next release. Embedded spaces, default antenna mode and all..
Strange,
I tried my lines above to switch the antenna again and it worked once, but not after that.
Regards, Steffen
The way the code is currently, if you use a "%20" that gets translated into a space character in the Kiwi configuration itself, which is no good.
What I've done is made the "+" character get translated into a space. This is a URL standard and compatible with the fact that the field is being interpreted as a curl URL argument. An actual space character is used to separate multiple curl commands as it is now for backward compatibility.
Now that my antenna switch is working well, I have noticed one more thing that I wanted to ask if this is correct.
With 2 users the antenna switch is disabled, that's clear to me so far.
If one of the two users disconnects and only one user is still connected to the Kiwi, but here as user RX1, then the antenna switch remains disabled.
Only after the user RX1 is completely disconnected from the Kiwi, i.e. no more users are connected, and reconnects, now as user RX0, is the antenna switch enabled again.
Is this correct?
Regards, Steffen
No, it's not correct. I've fixed it now for the next release. Thanks