Changes

16,010 bytes removed ,  13:47, 14 July 2022
Line 45: Line 45:  
If camera is disconnected and later reconnected, a device will detect it by periodic camera ping packet. Once camera is detected, the device will reissue the reconfiguration procedure.
 
If camera is disconnected and later reconnected, a device will detect it by periodic camera ping packet. Once camera is detected, the device will reissue the reconfiguration procedure.
 
<br>
 
<br>
==Communication protocol==
  −
'''Close a session command (CMD ID 0x0000)'''<br>
  −
In case when a device connects to a server, but the server does not expect it to connect, the server will respond by sending a CLOSE command after which the connection will be terminated. This command is also used when the device connects to a server for a custom file sending and the server finishes to send all custom files to the device.
  −
{| class="wikitable"
  −
|+
  −
! rowspan="1" style="width: 600px; background: #0054A6; color: white;" |'''Command ID'''
  −
! rowspan="1" style="width: 600px; background: #0054A6; color: white;" |'''Data length'''
  −
|-
  −
| rowspan="1" style="text-align: center; style=" width: 150px; background: white; color: black;" |0x0000
  −
| rowspan="1" style="text-align: center; style=" width: 150px; background: white; color: black;" |0x0000
  −
|}
  −
<br>
  −
'''Start file transfer command (CMD ID 0x0001)'''<br>
  −
After device received file request command from the server (0x0008) device sends START command with file data (packet count).
  −
{| class="wikitable"
  −
|+
  −
! rowspan="1" style="width: 400px; background: #0054A6; color: white;" |'''Command ID'''
  −
! rowspan="1" style="width: 400px; background: #0054A6; color: white;" |'''Data length'''
  −
! rowspan="1" style="width: 400px; background: #0054A6; color: white;" |'''File Packets (4 bytes)'''
  −
! rowspan="1" style="width: 400px; background: #0054A6; color: white;" |'''Blank field (2 bytes)'''
  −
|-
  −
| rowspan="1" style="text-align: center; style=" width: 150px; background: white; color: black;" |0x0001
  −
| rowspan="1" style="text-align: center; style=" width: 150px; background: white; color: black;" |0x0006
  −
| rowspan="1" style="text-align: center; style=" width: 150px; background: white; color: black;" |0x12345678
  −
| rowspan="1" style="text-align: center; style=" width: 150px; background: white; color: black;" |0x0000 (always same value)
  −
|}
  −
<br>
  −
'''File request command (CMD ID 0x0008)'''<br>
  −
After the device is connected for a file upload, the server initiates file transfer by sending a FILE REQ command.
  −
{| class="wikitable"
  −
|+
  −
! rowspan="1" style="width: 400px; background: #0054A6; color: white;" |'''Command ID'''
  −
! rowspan="1" style="width: 400px; background: #0054A6; color: white;" |'''Data length'''
  −
! rowspan="1" style="width: 400px; background: #0054A6; color: white;" |'''File Identifier'''
  −
|-
  −
| rowspan="1" style="text-align: center; style=" width: 150px; background: white; color: black;" |0x0008
  −
| rowspan="1" style="text-align: center; style=" width: 150px; background: white; color: black;" |2 bytes
  −
| rowspan="1" style="text-align: center; style=" width: 150px; background: white; color: black;" |''See the table below''
  −
|}
  −
The device should answer with a START command described above indicating the size and CRC of the requested file.
  −
{| class="wikitable"
  −
|+
  −
! rowspan="1" style="width: 600px; background: #0054A6; color: white;" |'''File source, type'''
  −
! rowspan="1" style="width: 600px; background: #0054A6; color: white;" |'''Identifier (ASCII chars)'''
  −
|-
  −
| rowspan="1" style="text-align: center; style=" width: 150px; background: white; color: black;" |Photo from camera, rear
  −
| rowspan="1" style="text-align: center; style=" width: 150px; background: white; color: black;" |%photor
  −
|-
  −
| rowspan="1" style="text-align: center; style=" width: 150px; background: white; color: black;" |Photo from camera, front
  −
| rowspan="1" style="text-align: center; style=" width: 150px; background: white; color: black;" |%photof
  −
|-
  −
| rowspan="1" style="text-align: center; style=" width: 150px; background: white; color: black;" |Video from camera, rear
  −
| rowspan="1" style="text-align: center; style=" width: 150px; background: white; color: black;" |%videor
  −
|-
  −
| rowspan="1" style="text-align: center; style=" width: 150px; background: white; color: black;" |Video from camera, front
  −
| rowspan="1" style="text-align: center; style=" width: 150px; background: white; color: black;" |%videof
  −
|}
  −
