Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CoT messages not showing in WinTAK #57

Open
iandresolares opened this issue Dec 7, 2023 · 3 comments
Open

CoT messages not showing in WinTAK #57

iandresolares opened this issue Dec 7, 2023 · 3 comments

Comments

@iandresolares
Copy link

Hello!
First of all thank you for the the library!

So I am having troubles understanding how to connect to WinTAK. Basically for now I just want to test sending GPS data to WinTAK so it shows as a marker of some type. Later I plan to integrate the device with UAS plugin in order to manage waypoint navigation (I hope this is possible).
The thing is, I have slightly modified the example send.py script, to send fake data to my WinTAK (both the script and WinTAK are running on the same PC).
However I do not receive anything at all in WinTAK (I guess there is network configuration problem in WinTAK) and I can not figure out why.

Here is the code:

import asyncio
import xml.etree.ElementTree as ET

from configparser import ConfigParser

import pytak
import takproto

import time
import datetime

class MySerializer(pytak.QueueWorker):
    """
    Defines how you process or generate your Cursor on Target Events.
    From there it adds the CoT Events to a queue for TX to a COT_URL.
    """

    async def handle_data(self, data):
        """Handle pre-CoT data, serialize to CoT Event, then puts on queue."""
        event = data
        resp = await self.put_queue(event)
        print(resp)

    async def run(self, number_of_iterations=-1):
        """Run the loop for processing or generating pre-CoT data."""
        while 1:
            # data = tak_pong()
            # await self.handle_data(data)
            # print("pong data has been sent")
            # await asyncio.sleep(20)
            now = datetime.datetime.utcnow()
            stale = now
            stale += datetime.timedelta(hours=1)
            now_iso = now.isoformat()[:-4] + "Z"
            stale_iso = stale.isoformat()[:-4] + "Z"
            # 2023-12-05T08:46:22.96Z
            # 2023-12-07T12:01:37.681452Z
            print(now_iso)
            print(stale_iso)
            cot = f"""<?xml version='1.0' encoding='utf-16' standalone='yes'?>
<event version='2.0' uid='S-1-5-21-3327203913-228467099-2355216783-1001' type='a-f-G' time='{now_iso}' start='{now_iso}' stale='{stale_iso}' how='h-e'>
    <point lat='43.545231' lon='-5.661920' hae='9999999' ce='9999999' le='9999999' />
    <detail>
        <takv version='4.1.0.231' platform='WinTAK-CIV' os='Microsoft Windows 11 Home' device='HP HP Laptop 15-da0xxx' />
        <contact callsign='FONG' endpoint='' />
        <uid Droid='FONG' />
        <__group name='Cyan' role='Team Member' />
        <status battery='50' />
        <track course='0.00000000' speed='0.00000000' />
    </detail>
</event>
"""
            
            buf = takproto.xml2proto(cot,  takproto.TAKProtoVer.STREAM)
            print(buf)
            await self.handle_data(buf)
            # await asyncio.sleep(20)
            time.sleep(2)

def tak_pong():
    """Generate a simple takPong CoT Event."""
    root = ET.Element("event")
    root.set("version", "2.0")
    root.set("type", "t-x-d-d")
    root.set("uid", "takPong")
    root.set("how", "m-g")
    root.set("time", pytak.cot_time())
    root.set("start", pytak.cot_time())
    root.set("stale", pytak.cot_time(3600))
    return ET.tostring(root)


async def main():
    """Main definition of your program, sets config params and
    adds your serializer to the asyncio task list.
    """
    config = ConfigParser()
    config["mycottool"] = {"COT_URL": "tcp://192.168.99.108:4242"}
    config = config["mycottool"]

    # Initializes worker queues and tasks.
    clitool = pytak.CLITool(config)
    await clitool.setup()

    # Add your serializer to the asyncio task list.
    clitool.add_tasks(set([MySerializer(clitool.tx_queue, config)]))

    # Start all tasks.
    await clitool.run()


if __name__ == "__main__":
    asyncio.run(main())

Also I attach some WinTAK screenshots which may be useful:
imagen
imagen
imagen

Some help is greatly appreciate it. Thanks!!

BR

@jackwilliams2480
Copy link

Did you ever figure out the solution?

@omkarjoshi-07
Copy link

Hey guys! I am also trying to send some sample COT drone detection event from python in the way mentioned above. It seems data is being sent to winTAK, but I am not able to see anything on winTAK. Can anyone please help me to understand?

@surabhiwireless
Copy link

Hi all, I am facing the same issue as well. I am trying to send COT messages to the server, the server port shows bytes received; but I can see nothing on webtak (the one which is available on the TAK server installation, and when the TAK server is launched on the web).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants