Skip to main content

A Free Network Discovery Service

Project description

Cosmo Network Discovery API

Documentation for The OpenSource Cosmo Network Discovery API

This is the main implemtation written in python. For other implementations see Implemtations and for a description on the API and Protocol see API Docs

Installation

You can Install it with Pip and PyPi

python3 -m pip install cosmodiscovery

or with Pip and Github without PyPi

python3 -m pip install git+https://github.com/SamHDev/CosmoDiscovery.git

Usage

Import the libary

import cosmodiscovery as discovery

A Discovery Server

server = discovery.DiscoveryServer()
server.listen()

Yep! Thats it!

If you want a custom scheme or port you can do it like this:

server = discovery.DiscoveryServer(port=12892, scheme="_discovery._cosmo.home_device"))

Sending Custom Data with the discovery reply. cls is a DiscoveryRequestMessage Object

@server.discovery_callback
def on_msg(cls):
cls.reply(data={})

A Discovery Client

Create a DiscoveryClient Object like this

server = discovery.DiscoveryServer()

Or with Paramaters like so

client = discovery.DiscoveryClient(port=12892, scheme="_discovery._cosmo.home_device"))

One Created you can run this

results = client.discovery()

This function returns a list of DiscoveryResult objects. If the list is empty, then no devices were found.

If you wish to add arguments such as custom data to send within the Discovery Request or shorten the discovey reply wait time you can do so like this: results = discovery(timeout=1, data={}) Again! Its that simple

Further Documentation

For Further Documentation see docs.md


Written for CosmoHome by SamHDev. Licensed under GNU General Public License v3.0 as per License File

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cosmodiscovery-0.1.0.tar.gz (3.5 kB view hashes)

Uploaded Source

Built Distribution

cosmodiscovery-0.1.0-py3-none-any.whl (17.5 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page