Browse Source

Examples and basic README.md added

Stephen Downward 1 year ago
parent
commit
bd2f52b672
3 changed files with 67 additions and 0 deletions
  1. 24 0
      README.md
  2. 20 0
      examples/example_client.py
  3. 23 0
      examples/example_server.py

+ 24 - 0
README.md

@ -0,0 +1,24 @@
1
# AX26
2
3
This is meant to be a successor to the AX25 protocol. It has many advantages:
4
5
* Unlimited data sizes (Broken up into smaller packets seamlessly)
6
7
* Configurable packet sizes
8
9
* Built in compression (Level 9 gzip)
10
11
* IDs that are basically limitless (Up to the size of the packet)
12
13
* Error correction (MD5)
14
15
The library is very WIP and should not be used in production. Classes and functions are subject to change.
16
17
18
There is a client and a server class. The client is made to connect to the server, and the server will accept connections from as many clients as you want, spawning a new thread for each.
19
Please look at the example code for more information.
20
21
22
TODO:
23
24
- License

+ 20 - 0
examples/example_client.py

@ -0,0 +1,20 @@
1
import time
2
import kiss2
3
import ax26
4
5
k = kiss2.TCPKISS(host='localhost', port=8001)
6
k.start()
7
8
x = ax26.Client(k, "CLIENT_CALLSIGN-SSID")  # The client's SSID
9
x.connect("SERVER_CALLSIGN-SSID")  # The server's SSID
10
11
data_to_send = b'Hello server, this is client!'  # Notice that this is a byte array
12
start = time.time()
13
x.send_data(data_to_send)
14
print("SENT " + str(len(data_to_send)) + "BYTES IN " + str(time.time() - start) + " SECONDS")
15
while True:
16
	r = x.receive_data()  # Wait for data from server and then exit
17
	if r is not None:
18
		print(r)
19
		x.disconnect()
20
		break

+ 23 - 0
examples/example_server.py

@ -0,0 +1,23 @@
1
import kiss
2
3
import ax26
4
5
k = kiss.TCPKISS(host='localhost', port=8001)
6
k.start()
7
8
x = ax26.Server(k, "SERVER_CALLSIGN-SSID")  # The server's SSID
9
10
class handler:
11
	def __init__(self, client_call):
12
		print(b"New connection from " + client_call)
13
		self.their_callsign = client_call
14
15
	def on_recv(self, data):
16
		print (data)
17
		x.send_data(self.their_callsign, b"Data received. Here is a reply!")
18
19
	def on_disconnect(self):
20
		print(self.their_callsign + b" disconnected")
21
22
23
x.serve_forever(handler)