<br>
  −
'''Resume file transfer command (CMD ID 0x0002)'''<br>
  −
In a response to the START command a RESUME command must be sent from server.
  −
{| class="wikitable"
  −
|+
  −
! rowspan="1" style="width: 400px; background: #0054A6; color: white;" |'''Command ID'''
  −
! rowspan="1" style="width: 400px; background: #0054A6; color: white;" |'''Data length'''
  −
! rowspan="1" style="width: 400px; background: #0054A6; color: white;" |'''Packet offset (4 bytes)'''
  −
|-
  −
| rowspan="1" style="text-align: center; style=" width: 150px; background: white; color: black;" |0x0002
  −
| rowspan="1" style="text-align: center; style=" width: 150px; background: white; color: black;" |0x0004
  −
| rowspan="1" style="text-align: center; style=" width: 150px; background: white; color: black;" |0x00000001
  −
|}
  −
To begin file transfer from the start, offset should be set to 1 (4 bytes value). In case when the file transfer was interrupted, to resume file transfer, offset can be set to the desired value (1 ≤ [offset] ≤ [file packets]).
  −
<br>
  −
<br>
  −
'''Synchronize file transfer command (CMD ID 0x0003)'''<br>
  −
In a response to the RESUME command a SYNC command is sent from device.
  −
{| class="wikitable"
  −
|+
  −
! rowspan="1" style="width: 400px; background: #0054A6; color: white;" |'''Command ID'''
  −
! rowspan="1" style="width: 400px; background: #0054A6; color: white;" |'''Data length'''
  −
! rowspan="1" style="width: 400px; background: #0054A6; color: white;" |'''File offset (4 bytes)'''
  −
|-
  −
| rowspan="1" style="text-align: center; style=" width: 150px; background: white; color: black;" |0x0003
  −
| rowspan="1" style="text-align: center; style=" width: 150px; background: white; color: black;" |0x0004
  −
| rowspan="1" style="text-align: center; style=" width: 150px; background: white; color: black;" |0x00000001
  −
|}
  −
By sending the SYNC command it is ensured that the next data command will contain file data starting from the specified offset.
  −
<br>
  −
<br>
  −
'''File data transfer command (CMD ID 0x0004)'''<br>
  −
After sending a SYNC command, a file data transfer is started by sending DATA commands.
  −
{| class="wikitable"
  −
|+
  −
! rowspan="1" style="width: 400px; background: #0054A6; color: white;" |'''Command ID'''
  −
! rowspan="1" style="width: 400px; background: #0054A6; color: white;" |'''Data length'''
  −
! rowspan="1" style="width: 400px; background: #0054A6; color: white;" |'''File data (up to 1024 bytes)'''
  −
! rowspan="1" style="width: 400px; background: #0054A6; color: white;" |'''Data CRC (2 bytes)'''
  −
|-
  −
| rowspan="1" style="text-align: center; style=" width: 150px; background: white; color: black;" |0x0004
  −
| rowspan="1" style="text-align: center; style=" width: 150px; background: white; color: black;" |0x0402
  −
| rowspan="1" style="text-align: center; style=" width: 150px; background: white; color: black;" |...
  −
| rowspan="1" style="text-align: center; style=" width: 150px; background: white; color: black;" |...
  −
|}
  −
A File data is split into 1024 byte parts, each part wrapped into a DATA command and is sent. <br>
  −
Note: ''if a command with a bad CRC is received, RESUME command should be sent with the last valid file offset, after receiving a RESUME command, the server will stop sending DATA commands and continue communication from'' '''“Resume file transfer”''' ''step.''<br>
  −
CRC polynomial expression: 0x8408
  −
The initial value, when calculating CRC, is the previously received packet (CMD ID 0x0004) CRC value.
  −
<br>
  −
<br>
  −
'''File transfer status command (CMD ID 0x0005)'''<br>
  −
