# Downloading Process

This section describes the process for performing the download using IP Over USB network. XDLD command is used as basis and updated to XDLD2 to support this functionality.

### XDLD2 Command Details

The XDLD2 command is used to perform the process to download Android updates on the payment devices from POS without VHQ support. This download happens via the Netloader protocol using the IP over USB network from POS or PC. This command is supported in M440 and M424 devices.

| **!\[]\(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA...**                                                                                                       | NOTE\*\* |
| ----------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- |
| This command should only be used to download/install android updates. For engage side file downloads, the XDLD command or other existing commands should be used. |          |

| **Request Format:** |          |               |
| ------------------- | -------- | ------------- |
| **XDLD2**FileName   |          |               |
| **Elements:**       |          |               |
|                     |          | 1H            |
|                     | XDLD2    | 4A            |
|                     |          | 1H            |
|                     | FileName | 128A          |
|                     |          | 1H            |
|                     |          | 1H            |
| **LRC Response:**   |          |               |
|                     |          | LRC O.K.      |
|                     |          | LRC Incorrect |

| **Response Format:**        |              |                 |
| --------------------------- | ------------ | --------------- |
| **XDLD2**RetValRetValString |              |                 |
| **Elements:**               |              |                 |
|                             |              | 1H              |
|                             | XDLD2        | 4A              |
|                             |              | 1H              |
|                             | RetVal       | 1N              |
|                             |              | 1H              |
|                             | RetValString | Variable Length |
|                             |              | 1H              |
|                             |              | 1H              |
| **LRC Response:**           |              |                 |
|                             |              | LRC O.K.        |
|                             |              | LRC Incorrect   |

#### RetValString Values

| **Value**                            | **Description**                                                                                                                                                                                                    |
| ------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| SUCCESS:UPDATE PROCESS STARTED       | Update process successfully started; POS can start the file transfer using the Netloader protocol.                                                                                                                 |
| FAILURE:NOT SUPPORTED                | XDLD2 command is not supported in the underlying device/platform.                                                                                                                                                  |
| FAILURE:INVALID COMM TYPE            | XDLD2 is sent when the CommType between POS and XPI is not USBD.                                                                                                                                                   |
| FAILURE:INVALID FILE TYPE            | Received file name is not of .zip extension type.                                                                                                                                                                  |
| FAILURE:UPDATE PROCESS START FAILED  | Unable to start the Download/Update process.                                                                                                                                                                       |
| SUCCESS:DEVICE REBOOTING             | File was downloaded/installed successfully, and the device is about to restart.                                                                                                                                    |
| SUCCESS:INSTALLING                   | File was transferred successfully, and the installation process has begun. **NOTE:** This response will be available only with the Android versions that includes the provision for sending the INSTALLING Status. |
| FAILURE:DOWNLOAD/INSTALLATION FAILED | Download/Installation is failed.                                                                                                                                                                                   |

| **!\[]\(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA...**                                                                                                                                                                                           | NOTE\*\* |
| ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- |
| As part of XDLD2 command processing, XPI will not display any UI on the screen, the display will remain on the previously displayed screen. Once the file installation starts the "Verifone Software Update" will take over and display the progress. |          |

Following are the steps, explaining the process:

{% stepper %}
{% step %}

### POS sends the XDLD2 request

Example: \[DLD request body example] DLD: XDLD2dl.filename.zip
{% endstep %}

{% step %}

### XPI receives the command and parses the command data

* If the command is not valid or the conditions to process an XDLD2 command are not met then a failure response will be sent and XDLD2 command processing will not be completed.
  {% endstep %}

{% step %}

### On a valid XDLD2 command, XPI will process the command

{% endstep %}

{% step %}

### On an M440/M424 device, XPI starts Update Proxy service

XPI starts Update Proxy service as part of the XDLD2 command processing and gets the status of the Update Proxy.
{% endstep %}

{% step %}

### Update Proxy listens for incoming connections

Update Proxy service attempts to listen on the system configured IP and Port for incoming connections from POS for file transfer.
{% endstep %}

{% step %}

### Based on Update Proxy status XPI responds to POS

* Success response: XDLD21SUCCESS:UPDATE PROCESS STARTED
* Failure response: XDLD20FAILURE:UPDATE PROCESS START FAILED
  {% endstep %}

{% step %}

### POS initiates the file transfer

Once the POS receives the success response, it needs to initiate the file transfer using the Netloader protocol via MXDownloader or any other appropriate tool.
{% endstep %}

{% step %}

### Device receives file, performs validation and installation

Once the file transfer is started from POS side, the device will receive the file, perform validation, extraction, installation (post 100% file transfer).
{% endstep %}

{% step %}

### Device restart after successful installation

After the download and installation process is successfully completed, the device will be restarted.
{% endstep %}
{% endstepper %}

| **!\[]\(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA...**                                                                                                                                                                                                                                                                                                                                                                                                                                                          | NOTE\*\* |
| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- |
| Once the file transfer is started by POS, the progress can be monitored via the tool which uses the NETLOADER protocol to transfer the file. The normal way POS apps do this is by shelling out the app that will perform the actual download, and then monitoring for when the shelled program exits to determine that the process is over. It is the shelled program that will know about the file transfer progress, while it sends chunks to Netloader, and receives a final response from Netloader at the end. |          |
| ---                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  | ---      |

#### XPI Master Zip Download

A separate zip file needs to be requested or generated to download XPI master zip file using XDLD2, with the naming format of "XPI\_Master--.zip".

For example: XPI\_Master-1.0-PROD.zip.

| **!\[]\(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA...**                              | NOTE\*\* |
| ---------------------------------------------------------------------------------------- | -------- |
| The minimum required XPI version is 20.04.10.00 for the XPI Master Zip Download support. |          |

### Netloader Protocol

* The Netloader daemon (netloaderd) on the terminal uses TCP and is listening at port 5142.
* Only one command is executed per session. Once a session is established, a command must be received within 2 seconds, or the connection will be closed.
* The command and response messages are ASCII text based, unless otherwise noted.

#### Download a File

To download a file, following command needs to be used:

DLD: Command Message

| Field ID        | Format                   | Definition                                                |
| --------------- | ------------------------ | --------------------------------------------------------- |
| Command         | **DLD:**                 | Download command                                          |
| Filename        | Variable                 | Name of file to download                                  |
| Field Separator | NULL                     |                                                           |
| Size            | Variable                 | Size of the download file                                 |
| Field Separator | NULL                     |                                                           |
| Mask            | “xxx” 3 hex digits       | File permission mask (of hex format in ASCII)             |
| Field Separator | NULL                     |                                                           |
| User            | “os” or “usr1”           | File Owner                                                |
| Field Separator | NULL                     |                                                           |
| Group           | “os” or “users”          | File Group                                                |
| Field Separator | NULL                     |                                                           |
| Download Type   | ‘F’ = Full ‘P’ = Partial | Full download will remove the existing application files. |
| Field Separator | NULL                     |                                                           |

**Example:** \[DLD:mytarball.tgz14876644usr1users]

In response to the command packet, the daemon will return the status string in ASCII:

DLD: Response Message

| Status  | Definition                                                                                                                                                                                                                                        |
| ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| OK      | Command OK, and room for file, can proceed with download                                                                                                                                                                                          |
| NOSPACE | No space, not enough free flash space for file (remember 2x)                                                                                                                                                                                      |
| BADARGS | Bad argument(s) in command packet. Possible causes are: \* bad mask, mask must be >= 600 \* bad user, must be "os" or "usr1", “usr2”, … (typical) \* bad group, must be "root" or "users" (typical) \* unable to open filename (bad format, etc.) |

Once done, a response packet is sent with the following possible values:

DLD: Response Message (2)

| Status      | Definition                                      |
| ----------- | ----------------------------------------------- |
| DNLD\_RBOOT | Download completed with Install, unit rebooting |
| DNLD\_DONE  | Download completed, Install completed           |
| DNLD\_FAIL  | Download FAILED                                 |

\| Flow Diagram


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.verifone.com/xpi/tbd-documentation/android-updates-m4xx-setup-guide/downloading-process.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
