Page 1 of 1

Mikrotik Starlink Stow button action

Posted: Fri Jun 02, 2023 11:06 pm
by diablonet
Hello, I own a Mikrotik Router (with MODE button), I use it with a starlink in ethernet bypass mode, so I want to make a script to STOW the antenna with a script or pressing the MODE button, any suggestion on how to make this? thank you in advance.

Re: Mikrotik Starlink Stow button action

Posted: Fri Jun 02, 2023 11:30 pm
by Amm0
Theoretically possible... But the issue is that Starlink uses https://grpc.io instead of more normal REST API. gRPC to starlink uses these binary blobs called protocol buffers so not easy as it might sound to call /tool/fetch to do this. Be useful. It works from from a real OS with some libraries, so if you have a container support, but again not a direct path either.

Re: Mikrotik Starlink Stow button action

Posted: Fri Jun 02, 2023 11:43 pm
by rextended
Sorry, I don't know Starlink, but the command is for ROTATE the antenna or for CLOSE the antenna, or for FOLD UP the antenna?
Or for STOW the antenna, what really is mean?
Thank you.

Re: Mikrotik Starlink Stow button action

Posted: Fri Jun 02, 2023 11:52 pm
by Amm0
Normally the dish points to the north at ~45º to the mount. Since the head on the dish/pole moves, you can move to ~15% so it fits in the box (or drop snow/debree from the dish since it can become almost flat). That action is called "stow" – actually a common term for satellites.

But the binary protbufs in gRPC are the issue – not as hard as SMS PDUs but not one-line. ;)

There's libraries for various languages like Go, Node, etc for gRPC – but in RouterOS not so lucky...

Re: Mikrotik Starlink Stow button action

Posted: Fri Jun 02, 2023 11:54 pm
by rextended
Thanks for the info, I do not have Starlink, I'm the WISP of myself :lol: :lol: :lol:
Had it, I would have tried something with containers indeed...

Re: Mikrotik Starlink Stow button action

Posted: Sat Jun 03, 2023 12:21 am
by Amm0
Thanks for the info, I do not have Starlink, I'm the WISP of myself :lol: :lol: :lol:
Had it, I would have tried something with containers indeed...
Yup. I use a container to pull signal data from them, but I've never tried any operations.

All of the ones I manage are remote, so the "stow" will lose the signal – so not easy to test even ;).

Re: Mikrotik Starlink Stow button action

Posted: Sat Jun 03, 2023 12:36 am
by rextended
So in places closer to the equator do storks nest on top of it? :lol: :lol: :lol:

Re: Mikrotik Starlink Stow button action  [SOLVED]

Posted: Sat Jun 03, 2023 1:29 am
by diablonet
thank you for the help, I managed to make it with the following settings:

-The Mikrotik/Starlink connects to my L2TP main connection on fixed VPN IP address, I own also a linux box with apache/PHP.

So I made a PHP with the following code:
<?php
$cmd = $_GET['cmd'];

if ($cmd == "stow") {
#   echo "ok";
   shell_exec('grpcurl -plaintext -d {\"dish_stow\":{}} starlinkipvial2tp:9200 SpaceX.API.Device.Device/Handle');
} else {
#    echo "error";
    }
?>
Note that I am using grpcurl, you can download it somewhere, also, pre compiled versions.

On the Mikrotik / starlink side, I have the following setting:
/ip firewall nat add action=dst-nat chain=dstnat comment="Stow via VPN" dst-port=9200 in-interface=L2TP-VPN protocol=tcp to-addresses=192.168.100.1 to-ports=9200
/system routerboard mode-button set enabled=yes on-event="/log error \"Mode button pressed, executing Stow...\"\r\
    \n/tool fetch url=\"http://linux-ip/sl.php\?cmd=stow\""
It works that way but maybe there is a simpler way to archive this, thank you again

Re: Mikrotik Starlink Stow button action

Posted: Sat Jun 03, 2023 5:15 pm
by Amm0
Note that I am using grpcurl, you can download it somewhere, also, pre compiled versions.
Yeah I use "grpcurl" too. https://github.com/fullstorydev/grpcurl
It works that way but maybe there is a simpler way to archive this, thank you again
I think that's best you can do. While I use container, that part isn't important. I also do NAT'ing to 192.168.100.1 to get them remotely (and since I have multiple starlinks give each different IP within mgmt IP subnet).

In my case, the only downside to "grpcurl" is that make a >30Mb container. With Go language... could theoritically compile just the starlink gRPC bindings (not all of grpcurl) with the Go https server into a container – that be smaller. But I just accepted a bigger container to do this. There is also another container https://github.com/danopstech/starlink_exporter that does monitoring to Promethesis – that could be adapted to support "stow" since they run a web server.

But as for a "mode button to stow", I think that's about as simple as you could make, given spacex [dumb] usage of gRPCs. Also pretty nifty since you need to stow to move it & using the app isn't as easy as "one touch" on the Mikrotik.

Re: Mikrotik Starlink Stow button action

Posted: Sat Jun 03, 2023 8:37 pm
by diablonet
Thank you Amm0 for your help and suggestions, at least it works on a "tricky" way, greetings