After a file transfer is completed and no more files are required from the device, a server should send a COMPLETED command to the device (this command does not work after executing repeat init command0 x0009 – in this case, the server should send a CLOSE SESSION 0x0000 command mentioned before).
  −
{| class="wikitable"
  −
|+
  −
! rowspan="1" style="width: 400px; background: #0054A6; color: white;" |'''Command ID'''
  −
! rowspan="1" style="width: 400px; background: #0054A6; color: white;" |'''Data length'''
  −
! rowspan="1" style="width: 400px; background: #0054A6; color: white;" |'''Status (4 bytes)'''
  −
|-
  −
| rowspan="1" style="text-align: center; style=" width: 150px; background: white; color: black;" |0x0005
  −
| rowspan="1" style="text-align: center; style=" width: 150px; background: white; color: black;" |0x0004
  −
| rowspan="1" style="text-align: center; style=" width: 150px; background: white; color: black;" |0x00000000
  −
|}
  −
In case of the server using invalid arguments, commands or not following the file request flow, the device will send this command with a Status field set to one of the few possible error codes. A list of possible ones is provided below.
  −
{| class="wikitable"
  −
|+
  −
! rowspan="1" style="width: 400px; background: #0054A6; color: white;" |'''Status value (hexadecimal)'''
  −
! rowspan="1" style="width: 400px; background: #0054A6; color: white;" |'''Description'''
  −
! rowspan="1" style="width: 400px; background: #0054A6; color: white;" |'''Notes'''
  −
|-
  −
| rowspan="1" style="text-align: center; style=" width: 150px; background: white; color: black;" |0x00000000
  −
| rowspan="1" style="text-align: left; style=" width: 150px; background: white; color: black;" |File transfer process completed
  −
| rowspan="1" style="text-align: center; style=" width: 150px; background: white; color: black;" |Sent from server
  −
|-
  −
| rowspan="1" style="text-align: center; style=" width: 150px; background: white; color: black;" |0x00000002
  −
| rowspan="1" style="text-align: left; style=" width: 150px; background: white; color: black;" |Failed to close GPRS
  −
| rowspan="1" style="text-align: center; style=" width: 150px; background: white; color: black;" |Sent from device
  −
|-
  −
| rowspan="1" style="text-align: center; style=" width: 150px; background: white; color: black;" |0x00000003
  −
| rowspan="1" style="text-align: left; style=" width: 150px; background: white; color: black;" |Failed to close socket
  −
| rowspan="1" style="text-align: center; style=" width: 150px; background: white; color: black;" |Sent from device
  −
|-
  −
| rowspan="1" style="text-align: center; style=" width: 150px; background: white; color: black;" |0x00000005
  −
| rowspan="1" style="text-align: left; style=" width: 150px; background: white; color: black;" |Invalid response from server to init packet
  −
| rowspan="1" style="text-align: center; style=" width: 150px; background: white; color: black;" |Sent from device
  −
|-
  −
| rowspan="1" style="text-align: center; style=" width: 150px; background: white; color: black;" |0x00000011
  −
| rowspan="1" style="text-align: left; style=" width: 150px; background: white; color: black;" |This error code forces the device to disconnect from server
  −
| rowspan="1" style="text-align: left; style=" width: 150px; background: white; color: black;" |Sent from device. Possible causes:
  −
  −
*Camera is not configured
  −
*The requested file is not available by camera
  −
|}
  −
After a COMPLETED command device should disconnect from the server.
  −
<br>
  −
<br>
  −
'''Initialization packet repeat command (CMD ID 0x0009)'''<br>
  −
When sent, the initialization packet is repeated. This is used, when all of the files are downloaded and an additional check is carried out for any additional files, that may have been captured during the download operation.
  −
<br>
  −
  −
'''Query file metadata request (CMD ID 0x000A)'''<br>
  −
This command is used for retrieving extra information about a selected file. A file identifier is used to determine which file’s information will be received. File identifiers are identical and used in the same way as in the File Request Command (0x0008).
  −
{| class="wikitable"
  −
|+
  −
! rowspan="1" style="width: 400px; background: #0054A6; color: white;" |'''Command ID (2 bytes)'''
  −
! rowspan="1" style="width: 400px; background: #0054A6; color: white;" |'''Data length (2 bytes)'''
  −
! rowspan="1" style="width: 400px; background: #0054A6; color: white;" |'''File Identifier (7 bytes)'''
  −
|-
  −
| rowspan="1" style="text-align: center; style=" width: 150px; background: white; color: black;" |0x000A
  −
| rowspan="1" style="text-align: center; style=" width: 150px; background: white; color: black;" |0x0007
  −
| rowspan="1" style="text-align: center; style=" width: 150px; background: white; color: black;" |0xFFFFFFFFFFFFFF
  −
|-
  −
|}
  −
  −
