├── .github ├── FUNDING.yml └── workflows │ ├── debian.yml │ ├── python-publish_to_pypi.yml │ └── python-test_and_lint.yml ├── .gitignore ├── .readthedocs.yml ├── CHANGELOG.md ├── LICENSE ├── Makefile ├── README.md ├── debian ├── install_pkg_build_deps.sh ├── takproto.conf ├── takproto.postinst └── takproto.service ├── docs ├── changelog.md ├── index.md ├── installation.md ├── media │ ├── atak_screenshot_with_pytak_logo-x25.jpg │ ├── atak_screenshot_with_pytak_logo-x25.png │ ├── atak_screenshot_with_pytak_logo.jpg │ ├── pytak_logo-256x264.png │ ├── pytak_logo.png │ └── takproto_chart.png ├── origin.md ├── requirements.txt ├── tak_protocols.md └── usage.md ├── mkdocs.yml ├── requirements_test.txt ├── setup.cfg ├── setup.py ├── src-protobuf ├── .cvsignore ├── LICENSE.md ├── contact.proto ├── cotevent.proto ├── detail.proto ├── group.proto ├── precisionlocation.proto ├── protocol.txt ├── status.proto ├── takcontrol.proto ├── takmessage.proto ├── takv.proto └── track.proto ├── stdeb.cfg ├── takproto ├── .gitignore ├── __init__.py ├── constants.py ├── delimited_protobuf.py ├── functions.py └── proto │ ├── .gitignore │ ├── __init__.py │ ├── contact_pb2.py │ ├── cotevent_pb2.py │ ├── detail_pb2.py │ ├── group_pb2.py │ ├── precisionlocation_pb2.py │ ├── status_pb2.py │ ├── takcontrol_pb2.py │ ├── takmessage_pb2.py │ ├── takv_pb2.py │ └── track_pb2.py └── tests └── test_functions.py /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: ampledata 4 | patreon: # Replace with a single Patreon username 5 | open_collective: # Replace with a single Open Collective username 6 | ko_fi: ampledata 7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 9 | liberapay: # Replace with a single Liberapay username 10 | issuehunt: # Replace with a single IssueHunt username 11 | otechie: # Replace with a single Otechie username 12 | lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry 13 | custom: https://www.buymeacoffee.com/ampledata 14 | -------------------------------------------------------------------------------- /.github/workflows/debian.yml: -------------------------------------------------------------------------------- 1 | name: Build Debian Package 2 | 3 | on: 4 | push: 5 | tags: 6 | - '*' 7 | 8 | env: 9 | DEB_BUILD_OPTIONS: nocheck 10 | 11 | jobs: 12 | build-artifact: 13 | runs-on: ubuntu-20.04 14 | 15 | steps: 16 | - uses: actions/checkout@master 17 | 18 | - name: Install Debian Package Building Dependencies 19 | run: sudo bash debian/install_pkg_build_deps.sh 20 | 21 | - name: Create Debian Package 22 | run: make clean package 23 | 24 | - name: Upload Artifacts to GitHub 25 | uses: actions/upload-artifact@master 26 | with: 27 | name: artifact-deb 28 | path: deb_dist/*.deb 29 | 30 | - name: Create GitHub Release 31 | id: create_release 32 | uses: actions/create-release@master 33 | env: 34 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 35 | with: 36 | tag_name: ${{ github.ref }} 37 | release_name: Release ${{ github.ref }} 38 | draft: false 39 | prerelease: false 40 | 41 | - name: Upload Release Asset to GitHub 42 | id: upload-release-asset 43 | uses: svenstaro/upload-release-action@v2 44 | with: 45 | repo_token: ${{ secrets.GITHUB_TOKEN }} 46 | file: deb_dist/*.deb 47 | tag: ${{ github.ref }} 48 | overwrite: true 49 | file_glob: true -------------------------------------------------------------------------------- /.github/workflows/python-publish_to_pypi.yml: -------------------------------------------------------------------------------- 1 | # This workflow will upload a Python Package using Twine when a release is created 2 | name: Publish package to PyPI 3 | 4 | on: 5 | push: 6 | tags: 7 | - '*' 8 | 9 | jobs: 10 | deploy: 11 | 12 | runs-on: ubuntu-latest 13 | 14 | steps: 15 | - uses: actions/checkout@v2 16 | - name: Set up Python 17 | uses: actions/setup-python@v2 18 | with: 19 | python-version: '3.x' 20 | - name: Install dependencies 21 | run: | 22 | python3 -m pip install --upgrade pip 23 | python3 -m pip install setuptools wheel twine 24 | - name: Build 25 | run: | 26 | python3 setup.py sdist bdist_wheel 27 | - name: Publish package 28 | uses: pypa/gh-action-pypi-publish@release/v1 29 | with: 30 | user: __token__ 31 | password: ${{ secrets.PYPI_API_TOKEN }} 32 | -------------------------------------------------------------------------------- /.github/workflows/python-test_and_lint.yml: -------------------------------------------------------------------------------- 1 | name: Lint & Test Code 2 | 3 | on: 4 | push: 5 | branches: [ main ] 6 | pull_request: 7 | branches: [ main ] 8 | 9 | jobs: 10 | build: 11 | 12 | runs-on: ubuntu-20.04 13 | strategy: 14 | fail-fast: false 15 | matrix: 16 | python-version: [3.6, 3.7, 3.8, 3.9, "3.10", "3.11", "3.12"] 17 | 18 | steps: 19 | - uses: actions/checkout@v2 20 | - name: Set up Python ${{ matrix.python-version }} 21 | uses: actions/setup-python@v2 22 | with: 23 | python-version: ${{ matrix.python-version }} 24 | - name: Install test requirements 25 | run: | 26 | make install_test_requirements 27 | - name: Install package itself (editable) 28 | run: | 29 | make editable 30 | - name: Lint with pylint 31 | run: | 32 | make pylint 33 | - name: Lint with flake8 34 | run: | 35 | make flake8 36 | - name: Test with pytest-cov 37 | run: | 38 | make test_cov 39 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .vscode/ 2 | *.deb 3 | *.egg 4 | *.egg-info/ 5 | *.egg/ 6 | *.ignore 7 | *.py[co] 8 | *.py[oc] 9 | *.spl 10 | *.vagrant 11 | .DS_Store 12 | .coverage 13 | .eggs/ 14 | .eggs/* 15 | .idea 16 | .idea/ 17 | .pt 18 | .vagrant/ 19 | RELEASE-VERSION.txt 20 | build/ 21 | cover/ 22 | dist/ 23 | dump.rdb 24 | flake8.log 25 | local/ 26 | local_* 27 | metadata/ 28 | nosetests.xml 29 | output.xml 30 | pylint.log 31 | redis-server.log 32 | redis-server/ 33 | __pycache__ 34 | .ipynb_checkpoints/ 35 | config.ini 36 | .python-version 37 | -------------------------------------------------------------------------------- /.readthedocs.yml: -------------------------------------------------------------------------------- 1 | # .readthedocs.yaml 2 | # Read the Docs configuration file 3 | # See https://docs.readthedocs.io/en/stable/config-file/v2.html for details 4 | 5 | version: 2 6 | 7 | build: 8 | os: ubuntu-22.04 9 | tools: 10 | python: "3.11" 11 | 12 | mkdocs: 13 | configuration: mkdocs.yml 14 | 15 | python: 16 | install: 17 | - requirements: docs/requirements.txt 18 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## TAKProto 3.0.0 2 | 3 | Happy Summer Solstice! 4 | 5 | - Fixes #15: Time data from iTak not parsed. 6 | - Fixes #12: Add CHANGELOG 7 | - Fixes #19: Support timestamps without microseconds. Thanks @sei-jmattson 8 | - Fixes #17/#18: Support mixed-mode rx. Thanks @sei-jmattson 9 | - Fixes #16: Fix datetime parsing for newer TAK clients that don't include microseconds in the timestamp. Thanks @brian7704 10 | - Rewrote GitHub actions, moved most logic to shell script and Makefile. 11 | - Renamed Debian package from python3-takproto to takproto. 12 | - Standardized Makefile for all PyTAK based programs. 13 | - Cleaned, simplified and expanded documentation. 14 | - Created Makefile jobs for Debian packaging and TAKProto customization. 15 | - Moved all media to media sub directory under docs/. 16 | - Converted README.rst to README.md. 17 | - Style & Linting of code. 18 | 19 | ## TAKProto 2.1.1 20 | 21 | - Fixes #12: Add Changelog. 22 | - Fixes #13: Missing Proto dir? 23 | - Fixes #14: Don't throw away ImportError in __init__.py 24 | 25 | ## TAKProto 2.1.0 26 | 27 | - Fixes #6: Fix xmlDetail compostion (include all details). Thanks @sei-jmattson! 28 | - Fixes #7: CoT Time/Start/Stale timestamps aren't actually ISO-8601. 29 | - Fixes #8: Add readthedocs documentation site. 30 | - Fixes #9: Move setup.py metadata to setup.cfg 31 | - Fixes #10: Add additional test targets: Python 3.11 & 3.12 32 | - Fixes #11: Python 3.6 Build Fails. 33 | - Fixes #12: Add CHANGELOG. 34 | - Documentation Updates. 35 | - Linting & Style. 36 | 37 | ## TAKProto 2.0.0 38 | 39 | - Documentation Updates. 40 | - Fixed example error and problem encoding xmldetail. 41 | - Rewrite to add support for mesh & stream formats. 42 | - Fixes #3: parse_proto in README is inaccurate. Thanks @sei-jmattson! 43 | - Fixes #2: Include generated protobuf folder in the install. Thanks @shelbydavis! 44 | 45 | ## TAKProto 1.0.2 46 | 47 | Documentation updates. 48 | 49 | ## TAKProto 1.0.1 50 | 51 | Documentation updates. 52 | 53 | ## TAKProto 1.0.0 54 | 55 | Initial public release of re-write by @ampledata 56 | 57 | ## takprotobuf 0.0.1 58 | 59 | Initial public release from @dB-SPL -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright Sensors & Signals LLC https://www.snstac.com 2 | Copyright 2020 Delta Bravo-15 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy 5 | of this software and associated documentation files (the "Software"), to deal 6 | in the Software without restriction, including without limitation the rights 7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | copies of the Software, and to permit persons to whom the Software is 9 | furnished to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in all 12 | copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | SOFTWARE. 21 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # Makefile from https://github.com/snstac/pytak 2 | # PyTAK Makefile 3 | # 4 | # Copyright Sensors & Signals LLC https://www.snstac.com/ 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | 17 | REPO_NAME ?= $(shell echo $(wildcard */__init__.py) | awk -F'/' '{print $$1}') 18 | SHELL := /bin/bash 19 | .DEFAULT_GOAL := editable 20 | # postinst = $(wildcard debian/*.postinst.sh) 21 | # service = $(wildcard debian/*.service) 22 | 23 | prepare: 24 | mkdir -p build/ 25 | 26 | develop: 27 | python3 setup.py develop 28 | 29 | editable: 30 | python3 -m pip install -e . 31 | 32 | install_test_requirements: 33 | python3 -m pip install -r requirements_test.txt 34 | 35 | install: 36 | python3 setup.py install 37 | 38 | uninstall: 39 | python3 -m pip uninstall -y $(REPO_NAME) 40 | 41 | reinstall: uninstall install 42 | 43 | publish: 44 | python3 setup.py publish 45 | 46 | clean: 47 | @rm -rf *.egg* build dist *.py[oc] */*.py[co] cover doctest_pypi.cfg \ 48 | nosetests.xml pylint.log output.xml flake8.log tests.log \ 49 | test-result.xml htmlcov fab.log .coverage __pycache__ \ 50 | */__pycache__ deb_dist .mypy_cache 51 | 52 | pep8: 53 | flake8 --max-line-length=88 --extend-ignore=E203 --exit-zero $(REPO_NAME)/*.py 54 | 55 | flake8: pep8 56 | 57 | lint: 58 | pylint --msg-template="{path}:{line}: [{msg_id}({symbol}), {obj}] {msg}" \ 59 | --max-line-length=88 -r n $(REPO_NAME)/*.py || exit 0 60 | 61 | pylint: lint 62 | 63 | checkmetadata: 64 | python3 setup.py check -s --restructuredtext 65 | 66 | mypy: 67 | mypy --strict . 68 | 69 | pytest: 70 | pytest 71 | 72 | test: editable install_test_requirements pytest 73 | 74 | test_cov: 75 | pytest --cov=$(REPO_NAME) --cov-report term-missing 76 | 77 | black: 78 | black . 79 | 80 | mkdocs: 81 | pip install -r docs/requirements.txt 82 | mkdocs serve 83 | 84 | deb_dist: 85 | python3 setup.py --command-packages=stdeb.command sdist_dsc 86 | 87 | deb_custom: 88 | cp debian/$(REPO_NAME).conf $(wildcard deb_dist/*/debian)/$(REPO_NAME).default 89 | cp debian/$(REPO_NAME).postinst $(wildcard deb_dist/*/debian)/$(REPO_NAME).postinst 90 | cp debian/$(REPO_NAME).service $(wildcard deb_dist/*/debian)/$(REPO_NAME).service 91 | 92 | bdist_deb: deb_dist deb_custom 93 | cd deb_dist/$(REPO_NAME)-*/ && dpkg-buildpackage -rfakeroot -uc -us 94 | 95 | faux_latest: 96 | cp deb_dist/$(REPO_NAME)_*-1_all.deb deb_dist/$(REPO_NAME)_latest_all.deb 97 | cp deb_dist/$(REPO_NAME)_*-1_all.deb deb_dist/python3-$(REPO_NAME)_latest_all.deb 98 | 99 | package: bdist_deb faux_latest 100 | 101 | extract: 102 | dpkg-deb -e $(wildcard deb_dist/*latest_all.deb) deb_dist/extract 103 | dpkg-deb -x $(wildcard deb_dist/*latest_all.deb) deb_dist/extract 104 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Encode and Decode TAK data with Python 2 | 3 | TAKProto is a Python module for encoding & decoding TAK Protocol Payloads, for use 4 | with [TAK Products](https://www.tak.gov/) including ATAK, WinTAK, iTAK, TAKX, TAK 5 | Tracker & TAK Server. TAKProto includes functions for converting TAK Protocol 6 | Protobuf messages to Python objects, and serializing CoT XML messages as Protobuf. 7 | 8 | [Documentation is available here.](https://takproto.rtfd.io/) 9 | 10 | ## Copyright & License 11 | 12 | TAKProto is licensed under the MIT License. 13 | 14 | Copyright Sensors & Signals LLC https://www.snstac.com 15 | 16 | Copyright 2020 Delta Bravo-15 17 | 18 | Permission is hereby granted, free of charge, to any person obtaining a copy 19 | of this software and associated documentation files (the "Software"), to deal 20 | in the Software without restriction, including without limitation the rights 21 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 22 | copies of the Software, and to permit persons to whom the Software is 23 | furnished to do so, subject to the following conditions: 24 | 25 | The above copyright notice and this permission notice shall be included in all 26 | copies or substantial portions of the Software. 27 | 28 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 29 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 30 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 31 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 32 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 33 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 34 | SOFTWARE. 35 | 36 | delimited_protobuf.py licensed under the Apache License, Version 2.0 and is 37 | copyright 2024 Frank Dai https://github.com/soulmachine 38 | -------------------------------------------------------------------------------- /debian/install_pkg_build_deps.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo "Installing Debian package build dependencies" 4 | 5 | apt-get update -qq 6 | 7 | apt-get install -y \ 8 | python3 python3-dev python3-pip python3-venv python3-all \ 9 | dh-python debhelper devscripts dput software-properties-common \ 10 | python3-distutils python3-setuptools python3-wheel python3-stdeb 11 | -------------------------------------------------------------------------------- /debian/takproto.conf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/snstac/takproto/5acacdce4afe3462fd26884330de6087eaee4dcf/debian/takproto.conf -------------------------------------------------------------------------------- /debian/takproto.postinst: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | exit 0 6 | -------------------------------------------------------------------------------- /debian/takproto.service: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/snstac/takproto/5acacdce4afe3462fd26884330de6087eaee4dcf/debian/takproto.service -------------------------------------------------------------------------------- /docs/changelog.md: -------------------------------------------------------------------------------- 1 | {!CHANGELOG.md!} -------------------------------------------------------------------------------- /docs/index.md: -------------------------------------------------------------------------------- 1 | {!README.md!} -------------------------------------------------------------------------------- /docs/installation.md: -------------------------------------------------------------------------------- 1 | ## Install on Debian, Ubuntu or Raspberry Pi 2 | 3 | TAKProto is distributed as a Debian package (``.deb``). takproto should be compatible 4 | with most contemporary system-Python versions from Python 3.6 onward. 5 | 6 | To install takproto, download the takproto package and install using apt: 7 | 8 | ```sh linenums="1" 9 | sudo apt update -qq 10 | wget https://github.com/snstac/takproto/releases/latest/download/takproto_latest_all.deb 11 | sudo apt install -f ./takproto_latest_all.deb 12 | ``` 13 | 14 | ## Install from Python Package Index (PyPI) 15 | 16 | ```sh linenums="1" 17 | python3 -m pip install takproto 18 | ``` 19 | 20 | ## Install from Source 21 | 22 | ```sh linenums="1" 23 | git clone https://github.com/snstac/takproto.git 24 | cd takproto/ 25 | python3 -m pip install . 26 | ``` 27 | -------------------------------------------------------------------------------- /docs/media/atak_screenshot_with_pytak_logo-x25.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/snstac/takproto/5acacdce4afe3462fd26884330de6087eaee4dcf/docs/media/atak_screenshot_with_pytak_logo-x25.jpg -------------------------------------------------------------------------------- /docs/media/atak_screenshot_with_pytak_logo-x25.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/snstac/takproto/5acacdce4afe3462fd26884330de6087eaee4dcf/docs/media/atak_screenshot_with_pytak_logo-x25.png -------------------------------------------------------------------------------- /docs/media/atak_screenshot_with_pytak_logo.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/snstac/takproto/5acacdce4afe3462fd26884330de6087eaee4dcf/docs/media/atak_screenshot_with_pytak_logo.jpg -------------------------------------------------------------------------------- /docs/media/pytak_logo-256x264.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/snstac/takproto/5acacdce4afe3462fd26884330de6087eaee4dcf/docs/media/pytak_logo-256x264.png -------------------------------------------------------------------------------- /docs/media/pytak_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/snstac/takproto/5acacdce4afe3462fd26884330de6087eaee4dcf/docs/media/pytak_logo.png -------------------------------------------------------------------------------- /docs/media/takproto_chart.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/snstac/takproto/5acacdce4afe3462fd26884330de6087eaee4dcf/docs/media/takproto_chart.png -------------------------------------------------------------------------------- /docs/origin.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | ``takproto`` is a fork & complete re-write of @dB-SPL's 4 | `takprotobuf `_. 5 | 6 | Notable differences between the original ``takprotobuf`` & this module ``takproto``: 7 | 8 | 1. Rebuild proto files using `Protocol Buffers v21 `_. 9 | 2. Added support for encoding & decoding plain XML, Mesh & Stream TAK Protocol formats. 10 | 3. Remove dependency on ``untangle`` module, allowing compatibility with Python 3.6 11 | through 3.10. Unfortunately many single-board computers (i.e. Raspberry Pi) still 12 | ship with Python 3.6, this change allows ``takproto`` to run on those systems. 13 | 4. Added ``xmlDetails`` detection for supporting undefined Protobuf elements in XML. 14 | 5. > 90% test coverage with **new** Unit Tests. 15 | 6. PEP-8 & Black style, linting, documentation & formatting of code. 16 | 17 | As much as possible @db-SPL's licensing terms were honored in this fork. 18 | -------------------------------------------------------------------------------- /docs/requirements.txt: -------------------------------------------------------------------------------- 1 | click 2 | ghp-import 3 | griffe 4 | importlib-metadata 5 | jinja2 6 | markdown 7 | markdown-include 8 | markupsafe 9 | mergedeep 10 | mkdocs 11 | mkdocs-autorefs 12 | mkdocs-include-markdown-plugin 13 | mkdocs-material 14 | mkdocstrings-python 15 | mkdocstrings[python] 16 | packaging 17 | pymdown-extensions 18 | pyparsing 19 | python-dateutil 20 | pyyaml 21 | pyyaml-env-tag 22 | six 23 | zipp 24 | -------------------------------------------------------------------------------- /docs/tak_protocols.md: -------------------------------------------------------------------------------- 1 | # TAK Protocol Description 2 | 3 | From the [ATAK source](https://github.com/deptofdefense/AndroidTacticalAssaultKit-CIV/blob/master/commoncommo/core/impl/protobuf/protocol.txt): 4 | 5 | Version 1 of the TAK Protocol Payload is a Google Protocol Buffer based 6 | payload. Each Payload consists of one (and only one) 7 | atakmap::commoncommo::v1::TakMessage message which is serialized using 8 | Google protocol buffers version 3. 9 | 10 | Originally the TAK Products spoke Cursor on Target (CoT) encoded as plain XML. Later versions of the TAK Products added support for sending CoT as Google Protobuf, which TPC named 'TAK Protocol Version 1'. 11 | 12 | Out of the box, TAK Products such as ATAK and WinTAK configured for 'Mesh SA' will send TAK Protocol Version 1 Mesh formatted CoT. This format utizes a static payload header of the format `191 1 191 `. 13 | 14 | TAK Products configured for connecting to a TAK Server will send TAK Protocol Version 1 Stream formatted CoT. This format utizes a dynamic payload header of the format `191 `. This header format is required for specifying the size of the payload within the TCP packet. 15 | 16 | The `takproto` module supports encoding and decoding all 3 formats of CoT messages. 17 | 18 | ![TAK Protocol Chart](media/takproto_chart.png) 19 | -------------------------------------------------------------------------------- /docs/usage.md: -------------------------------------------------------------------------------- 1 | 2 | The TAKProto Python module exports two functions: 3 | 4 | 1. `xml2proto()`: Convert CoT XML to TAK Protocol - Version 1 Protobuf. 5 | 2. `parse_proto()`: Parse a TAK Protocol - Version 1 Protobuf into a Python object. 6 | 7 | 8 | ## xml2proto() 9 | 10 | Given a `bytes` CoT XML message (or the path to an file containing a CoT XML message), `xml2proto()` returns a `bytearray` containing a TAK Protocol - Version 1 Protobuf. 11 | 12 | ### UDP Multicast (Mesh SA) 13 | 14 | ```py linenums="1" hl_lines="16" title="cot2mesh.py" 15 | import takproto 16 | 17 | cot = """ 18 | 19 | 20 | 21 | 22 | 23 | <__group name='Yellow' role='HQ'/> 24 | 25 | 26 | 27 | 28 | """ 29 | 30 | buf = takproto.xml2proto(cot) 31 | print(buf) 32 | ``` 33 | 34 | By default, `xml2proto()` returns data as TAK Protocol - Version 1 Protobuf in Mesh SA format (UDP Multicast): 35 | 36 | ```py 37 | bytearray(b'\xbf\x01\xbf\x12\xff\x01\n\x0ba-f-G-E-V-C*$aa0b0312-b5cd-4c2c-bbbc-9c4c702162610\xa0\xa2\xc7\xb8\x82.8\xa0\xa2\xc7\xb8\x82.@\x98\xf5\xc8\xb8\x82.J\x03h-eQ3\x98T\xa7b\xfdE@Y}*~\xbe\xf3\x84P\xc0aW\\\x1c\x95\x9b\xc4:@i\x00\x00\x00\xe0\xcf\x12cAq\x00\x00\x00\xe0\xcf\x12cAz\x82\x01\x12$\n\x15192.168.1.10:4242:tcp\x12\x0bEliopoli HQ\x1a\x0c\n\x06Yellow\x12\x02HQ*\x02\x08d2F\n\x11LENOVO 20QV0007US\x12\nWinTAK-CIV\x1a\x19Microsoft Windows 10 Home"\n1.10.0.137:\x00') 38 | ``` 39 | 40 | ### TCP Unicast (TAK Server) 41 | 42 | Calling `xml2proto()` with the `takproto.TAKProtoVer.STREAM` ENUM parameter returns data as TAK Protocol - Version 1 Protobuf in Stream format (TCP Unicast): 43 | 44 | ```py linenums="1" hl_lines="16" title="cot2stream.py" 45 | import takproto 46 | 47 | cot = """ 48 | 49 | 50 | 51 | 52 | 53 | <__group name='Yellow' role='HQ'/> 54 | 55 | 56 | 57 | 58 | """ 59 | 60 | buf = takproto.xml2proto(cot, takproto.TAKProtoVer.STREAM) 61 | print(buf) 62 | ``` 63 | 64 | Would return the CoT XML encoded as TAK Protocol - Version 1 Protobuf (Stream TCP Unicast format for TAK Server connections): 65 | 66 | ```py 67 | bytearray(b'\xbf\x9f\x02\x12\xff\x01\n\x0ba-f-G-E-V-C*$aa0b0312-b5cd-4c2c-bbbc-9c4c702162610\xa0\xa2\xc7\xb8\x82.8\xa0\xa2\xc7\xb8\x82.@\x98\xf5\xc8\xb8\x82.J\x03h-eQ3\x98T\xa7b\xfdE@Y}*~\xbe\xf3\x84P\xc0aW\\\x1c\x95\x9b\xc4:@i\x00\x00\x00\xe0\xcf\x12cAq\x00\x00\x00\xe0\xcf\x12cAz\x82\x01\x12$\n\x15192.168.1.10:4242:tcp\x12\x0bEliopoli HQ\x1a\x0c\n\x06Yellow\x12\x02HQ*\x02\x08d2F\n\x11LENOVO 20QV0007US\x12\nWinTAK-CIV\x1a\x19Microsoft Windows 10 Home"\n1.10.0.137:\x00') 68 | ``` 69 | 70 | ## parse_proto() 71 | 72 | Given a `bytearray` TAK Protocol - Version 1 Protobuf, `parse_proto()` returns an instance of the Protobuf class. You can then access the contents as an object: 73 | 74 | ```py linenums="1" hl_lines="5" title="decode_tak.py" 75 | import takproto 76 | 77 | pb = bytearray(b'\xbf\x01\xbf\x12\xff\x01\n\x0ba-f-G-E-V-C*$aa0b0312-b5cd-4c2c-bbbc-9c4c702162610\xa0\xa2\xc7\xb8\x82.8\xa0\xa2\xc7\xb8\x82.@\x98\xf5\xc8\xb8\x82.J\x03h-eQ3\x98T\xa7b\xfdE@Y}*~\xbe\xf3\x84P\xc0aW\\\x1c\x95\x9b\xc4:@i\x00\x00\x00\xe0\xcf\x12cAq\x00\x00\x00\xe0\xcf\x12cAz\x82\x01\x12$\n\x15192.168.1.10:4242:tcp\x12\x0bEliopoli HQ\x1a\x0c\n\x06Yellow\x12\x02HQ*\x02\x08d2F\n\x11LENOVO 20QV0007US\x12\nWinTAK-CIV\x1a\x19Microsoft Windows 10 Home"\n1.10.0.137:\x00') 78 | 79 | cot = parse_proto(pb) 80 | ``` 81 | 82 | This method of calling `parse_proto` would return an object containing the data from the Protobuf. 83 | 84 | If you were to `print(cot)`, you would see: 85 | 86 | ```json linenums="1" 87 | cotEvent { 88 | type: "a-f-G-E-V-C" 89 | uid: "aa0b0312-b5cd-4c2c-bbbc-9c4c70216261" 90 | sendTime: 1581203444000 91 | startTime: 1581203444000 92 | staleTime: 1581203471000 93 | how: "h-e" 94 | lat: 43.97957317 95 | lon: -66.07737696 96 | hae: 26.767999 97 | ce: 9999999.0 98 | le: 9999999.0 99 | detail { 100 | contact { 101 | endpoint: "192.168.1.10:4242:tcp" 102 | callsign: "Eliopoli HQ" 103 | } 104 | group { 105 | name: "Yellow" 106 | role: "HQ" 107 | } 108 | status { 109 | battery: 100 110 | } 111 | takv { 112 | device: "LENOVO 20QV0007US" 113 | platform: "WinTAK-CIV" 114 | os: "Microsoft Windows 10 Home" 115 | version: "1.10.0.137" 116 | } 117 | track { 118 | } 119 | } 120 | } 121 | ``` 122 | 123 | Object attributes can be accessed by calling them in a Pythonic manner: 124 | 125 | ```py 126 | print(cot.cotEvent.detail.contact.callsign) 127 | "Eliopoli HQ" 128 | ``` -------------------------------------------------------------------------------- /mkdocs.yml: -------------------------------------------------------------------------------- 1 | site_name: Encode and Decode TAK data with Python 2 | site_url: https://takproto.rtfd.io/ 3 | repo_url: https://github.com/snstac/takproto/ 4 | site_description: A Python module to encode & decode Team Awareness Kit (TAK) Protocol-based Cursor on Target (CoT) messages. 5 | site_author: Greg Albrecht 6 | copyright: Copyright Sensors & Signals LLC https://www.snstac.com 7 | 8 | theme: 9 | name: material 10 | highlightjs: true 11 | features: 12 | - content.code.copy 13 | - content.code.select 14 | - content.code.annotate 15 | 16 | plugins: 17 | - include-markdown: 18 | opening_tag: "{!" 19 | closing_tag: "!}" 20 | - search 21 | - mkdocstrings: 22 | handlers: 23 | # See: https://mkdocstrings.github.io/python/usage/ 24 | python: 25 | options: 26 | docstring_style: sphinx 27 | 28 | markdown_extensions: 29 | - markdown_include.include: 30 | base_path: . 31 | - admonition 32 | - toc: 33 | permalink: True 34 | - pymdownx.highlight: 35 | anchor_linenums: true 36 | line_spans: __span 37 | pygments_lang_class: true 38 | - pymdownx.inlinehilite 39 | - pymdownx.snippets 40 | - pymdownx.superfences -------------------------------------------------------------------------------- /requirements_test.txt: -------------------------------------------------------------------------------- 1 | pytest-asyncio 2 | pytest-cov 3 | pylint 4 | flake8 5 | black 6 | -------------------------------------------------------------------------------- /setup.cfg: -------------------------------------------------------------------------------- 1 | # Setup for the Python TAK Protocol Packet - Version 1 Module. 2 | # setup.cfg from https://github.com/snstac/takproto 3 | # 4 | # Copyright Sensors & Signals LLC https://www.snstac.com 5 | # Copyright 2020 Delta Bravo-15 6 | # 7 | # Permission is hereby granted, free of charge, to any person obtaining a copy 8 | # of this software and associated documentation files (the "Software"), to deal 9 | # in the Software without restriction, including without limitation the rights 10 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | # copies of the Software, and to permit persons to whom the Software is 12 | # furnished to do so, subject to the following conditions: 13 | # 14 | # The above copyright notice and this permission notice shall be included in all 15 | # copies or substantial portions of the Software. 16 | # 17 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | # SOFTWARE. 24 | # 25 | 26 | 27 | [metadata] 28 | name = takproto 29 | version = attr: takproto.__version__ 30 | url = https://github.com/snstac/takproto 31 | project_urls = 32 | CI: GitHub Actions = https://github.com/snstac/takproto/actions 33 | GitHub: issues = https://github.com/snstac/takproto/issues 34 | GitHub: repo = https://github.com/snstac/takproto 35 | description = TAKProto is a Python package to encode and decode TAK data. 36 | long_description = file: README.md 37 | long_description_content_type = text/markdown 38 | maintainer = Greg Albrecht 39 | maintainer_email = oss@undef.net 40 | license = MIT License 41 | license_files = LICENSE 42 | classifiers = 43 | License :: OSI Approved :: MIT License 44 | Intended Audience :: Developers 45 | Programming Language :: Python 46 | Programming Language :: Python :: 3 47 | Programming Language :: Python :: 3 :: Only 48 | Programming Language :: Python :: 3.6 49 | Programming Language :: Python :: 3.7 50 | Programming Language :: Python :: 3.8 51 | Programming Language :: Python :: 3.9 52 | Programming Language :: Python :: 3.10 53 | Programming Language :: Python :: 3.11 54 | Programming Language :: Python :: 3.12 55 | Development Status :: 5 - Production/Stable 56 | Operating System :: POSIX 57 | Operating System :: MacOS :: MacOS X 58 | Operating System :: Microsoft :: Windows 59 | Operating System :: OS Independent 60 | keywords = 61 | Cursor on Target 62 | CoT 63 | ATAK 64 | TAK 65 | WinTAK 66 | iTAK 67 | TAK Server 68 | TAKX 69 | Protobuf 70 | 71 | 72 | [options] 73 | python_requires = >=3.6, <4 74 | packages = takproto, takproto.proto 75 | package_dir = 76 | takproto = takproto 77 | install_requires = 78 | protobuf >= 4.21.0 79 | 80 | 81 | [options.extras_require] 82 | test = 83 | pytest-cov 84 | pylint 85 | flake8 86 | black 87 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # setup.py from https://github.com/snstac/takproto 4 | # 5 | # Copyright Sensors & Signals LLC https://www.snstac.com 6 | # Copyright 2020 Delta Bravo-15 7 | # 8 | # Permission is hereby granted, free of charge, to any person obtaining a copy 9 | # of this software and associated documentation files (the "Software"), to deal 10 | # in the Software without restriction, including without limitation the rights 11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | # copies of the Software, and to permit persons to whom the Software is 13 | # furnished to do so, subject to the following conditions: 14 | # 15 | # The above copyright notice and this permission notice shall be included in all 16 | # copies or substantial portions of the Software. 17 | # 18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | # SOFTWARE. 25 | # 26 | 27 | 28 | """Setup for the Python TAK Protocol Package.""" 29 | 30 | from setuptools import setup 31 | 32 | if __name__ == "__main__": 33 | setup() 34 | -------------------------------------------------------------------------------- /src-protobuf/.cvsignore: -------------------------------------------------------------------------------- 1 | *.h 2 | *.cc 3 | -------------------------------------------------------------------------------- /src-protobuf/LICENSE.md: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | If you modify this Program, or any covered work, by linking or combining 408 | it with ACRA (or a modified version of that library), 409 | containing parts covered by the terms of the Apache License v2.0, the 410 | licensors of this Program grant you additional permission to convey the 411 | resulting work. Corresponding Source for a non-source form of such a 412 | combination shall include the source code for the parts of ACRA 413 | used as well as that of the covered work. 414 | 415 | If you modify this Program, or any covered work, by linking or combining 416 | it with AChartEngine (or a modified version of that library), 417 | containing parts covered by the terms of the Apache License v2.0, the 418 | licensors of this Program grant you additional permission to convey the 419 | resulting work. Corresponding Source for a non-source form of such a 420 | combination shall include the source code for the parts of AChartEngine 421 | used as well as that of the covered work. 422 | 423 | If you modify this Program, or any covered work, by linking or combining 424 | it with USB Serial for Android (or a modified version of that library), 425 | containing parts covered by the terms of the GNU Lesser General Public License, the 426 | licensors of this Program grant you additional permission to convey the 427 | resulting work. Corresponding Source for a non-source form of such a 428 | combination shall include the source code for the parts of USB Serial for Android 429 | used as well as that of the covered work. 430 | 431 | If you modify this Program, or any covered work, by linking or combining 432 | it with DataDroid (or a modified version of that library), 433 | containing parts covered by the terms of the Beerware License, the 434 | licensors of this Program grant you additional permission to convey the 435 | resulting work. Corresponding Source for a non-source form of such a 436 | combination shall include the source code for the parts of DataDroid 437 | used as well as that of the covered work. 438 | 439 | If you modify this Program, or any covered work, by linking or combining 440 | it with Jackcess (or a modified version of that library), 441 | containing parts covered by the terms of the Lesser GNU Public License, the 442 | licensors of this Program grant you additional permission to convey the 443 | resulting work. Corresponding Source for a non-source form of such a 444 | combination shall include the source code for the parts of Jackcess 445 | used as well as that of the covered work. 446 | 447 | If you modify this Program, or any covered work, by linking or combining 448 | it with Gv2F (or a modified version of that library), 449 | containing parts covered by the terms of the PAR Gv2F License, the 450 | licensors of this Program grant you additional permission to convey the 451 | resulting work. 452 | 453 | If you modify this Program, or any covered work, by linking or combining 454 | it with PGSC Mobile Video (or a modified version of that library), 455 | containing parts covered by the terms of the PAR Gv2F License, the 456 | licensors of this Program grant you additional permission to convey the 457 | resulting work. 458 | 459 | If you modify this Program, or any covered work, by linking or combining 460 | it with OpenCSV (or a modified version of that library), 461 | containing parts covered by the terms of Apache License v2.0, the 462 | licensors of this Program grant you additional permission to convey the 463 | resulting work. Corresponding Source for a non-source form of such a 464 | combination shall include the source code for the parts of OpenCSV 465 | used as well as that of the covered work. 466 | 467 | If you modify this Program, or any covered work, by linking or combining 468 | it with OpenNMEA (or a modified version of that library), 469 | containing parts covered by the terms of the GNU Lesser General Public License, the 470 | licensors of this Program grant you additional permission to convey the 471 | resulting work. Corresponding Source for a non-source form of such a 472 | combination shall include the source code for the parts of OpenNMEA 473 | used as well as that of the covered work. 474 | 475 | If you modify this Program, or any covered work, by linking or combining 476 | it with Sanselan (or a modified version of that library), 477 | containing parts covered by the terms of the Apache License v2.0, the 478 | licensors of this Program grant you additional permission to convey the 479 | resulting work. Corresponding Source for a non-source form of such a 480 | combination shall include the source code for the parts of SimpleKML 481 | used as well as that of the covered work. 482 | 483 | If you modify this Program, or any covered work, by linking or combining 484 | it with SimpleKML (or a modified version of that library), 485 | containing parts covered by the terms of the Apache License v2.0, the 486 | licensors of this Program grant you additional permission to convey the 487 | resulting work. Corresponding Source for a non-source form of such a 488 | combination shall include the source code for the parts of SimpleKML 489 | used as well as that of the covered work. 490 | 491 | If you modify this Program, or any covered work, by linking or combining 492 | it with SimpleXML (or a modified version of that library), 493 | containing parts covered by the terms of the Apache License v2.0, the 494 | licensors of this Program grant you additional permission to convey the 495 | resulting work Corresponding Source for a non-source form of such a 496 | combination shall include the source code for the parts of SimpleXML 497 | used as well as that of the covered work. 498 | 499 | If you modify this Program, or any covered work, by linking or combining 500 | it with FFMPEG (or a modified version of that library), 501 | containing parts covered by the terms of the Lesser GNU Public License, the 502 | licensors of this Program grant you additional permission to convey the 503 | resulting work. Corresponding Source for a non-source form of such a 504 | combination shall include the source code for the parts of FFMPEG 505 | used as well as that of the covered work. 506 | 507 | If you modify this Program, or any covered work, by linking or combining 508 | it with Apache Commons (or a modified version of that library), 509 | containing parts covered by the terms of Apache License v2.0, the 510 | licensors of this Program grant you additional permission to convey the 511 | resulting work. Corresponding Source for a non-source form of such a 512 | combination shall include the source code for the parts of Apache Commons 513 | used as well as that of the covered work. 514 | 515 | If you modify this Program, or any covered work, by linking or combining 516 | it with GLU (or a modified version of that library), 517 | containing parts covered by the terms of SGI Free Software License B, the 518 | licensors of this Program grant you additional permission to convey the 519 | resulting work. Corresponding Source for a non-source form of such a 520 | combination shall include the source code for the parts of GLU 521 | used as well as that of the covered work. 522 | 523 | If you modify this Program, or any covered work, by linking or combining 524 | it with Jama (or a modified version of that library), 525 | containing parts that are Public Domain software, the 526 | licensors of this Program grant you additional permission to convey the 527 | resulting work. Corresponding Source for a non-source form of such a 528 | combination shall include the source code for the parts of Jama 529 | used as well as that of the covered work. 530 | 531 | If you modify this Program, or any covered work, by linking or combining 532 | it with ASSIMP (or a modified version of that library), 533 | containing parts covered by the terms of the Open Asset Import Library, the 534 | licensors of this Program grant you additional permission to convey the 535 | resulting work. Corresponding Source for a non-source form of such a 536 | combination shall include the source code for the parts of ASSIMP 537 | used as well as that of the covered work. 538 | 539 | If you modify this Program, or any covered work, by linking or combining 540 | it with LIBCHARSET (or a modified version of that library), 541 | containing parts covered by the terms of the Lesser GNU Public License, the 542 | licensors of this Program grant you additional permission to convey the 543 | resulting work. Corresponding Source for a non-source form of such a 544 | combination shall include the source code for the parts of LIBCHARSET 545 | used as well as that of the covered work. 546 | 547 | If you modify this Program, or any covered work, by linking or combining 548 | it with GDAL (or a modified version of that library), 549 | containing parts covered by the terms of the GDAL/OGR License, the 550 | licensors of this Program grant you additional permission to convey the 551 | resulting work. Corresponding Source for a non-source form of such a 552 | combination shall include the source code for the parts of GDAL 553 | used as well as that of the covered work. 554 | 555 | If you modify this Program, or any covered work, by linking or combining 556 | it with GEOS (or a modified version of that library), 557 | containing parts covered by the terms of Lesser GNU Public License, the 558 | licensors of this Program grant you additional permission to convey the 559 | resulting work. Corresponding Source for a non-source form of such a 560 | combination shall include the source code for the parts of GEOS 561 | used as well as that of the covered work. 562 | 563 | If you modify this Program, or any covered work, by linking or combining 564 | it with LIBICONV (or a modified version of that library), 565 | containing parts covered by the terms of Lesser GNU Public License, the 566 | licensors of this Program grant you additional permission to convey the 567 | resulting work. Corresponding Source for a non-source form of such a 568 | combination shall include the source code for the parts of LIBICONV 569 | used as well as that of the covered work. 570 | 571 | If you modify this Program, or any covered work, by linking or combining 572 | it with the MrSID Decode SDK (or a modified version of that library), 573 | containing parts covered by the terms of LizardTech Geo Express DSDK License, the 574 | licensors of this Program grant you additional permission to convey the 575 | resulting work. 576 | 577 | If you modify this Program, or any covered work, by linking or combining 578 | it with Kakadu (or a modified version of that library), 579 | containing parts covered by the terms of the Kakadu License, the 580 | licensors of this Program grant you additional permission to convey the 581 | resulting work. 582 | 583 | If you modify this Program, or any covered work, by linking or combining 584 | it with LIBKML (or a modified version of that library), 585 | containing parts covered by the terms of the LIBKML license, the 586 | licensors of this Program grant you additional permission to convey the 587 | resulting work. Corresponding Source for a non-source form of such a 588 | combination shall include the source code for the parts of LIBKML 589 | used as well as that of the covered work. 590 | 591 | If you modify this Program, or any covered work, by linking or combining 592 | it with uriparser (or a modified version of that library), 593 | containing parts covered by the terms of the uriparser license, the 594 | licensors of this Program grant you additional permission to convey the 595 | resulting work. Corresponding Source for a non-source form of such a 596 | combination shall include the source code for the parts of uriparser 597 | used as well as that of the covered work. 598 | 599 | If you modify this Program, or any covered work, by linking or combining 600 | it with Boost (or a modified version of that library), 601 | containing parts covered by the terms of the Boost Software License v1.0, the 602 | licensors of this Program grant you additional permission to convey the 603 | resulting work. Corresponding Source for a non-source form of such a 604 | combination shall include the source code for the parts of Boost 605 | used as well as that of the covered work. 606 | 607 | If you modify this Program, or any covered work, by linking or combining 608 | it with minizip (or a modified version of that library), 609 | containing parts covered by the terms of the minizip license, the 610 | licensors of this Program grant you additional permission to convey the 611 | resulting work. Corresponding Source for a non-source form of such a 612 | combination shall include the source code for the parts of minizip 613 | used as well as that of the covered work. 614 | 615 | If you modify this Program, or any covered work, by linking or combining 616 | it with OGDI (or a modified version of that library), 617 | containing parts covered by the terms of the OGDI License, the 618 | licensors of this Program grant you additional permission to convey the 619 | resulting work Corresponding Source for a non-source form of such a 620 | combination shall include the source code for the parts of OGDI 621 | used as well as that of the covered work. 622 | 623 | If you modify this Program, or any covered work, by linking or combining 624 | it with Proj.4 (or a modified version of that library), 625 | containing parts covered by the terms of the Proj.4 License, the 626 | licensors of this Program grant you additional permission to convey the 627 | resulting work. Corresponding Source for a non-source form of such a 628 | combination shall include the source code for the parts of Proj.4 629 | used as well as that of the covered work. 630 | 631 | If you modify this Program, or any covered work, by linking or combining 632 | it with SQLite (or a modified version of that library), 633 | containing parts covered by the terms of the SQLite License, the 634 | licensors of this Program grant you additional permission to convey the 635 | resulting work. Corresponding Source for a non-source form of such a 636 | combination shall include the source code for the parts of SQLite 637 | used as well as that of the covered work. 638 | 639 | If you modify this Program, or any covered work, by linking or combining 640 | it with SQL Cipher(or a modified version of that library), 641 | containing parts covered by the terms of the SQL Cipher License, the 642 | licensors of this Program grant you additional permission to convey the 643 | resulting work. Corresponding Source for a non-source form of such a 644 | combination shall include the source code for the parts of SQL Cipher 645 | used as well as that of the covered work. 646 | 647 | If you modify this Program, or any covered work, by linking or combining 648 | it with SpatiaLite (or a modified version of that library), 649 | containing parts covered by the terms of the Mozilla Public License 1.1.1, the 650 | licensors of this Program grant you additional permission to convey the 651 | resulting work. Corresponding Source for a non-source form of such a 652 | combination shall include the source code for the parts of SpatiaLite 653 | used as well as that of the covered work. 654 | 655 | If you modify this Program, or any covered work, by linking or combining 656 | it with zlib (or a modified version of that library), 657 | containing parts covered by the terms of the zlib License, the 658 | licensors of this Program grant you additional permission to convey the 659 | resulting work. Corresponding Source for a non-source form of such a 660 | combination shall include the source code for the parts of zlib 661 | used as well as that of the covered work. 662 | 663 | If you modify this Program, or any covered work, by linking or combining 664 | it with tinygltf (or a modified version of that library), 665 | containing parts covered by the terms of the MIT License, the 666 | licensors of this Program grant you additional permission to convey the 667 | resulting work. Corresponding Source for a non-source form of such a 668 | combination shall include the source code for the parts of tinygltf 669 | used as well as that of the covered work. 670 | 671 | If you modify this Program, or any covered work, by linking or combining 672 | it with tinygltfloader (or a modified version of that library), 673 | containing parts covered by the terms of the MIT License, the 674 | licensors of this Program grant you additional permission to convey the 675 | resulting work. Corresponding Source for a non-source form of such a 676 | combination shall include the source code for the parts of tinygltfloader 677 | used as well as that of the covered work. 678 | 679 | If you modify this Program, or any covered work, by linking or combining 680 | it with JSON For Modern C++ (or a modified version of that library), 681 | containing parts covered by the terms of the MIT License, the 682 | licensors of this Program grant you additional permission to convey the 683 | resulting work. Corresponding Source for a non-source form of such a 684 | combination shall include the source code for the parts of JSON For Modern C++ 685 | used as well as that of the covered work. 686 | 687 | If you modify this Program, or any covered work, by linking or combining 688 | it with stb_image (or a modified version of that library), 689 | containing parts that are Public Domain software, the 690 | licensors of this Program grant you additional permission to convey the 691 | resulting work. Corresponding Source for a non-source form of such a 692 | combination shall include the source code for the parts of stb_image 693 | used as well as that of the covered work. 694 | 695 | If you modify this Program, or any covered work, by linking or combining 696 | it with stb_image_write (or a modified version of that library), 697 | containing parts that are Public Domain software, the 698 | licensors of this Program grant you additional permission to convey the 699 | resulting work. Corresponding Source for a non-source form of such a 700 | combination shall include the source code for the parts of stb_image_write 701 | used as well as that of the covered work. 702 | 703 | If you modify this Program, or any covered work, by linking or combining 704 | it with LIBEXPAT (or a modified version of that library), 705 | containing parts covered by the terms of the LIBEXPAT License, the 706 | licensors of this Program grant you additional permission to convey the 707 | resulting work. Corresponding Source for a non-source form of such a 708 | combination shall include the source code for the parts of LIBEXPAT 709 | used as well as that of the covered work. 710 | 711 | If you modify this Program, or any covered work, by linking or combining 712 | it with STL Soft (or a modified version of that library), 713 | containing parts covered by the terms of the STL Soft License, the 714 | licensors of this Program grant you additional permission to convey the 715 | resulting work. Corresponding Source for a non-source form of such a 716 | combination shall include the source code for the parts of STL Soft 717 | used as well as that of the covered work. 718 | 719 | If you modify this Program, or any covered work, by linking or combining 720 | it with GLUES (or a modified version of that library), 721 | containing parts covered by the terms of the SGI Free Software License B, the 722 | licensors of this Program grant you additional permission to convey the 723 | resulting work. Corresponding Source for a non-source form of such a 724 | combination shall include the source code for the parts of GLUES 725 | used as well as that of the covered work. 726 | 727 | If you modify this Program, or any covered work, by linking or combining 728 | it with STB DXT (or a modified version of that library), 729 | containing parts that are Public Domain software, the 730 | licensors of this Program grant you additional permission to convey the 731 | resulting work. Corresponding Source for a non-source form of such a 732 | combination shall include the source code for the parts of STB DXT 733 | used as well as that of the covered work. 734 | 735 | If you modify this Program, or any covered work, by linking or combining 736 | it with WMM (or a modified version of that library), 737 | containing parts that are Public Domain software, the 738 | licensors of this Program grant you additional permission to convey the 739 | resulting work. Corresponding Source for a non-source form of such a 740 | combination shall include the source code for the parts of WMM 741 | used as well as that of the covered work. 742 | 743 | If you modify this Program, or any covered work, by linking or combining 744 | it with Protocol Buffers (or a modified version of that library), 745 | containing parts covered by the terms of Protocol Buffers License, the 746 | licensors of this Program grant you additional permission to convey the 747 | resulting work. Corresponding Source for a non-source form of such a 748 | combination shall include the source code for the parts of Protocol Buffers 749 | used as well as that of the covered work. 750 | 751 | If you modify this Program, or any covered work, by linking or combining 752 | it with LIBMICROHTTPD (or a modified version of that library), 753 | containing parts covered by the terms of the Lesser GNU Public License, the 754 | licensors of this Program grant you additional permission to convey the 755 | resulting work. Corresponding Source for a non-source form of such a 756 | combination shall include the source code for the parts of LIBMICROHTTPD 757 | used as well as that of the covered work. 758 | 759 | If you modify this Program, or any covered work, by linking or combining 760 | it with LIBCURL (or a modified version of that library), 761 | containing parts covered by the terms of the libcurl License, the 762 | licensors of this Program grant you additional permission to convey the 763 | resulting work. Corresponding Source for a non-source form of such a 764 | combination shall include the source code for the parts of LIBCURL 765 | used as well as that of the covered work. 766 | 767 | If you modify this Program, or any covered work, by linking or combining 768 | it with libxml2 (or a modified version of that library), 769 | containing parts covered by the terms of the MIT License, the 770 | licensors of this Program grant you additional permission to convey the 771 | resulting work. Corresponding Source for a non-source form of such a 772 | combination shall include the source code for the parts of LIBXML2 773 | used as well as that of the covered work. 774 | 775 | If you modify this Program, or any covered work, by linking or combining 776 | it with OpenSSL (or a modified version of that library), 777 | containing parts covered by the terms of the Open SSL License and the SSLeay License, the 778 | licensors of this Program grant you additional permission to convey the 779 | resulting work. Corresponding Source for a non-source form of such a 780 | combination shall include the source code for the parts of OpenSSL 781 | used as well as that of the covered work. 782 | 783 | If you modify this Program, or any covered work, by linking or combining 784 | it with GNU libstdc++ (or a modified version of that library), 785 | containing parts covered by the terms of the GNU Public License v3, the 786 | licensors of this Program grant you additional permission to convey the 787 | resulting work. Corresponding Source for a non-source form of such a 788 | combination shall include the source code for the parts of GNU libstdc++ 789 | used as well as that of the covered work. 790 | 791 | 8. Termination. 792 | 793 | You may not propagate or modify a covered work except as expressly 794 | provided under this License. Any attempt otherwise to propagate or 795 | modify it is void, and will automatically terminate your rights under 796 | this License (including any patent licenses granted under the third 797 | paragraph of section 11). 798 | 799 | However, if you cease all violation of this License, then your 800 | license from a particular copyright holder is reinstated (a) 801 | provisionally, unless and until the copyright holder explicitly and 802 | finally terminates your license, and (b) permanently, if the copyright 803 | holder fails to notify you of the violation by some reasonable means 804 | prior to 60 days after the cessation. 805 | 806 | Moreover, your license from a particular copyright holder is 807 | reinstated permanently if the copyright holder notifies you of the 808 | violation by some reasonable means, this is the first time you have 809 | received notice of violation of this License (for any work) from that 810 | copyright holder, and you cure the violation prior to 30 days after 811 | your receipt of the notice. 812 | 813 | Termination of your rights under this section does not terminate the 814 | licenses of parties who have received copies or rights from you under 815 | this License. If your rights have been terminated and not permanently 816 | reinstated, you do not qualify to receive new licenses for the same 817 | material under section 10. 818 | 819 | 9. Acceptance Not Required for Having Copies. 820 | 821 | You are not required to accept this License in order to receive or 822 | run a copy of the Program. Ancillary propagation of a covered work 823 | occurring solely as a consequence of using peer-to-peer transmission 824 | to receive a copy likewise does not require acceptance. However, 825 | nothing other than this License grants you permission to propagate or 826 | modify any covered work. These actions infringe copyright if you do 827 | not accept this License. Therefore, by modifying or propagating a 828 | covered work, you indicate your acceptance of this License to do so. 829 | 830 | 10. Automatic Licensing of Downstream Recipients. 831 | 832 | Each time you convey a covered work, the recipient automatically 833 | receives a license from the original licensors, to run, modify and 834 | propagate that work, subject to this License. You are not responsible 835 | for enforcing compliance by third parties with this License. 836 | 837 | An "entity transaction" is a transaction transferring control of an 838 | organization, or substantially all assets of one, or subdividing an 839 | organization, or merging organizations. If propagation of a covered 840 | work results from an entity transaction, each party to that 841 | transaction who receives a copy of the work also receives whatever 842 | licenses to the work the party's predecessor in interest had or could 843 | give under the previous paragraph, plus a right to possession of the 844 | Corresponding Source of the work from the predecessor in interest, if 845 | the predecessor has it or can get it with reasonable efforts. 846 | 847 | You may not impose any further restrictions on the exercise of the 848 | rights granted or affirmed under this License. For example, you may 849 | not impose a license fee, royalty, or other charge for exercise of 850 | rights granted under this License, and you may not initiate litigation 851 | (including a cross-claim or counterclaim in a lawsuit) alleging that 852 | any patent claim is infringed by making, using, selling, offering for 853 | sale, or importing the Program or any portion of it. 854 | 855 | 11. Patents. 856 | 857 | A "contributor" is a copyright holder who authorizes use under this 858 | License of the Program or a work on which the Program is based. The 859 | work thus licensed is called the contributor's "contributor version". 860 | 861 | A contributor's "essential patent claims" are all patent claims 862 | owned or controlled by the contributor, whether already acquired or 863 | hereafter acquired, that would be infringed by some manner, permitted 864 | by this License, of making, using, or selling its contributor version, 865 | but do not include claims that would be infringed only as a 866 | consequence of further modification of the contributor version. For 867 | purposes of this definition, "control" includes the right to grant 868 | patent sublicenses in a manner consistent with the requirements of 869 | this License. 870 | 871 | Each contributor grants you a non-exclusive, worldwide, royalty-free 872 | patent license under the contributor's essential patent claims, to 873 | make, use, sell, offer for sale, import and otherwise run, modify and 874 | propagate the contents of its contributor version. 875 | 876 | In the following three paragraphs, a "patent license" is any express 877 | agreement or commitment, however denominated, not to enforce a patent 878 | (such as an express permission to practice a patent or covenant not to 879 | sue for patent infringement). To "grant" such a patent license to a 880 | party means to make such an agreement or commitment not to enforce a 881 | patent against the party. 882 | 883 | If you convey a covered work, knowingly relying on a patent license, 884 | and the Corresponding Source of the work is not available for anyone 885 | to copy, free of charge and under the terms of this License, through a 886 | publicly available network server or other readily accessible means, 887 | then you must either (1) cause the Corresponding Source to be so 888 | available, or (2) arrange to deprive yourself of the benefit of the 889 | patent license for this particular work, or (3) arrange, in a manner 890 | consistent with the requirements of this License, to extend the patent 891 | license to downstream recipients. "Knowingly relying" means you have 892 | actual knowledge that, but for the patent license, your conveying the 893 | covered work in a country, or your recipient's use of the covered work 894 | in a country, would infringe one or more identifiable patents in that 895 | country that you have reason to believe are valid. 896 | 897 | If, pursuant to or in connection with a single transaction or 898 | arrangement, you convey, or propagate by procuring conveyance of, a 899 | covered work, and grant a patent license to some of the parties 900 | receiving the covered work authorizing them to use, propagate, modify 901 | or convey a specific copy of the covered work, then the patent license 902 | you grant is automatically extended to all recipients of the covered 903 | work and works based on it. 904 | 905 | A patent license is "discriminatory" if it does not include within 906 | the scope of its coverage, prohibits the exercise of, or is 907 | conditioned on the non-exercise of one or more of the rights that are 908 | specifically granted under this License. You may not convey a covered 909 | work if you are a party to an arrangement with a third party that is 910 | in the business of distributing software, under which you make payment 911 | to the third party based on the extent of your activity of conveying 912 | the work, and under which the third party grants, to any of the 913 | parties who would receive the covered work from you, a discriminatory 914 | patent license (a) in connection with copies of the covered work 915 | conveyed by you (or copies made from those copies), or (b) primarily 916 | for and in connection with specific products or compilations that 917 | contain the covered work, unless you entered into that arrangement, 918 | or that patent license was granted, prior to 28 March 2007. 919 | 920 | Nothing in this License shall be construed as excluding or limiting 921 | any implied license or other defenses to infringement that may 922 | otherwise be available to you under applicable patent law. 923 | 924 | 12. No Surrender of Others' Freedom. 925 | 926 | If conditions are imposed on you (whether by court order, agreement or 927 | otherwise) that contradict the conditions of this License, they do not 928 | excuse you from the conditions of this License. If you cannot convey a 929 | covered work so as to satisfy simultaneously your obligations under this 930 | License and any other pertinent obligations, then as a consequence you may 931 | not convey it at all. For example, if you agree to terms that obligate you 932 | to collect a royalty for further conveying from those to whom you convey 933 | the Program, the only way you could satisfy both those terms and this 934 | License would be to refrain entirely from conveying the Program. 935 | 936 | 13. Use with the GNU Affero General Public License. 937 | 938 | Notwithstanding any other provision of this License, you have 939 | permission to link or combine any covered work with a work licensed 940 | under version 3 of the GNU Affero General Public License into a single 941 | combined work, and to convey the resulting work. The terms of this 942 | License will continue to apply to the part which is the covered work, 943 | but the special requirements of the GNU Affero General Public License, 944 | section 13, concerning interaction through a network will apply to the 945 | combination as such. 946 | 947 | 14. Revised Versions of this License. 948 | 949 | The Free Software Foundation may publish revised and/or new versions of 950 | the GNU General Public License from time to time. Such new versions will 951 | be similar in spirit to the present version, but may differ in detail to 952 | address new problems or concerns. 953 | 954 | Each version is given a distinguishing version number. If the 955 | Program specifies that a certain numbered version of the GNU General 956 | Public License "or any later version" applies to it, you have the 957 | option of following the terms and conditions either of that numbered 958 | version or of any later version published by the Free Software 959 | Foundation. If the Program does not specify a version number of the 960 | GNU General Public License, you may choose any version ever published 961 | by the Free Software Foundation. 962 | 963 | If the Program specifies that a proxy can decide which future 964 | versions of the GNU General Public License can be used, that proxy's 965 | public statement of acceptance of a version permanently authorizes you 966 | to choose that version for the Program. 967 | 968 | Later license versions may give you additional or different 969 | permissions. However, no additional obligations are imposed on any 970 | author or copyright holder as a result of your choosing to follow a 971 | later version. 972 | 973 | 15. Disclaimer of Warranty. 974 | 975 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 976 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 977 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 978 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 979 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 980 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 981 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 982 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 983 | 984 | 16. Limitation of Liability. 985 | 986 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 987 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 988 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 989 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 990 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 991 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 992 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 993 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 994 | SUCH DAMAGES. 995 | 996 | 17. Interpretation of Sections 15 and 16. 997 | 998 | If the disclaimer of warranty and limitation of liability provided 999 | above cannot be given local legal effect according to their terms, 1000 | reviewing courts shall apply local law that most closely approximates 1001 | an absolute waiver of all civil liability in connection with the 1002 | Program, unless a warranty or assumption of liability accompanies a 1003 | copy of the Program in return for a fee. 1004 | 1005 | END OF TERMS AND CONDITIONS 1006 | 1007 | How to Apply These Terms to Your New Programs 1008 | 1009 | If you develop a new program, and you want it to be of the greatest 1010 | possible use to the public, the best way to achieve this is to make it 1011 | free software which everyone can redistribute and change under these terms. 1012 | 1013 | To do so, attach the following notices to the program. It is safest 1014 | to attach them to the start of each source file to most effectively 1015 | state the exclusion of warranty; and each file should have at least 1016 | the "copyright" line and a pointer to where the full notice is found. 1017 | 1018 | 1019 | Copyright (C) 1020 | 1021 | This program is free software: you can redistribute it and/or modify 1022 | it under the terms of the GNU General Public License as published by 1023 | the Free Software Foundation, either version 3 of the License, or 1024 | (at your option) any later version. 1025 | 1026 | This program is distributed in the hope that it will be useful, 1027 | but WITHOUT ANY WARRANTY; without even the implied warranty of 1028 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1029 | GNU General Public License for more details. 1030 | 1031 | You should have received a copy of the GNU General Public License 1032 | along with this program. If not, see . 1033 | 1034 | Also add information on how to contact you by electronic and paper mail. 1035 | 1036 | If the program does terminal interaction, make it output a short 1037 | notice like this when it starts in an interactive mode: 1038 | 1039 | Copyright (C) 1040 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 1041 | This is free software, and you are welcome to redistribute it 1042 | under certain conditions; type `show c' for details. 1043 | 1044 | The hypothetical commands `show w' and `show c' should show the appropriate 1045 | parts of the General Public License. Of course, your program's commands 1046 | might be different; for a GUI interface, you would use an "about box". 1047 | 1048 | You should also get your employer (if you work as a programmer) or school, 1049 | if any, to sign a "copyright disclaimer" for the program, if necessary. 1050 | For more information on this, and how to apply and follow the GNU GPL, see 1051 | . 1052 | 1053 | The GNU General Public License does not permit incorporating your program 1054 | into proprietary programs. If your program is a subroutine library, you 1055 | may consider it more useful to permit linking proprietary applications with 1056 | the library. If this is what you want to do, use the GNU Lesser General 1057 | Public License instead of this License. But first, please read 1058 | . -------------------------------------------------------------------------------- /src-protobuf/contact.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | option optimize_for = LITE_RUNTIME; 3 | 4 | package atakmap.commoncommo.protobuf.v1; 5 | 6 | // All items are required unless otherwise noted! 7 | // "required" means if they are missing on send, the conversion 8 | // to the message format will be rejected and fall back to opaque 9 | // XML representation 10 | message Contact { 11 | // Endpoint is optional; if missing/empty do not populate. 12 | string endpoint = 1; // endpoint= 13 | string callsign = 2; // callsign= 14 | } 15 | -------------------------------------------------------------------------------- /src-protobuf/cotevent.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | option optimize_for = LITE_RUNTIME; 4 | 5 | package atakmap.commoncommo.protobuf.v1; 6 | 7 | import "detail.proto"; 8 | 9 | // A note about timestamps: 10 | // Uses "timeMs" units, which is number of milliseconds since 11 | // 1970-01-01 00:00:00 UTC 12 | // 13 | // All items are required unless otherwise noted! 14 | // "required" means if they are missing in the XML during outbound 15 | // conversion to protobuf, the message will be 16 | // rejected 17 | message CotEvent { 18 | // 19 | 20 | string type = 1; // 21 | 22 | string access = 2; // optional 23 | string qos = 3; // optional 24 | string opex = 4; // optional 25 | 26 | string uid = 5; // 27 | uint64 sendTime = 6; // converted to timeMs 28 | uint64 startTime = 7; // converted to timeMs 29 | uint64 staleTime = 8; // converted to timeMs 30 | string how = 9; // 31 | 32 | // 33 | double lat = 10; // 34 | double lon = 11; // 35 | double hae = 12; // use 999999 for unknown 36 | double ce = 13; // use 999999 for unknown 37 | double le = 14; // use 999999 for unknown 38 | 39 | // comprises children of 40 | // This is optional - if omitted, then the cot message 41 | // had no data under 42 | Detail detail = 15; 43 | } 44 | 45 | -------------------------------------------------------------------------------- /src-protobuf/detail.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | option optimize_for = LITE_RUNTIME; 3 | 4 | package atakmap.commoncommo.protobuf.v1; 5 | 6 | import "contact.proto"; 7 | import "group.proto"; 8 | import "precisionlocation.proto"; 9 | import "status.proto"; 10 | import "takv.proto"; 11 | import "track.proto"; 12 | 13 | // CotEvent detail 14 | // The strong typed message fields are optional. If used, they *MUST* adhere 15 | // to the requirements of the message (see their proto file) and 16 | // their XML source element used to populate the message MUST 17 | // be omitted from the xmlDetail. 18 | // WHOLE ELEMENTS MUST BE CONVERTED TO MESSAGES. Do not try to 19 | // put part of the data from a given element into one of the messages 20 | // and put other parts of the data in an element of xmlDetail! This applies 21 | // especially if you add new things to the XML representation which do not 22 | // have a place in the equivalent protobuf message. Instead, omit the 23 | // message and put the entire element in xmlDetail! 24 | // 25 | // xmlDetail is optional. If omitted, all Detail data has been 26 | // converted to the strongly typed message fields. 27 | // If present, this contains any remaining detail data that has NOT been 28 | // included in one of the strongly typed message fields. To process the 29 | // xmlDetail, the following rules MUST be followed: 30 | // Senders of this message MUST: 31 | // 1. Remove child elements used to populate the other message 32 | // fields. If the same child element appears more times than an 33 | // associated message field(s) is intended to encompass, or if any 34 | // error occurs mapping to the message equivalent, do not remove 35 | // the element(s) in question and do not populate the message 36 | // equivalent. 37 | // 2. If no data under remains, STOP - do not populate 38 | // xmlDetail 39 | // 3. Serialize the remaining XML tree under .... 40 | // as XML in UTF-8 encoding 41 | // 4. Remove the and element tags 42 | // 5. Remove the XML header 43 | // 6. Place the result in xmlDetail 44 | // Receivers of this message MUST do the equivalent of the following: 45 | // 1. If the field is not present (zero length), stop - do nothing 46 | // 2. Prepend and append 47 | // 3. Prepend an XML header for UTF-8 encoding, version 1.0 48 | // ( or similar) 49 | // 4. Read the result, expecting a valid XML document with a document 50 | // root of 51 | // 5. Merge in XML equivalents of each of the strongly typed 52 | // messages present in this Detail message. 53 | // In the event that a sending application does not follow 54 | // sending rule #1 above properly and data for the same element 55 | // appears in xmlDetail, the data in xmlDetail should be left alone 56 | // and the data in the equivalent message should ignored. 57 | 58 | message Detail { 59 | string xmlDetail = 1; 60 | 61 | // 62 | Contact contact = 2; 63 | 64 | // <__group> 65 | Group group = 3; 66 | 67 | // 68 | PrecisionLocation precisionLocation = 4; 69 | 70 | // 71 | Status status = 5; 72 | 73 | // 74 | Takv takv = 6; 75 | 76 | // 77 | Track track = 7; 78 | } 79 | -------------------------------------------------------------------------------- /src-protobuf/group.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | option optimize_for = LITE_RUNTIME; 3 | 4 | package atakmap.commoncommo.protobuf.v1; 5 | 6 | // All items are required unless otherwise noted! 7 | // "required" means if they are missing on send, the conversion 8 | // to the message format will be rejected and fall back to opaque 9 | // XML representation 10 | message Group { 11 | string name = 1; // name= 12 | string role = 2; // role= 13 | } 14 | -------------------------------------------------------------------------------- /src-protobuf/precisionlocation.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | option optimize_for = LITE_RUNTIME; 3 | 4 | package atakmap.commoncommo.protobuf.v1; 5 | 6 | // All items are required unless otherwise noted! 7 | // "required" means if they are missing on send, the conversion 8 | // to the message format will be rejected and fall back to opaque 9 | // XML representation 10 | message PrecisionLocation { 11 | string geopointsrc = 1; // geopointsrc= 12 | string altsrc = 2; // altsrc= 13 | } 14 | -------------------------------------------------------------------------------- /src-protobuf/protocol.txt: -------------------------------------------------------------------------------- 1 | *** Traditional Protocol - "Protocol Version 0" 2 | 3 | Clients send and receive XML CoT messages. 4 | "Mesh" network participants announce via "SA" messages via UDP datagrams 5 | over multicast to a well known address and port. Each UDP datagram contains 6 | one (and only one) CoT XML message as its payload. 7 | 8 | Messages directed only to specific network participants are send by making 9 | TCP connection to the remote recipient, sending the CoT XML, then closing 10 | the connection. 11 | 12 | 13 | Streaming connections (to TAK servers) send the same XML-based CoT payloads 14 | over TCP sockets. The TCP stream is comprised of one CoT after 15 | another. Messages are delimited and broken apart by searching for the token 16 | "" and breaking apart immediately after that token. 17 | When sending, messages must be prefaced by XML header (), 18 | followed by a newline, followed by the complete XML . TAK servers 19 | require that no arbitrary newlines follow the end of message and 20 | that the next character immediate commences the next header. 21 | 22 | 23 | 24 | *** TAK Protocol - Design Goals 25 | 26 | The goal of the new TAK Protocol design is to allow interoperation with 27 | other legacy clients and TAK server, as well as to strongly identify 28 | what rendition of communication will be used in a session. This is to allow 29 | for future expansion or complete revision of the protocol while allowing 30 | an opportunity to support mixed client versions (and varying versions of TAK 31 | servers). 32 | 33 | 34 | *** TAK Protocol - Ground Rules 35 | 36 | All clients obey the following basic rules regardless of the version(s) 37 | of TAK protocol that they support. These rules are important base rules 38 | upon which the protocol version negotiations detailed in subsequent sections 39 | rely: 40 | 41 | 1. A client sending TAK protocol version "V" is also capable of receiving 42 | and decoding version "V" 43 | 2. All clients must support decoding TAK protocol version "0" (legacy XML) 44 | 45 | 46 | *** TAK Protocol - Generic Framework - Mesh Networks 47 | 48 | Mesh networks broadcasts (SA announces, etc) will reuse the existing UDP 49 | datagram-based networking already in place. Directed (unicasted) TCP 50 | messages will reuse the existing connect, send 1 message, disconnect 51 | networking. 52 | 53 | For both TCP and UDP, instead of sending CoT as XML, clients will send data 54 | packets whose payloads contain one message complying with the new "TAK 55 | Protocol". 56 | Both types of messages will utilize a data payload that begins with the "TAK 57 | Protocol Header" followed by the "TAK Protocol Payload". The header 58 | serves to self-identify as a TAK Protocol message, as well as indicate a 59 | particular version number to which the subsequent Payload comforms. 60 | 61 | TAK Protocol Message: 62 | 63 | 64 | The "TAK Protocol Header" is nothing more than a set of "magic numbers" to 65 | identify the message header as such, and a version identifier to indicate 66 | what TAK Protocol version the remainder of the payload is comprised of. 67 | 68 | TAK Protocol Header: 69 | Where.... 70 | is the single byte 0xbf 71 | is the version number of the TAK Protocol the payload 72 | in the remainder of the message conforms to. This is encoded as a "varint". 73 | See "TAK Protocol Varint Encoding". 74 | 75 | 76 | 77 | *** TAK Protocol - Generic Framework - Streaming Connections 78 | 79 | Steaming connections (TAK server connections) use a different message style 80 | as the repeating protocol version information in every message that is done 81 | in mesh TAK Protocol Messages would be a waste of resources in the streaming 82 | environment (since all messages will use the same Version). 83 | The TAK Protocol Stream Message is instead defined to provide the length of 84 | the streaming message (necessary to break apart the message from its 85 | neighbors to avoid need to scan for special tokens). 86 | 87 | In a streaming connection, "TAK Protocol Streaming Messages" are sent one 88 | after another (with no intervening data) over the streaming connection. 89 | 90 | TAK Protocol Stream Message: 91 | 92 | 93 | Important to note here is that the "TAK Protocol Payload" is precisely the 94 | same in form and content to that which is used for mesh network messages for 95 | a given protocol version. 96 | 97 | 98 | 99 | The "TAK Protocol Streaming Header" is as follows: 100 | 101 | TAK Protocol Streaming Header: 102 | 103 | Where... 104 | is the single byte 0xbf 105 | is the number of bytes in the "TAK Protocol Payload" which 106 | follows the header. This is encoded as a "varint". 107 | 108 | As mentioned prior, the version identification for the message's payload 109 | format is omitted from the streaming header. Protocol version negotiation 110 | is expected to occur outside of core TAK Protocol message exchange. 111 | See "Streaming Connection Protocol Negotiation". 112 | 113 | 114 | 115 | 116 | *** TAK Protocol Payload - Version 1 117 | 118 | Version 1 of the TAK Protocol Payload is a Google Protocol Buffer based 119 | payload. Each Payload consists of one (and only one) 120 | atakmap::commoncommo::v1::TakMessage message which is serialized using 121 | Google protocol buffers version 3. 122 | 123 | See the .proto files for more information on the specific messages and their 124 | fields, as well as the mapping to/from CoT XML. 125 | 126 | Revising the messages used by Version 1 may be done in accordance with the 127 | following rules: 128 | 129 | 1. Additional message fields MAY be added to the end of existing messages 130 | following normal google protobuf rules if and only if 131 | ignorance of the new fields on decoding is 100% irrelevant to correct 132 | semantic operation at the TAK application level of ALL TAK applications. 133 | 2. Otherwise, any and all changes must be tied to a protocol version change. 134 | 135 | 136 | This version of TAK Protocol does not define any additional attributes to be 137 | used during Streaming Connection Protocol Negotiation. 138 | 139 | 140 | 141 | *** Streaming Connection Protocol Negotiation 142 | 143 | TAK clients often connect to a variety of TAK servers, each of which may be 144 | a different version of software capable of different versions of the TAK 145 | Protocol (or indeed not capable of the TAK Protocol and simply only 146 | supporting traditional streaming CoT as XML). 147 | 148 | Because of the desire to allow operation of various client and server 149 | versions, and the desire to keep the traditional XML encoding available, the 150 | following negotiation is performed when connecting to a TAK server with a 151 | client that supports the TAK Protocol. 152 | 153 | 1. Once the connection is established, client and server should expect to 154 | exchange traditional CoT XML messages per "Traditional Protocol" section. 155 | Note, however, if the server requires authentication, the auth XML message 156 | MUST be the first message sent to the TAK server by the client. 157 | Even if awaiting auth, the server MAY send CoT XML. Upon supplying an 158 | auth message (when required), one of two things happens: 159 | 1a. If the server accepts the auth, proceed to 2. 160 | 1b. If the server denies the auth, the connection is closed. 161 | 2. Client and server continue to expect to exchange traditional 162 | CoT XML messages per "Traditional Protocol" section. 163 | 3. A server which supports the TAK Protocol MAY send the following CoT XML 164 | message to indicate this support (whitespace added, xml header omitted): 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | ... where the version attribute is an integer number specifying 175 | a version of the TAK Protocol the server supports. This message 176 | may contain one or more TakProtocolSupport elements inside the single 177 | detail, each specifying a supported version. 178 | The TAK server MUST send this message no more than once per connection. 179 | 180 | To allow for ancillary information in the negotiation, the 181 | TakProtocolSupport element MAY contain additional attributes compliant 182 | with the Protocol version indicated. 183 | 4. Client and server continue to expect to exchange traditional CoT XML 184 | messages per "Traditional Protocol" section. 185 | 5. If the client wishes to initiate a transfer to TAK Protocol encoding, it 186 | selects one of the supported versions advertised in the server's message 187 | from step 3. It then sends the following CoT XML: 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | ... where the version attribute is the integer version chosen above. 198 | Only ONE TakRequest element is allowed. 199 | 200 | To allow for ancillary information in the negotiation, the 201 | TakRequest element MAY contain additional attributes compliant 202 | with the Protocol version indicated. 203 | 204 | Clients SHALL NOT send this message unless they have observed the 205 | message from step #3, above, first. 206 | Server MUST examine all receive CoT events for this message from the point 207 | in time when the message in #3 is sent until at least one minute following 208 | that point in time. If a "false" status is subsequently issued per step #6 209 | below step, this time limit SHALL be extended to at least one minute 210 | from the point in time the failure response message specified in 211 | #6 is issued to allow the client additional time to retry. 212 | 213 | 6. Once the client sends the message in #5, it MUST NOT send additional 214 | CoT XML to the server. Client also MUST still process incoming CoT XML 215 | from the server. The client MUST wait in this state for a response per 216 | the following for at least one minute. 217 | The server MAY still send CoT XML messages up until it notices the 218 | control request from the client (from step #5) and is ready to respond. 219 | The server MUST then respond as soon as possible to the client with the 220 | following message to indicate either acceptance or denial of the request: 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | ... where the status attribute is either true (to indicate the server 231 | accepts the requested version) or false (to indicate that the server 232 | denies the request). 233 | Only ONE TakResponse element is allowed. 234 | 235 | To allow for ancillary information in the negotiation, the 236 | TakResponse element MAY contain additional attributes compliant 237 | with the Protocol version selected in the request that this response 238 | applies to. 239 | 240 | If no response is received by the client before its timeout elapses, 241 | the client SHALL disconnect as the entire negotiation is in an 242 | indeterminate state. The client SHOULD reconnect and begin again at step 243 | 1, possibly with a longer timeout or alternate protocol version choice. 244 | 245 | 7. Operation at this point depends on the response send in #6: 246 | 7a. If status was true: The server MUST NOT send additiona CoT XML after the 247 | "true" response in #6. Instead, the server SHALL send all future data 248 | in accordance with the TAK Protocol Streaming Connection framework 249 | and containing TAK Payloads of the negotiated version. 250 | The client MAY resume sending messages at this time but MUST immediately 251 | send said messages in accordance with the TAK Protocol Streaming 252 | Connection framework and containing TAK Payloads of the negotiated 253 | version. NOTE: the negotiated version SHALL be the same for both 254 | directions of the streaming connection! 255 | 7b. If status was false: Both client and server resume operation as though 256 | they were back at step #4. The client may attempt a new negotiation 257 | if it wishes, or may simply continue to exchange traditional XML-based 258 | CoT messages. 259 | 260 | In the messages in 3, 5, and 6 above, the following common rules apply: 261 | a. "protouid" is any valid UID representing the negotiation transaction. 262 | The server generates this when offering protocol versions. The client 263 | re-uses it when placing request(s) and the server re-uses it when 264 | issuing the response to a request. 265 | The UID SHALL be unique from UIDs used for other messages and purposes. 266 | b. "TIME" is filled with a valid time representation per the CoT schemas. 267 | The TIME values may be different from each other as needed. 268 | 269 | 270 | *** "Mesh Network" Protocol Negotiation 271 | 272 | Mesh networking in TAK products relies on repeated broadcasting of 273 | device presence and "SA" data that gives basic information on how to reach 274 | local network participants. To allow for clients with mixed TAK protocol 275 | versions (as well as legacy XML only capabilities), the following protocol 276 | selection and support advertisement shall be performed on each device: 277 | 278 | 1. All devices supporting TAK Protocol versions > 0 (legacy xml) MUST 279 | broadcast to all configured and active non-TAK server broadcast destinations 280 | the TakControl message in a TakMessage at least once every 60 seconds. 281 | This information MAY be sent alongside CotEvent data or standalone. 282 | This message indicates the minimum and maximum versions of TAK protocol 283 | that the device can **decode**. 284 | Note that devices not supporting TAK protocol > 0 will not be sending these 285 | messages. 286 | It is RECOMMENDED that devices do *not* frequently change the 287 | version information in these messages as receivers may optimize around 288 | the information being mostly static/fixed. 289 | This information SHALL be sent using the protocol level 290 | determined under the rule in 4 except when rule 4 results in 291 | protocol level 0, in which case TakControl information 292 | SHALL be sent using the lowest protocol version > 0 supported by the 293 | sender. 294 | 2. Each device MUST examine and decode the TakControl message in any message 295 | it receives and knows how to decode. If for a version that the device 296 | does not support, it MAY discard the message. 297 | 3. Each device MUST maintain the minimum and maximum supported TAK protocol 298 | versions known from every client known to exist on the network based on 299 | the following ruleset: 300 | 3a. Newly detected clients are assigned a min/max supported version 301 | equal to the version used to relay the message that resulted 302 | in discovery of the client. Note that this could be version 0 303 | (legacy XML) 304 | 3b. Upon receipt of a TakControl message, the min/max version info 305 | is updated to match the information in the message. Optimizing 306 | for infrequent changes of this info is recommended. 307 | Note that TakControl messages do NOT allow versions of 0 in them. 308 | Support for version 0 is implied (see base rules) and need not be 309 | tracked except for those clients which support *only* version 0. 310 | 3c. Known clients that have not sent any TakControl messages in the previous 311 | 2 minutes shall revert to a minimum and maximum version equal 312 | to the version used in the most recently received message that 313 | keeps the client from becoming entirely stale. Note that this could 314 | be version 0 (legacy XML). 315 | 3d. Received messages that are not decodable by the receiver should 316 | continue to be treated as not having received TakControl messages 317 | under 3c. 318 | 4. Devices MUST send out broadcast messages using the highest protocol version 319 | supported by *all* known contacts (including consideration of the 320 | sending device itself) tracked based on the rules in (3) at the time 321 | of sending. 322 | This includes SA announcements/broadcasts. 323 | If there is no version overlap suitable for all versions, then protocol 324 | "version 0" must be used. 325 | If this is "version 0" (legacy xml), then XML shall be used. 326 | 5. Whenever the version computed via rule 5 changes, clients SHALL immediately 327 | send out a TakControl message using the new version per rule 1. 328 | This must be done even if not otherwise broadcasting a message. 329 | 330 | 331 | 332 | *** TAK Protocol Varint Encoding 333 | 334 | The varints used in the headers of the TAK Protocol are encoded in 335 | accordance with the UNSIGNED varint rules for Google protocol buffers. 336 | This encoding is summarized here: 337 | 338 | 1. The value must be UNSIGNED. Only values equal to or greater than zero 339 | are allowed. 340 | 2. The value to be encoded is taken 7 bits at a time, starting with the 341 | least significant 7 bits (bits 7 -> 0), then the next least significant bits 342 | (14 -> 8), etc. This repeats over all 7 bit values that are significant 343 | (that is, up to and including the most significant '1' bit). 344 | 3. For each 7 bit group: 345 | 3a. Let S = 0 if this is the the last 7 bit group, else let S = 1 346 | 3b. Output a byte that is (S << 7) | (the 7 bits) 347 | 348 | The TAK Protocol use of Varints limits use to 64-bit values. This 349 | effectively limits the range as [ 0, (2^63 - 1) ] and the varint coded value 350 | to be limited to 10 bytes. 351 | 352 | 353 | -------------------------------------------------------------------------------- /src-protobuf/status.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | option optimize_for = LITE_RUNTIME; 3 | 4 | package atakmap.commoncommo.protobuf.v1; 5 | 6 | // All items are required unless otherwise noted! 7 | // "required" means if they are missing on send, the conversion 8 | // to the message format will be rejected and fall back to opaque 9 | // XML representation 10 | message Status { 11 | uint32 battery = 1; // battery= 12 | } 13 | -------------------------------------------------------------------------------- /src-protobuf/takcontrol.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | option optimize_for = LITE_RUNTIME; 3 | 4 | package atakmap.commoncommo.protobuf.v1; 5 | 6 | // TAK Protocol control message 7 | // This specifies to a recipient what versions 8 | // of protocol elements this sender supports during 9 | // decoding. 10 | message TakControl { 11 | // Lowest TAK protocol version supported 12 | // If not filled in (reads as 0), version 1 is assumed 13 | uint32 minProtoVersion = 1; 14 | 15 | // Highest TAK protocol version supported 16 | // If not filled in (reads as 0), version 1 is assumed 17 | uint32 maxProtoVersion = 2; 18 | 19 | // UID of the sending contact. May be omitted if 20 | // this message is paired in a TakMessage with a CotEvent 21 | // and the CotEvent contains this information 22 | string contactUid = 3; 23 | } 24 | 25 | -------------------------------------------------------------------------------- /src-protobuf/takmessage.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | option optimize_for = LITE_RUNTIME; 3 | 4 | import "cotevent.proto"; 5 | import "takcontrol.proto"; 6 | 7 | package atakmap.commoncommo.protobuf.v1; 8 | 9 | // Top level message sent for TAK Messaging Protocol Version 1. 10 | message TakMessage { 11 | // Optional - if omitted, continue using last reported control 12 | // information 13 | TakControl takControl = 1; 14 | 15 | // Optional - if omitted, no event data in this message 16 | CotEvent cotEvent = 2; 17 | } 18 | 19 | -------------------------------------------------------------------------------- /src-protobuf/takv.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | option optimize_for = LITE_RUNTIME; 3 | 4 | package atakmap.commoncommo.protobuf.v1; 5 | 6 | // All items are required unless otherwise noted! 7 | // "required" means if they are missing on send, the conversion 8 | // to the message format will be rejected and fall back to opaque 9 | // XML representation 10 | message Takv { 11 | string device = 1; // device= 12 | string platform = 2; // platform= 13 | string os = 3; // os= 14 | string version = 4; // version= 15 | } 16 | -------------------------------------------------------------------------------- /src-protobuf/track.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | option optimize_for = LITE_RUNTIME; 3 | 4 | package atakmap.commoncommo.protobuf.v1; 5 | 6 | // All items are required unless otherwise noted! 7 | // "required" means if they are missing on send, the conversion 8 | // to the message format will be rejected and fall back to opaque 9 | // XML representation 10 | message Track { 11 | double speed = 1; // speed= 12 | double course = 2; // course= 13 | } 14 | -------------------------------------------------------------------------------- /stdeb.cfg: -------------------------------------------------------------------------------- 1 | [DEFAULT] 2 | Package3: takproto 3 | Replaces3: python3-takproto 4 | Depends3: python3-protobuf -------------------------------------------------------------------------------- /takproto/.gitignore: -------------------------------------------------------------------------------- 1 | 2 | ### Linux ### 3 | 4 | *~ 5 | 6 | # temporary files which can be created if a process still has a handle open of a deleted file 7 | 8 | .fuse_hidden* 9 | 10 | # KDE directory preferences 11 | 12 | .directory 13 | 14 | # Linux trash folder which might appear on any partition or disk 15 | 16 | .Trash-* 17 | 18 | # .nfs files are created when an open file is removed but is still being accessed 19 | 20 | .nfs* 21 | 22 | ### macOS ### 23 | 24 | # General 25 | 26 | .DS_Store 27 | 28 | .AppleDouble 29 | 30 | .LSOverride 31 | 32 | # Icon must end with two \r 33 | 34 | Icon 35 | 36 | # Thumbnails 37 | 38 | ._* 39 | 40 | # Files that might appear in the root of a volume 41 | 42 | .DocumentRevisions-V100 43 | 44 | .fseventsd 45 | 46 | .Spotlight-V100 47 | 48 | .TemporaryItems 49 | 50 | .Trashes 51 | 52 | .VolumeIcon.icns 53 | 54 | .com.apple.timemachine.donotpresent 55 | 56 | # Directories potentially created on remote AFP share 57 | 58 | .AppleDB 59 | 60 | .AppleDesktop 61 | 62 | Network Trash Folder 63 | 64 | Temporary Items 65 | 66 | .apdisk 67 | 68 | ### Python ### 69 | 70 | # Byte-compiled / optimized / DLL files 71 | 72 | __pycache__/ 73 | 74 | *.py[cod] 75 | 76 | *$py.class 77 | 78 | # C extensions 79 | 80 | *.so 81 | 82 | # Distribution / packaging 83 | 84 | .Python 85 | 86 | build/ 87 | 88 | develop-eggs/ 89 | 90 | dist/ 91 | 92 | downloads/ 93 | 94 | eggs/ 95 | 96 | .eggs/ 97 | 98 | lib/ 99 | 100 | lib64/ 101 | 102 | parts/ 103 | 104 | sdist/ 105 | 106 | var/ 107 | 108 | wheels/ 109 | 110 | pip-wheel-metadata/ 111 | 112 | share/python-wheels/ 113 | 114 | *.egg-info/ 115 | 116 | .installed.cfg 117 | 118 | *.egg 119 | 120 | MANIFEST 121 | 122 | # PyInstaller 123 | 124 | # Usually these files are written by a python script from a template 125 | 126 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 127 | 128 | *.manifest 129 | 130 | *.spec 131 | 132 | # Installer logs 133 | 134 | pip-log.txt 135 | 136 | pip-delete-this-directory.txt 137 | 138 | # Unit test / coverage reports 139 | 140 | htmlcov/ 141 | 142 | .tox/ 143 | 144 | .nox/ 145 | 146 | .coverage 147 | 148 | .coverage.* 149 | 150 | .cache 151 | 152 | nosetests.xml 153 | 154 | coverage.xml 155 | 156 | *.cover 157 | 158 | *.py,cover 159 | 160 | .hypothesis/ 161 | 162 | .pytest_cache/ 163 | 164 | pytestdebug.log 165 | 166 | # Translations 167 | 168 | *.mo 169 | 170 | *.pot 171 | 172 | # Django stuff: 173 | 174 | *.log 175 | 176 | local_settings.py 177 | 178 | db.sqlite3 179 | 180 | db.sqlite3-journal 181 | 182 | # Flask stuff: 183 | 184 | instance/ 185 | 186 | .webassets-cache 187 | 188 | # Scrapy stuff: 189 | 190 | .scrapy 191 | 192 | # Sphinx documentation 193 | 194 | docs/_build/ 195 | 196 | doc/_build/ 197 | 198 | # PyBuilder 199 | 200 | target/ 201 | 202 | # Jupyter Notebook 203 | 204 | .ipynb_checkpoints 205 | 206 | # IPython 207 | 208 | profile_default/ 209 | 210 | ipython_config.py 211 | 212 | # pyenv 213 | 214 | .python-version 215 | 216 | # pipenv 217 | 218 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 219 | 220 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 221 | 222 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 223 | 224 | # install all needed dependencies. 225 | 226 | #Pipfile.lock 227 | 228 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow 229 | 230 | __pypackages__/ 231 | 232 | # Celery stuff 233 | 234 | celerybeat-schedule 235 | 236 | celerybeat.pid 237 | 238 | # SageMath parsed files 239 | 240 | *.sage.py 241 | 242 | # Environments 243 | 244 | .env 245 | 246 | .venv 247 | 248 | env/ 249 | 250 | venv/ 251 | 252 | ENV/ 253 | 254 | env.bak/ 255 | 256 | venv.bak/ 257 | 258 | pythonenv* 259 | 260 | # Spyder project settings 261 | 262 | .spyderproject 263 | 264 | .spyproject 265 | 266 | # Rope project settings 267 | 268 | .ropeproject 269 | 270 | # mkdocs documentation 271 | 272 | /site 273 | 274 | # mypy 275 | 276 | .mypy_cache/ 277 | 278 | .dmypy.json 279 | 280 | dmypy.json 281 | 282 | # Pyre type checker 283 | 284 | .pyre/ 285 | 286 | # pytype static type analyzer 287 | 288 | .pytype/ 289 | 290 | # profiling data 291 | 292 | .prof 293 | 294 | ### Windows ### 295 | 296 | # Windows thumbnail cache files 297 | 298 | Thumbs.db 299 | 300 | Thumbs.db:encryptable 301 | 302 | ehthumbs.db 303 | 304 | ehthumbs_vista.db 305 | 306 | # Dump file 307 | 308 | *.stackdump 309 | 310 | # Folder config file 311 | 312 | [Dd]esktop.ini 313 | 314 | # Recycle Bin used on file shares 315 | 316 | $RECYCLE.BIN/ 317 | 318 | # Windows Installer files 319 | 320 | *.cab 321 | 322 | *.msi 323 | 324 | *.msix 325 | 326 | *.msm 327 | 328 | *.msp 329 | 330 | # Windows shortcuts 331 | 332 | *.lnk 333 | 334 | # End of https://www.toptal.com/developers/gitignore/api/python,windows,macos,linux 335 | -------------------------------------------------------------------------------- /takproto/__init__.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # __init__.py from https://github.com/snstac/takproto 4 | # 5 | # Copyright Sensors & Signals LLC https://www.snstac.com 6 | # 7 | # Permission is hereby granted, free of charge, to any person obtaining a copy 8 | # of this software and associated documentation files (the "Software"), to deal 9 | # in the Software without restriction, including without limitation the rights 10 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | # copies of the Software, and to permit persons to whom the Software is 12 | # furnished to do so, subject to the following conditions: 13 | # 14 | # The above copyright notice and this permission notice shall be included in all 15 | # copies or substantial portions of the Software. 16 | # 17 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | # SOFTWARE. 24 | # 25 | 26 | """TAKProto: Encode & Decode TAK Protocol Payloads using Python.""" 27 | 28 | __version__ = "3.0.1" 29 | 30 | # COMPAT Python 3.6 import work-around. 31 | try: 32 | from .functions import ( # NOQA 33 | xml2proto, 34 | parse_proto, 35 | parse_mesh, 36 | parse_stream, 37 | format_time, 38 | ) 39 | from .constants import TAKProtoVer # NOQA 40 | except ImportError as exc: 41 | import warnings 42 | 43 | warnings.warn(f"COMPAT Python 3.6. Ignoring Exception: {str(exc)}") 44 | -------------------------------------------------------------------------------- /takproto/constants.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # constants.py from https://github.com/snstac/takproto 4 | # 5 | # Copyright Sensors & Signals LLC https://www.snstac.com 6 | # 7 | # Permission is hereby granted, free of charge, to any person obtaining a copy 8 | # of this software and associated documentation files (the "Software"), to deal 9 | # in the Software without restriction, including without limitation the rights 10 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | # copies of the Software, and to permit persons to whom the Software is 12 | # furnished to do so, subject to the following conditions: 13 | # 14 | # The above copyright notice and this permission notice shall be included in all 15 | # copies or substantial portions of the Software. 16 | # 17 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | # SOFTWARE. 24 | # 25 | 26 | """TAKProto Constants.""" 27 | 28 | from enum import Enum 29 | 30 | DEFAULT_PROTO_HEADER = bytearray(b"\xbf") 31 | DEFAULT_MESH_HEADER = bytearray(b"\xbf\x01\xbf") 32 | DEFAULT_XML_HEADER = bytearray(b" int: 32 | """Read a varint from the stream.""" 33 | if offset > 0: 34 | stream.seek(offset) 35 | buf: bytes = stream.read(1) 36 | if buf == b"": 37 | return 0 # reached EOF 38 | while (buf[-1] & 0x80) >> 7 == 1: # while the MSB is 1 39 | new_byte = stream.read(1) 40 | if new_byte == b"": 41 | raise EOFError("unexpected EOF") 42 | buf += new_byte 43 | varint, _ = _DecodeVarint(buf, 0) 44 | return varint 45 | 46 | 47 | def read(stream: BinaryIO, proto_class_name: Type[T]) -> Optional[T]: 48 | """ 49 | Read a single length-delimited message from the given stream. 50 | 51 | Similar to: 52 | * [`CodedInputStream`](https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/io/coded_stream.h#L66) 53 | * [`parseDelimitedFrom()`](https://github.com/protocolbuffers/protobuf/blob/master/java/core/src/main/java/com/google/protobuf/Parser.java) 54 | """ 55 | size = _read_varint(stream) 56 | if size == 0: 57 | return None 58 | buf = stream.read(size) 59 | msg = proto_class_name() 60 | msg.ParseFromString(buf) 61 | return msg 62 | 63 | 64 | def write(stream: BinaryIO, msg: T): 65 | """ 66 | Write a single length-delimited message to the given stream. 67 | 68 | Similar to: 69 | * [`CodedOutputStream`](https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/io/coded_stream.h#L47) 70 | * [`MessageLite#writeDelimitedTo`](https://github.com/protocolbuffers/protobuf/blob/master/java/core/src/main/java/com/google/protobuf/MessageLite.java#L126) 71 | """ 72 | assert stream is not None 73 | _EncodeVarint(stream.write, msg.ByteSize()) 74 | stream.write(msg.SerializeToString()) 75 | -------------------------------------------------------------------------------- /takproto/functions.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # constants.py from https://github.com/snstac/takproto 4 | # 5 | # Copyright Sensors & Signals LLC https://www.snstac.com 6 | # Copyright 2020 Delta Bravo-15 7 | # 8 | # Permission is hereby granted, free of charge, to any person obtaining a copy 9 | # of this software and associated documentation files (the "Software"), to deal 10 | # in the Software without restriction, including without limitation the rights 11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | # copies of the Software, and to permit persons to whom the Software is 13 | # furnished to do so, subject to the following conditions: 14 | # 15 | # The above copyright notice and this permission notice shall be included in all 16 | # copies or substantial portions of the Software. 17 | # 18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | # SOFTWARE. 25 | # 26 | 27 | """TAKProto Functions for manipulating TAK Protocol Version 1 messages.""" 28 | 29 | import re 30 | import xml.etree.ElementTree as ET 31 | 32 | from datetime import datetime 33 | from io import BytesIO 34 | from typing import Optional 35 | 36 | import takproto.delimited_protobuf as dpb 37 | from takproto.constants import ( 38 | ISO_8601_UTC, 39 | W3C_XML_DATETIME, 40 | DEFAULT_MESH_HEADER, 41 | DEFAULT_PROTO_HEADER, 42 | DEFAULT_XML_HEADER, 43 | TAKProtoVer, 44 | ) 45 | from takproto.proto import TakMessage 46 | 47 | 48 | def parse_proto(msg: bytearray) -> Optional[TakMessage]: 49 | """Parse TAK Protocol Version 1 Mesh & Stream message.""" 50 | parsed = None 51 | if msg[:3] == DEFAULT_MESH_HEADER: 52 | parsed = parse_mesh(msg) 53 | elif msg[0] in DEFAULT_PROTO_HEADER: 54 | parsed = parse_stream(msg) 55 | elif msg[:5] == DEFAULT_XML_HEADER: 56 | parsed = xml2message(msg) 57 | return parsed 58 | 59 | 60 | def parse_mesh(msg): 61 | """Parse TAK Protocol Version 1 Mesh message.""" 62 | msg = msg[3:] 63 | protobuf = TakMessage() 64 | protobuf.ParseFromString(bytes(msg)) 65 | return protobuf 66 | 67 | 68 | def parse_stream(msg) -> TakMessage: 69 | """Parse TAK Protocol Version 1 Stream message.""" 70 | bio = BytesIO(msg[1:]) 71 | msg = dpb.read(bio, TakMessage) 72 | return msg 73 | 74 | 75 | def format_time(time: str) -> int: 76 | """Format timestamp as microseconds.""" 77 | try: 78 | s_time = datetime.strptime(time + "+0000", ISO_8601_UTC + "%z") 79 | except ValueError: 80 | s_time = datetime.strptime(time + "+0000", W3C_XML_DATETIME + "%z") 81 | return int(s_time.timestamp() * 1000) 82 | 83 | 84 | def xml2message( 85 | xml: bytearray, 86 | ) -> ( 87 | TakMessage 88 | ): # NOQA pylint: disable=too-many-locals,too-many-branches,too-many-statements 89 | """Convert plain XML CoT to Protobuf.""" 90 | event = ET.fromstring(xml) 91 | tak_message = TakMessage() 92 | tak_control = tak_message.takControl 93 | new_event = tak_message.cotEvent 94 | 95 | # If this is a GeoChat message, extract the sender's UID from the event UID and 96 | # place it in takControl.contactUid 97 | uid = event.get("uid") 98 | if uid and "GeoChat." in uid: 99 | tak_control.contactUid = uid.split(".")[1] 100 | 101 | base_attribs = ["type", "access", "qos", "opex", "uid", "how"] 102 | for attrib in base_attribs: 103 | val = event.get(attrib) 104 | if val: 105 | setattr(new_event, attrib, val) 106 | 107 | # TAK protobuf times are expressed as miliseconds since 1970-01-01 00:00:00 UTC 108 | # Convert time, start, and stale, from ISO time format to miliseconds since epoch 109 | time_attribs = ["time", "start", "stale"] 110 | for attrib in time_attribs: 111 | val = event.get(attrib) 112 | if val: 113 | if attrib == "time": 114 | attrib = "send" 115 | setattr(new_event, f"{attrib}Time", format_time(val)) 116 | 117 | # If the event element includes a point child, write the attributes 118 | point = event.find("point") 119 | if point is not None: 120 | attribs = ["lat", "lon", "hae", "ce", "le"] 121 | for attrib in attribs: 122 | val = point.get(attrib) 123 | if val: 124 | setattr(new_event, attrib, float(val)) 125 | 126 | detail = event.find("detail") 127 | if detail is not None: 128 | # If the XML includes a element, create new_event.detail 129 | new_detail = new_event.detail 130 | 131 | # The new_event.detail field of a TAK protobuf is structured differently 132 | # from CoT XML. new_event.detail may only contain xmlDetail, contact, 133 | # __group, precisionlocation, status, takv, and track. xmlDetail should 134 | # contain an XML string with any data that does not adhere to the other 135 | # strongly-typed fields. See more information about each field below. 136 | 137 | # If this is a GeoChat message, write the contents of in xmlDetail. 138 | if uid and "GeoChat." in uid: 139 | pattern = "(.*?)" 140 | target = ET.tostring(detail).decode("utf-8") 141 | re_search = re.search(pattern, target) 142 | if re_search: 143 | xmldetailstr = re_search.group(1) 144 | new_detail.xmlDetail = xmldetailstr 145 | else: 146 | # Add unknown elements to xmlDetail field. 147 | known_elem = [ 148 | "contact", 149 | "__group", 150 | "precisionlocation", 151 | "status", 152 | "takv", 153 | "track", 154 | ] 155 | for elem in detail.iterfind("*"): 156 | if elem.tag not in known_elem: 157 | new_detail.xmlDetail += ET.tostring(elem).strip().decode() 158 | 159 | contact = detail.find("contact") 160 | if contact is not None: 161 | attribs = ["endpoint", "callsign"] 162 | for attrib in attribs: 163 | attrib_val = contact.get(attrib) 164 | if attrib_val: 165 | setattr(new_detail.contact, attrib, attrib_val) 166 | 167 | group = detail.find("__group") # pylint: disable=protected-access 168 | if group is not None: 169 | attribs = ["name", "role"] 170 | for attrib in attribs: 171 | attrib_val = group.get(attrib) 172 | if attrib_val: 173 | setattr(new_detail.group, attrib, attrib_val) 174 | 175 | prec_loc = detail.find("precisionlocation") 176 | if prec_loc is not None: 177 | attribs = ["geopointsrc", "altsrc"] 178 | for attrib in attribs: 179 | attrib_val = prec_loc.get(attrib) 180 | if attrib_val: 181 | setattr(new_detail.precisionLocation, attrib, attrib_val) 182 | 183 | status = detail.find("status") 184 | if status is not None: 185 | battery = status.get("battery") 186 | if battery: 187 | new_detail.status.battery = int(battery) 188 | 189 | takv = detail.find("takv") 190 | if takv is not None: 191 | attribs = ["device", "platform", "os", "version"] 192 | for attrib in attribs: 193 | attrib_val = takv.get(attrib) 194 | if attrib_val: 195 | setattr(new_detail.takv, attrib, attrib_val) 196 | 197 | # The fields in track are double-precision floating-point numbers. 198 | # We can use Python's native float, since that is actually 64-bit 199 | # floating-point. 200 | track = detail.find("track") 201 | if track is not None: 202 | attribs = ["speed", "course"] 203 | for attrib in attribs: 204 | attrib_val = track.get(attrib) 205 | if attrib_val: 206 | setattr(new_detail.track, attrib, float(attrib_val)) 207 | 208 | return tak_message 209 | 210 | 211 | def xml2proto(xml: str, protover: Optional[TAKProtoVer] = None): 212 | """Convert TAK XML COT to TAK Protobuf COT.""" 213 | tak_message = xml2message(xml) 214 | output = msg2proto(tak_message, protover) 215 | return output 216 | 217 | 218 | def msg2proto(msg, protover: Optional[TAKProtoVer] = None) -> bytearray: 219 | """Convert a TakMessage into a TAK Protocol Version 1 protobuf.""" 220 | protover = protover or TAKProtoVer.MESH 221 | 222 | output_ba = bytearray() 223 | header_ba = bytearray() 224 | proto_ba = bytearray() 225 | 226 | if protover == TAKProtoVer.MESH: 227 | header_ba = DEFAULT_MESH_HEADER 228 | proto_ba = bytearray(msg.SerializeToString()) 229 | elif protover == TAKProtoVer.STREAM: 230 | header_ba = DEFAULT_PROTO_HEADER 231 | output_io = BytesIO() 232 | dpb.write(output_io, msg) 233 | proto_ba = bytearray(output_io.getvalue()) 234 | else: 235 | raise ValueError(f"Unsupported TAKProtoVer: {protover}") 236 | 237 | output_ba = header_ba + proto_ba 238 | return output_ba 239 | -------------------------------------------------------------------------------- /takproto/proto/.gitignore: -------------------------------------------------------------------------------- 1 | ### Linux ### 2 | 3 | *~ 4 | 5 | # temporary files which can be created if a process still has a handle open of a deleted file 6 | 7 | .fuse_hidden* 8 | 9 | # KDE directory preferences 10 | 11 | .directory 12 | 13 | # Linux trash folder which might appear on any partition or disk 14 | 15 | .Trash-* 16 | 17 | # .nfs files are created when an open file is removed but is still being accessed 18 | 19 | .nfs* 20 | 21 | ### macOS ### 22 | 23 | # General 24 | 25 | .DS_Store 26 | 27 | .AppleDouble 28 | 29 | .LSOverride 30 | 31 | # Icon must end with two \r 32 | 33 | Icon 34 | 35 | # Thumbnails 36 | 37 | ._* 38 | 39 | # Files that might appear in the root of a volume 40 | 41 | .DocumentRevisions-V100 42 | 43 | .fseventsd 44 | 45 | .Spotlight-V100 46 | 47 | .TemporaryItems 48 | 49 | .Trashes 50 | 51 | .VolumeIcon.icns 52 | 53 | .com.apple.timemachine.donotpresent 54 | 55 | # Directories potentially created on remote AFP share 56 | 57 | .AppleDB 58 | 59 | .AppleDesktop 60 | 61 | Network Trash Folder 62 | 63 | Temporary Items 64 | 65 | .apdisk 66 | 67 | ### Python ### 68 | 69 | # Byte-compiled / optimized / DLL files 70 | 71 | __pycache__/ 72 | 73 | *.py[cod] 74 | 75 | *$py.class 76 | 77 | # C extensions 78 | 79 | *.so 80 | 81 | # Distribution / packaging 82 | 83 | .Python 84 | 85 | build/ 86 | 87 | develop-eggs/ 88 | 89 | dist/ 90 | 91 | downloads/ 92 | 93 | eggs/ 94 | 95 | .eggs/ 96 | 97 | lib/ 98 | 99 | lib64/ 100 | 101 | parts/ 102 | 103 | sdist/ 104 | 105 | var/ 106 | 107 | wheels/ 108 | 109 | pip-wheel-metadata/ 110 | 111 | share/python-wheels/ 112 | 113 | *.egg-info/ 114 | 115 | .installed.cfg 116 | 117 | *.egg 118 | 119 | MANIFEST 120 | 121 | # PyInstaller 122 | 123 | # Usually these files are written by a python script from a template 124 | 125 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 126 | 127 | *.manifest 128 | 129 | *.spec 130 | 131 | # Installer logs 132 | 133 | pip-log.txt 134 | 135 | pip-delete-this-directory.txt 136 | 137 | # Unit test / coverage reports 138 | 139 | htmlcov/ 140 | 141 | .tox/ 142 | 143 | .nox/ 144 | 145 | .coverage 146 | 147 | .coverage.* 148 | 149 | .cache 150 | 151 | nosetests.xml 152 | 153 | coverage.xml 154 | 155 | *.cover 156 | 157 | *.py,cover 158 | 159 | .hypothesis/ 160 | 161 | .pytest_cache/ 162 | 163 | pytestdebug.log 164 | 165 | # Translations 166 | 167 | *.mo 168 | 169 | *.pot 170 | 171 | # Django stuff: 172 | 173 | *.log 174 | 175 | local_settings.py 176 | 177 | db.sqlite3 178 | 179 | db.sqlite3-journal 180 | 181 | # Flask stuff: 182 | 183 | instance/ 184 | 185 | .webassets-cache 186 | 187 | # Scrapy stuff: 188 | 189 | .scrapy 190 | 191 | # Sphinx documentation 192 | 193 | docs/_build/ 194 | 195 | doc/_build/ 196 | 197 | # PyBuilder 198 | 199 | target/ 200 | 201 | # Jupyter Notebook 202 | 203 | .ipynb_checkpoints 204 | 205 | # IPython 206 | 207 | profile_default/ 208 | 209 | ipython_config.py 210 | 211 | # pyenv 212 | 213 | .python-version 214 | 215 | # pipenv 216 | 217 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 218 | 219 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 220 | 221 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 222 | 223 | # install all needed dependencies. 224 | 225 | #Pipfile.lock 226 | 227 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow 228 | 229 | __pypackages__/ 230 | 231 | # Celery stuff 232 | 233 | celerybeat-schedule 234 | 235 | celerybeat.pid 236 | 237 | # SageMath parsed files 238 | 239 | *.sage.py 240 | 241 | # Environments 242 | 243 | .env 244 | 245 | .venv 246 | 247 | env/ 248 | 249 | venv/ 250 | 251 | ENV/ 252 | 253 | env.bak/ 254 | 255 | venv.bak/ 256 | 257 | pythonenv* 258 | 259 | # Spyder project settings 260 | 261 | .spyderproject 262 | 263 | .spyproject 264 | 265 | # Rope project settings 266 | 267 | .ropeproject 268 | 269 | # mkdocs documentation 270 | 271 | /site 272 | 273 | # mypy 274 | 275 | .mypy_cache/ 276 | 277 | .dmypy.json 278 | 279 | dmypy.json 280 | 281 | # Pyre type checker 282 | 283 | .pyre/ 284 | 285 | # pytype static type analyzer 286 | 287 | .pytype/ 288 | 289 | # profiling data 290 | 291 | .prof 292 | 293 | ### Windows ### 294 | 295 | # Windows thumbnail cache files 296 | 297 | Thumbs.db 298 | 299 | Thumbs.db:encryptable 300 | 301 | ehthumbs.db 302 | 303 | ehthumbs_vista.db 304 | 305 | # Dump file 306 | 307 | *.stackdump 308 | 309 | # Folder config file 310 | 311 | [Dd]esktop.ini 312 | 313 | # Recycle Bin used on file shares 314 | 315 | $RECYCLE.BIN/ 316 | 317 | # Windows Installer files 318 | 319 | *.cab 320 | 321 | *.msi 322 | 323 | *.msix 324 | 325 | *.msm 326 | 327 | *.msp 328 | 329 | # Windows shortcuts 330 | 331 | *.lnk 332 | -------------------------------------------------------------------------------- /takproto/proto/__init__.py: -------------------------------------------------------------------------------- 1 | from .takmessage_pb2 import TakMessage 2 | -------------------------------------------------------------------------------- /takproto/proto/contact_pb2.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Generated by the protocol buffer compiler. DO NOT EDIT! 3 | # source: contact.proto 4 | """Generated protocol buffer code.""" 5 | from google.protobuf.internal import builder as _builder 6 | from google.protobuf import descriptor as _descriptor 7 | from google.protobuf import descriptor_pool as _descriptor_pool 8 | from google.protobuf import symbol_database as _symbol_database 9 | 10 | # @@protoc_insertion_point(imports) 11 | 12 | _sym_db = _symbol_database.Default() 13 | 14 | 15 | DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile( 16 | b'\n\rcontact.proto\x12\x1f\x61takmap.commoncommo.protobuf.v1"-\n\x07\x43ontact\x12\x10\n\x08\x65ndpoint\x18\x01 \x01(\t\x12\x10\n\x08\x63\x61llsign\x18\x02 \x01(\tB\x02H\x03\x62\x06proto3' 17 | ) 18 | 19 | _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, globals()) 20 | _builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, "contact_pb2", globals()) 21 | if _descriptor._USE_C_DESCRIPTORS == False: 22 | DESCRIPTOR._options = None 23 | DESCRIPTOR._serialized_options = b"H\003" 24 | _CONTACT._serialized_start = 50 25 | _CONTACT._serialized_end = 95 26 | # @@protoc_insertion_point(module_scope) 27 | -------------------------------------------------------------------------------- /takproto/proto/cotevent_pb2.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Generated by the protocol buffer compiler. DO NOT EDIT! 3 | # source: cotevent.proto 4 | """Generated protocol buffer code.""" 5 | from google.protobuf.internal import builder as _builder 6 | from google.protobuf import descriptor as _descriptor 7 | from google.protobuf import descriptor_pool as _descriptor_pool 8 | from google.protobuf import symbol_database as _symbol_database 9 | 10 | # @@protoc_insertion_point(imports) 11 | 12 | _sym_db = _symbol_database.Default() 13 | 14 | 15 | from . import detail_pb2 as detail__pb2 16 | 17 | 18 | DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile( 19 | b"\n\x0e\x63otevent.proto\x12\x1f\x61takmap.commoncommo.protobuf.v1\x1a\x0c\x64\x65tail.proto\"\x8d\x02\n\x08\x43otEvent\x12\x0c\n\x04type\x18\x01 \x01(\t\x12\x0e\n\x06\x61\x63\x63\x65ss\x18\x02 \x01(\t\x12\x0b\n\x03qos\x18\x03 \x01(\t\x12\x0c\n\x04opex\x18\x04 \x01(\t\x12\x0b\n\x03uid\x18\x05 \x01(\t\x12\x10\n\x08sendTime\x18\x06 \x01(\x04\x12\x11\n\tstartTime\x18\x07 \x01(\x04\x12\x11\n\tstaleTime\x18\x08 \x01(\x04\x12\x0b\n\x03how\x18\t \x01(\t\x12\x0b\n\x03lat\x18\n \x01(\x01\x12\x0b\n\x03lon\x18\x0b \x01(\x01\x12\x0b\n\x03hae\x18\x0c \x01(\x01\x12\n\n\x02\x63\x65\x18\r \x01(\x01\x12\n\n\x02le\x18\x0e \x01(\x01\x12\x37\n\x06\x64\x65tail\x18\x0f \x01(\x0b\x32'.atakmap.commoncommo.protobuf.v1.DetailB\x02H\x03\x62\x06proto3" 20 | ) 21 | 22 | _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, globals()) 23 | _builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, "cotevent_pb2", globals()) 24 | if _descriptor._USE_C_DESCRIPTORS == False: 25 | DESCRIPTOR._options = None 26 | DESCRIPTOR._serialized_options = b"H\003" 27 | _COTEVENT._serialized_start = 66 28 | _COTEVENT._serialized_end = 335 29 | # @@protoc_insertion_point(module_scope) 30 | -------------------------------------------------------------------------------- /takproto/proto/detail_pb2.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Generated by the protocol buffer compiler. DO NOT EDIT! 3 | # source: detail.proto 4 | """Generated protocol buffer code.""" 5 | from google.protobuf.internal import builder as _builder 6 | from google.protobuf import descriptor as _descriptor 7 | from google.protobuf import descriptor_pool as _descriptor_pool 8 | from google.protobuf import symbol_database as _symbol_database 9 | 10 | # @@protoc_insertion_point(imports) 11 | 12 | _sym_db = _symbol_database.Default() 13 | 14 | 15 | from . import contact_pb2 as contact__pb2 16 | from . import group_pb2 as group__pb2 17 | from . import precisionlocation_pb2 as precisionlocation__pb2 18 | from . import status_pb2 as status__pb2 19 | from . import takv_pb2 as takv__pb2 20 | from . import track_pb2 as track__pb2 21 | 22 | 23 | DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile( 24 | b"\n\x0c\x64\x65tail.proto\x12\x1f\x61takmap.commoncommo.protobuf.v1\x1a\rcontact.proto\x1a\x0bgroup.proto\x1a\x17precisionlocation.proto\x1a\x0cstatus.proto\x1a\ntakv.proto\x1a\x0btrack.proto\"\x81\x03\n\x06\x44\x65tail\x12\x11\n\txmlDetail\x18\x01 \x01(\t\x12\x39\n\x07\x63ontact\x18\x02 \x01(\x0b\x32(.atakmap.commoncommo.protobuf.v1.Contact\x12\x35\n\x05group\x18\x03 \x01(\x0b\x32&.atakmap.commoncommo.protobuf.v1.Group\x12M\n\x11precisionLocation\x18\x04 \x01(\x0b\x32\x32.atakmap.commoncommo.protobuf.v1.PrecisionLocation\x12\x37\n\x06status\x18\x05 \x01(\x0b\x32'.atakmap.commoncommo.protobuf.v1.Status\x12\x33\n\x04takv\x18\x06 \x01(\x0b\x32%.atakmap.commoncommo.protobuf.v1.Takv\x12\x35\n\x05track\x18\x07 \x01(\x0b\x32&.atakmap.commoncommo.protobuf.v1.TrackB\x02H\x03\x62\x06proto3" 25 | ) 26 | 27 | _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, globals()) 28 | _builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, "detail_pb2", globals()) 29 | if _descriptor._USE_C_DESCRIPTORS == False: 30 | DESCRIPTOR._options = None 31 | DESCRIPTOR._serialized_options = b"H\003" 32 | _DETAIL._serialized_start = 142 33 | _DETAIL._serialized_end = 527 34 | # @@protoc_insertion_point(module_scope) 35 | -------------------------------------------------------------------------------- /takproto/proto/group_pb2.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Generated by the protocol buffer compiler. DO NOT EDIT! 3 | # source: group.proto 4 | """Generated protocol buffer code.""" 5 | from google.protobuf.internal import builder as _builder 6 | from google.protobuf import descriptor as _descriptor 7 | from google.protobuf import descriptor_pool as _descriptor_pool 8 | from google.protobuf import symbol_database as _symbol_database 9 | 10 | # @@protoc_insertion_point(imports) 11 | 12 | _sym_db = _symbol_database.Default() 13 | 14 | 15 | DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile( 16 | b'\n\x0bgroup.proto\x12\x1f\x61takmap.commoncommo.protobuf.v1"#\n\x05Group\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x0c\n\x04role\x18\x02 \x01(\tB\x02H\x03\x62\x06proto3' 17 | ) 18 | 19 | _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, globals()) 20 | _builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, "group_pb2", globals()) 21 | if _descriptor._USE_C_DESCRIPTORS == False: 22 | DESCRIPTOR._options = None 23 | DESCRIPTOR._serialized_options = b"H\003" 24 | _GROUP._serialized_start = 48 25 | _GROUP._serialized_end = 83 26 | # @@protoc_insertion_point(module_scope) 27 | -------------------------------------------------------------------------------- /takproto/proto/precisionlocation_pb2.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Generated by the protocol buffer compiler. DO NOT EDIT! 3 | # source: precisionlocation.proto 4 | """Generated protocol buffer code.""" 5 | from google.protobuf.internal import builder as _builder 6 | from google.protobuf import descriptor as _descriptor 7 | from google.protobuf import descriptor_pool as _descriptor_pool 8 | from google.protobuf import symbol_database as _symbol_database 9 | 10 | # @@protoc_insertion_point(imports) 11 | 12 | _sym_db = _symbol_database.Default() 13 | 14 | 15 | DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile( 16 | b'\n\x17precisionlocation.proto\x12\x1f\x61takmap.commoncommo.protobuf.v1"8\n\x11PrecisionLocation\x12\x13\n\x0bgeopointsrc\x18\x01 \x01(\t\x12\x0e\n\x06\x61ltsrc\x18\x02 \x01(\tB\x02H\x03\x62\x06proto3' 17 | ) 18 | 19 | _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, globals()) 20 | _builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, "precisionlocation_pb2", globals()) 21 | if _descriptor._USE_C_DESCRIPTORS == False: 22 | DESCRIPTOR._options = None 23 | DESCRIPTOR._serialized_options = b"H\003" 24 | _PRECISIONLOCATION._serialized_start = 60 25 | _PRECISIONLOCATION._serialized_end = 116 26 | # @@protoc_insertion_point(module_scope) 27 | -------------------------------------------------------------------------------- /takproto/proto/status_pb2.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Generated by the protocol buffer compiler. DO NOT EDIT! 3 | # source: status.proto 4 | """Generated protocol buffer code.""" 5 | from google.protobuf.internal import builder as _builder 6 | from google.protobuf import descriptor as _descriptor 7 | from google.protobuf import descriptor_pool as _descriptor_pool 8 | from google.protobuf import symbol_database as _symbol_database 9 | 10 | # @@protoc_insertion_point(imports) 11 | 12 | _sym_db = _symbol_database.Default() 13 | 14 | 15 | DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile( 16 | b'\n\x0cstatus.proto\x12\x1f\x61takmap.commoncommo.protobuf.v1"\x19\n\x06Status\x12\x0f\n\x07\x62\x61ttery\x18\x01 \x01(\rB\x02H\x03\x62\x06proto3' 17 | ) 18 | 19 | _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, globals()) 20 | _builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, "status_pb2", globals()) 21 | if _descriptor._USE_C_DESCRIPTORS == False: 22 | DESCRIPTOR._options = None 23 | DESCRIPTOR._serialized_options = b"H\003" 24 | _STATUS._serialized_start = 49 25 | _STATUS._serialized_end = 74 26 | # @@protoc_insertion_point(module_scope) 27 | -------------------------------------------------------------------------------- /takproto/proto/takcontrol_pb2.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Generated by the protocol buffer compiler. DO NOT EDIT! 3 | # source: takcontrol.proto 4 | """Generated protocol buffer code.""" 5 | from google.protobuf.internal import builder as _builder 6 | from google.protobuf import descriptor as _descriptor 7 | from google.protobuf import descriptor_pool as _descriptor_pool 8 | from google.protobuf import symbol_database as _symbol_database 9 | 10 | # @@protoc_insertion_point(imports) 11 | 12 | _sym_db = _symbol_database.Default() 13 | 14 | 15 | DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile( 16 | b'\n\x10takcontrol.proto\x12\x1f\x61takmap.commoncommo.protobuf.v1"R\n\nTakControl\x12\x17\n\x0fminProtoVersion\x18\x01 \x01(\r\x12\x17\n\x0fmaxProtoVersion\x18\x02 \x01(\r\x12\x12\n\ncontactUid\x18\x03 \x01(\tB\x02H\x03\x62\x06proto3' 17 | ) 18 | 19 | _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, globals()) 20 | _builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, "takcontrol_pb2", globals()) 21 | if _descriptor._USE_C_DESCRIPTORS == False: 22 | DESCRIPTOR._options = None 23 | DESCRIPTOR._serialized_options = b"H\003" 24 | _TAKCONTROL._serialized_start = 53 25 | _TAKCONTROL._serialized_end = 135 26 | # @@protoc_insertion_point(module_scope) 27 | -------------------------------------------------------------------------------- /takproto/proto/takmessage_pb2.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Generated by the protocol buffer compiler. DO NOT EDIT! 3 | # source: takmessage.proto 4 | """Generated protocol buffer code.""" 5 | from google.protobuf.internal import builder as _builder 6 | from google.protobuf import descriptor as _descriptor 7 | from google.protobuf import descriptor_pool as _descriptor_pool 8 | from google.protobuf import symbol_database as _symbol_database 9 | 10 | # @@protoc_insertion_point(imports) 11 | 12 | _sym_db = _symbol_database.Default() 13 | 14 | 15 | from . import cotevent_pb2 as cotevent__pb2 16 | from . import takcontrol_pb2 as takcontrol__pb2 17 | 18 | 19 | DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile( 20 | b'\n\x10takmessage.proto\x12\x1f\x61takmap.commoncommo.protobuf.v1\x1a\x0e\x63otevent.proto\x1a\x10takcontrol.proto"\x8a\x01\n\nTakMessage\x12?\n\ntakControl\x18\x01 \x01(\x0b\x32+.atakmap.commoncommo.protobuf.v1.TakControl\x12;\n\x08\x63otEvent\x18\x02 \x01(\x0b\x32).atakmap.commoncommo.protobuf.v1.CotEventB\x02H\x03\x62\x06proto3' 21 | ) 22 | 23 | _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, globals()) 24 | _builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, "takmessage_pb2", globals()) 25 | if _descriptor._USE_C_DESCRIPTORS == False: 26 | DESCRIPTOR._options = None 27 | DESCRIPTOR._serialized_options = b"H\003" 28 | _TAKMESSAGE._serialized_start = 88 29 | _TAKMESSAGE._serialized_end = 226 30 | # @@protoc_insertion_point(module_scope) 31 | -------------------------------------------------------------------------------- /takproto/proto/takv_pb2.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Generated by the protocol buffer compiler. DO NOT EDIT! 3 | # source: takv.proto 4 | """Generated protocol buffer code.""" 5 | from google.protobuf.internal import builder as _builder 6 | from google.protobuf import descriptor as _descriptor 7 | from google.protobuf import descriptor_pool as _descriptor_pool 8 | from google.protobuf import symbol_database as _symbol_database 9 | 10 | # @@protoc_insertion_point(imports) 11 | 12 | _sym_db = _symbol_database.Default() 13 | 14 | 15 | DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile( 16 | b'\n\ntakv.proto\x12\x1f\x61takmap.commoncommo.protobuf.v1"E\n\x04Takv\x12\x0e\n\x06\x64\x65vice\x18\x01 \x01(\t\x12\x10\n\x08platform\x18\x02 \x01(\t\x12\n\n\x02os\x18\x03 \x01(\t\x12\x0f\n\x07version\x18\x04 \x01(\tB\x02H\x03\x62\x06proto3' 17 | ) 18 | 19 | _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, globals()) 20 | _builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, "takv_pb2", globals()) 21 | if _descriptor._USE_C_DESCRIPTORS == False: 22 | DESCRIPTOR._options = None 23 | DESCRIPTOR._serialized_options = b"H\003" 24 | _TAKV._serialized_start = 47 25 | _TAKV._serialized_end = 116 26 | # @@protoc_insertion_point(module_scope) 27 | -------------------------------------------------------------------------------- /takproto/proto/track_pb2.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Generated by the protocol buffer compiler. DO NOT EDIT! 3 | # source: track.proto 4 | """Generated protocol buffer code.""" 5 | from google.protobuf.internal import builder as _builder 6 | from google.protobuf import descriptor as _descriptor 7 | from google.protobuf import descriptor_pool as _descriptor_pool 8 | from google.protobuf import symbol_database as _symbol_database 9 | 10 | # @@protoc_insertion_point(imports) 11 | 12 | _sym_db = _symbol_database.Default() 13 | 14 | 15 | DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile( 16 | b'\n\x0btrack.proto\x12\x1f\x61takmap.commoncommo.protobuf.v1"&\n\x05Track\x12\r\n\x05speed\x18\x01 \x01(\x01\x12\x0e\n\x06\x63ourse\x18\x02 \x01(\x01\x42\x02H\x03\x62\x06proto3' 17 | ) 18 | 19 | _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, globals()) 20 | _builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, "track_pb2", globals()) 21 | if _descriptor._USE_C_DESCRIPTORS == False: 22 | DESCRIPTOR._options = None 23 | DESCRIPTOR._serialized_options = b"H\003" 24 | _TRACK._serialized_start = 48 25 | _TRACK._serialized_end = 86 26 | # @@protoc_insertion_point(module_scope) 27 | -------------------------------------------------------------------------------- /tests/test_functions.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # 4 | # Copyright 2023 Sensors & Signals LLC 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | # Author:: Greg Albrecht 19 | # Copyright:: Copyright 2023 Sensors & Signals LLC 20 | # License:: Apache License, Version 2.0 21 | # 22 | 23 | """TAKProto Module Tests.""" 24 | 25 | from datetime import datetime, timezone 26 | import unittest 27 | 28 | import takproto 29 | 30 | 31 | class TestFunctions(unittest.TestCase): 32 | 33 | def test_format_timestamp1(self): 34 | """Test formatting timestamp to and from Protobuf format 1.""" 35 | t_time = "2020-02-08T18:10:44.000000Z" 36 | t_ts = 1581185444000 37 | ts = takproto.format_time(t_time) 38 | self.assertEqual(ts, t_ts) 39 | 40 | def test_format_timestamp2(self): 41 | """Test formatting timestamp to and from Protobuf format 2.""" 42 | t_time = "2020-02-08T18:10:44.000000Z" 43 | t_ts = 1581185444000 44 | t_ts2 = t_ts / 1000 45 | time2 = datetime.fromtimestamp(t_ts2, timezone.utc).strftime( 46 | "%Y-%m-%dT%H:%M:%S.%fZ" 47 | ) 48 | self.assertEqual(time2, t_time) 49 | 50 | def test_format_timestamp_without_subseconds1(self): 51 | """Test formatting timestamp to and from Protobuf format 1.""" 52 | t_time = "2020-02-08T18:10:44Z" 53 | t_ts = 1581185444000 54 | ts = takproto.format_time(t_time) 55 | self.assertEqual(ts, t_ts) 56 | 57 | def test_format_timestamp_without_subseconds2(self): 58 | """Test formatting timestamp to and from Protobuf format 2.""" 59 | t_time = "2020-02-08T18:10:44Z" 60 | t_ts = 1581185444000 61 | t_ts2 = t_ts / 1000 62 | time2 = datetime.fromtimestamp(t_ts2, timezone.utc).strftime( 63 | "%Y-%m-%dT%H:%M:%SZ" 64 | ) 65 | self.assertEqual(time2, t_time) 66 | 67 | def test_xml2proto_default(self): 68 | """Test encoding XML string as Protobuf bytearray.""" 69 | t_xml = """ 70 | <__group name='Yellow' role='HQ'/> 71 | """ 72 | 73 | t_ba = bytearray( 74 | b'\xbf\x01\xbf\x12\xb0\x02\n\x0ba-f-G-E-V-C*$aa0b0312-b5cd-4c2c-bbbc-9c4c702162610\xa0\xd1\xfc\xaf\x82.8\xa0\xd1\xfc\xaf\x82.@\x98\xa4\xfe\xaf\x82.J\x03h-eQ3\x98T\xa7b\xfdE@Y}*~\xbe\xf3\x84P\xc0aW\\\x1c\x95\x9b\xc4:@i\x00\x00\x00\xe0\xcf\x12cAq\x00\x00\x00\xe0\xcf\x12cAz\xb3\x01\n/\x12$\n\x15192.168.1.10:4242:tcp\x12\x0bEliopoli HQ\x1a\x0c\n\x06Yellow\x12\x02HQ*\x02\x08d2F\n\x11LENOVO 20QV0007US\x12\nWinTAK-CIV\x1a\x19Microsoft Windows 10 Home"\n1.10.0.137:\x00' 75 | ) 76 | 77 | buf = takproto.xml2proto(t_xml) 78 | 79 | print("Generated: ") 80 | print(takproto.parse_proto(bytes(buf))) 81 | print(buf) 82 | 83 | print("Expected: ") 84 | print(takproto.parse_proto(bytes(t_ba))) 85 | print(t_ba) 86 | 87 | self.assertEqual(bytes(buf), bytes(t_ba)) 88 | 89 | def test_xml2proto_mesh(self): 90 | """Test encoding CoT XML string as TAK Protocol Version 1 Mesh Protobuf.""" 91 | t_xml = """ 92 | <__group name='Yellow' role='HQ'/> 93 | """ 94 | 95 | t_ba = bytearray( 96 | b'\xbf\x01\xbf\x12\xb0\x02\n\x0ba-f-G-E-V-C*$aa0b0312-b5cd-4c2c-bbbc-9c4c702162610\xa0\xd1\xfc\xaf\x82.8\xa0\xd1\xfc\xaf\x82.@\x98\xa4\xfe\xaf\x82.J\x03h-eQ3\x98T\xa7b\xfdE@Y}*~\xbe\xf3\x84P\xc0aW\\\x1c\x95\x9b\xc4:@i\x00\x00\x00\xe0\xcf\x12cAq\x00\x00\x00\xe0\xcf\x12cAz\xb3\x01\n/\x12$\n\x15192.168.1.10:4242:tcp\x12\x0bEliopoli HQ\x1a\x0c\n\x06Yellow\x12\x02HQ*\x02\x08d2F\n\x11LENOVO 20QV0007US\x12\nWinTAK-CIV\x1a\x19Microsoft Windows 10 Home"\n1.10.0.137:\x00' 97 | ) 98 | 99 | buf = takproto.xml2proto(t_xml, takproto.TAKProtoVer.MESH) 100 | 101 | self.assertEqual(bytes(buf), bytes(t_ba)) 102 | 103 | def test_parse_proto_mesh(self): 104 | """Test deserializing TAK Protocol Version 1 Mesh bytes to TakMessage Protobuf.""" 105 | t_ba = bytearray( 106 | b'\xbf\x01\xbf\x12\xb0\x02\n\x0ba-f-G-E-V-C*$aa0b0312-b5cd-4c2c-bbbc-9c4c702162610\xa0\xd1\xfc\xaf\x82.8\xa0\xd1\xfc\xaf\x82.@\x98\xa4\xfe\xaf\x82.J\x03h-eQ3\x98T\xa7b\xfdE@Y}*~\xbe\xf3\x84P\xc0aW\\\x1c\x95\x9b\xc4:@i\x00\x00\x00\xe0\xcf\x12cAq\x00\x00\x00\xe0\xcf\x12cAz\xb3\x01\n/\x12$\n\x15192.168.1.10:4242:tcp\x12\x0bEliopoli HQ\x1a\x0c\n\x06Yellow\x12\x02HQ*\x02\x08d2F\n\x11LENOVO 20QV0007US\x12\nWinTAK-CIV\x1a\x19Microsoft Windows 10 Home"\n1.10.0.137:\x00' 107 | ) 108 | 109 | parsed = takproto.parse_proto(t_ba) 110 | cot_event = parsed.cotEvent 111 | 112 | self.assertEqual(cot_event.type, "a-f-G-E-V-C") 113 | self.assertEqual(cot_event.uid, "aa0b0312-b5cd-4c2c-bbbc-9c4c70216261") 114 | self.assertEqual( 115 | cot_event.detail.xmlDetail, 116 | '', 117 | ) 118 | self.assertEqual(cot_event.detail.contact.callsign, "Eliopoli HQ") 119 | 120 | def test_xml2proto_stream(self): 121 | """Test encoding CoT XML string as TAK Protocol Version 1 Stream Protobuf.""" 122 | t_xml = """ 123 | <__group name='Yellow' role='HQ'/> 124 | """ 125 | 126 | t_ba = bytearray( 127 | b'\xbf\xb3\x02\x12\xb0\x02\n\x0ba-f-G-E-V-C*$aa0b0312-b5cd-4c2c-bbbc-9c4c702162610\xa0\xd1\xfc\xaf\x82.8\xa0\xd1\xfc\xaf\x82.@\x98\xa4\xfe\xaf\x82.J\x03h-eQ3\x98T\xa7b\xfdE@Y}*~\xbe\xf3\x84P\xc0aW\\\x1c\x95\x9b\xc4:@i\x00\x00\x00\xe0\xcf\x12cAq\x00\x00\x00\xe0\xcf\x12cAz\xb3\x01\n/\x12$\n\x15192.168.1.10:4242:tcp\x12\x0bEliopoli HQ\x1a\x0c\n\x06Yellow\x12\x02HQ*\x02\x08d2F\n\x11LENOVO 20QV0007US\x12\nWinTAK-CIV\x1a\x19Microsoft Windows 10 Home"\n1.10.0.137:\x00' 128 | ) 129 | 130 | buf = takproto.xml2proto(t_xml, takproto.TAKProtoVer.STREAM) 131 | 132 | self.assertEqual(bytes(buf), bytes(t_ba)) 133 | 134 | def test_parse_proto_stream(self): 135 | """Test deserializing TAK Protocol Version 1 Stream bytes to TakMessage Protobuf.""" 136 | t_ba = bytearray( 137 | b'\xbf\xb3\x02\x12\xb0\x02\n\x0ba-f-G-E-V-C*$aa0b0312-b5cd-4c2c-bbbc-9c4c702162610\xa0\xd1\xfc\xaf\x82.8\xa0\xd1\xfc\xaf\x82.@\x98\xa4\xfe\xaf\x82.J\x03h-eQ3\x98T\xa7b\xfdE@Y}*~\xbe\xf3\x84P\xc0aW\\\x1c\x95\x9b\xc4:@i\x00\x00\x00\xe0\xcf\x12cAq\x00\x00\x00\xe0\xcf\x12cAz\xb3\x01\n/\x12$\n\x15192.168.1.10:4242:tcp\x12\x0bEliopoli HQ\x1a\x0c\n\x06Yellow\x12\x02HQ*\x02\x08d2F\n\x11LENOVO 20QV0007US\x12\nWinTAK-CIV\x1a\x19Microsoft Windows 10 Home"\n1.10.0.137:\x00' 138 | ) 139 | 140 | parsed = takproto.parse_proto(t_ba) 141 | cot_event = parsed.cotEvent 142 | 143 | self.assertEqual(cot_event.type, "a-f-G-E-V-C") 144 | self.assertEqual(cot_event.uid, "aa0b0312-b5cd-4c2c-bbbc-9c4c70216261") 145 | self.assertEqual( 146 | cot_event.detail.xmlDetail, 147 | '', 148 | ) 149 | self.assertEqual(cot_event.detail.contact.callsign, "Eliopoli HQ") 150 | 151 | def test_parse_proto_xml(self): 152 | """Test deserializing CoT XML bytes to TakMessage Protobuf.""" 153 | t_xml = """ 154 | <__group name='Yellow' role='HQ'/> 155 | """ 156 | 157 | t_ba = bytearray(t_xml, encoding="utf-8") 158 | 159 | parsed = takproto.parse_proto(t_ba) 160 | print(parsed) 161 | print(type(parsed)) 162 | cot_event = parsed.cotEvent 163 | 164 | self.assertEqual(cot_event.type, "a-f-G-E-V-C") 165 | self.assertEqual(cot_event.uid, "aa0b0312-b5cd-4c2c-bbbc-9c4c70216261") 166 | self.assertEqual( 167 | cot_event.detail.xmlDetail, 168 | '', 169 | ) 170 | self.assertEqual(cot_event.detail.contact.callsign, "Eliopoli HQ") 171 | --------------------------------------------------------------------------------