i50 Manual (5.51)
Page 58
© 2018 Datalink Systems, Inc.
www.datalinksystemsinc.com
13.3 File Transfer
The i50 allows file transfer over cellular/external wi-fi networks. If a file transfer is attempted when
these networks are not available
, it will return a “Wrong network” error.
File transfer packets contain a single <FileData> parameter, which contains several binary values.
These packets do not end with <ETX> characters, but instead contain a length field to indicate how
long the packet is. When sending these packets, the full data packet must be sent before any further
commands can be issued.
The <FileData> parameter contains the following binary fields; where all integer values are stored
least significant byte first:
Length (2 bytes)
Length of following fields
Command (1 byte) 1=Start File, 2=Send Data, 3=ACK, 4=Error
Reserved (1 byte) Ignore this value
Data
Variable length field
The Data field contains different fields depending on the Command value.
Command
Data
1
Length (3 bytes) LSB. Total length of file.
Name (null terminated string). Name of file.
2
Offset (3 bytes) LSB. Offset of this data block within file. Starts at 1.
Length (2 bytes) LSB. Length of this data block. 1024 maximum.
RawData. Raw file data.
3
ACK Offset (3 bytes) LSB. Position of highest received byte.
Optional (included if server has missed some part of the file):
NAK Offset (3 bytes) LSB. Start of missing data.
NAK Length (3 bytes) LSB. Length of missing data.
The following example is shown in hexadecimal notation, where each 2-character hexadecimal value
represents a byte sent or received.
The first line starts a file transfer, where the total length of the file is 3000 bytes, and the file name is
“Test.txt”. The response is an ACK with offset set to zero. The file is then sent one block at a time.
Multiple blocks can be sent without waiting for an ACK, which will improve performance at the risk of
having to retry more blocks if signal is weak. If the server fails to receive one of several blocks, it will
include NAK fields in the ACK response. These fields indicate what data needs to be resent.
TX: 46 1A 0E 00 01 00 B8 0B 00 54 65 73 74 2E 74 78 74 00
RX: 66 1A 05 00 03 01 00 00 00
TX: 46 1A 07 04 02 00 01 00 00 00 04 .....
TX: 46 1A 07 04 02 00 01 04 00 00 04 .....
RX: 66 1A 05 00 03 01 01 04 00
...