Can be sent after the initialization packet or after the file transfer is complete. It is not a mandatory command and doesn’t have to be used.
  −
The response for this command is 0x000B (more details below).
  −
  −
'''Note: 0x000A command was added since 03.27.04.Rev.104 firmware version and would not work with older versions.'''
  −
<br>
  −
  −
'''File metadata response  (CMD ID 0x000B)'''<br>
  −
0x000B is a response command to the request command 0x000A.
  −
  −
Response command returns information about a specified file: file type, timestamp, trigger, and video length. Complete command’s structure:
  −
{| class="wikitable"
  −
|+
  −
! rowspan="1" style="width: 400px; background: #0054A6; color: white;" |'''Command ID (2 bytes)'''
  −
! rowspan="1" style="width: 400px; background: #0054A6; color: white;" |'''Data length (2 bytes)'''
  −
! rowspan="1" style="width: 400px; background: #0054A6; color: white;" |'''Command version (1 byte)'''
  −
! rowspan="1" style="width: 400px; background: #0054A6; color: white;" |'''File type (1 byte)'''
  −
! rowspan="1" style="width: 400px; background: #0054A6; color: white;" |'''Timestamp (8 bytes)'''
  −
! rowspan="1" style="width: 400px; background: #0054A6; color: white;" |'''Trigger (1 byte)'''
  −
! rowspan="1" style="width: 400px; background: #0054A6; color: white;" |'''Video length (2 bytes)'''
  −
|-
  −
| rowspan="1" style="text-align: center; style=" width: 150px; background: white; color: black;" |0x000B
  −
| rowspan="1" style="text-align: center; style=" width: 150px; background: white; color: black;" |0x000D
  −
| rowspan="1" style="text-align: center; style=" width: 150px; background: white; color: black;" |0xFF
  −
| rowspan="1" style="text-align: center; style=" width: 150px; background: white; color: black;" |0xFF
  −
| rowspan="1" style="text-align: center; style=" width: 150px; background: white; color: black;" |0xFFFFFFFFFFFFFF
  −
| rowspan="1" style="text-align: center; style=" width: 150px; background: white; color: black;" |0xFF
  −
| rowspan="1" style="text-align: center; style=" width: 150px; background: white; color: black;" |0xFFFF
  −
|-
  −
|}
  −
  −
'''Note: 0x000B command was added since 03.27.04.Rev.104 firmware version and would not work with older versions.'''
  −
<br>
  −
  −
Response command meta data:
  −
{| class="wikitable"
  −
|+
  −
! rowspan="1" style="width: 400px; background: #0054A6; color: white;" |'''Data'''
  −
! rowspan="1" style="width: 400px; background: #0054A6; color: white;" |'''Description'''
  −
|-
  −
| rowspan="1" style="text-align: center; style=" width: 150px; background: white; color: black;" |Command  version
  −
| rowspan="1" style="text-align: center; style=" width: 150px; background: white; color: black;" |Iteration  of the command itself to determine to parse of the data
  −
|-
  −
| rowspan="1" style="text-align: center; style=" width: 150px; background: white; color: black;" |File  type
  −
| rowspan="1" style="text-align: center; style=" width: 150px; background: white; color: black;" |Media type for confirming which file’s metadata is received. Byte structure is the  same as byte 3 in the initialization packet settings data
  −
|-
  −
| rowspan="1" style="text-align: center; style=" width: 150px; background: white; color: black;" |Timestamp
  −
| rowspan="1" style="text-align: center; style=" width: 150px; background: white; color: black;" |Timestamp at the time of the trigger. Same used in a corresponding SOS record
  −
|-
  −
| rowspan="1" style="text-align: center; style=" width: 150px; background: white; color: black;" |Trigger
  −
| rowspan="1" style="text-align: center; style=" width: 150px; background: white; color: black;" |Trigger values. Same values as video sending trigger in SOS record.
  −
|-
  −
| rowspan="1" style="text-align: center; style=" width: 150px; background: white; color: black;" |Video  length
  −
| rowspan="1" style="text-align: center; style=" width: 150px; background: white; color: black;" |Duration of the video in seconds. If the file type is a photo, this value is 0x0000.
  −
|-
  −
|}
  −
   
==File transfer visual flow==
 
==File transfer visual flow==
 
[[Image:File transfer Rev.03.jpg|{{{general|size}}}|center]]
 
[[Image:File transfer Rev.03.jpg|{{{general|size}}}|center]]