Reticulum/docs/source/examples.rst

142 lines
4.1 KiB
ReStructuredText
Raw Normal View History

2021-05-16 19:58:11 +00:00
.. _examples-main:
2021-09-25 21:22:33 +00:00
*************
Code Examples
*************
2021-05-16 19:58:11 +00:00
A number of examples are included in the source distribution of Reticulum.
You can use these examples to learn how to write your own programs.
2021-05-16 21:13:56 +00:00
.. _example-minimal:
2021-05-16 19:58:11 +00:00
Minimal
=======
The *Minimal* example demonstrates the bare-minimum setup required to connect to
a Reticulum network from your program. In about five lines of code, you will
have the Reticulum Network Stack initialised, and ready to pass traffic in your
program.
2021-05-17 09:32:00 +00:00
.. literalinclude:: ../../Examples/Minimal.py
This example can also be found at `<https://github.com/markqvist/Reticulum/blob/master/Examples/Minimal.py>`_.
2021-05-16 21:13:56 +00:00
.. _example-announce:
2021-05-16 19:58:11 +00:00
Announce
========
The *Announce* example builds upon the previous example by exploring how to
announce a destination on the network, and how to let your program receive
notifications about announces from relevant destinations.
2021-05-17 09:32:00 +00:00
.. literalinclude:: ../../Examples/Announce.py
This example can also be found at `<https://github.com/markqvist/Reticulum/blob/master/Examples/Announce.py>`_.
2021-05-16 21:13:56 +00:00
.. _example-broadcast:
2021-05-16 19:58:11 +00:00
Broadcast
=========
The *Broadcast* example explores how to transmit plaintext broadcast messages
over the network.
2021-05-17 09:32:00 +00:00
.. literalinclude:: ../../Examples/Broadcast.py
This example can also be found at `<https://github.com/markqvist/Reticulum/blob/master/Examples/Broadcast.py>`_.
2021-05-16 21:13:56 +00:00
.. _example-echo:
2021-05-16 19:58:11 +00:00
Echo
====
The *Echo* example demonstrates communication between two destinations using
the Packet interface.
2021-05-17 09:32:00 +00:00
.. literalinclude:: ../../Examples/Echo.py
This example can also be found at `<https://github.com/markqvist/Reticulum/blob/master/Examples/Echo.py>`_.
2021-05-16 19:58:11 +00:00
.. _example-link:
Link
====
The *Link* example explores establishing an encrypted link to a remote
destination, and passing traffic back and forth over the link.
2021-05-17 09:32:00 +00:00
.. literalinclude:: ../../Examples/Link.py
This example can also be found at `<https://github.com/markqvist/Reticulum/blob/master/Examples/Link.py>`_.
2021-08-19 12:11:22 +00:00
.. _example-identify:
Identification
==============
The *Identify* example explores identifying an intiator of a link, once
the link has been established.
.. literalinclude:: ../../Examples/Identify.py
This example can also be found at `<https://github.com/markqvist/Reticulum/blob/master/Examples/Identify.py>`_.
2021-08-20 21:29:06 +00:00
.. _example-request:
Requests & Responses
====================
The *Request* example explores sendig requests and receiving responses.
.. literalinclude:: ../../Examples/Request.py
This example can also be found at `<https://github.com/markqvist/Reticulum/blob/master/Examples/Request.py>`_.
2023-02-28 03:10:28 +00:00
.. _example-channel:
Channel
2023-03-02 11:47:55 +00:00
=======
2023-02-28 03:10:28 +00:00
The *Channel* example explores using a ``Channel`` to send structured
data between peers of a ``Link``.
.. literalinclude:: ../../Examples/Channel.py
This example can also be found at `<https://github.com/markqvist/Reticulum/blob/master/Examples/Channel.py>`_.
2023-03-02 23:21:32 +00:00
Buffer
======
The *Buffer* example explores using buffered readers and writers to send
binary data between peers of a ``Link``.
.. literalinclude:: ../../Examples/Buffer.py
This example can also be found at `<https://github.com/markqvist/Reticulum/blob/master/Examples/Buffer.py>`_.
2021-05-16 21:13:56 +00:00
.. _example-filetransfer:
2021-05-16 19:58:11 +00:00
Filetransfer
============
The *Filetransfer* example implements a basic file-server program that
allow clients to connect and download files. The program uses the Resource
2021-05-17 09:32:00 +00:00
interface to efficiently pass files of any size over a Reticulum :ref:`Link<api-link>`.
.. literalinclude:: ../../Examples/Filetransfer.py
This example can also be found at `<https://github.com/markqvist/Reticulum/blob/master/Examples/Filetransfer.py>`_.
.. _example-custominterface:
Custom Interfaces
=================
The *ExampleInterface* demonstrates creating custom interfaces for Reticulum.
Any number of custom interfaces can be loaded and utilised by Reticulum, and
will be fully on-par with natively included interfaces, including all supported
:ref:`interface modes<interfaces-modes>` and :ref:`common configuration options<interfaces-options>`.
.. literalinclude:: ../../Examples/ExampleInterface.py
This example can also be found at `<https://github.com/markqvist/Reticulum/blob/master/Examples/ExampleInterface.py>`_.