INDI Library v1.9.8 Released (29 Sep 2022)

Bi-monthly INDI Library released with new drivers and bug fixes.

Remote Control - WebSockets API to Ekos Module

  • Posts: 24
  • Thank you received: 14
Hi Jasem, Hi everyone!

Today I want to share my idea with you and know if it will be useful to you.

Who needs it for?
Sometimes when observing, especially without the use of a camera, it is necessary to move the mount slightly or to improve the sharpness using, for example, the Bahtinov mask .
This is where the control becomes problematic when the eyesight is directed to the eyepiece lens.
In Ekos, you can use, for example, "Mount Control", but looking through the eyepiece, it is difficult to manipulate the mouse on the screen and hit the appropriate button.

The idea is a wireless / wired handheld controller that could be a smartphone.
The application is a simple website using Vue.Js 3.0 that can be hosted anywhere.
Following the Plug & Play principle, I put a simple web server in the KStars project itself on port 1080, which displays this page.

Locally (you can test quickly):
Open a browser and go to http://localhost:1080 on the same device as running KStars with the "ManagerWebSocket" branch.

On a remote device that is on the same network as the computer and KStars, type http://<ADDRESS_IP_KSTARS>:1080/ in the browser.

Connect your phone via USB to the computer with KStars and select USB Tethering in your phone's settings.
Now you can access the website by typing http://<ADRES_IP_KSTAR>:1080/ in your browser

How it works?
On port 1081, communication takes place via the WebSocket protocol using the Json format.
The appropriate Json structure specifying the module, function, and arguments is sent to port 1081, then the function is searched for and executed.
If the function returns a type, it is returned in the same structure.

For example, if we want to call a function:
// Adjust focuser offset, relative or absolute
void adjustFocusOffset(int value, bool useAbsoluteOffset);
Which is in the "Focus" class, just send a text message with the structure and example values of the function argument:
    ekos: {
        focus: {
             adjustFocusOffset: [100, false]
And that's it. The focus will be shifted.

Modules are upgradeable over time, currently "mount" and "focus" are used.
See kstars/ekos/managerwebsocket.cpp
            /* ... */
            auto args = QJsonDocument::fromJson(message.toLatin1()).toVariant().toMap()["ekos"].toMap();
            if (args.count() == 0)
            QVariantMap result;
            s_invokeModule(m_manager->mountModule(), "mount", args, result); // mount
            s_invokeModule(m_manager->focusModule(), "focus", args, result); // focus
            /* ... */
            if (!result.isEmpty())
                QVariantMap resultMap;
                resultMap["ekos"] = result;
            /* ... */
To call the function, the "QMetaMethod::invoke" mechanism is used, which allows calling every function in the class (if it is correctly implemented).

What do you think about it?
The code is written, I decided to clean it today and share it.
I personally use it. If you like it and you have any suggestions on what I can improve, I can take care of it.

KStars feature/ManagerWebSocket
1 month 4 weeks ago #86678

Please Log in or Create an account to join the conversation.

Hi Pawel, thank you for the idea. We already have DBus for IPC, so methods can be invoked from DBus. The other option via WebSockets is EkosLive, perhaps it can be extended to support "generic method calls". I don't think we need to introduce yet another new method to control Ekos.
Jasem Mutlaq
Support INDI & Ekos; Get StellarMate Astrophotography Gadget.
How to Submit Logs when you have problems?
Add your observatory info
1 month 4 weeks ago #86682

Please Log in or Create an account to join the conversation.

  • Posts: 24
  • Thank you received: 14
Ah yes, I get it. I am currently using a powerful laptop to record videos at full bandwidth.
I have not found a simple solution to additionally be able to control from a smartphone without using the Internet.
From what I remember Ekos Live connects to the server, but does not create the server itself, although now I can see several different projects ;)
Thanks for the quick answer, I understand that many implementations of similar solutions are also troublesome to maintain.
1 month 4 weeks ago #86694

Please Log in or Create an account to join the conversation.

Time to create page: 0.623 seconds