/ docs / source / examples.rst
examples.rst
  1  .. _examples-main:
  2  
  3  *************
  4  Code Examples
  5  *************
  6  
  7  A number of examples are included in the source distribution of Reticulum.
  8  You can use these examples to learn how to write your own programs.
  9  
 10  .. _example-minimal:
 11  
 12  Minimal
 13  =======
 14  
 15  The *Minimal* example demonstrates the bare-minimum setup required to connect to
 16  a Reticulum network from your program. In about five lines of code, you will
 17  have the Reticulum Network Stack initialised, and ready to pass traffic in your
 18  program.
 19  
 20  .. literalinclude:: ../../Examples/Minimal.py
 21  
 22  This example can also be found at `<https://github.com/markqvist/Reticulum/blob/master/Examples/Minimal.py>`_.
 23  
 24  .. _example-announce:
 25  
 26  Announce
 27  ========
 28  
 29  The *Announce* example builds upon the previous example by exploring how to
 30  announce a destination on the network, and how to let your program receive
 31  notifications about announces from relevant destinations.
 32  
 33  .. literalinclude:: ../../Examples/Announce.py
 34  
 35  This example can also be found at `<https://github.com/markqvist/Reticulum/blob/master/Examples/Announce.py>`_.
 36  
 37  .. _example-broadcast:
 38  
 39  Broadcast
 40  =========
 41  The *Broadcast* example explores how to transmit plaintext broadcast messages
 42  over the network.
 43  
 44  .. literalinclude:: ../../Examples/Broadcast.py
 45  
 46  This example can also be found at `<https://github.com/markqvist/Reticulum/blob/master/Examples/Broadcast.py>`_.
 47  
 48  .. _example-echo:
 49  
 50  Echo
 51  ====
 52  
 53  The *Echo* example demonstrates communication between two destinations using
 54  the Packet interface.
 55  
 56  .. literalinclude:: ../../Examples/Echo.py
 57  
 58  This example can also be found at `<https://github.com/markqvist/Reticulum/blob/master/Examples/Echo.py>`_.
 59  
 60  .. _example-link:
 61  
 62  Link
 63  ====
 64  
 65  The *Link* example explores establishing an encrypted link to a remote
 66  destination, and passing traffic back and forth over the link.
 67  
 68  .. literalinclude:: ../../Examples/Link.py
 69  
 70  This example can also be found at `<https://github.com/markqvist/Reticulum/blob/master/Examples/Link.py>`_.
 71  
 72  .. _example-identify:
 73  
 74  Identification
 75  ==============
 76  
 77  The *Identify* example explores identifying an intiator of a link, once
 78  the link has been established.
 79  
 80  .. literalinclude:: ../../Examples/Identify.py
 81  
 82  This example can also be found at `<https://github.com/markqvist/Reticulum/blob/master/Examples/Identify.py>`_.
 83  
 84  .. _example-request:
 85  
 86  Requests & Responses
 87  ====================
 88  
 89  The *Request* example explores sending requests and receiving responses.
 90  
 91  .. literalinclude:: ../../Examples/Request.py
 92  
 93  This example can also be found at `<https://github.com/markqvist/Reticulum/blob/master/Examples/Request.py>`_.
 94  
 95  .. _example-channel:
 96  
 97  Channel
 98  =======
 99  
100  The *Channel* example explores using a ``Channel`` to send structured
101  data between peers of a ``Link``.
102  
103  .. literalinclude:: ../../Examples/Channel.py
104  
105  This example can also be found at `<https://github.com/markqvist/Reticulum/blob/master/Examples/Channel.py>`_.
106  
107  Buffer
108  ======
109  
110  The *Buffer* example explores using buffered readers and writers to send
111  binary data between peers of a ``Link``.
112  
113  .. literalinclude:: ../../Examples/Buffer.py
114  
115  This example can also be found at `<https://github.com/markqvist/Reticulum/blob/master/Examples/Buffer.py>`_.
116  
117  .. _example-filetransfer:
118  
119  Filetransfer
120  ============
121  
122  The *Filetransfer* example implements a basic file-server program that
123  allow clients to connect and download files. The program uses the Resource
124  interface to efficiently pass files of any size over a Reticulum :ref:`Link<api-link>`.
125  
126  .. literalinclude:: ../../Examples/Filetransfer.py
127  
128  This example can also be found at `<https://github.com/markqvist/Reticulum/blob/master/Examples/Filetransfer.py>`_.
129  
130  .. _example-custominterface:
131  
132  Custom Interfaces
133  =================
134  
135  The *ExampleInterface* demonstrates creating custom interfaces for Reticulum.
136  Any number of custom interfaces can be loaded and utilised by Reticulum, and
137  will be fully on-par with natively included interfaces, including all supported
138  :ref:`interface modes<interfaces-modes>` and :ref:`common configuration options<interfaces-options>`.
139  
140  .. literalinclude:: ../../Examples/ExampleInterface.py
141  
142  This example can also be found at `<https://github.com/markqvist/Reticulum/blob/master/Examples/ExampleInterface.py>`_.