File transfer example

This commit is contained in:
Mark Qvist 2018-04-25 22:46:05 +02:00
parent 4d48a50f7e
commit 8aa2f8613a
3 changed files with 13 additions and 5 deletions

View File

@ -86,8 +86,10 @@ def client_connected(link):
# We pack a list of files for sending in a packet # We pack a list of files for sending in a packet
data = umsgpack.packb(list_files()) data = umsgpack.packb(list_files())
RNS.log(str(len(data)))
# Check the size of the packed data # Check the size of the packed data
if len(data) <= RNS.Resource.SDU: if len(data) <= RNS.Reticulum.LINK_MDU:
# If it fits in one packet, we will just # If it fits in one packet, we will just
# send it as a single packet over the link. # send it as a single packet over the link.
list_packet = RNS.Packet(link, data) list_packet = RNS.Packet(link, data)

View File

@ -39,7 +39,7 @@ class Packet:
# This is used to calculate allowable # This is used to calculate allowable
# payload sizes # payload sizes
HEADER_MAXSIZE = 23 HEADER_MAXSIZE = RNS.Reticulum.HEADER_MAXSIZE
# TODO: This should be calculated # TODO: This should be calculated
# more intelligently # more intelligently

View File

@ -1,6 +1,7 @@
from Interfaces import * from Interfaces import *
import ConfigParser import ConfigParser
from vendor.configobj import ConfigObj from vendor.configobj import ConfigObj
import RNS
import atexit import atexit
import struct import struct
import array import array
@ -12,6 +13,11 @@ import RNS
class Reticulum: class Reticulum:
MTU = 500 MTU = 500
HEADER_MAXSIZE = 23
PAD_AES_HMAC = 64
MDU = MTU - HEADER_MAXSIZE
LINK_MDU = MDU - PAD_AES_HMAC
router = None router = None
config = None config = None