Download as pdf or txt
Download as pdf or txt
You are on page 1of 36

EC2x&EG2x&EG9x&EM05 Series

FILE Application Note

LTE Standard Module Series

Version: 1.2

Date: 2023-06-13

Status: Released
LTE Standard Module Series

At Quectel, our aim is to provide timely and comprehensive services to our customers. If you
require any assistance, please contact our headquarters:

Quectel Wireless Solutions Co., Ltd.


Building 5, Shanghai Business Park Phase III (Area B), No.1016 Tianlin Road, Minhang District, Shanghai
200233, China
Tel: +86 21 5108 6236
Email: info@quectel.com

Or our local offices. For more information, please visit:


http://www.quectel.com/support/sales.htm.

For technical support, or to report documentation errors, please visit:


http://www.quectel.com/support/technical.htm.
Or email us at: support@quectel.com.

Legal Notices
We offer information as a service to you. The provided information is based on your requirements and we
make every effort to ensure its quality. You agree that you are responsible for using independent analysis
and evaluation in designing intended products, and we provide reference designs for illustrative purposes
only. Before using any hardware, software or service guided by this document, please read this notice
carefully. Even though we employ commercially reasonable efforts to provide the best possible
experience, you hereby acknowledge and agree that this document and related services hereunder are
provided to you on an “as available” basis. We may revise or restate this document from time to time at
our sole discretion without any prior notice to you.

Use and Disclosure Restrictions


License Agreements
Documents and information provided by us shall be kept confidential, unless specific permission is
granted. They shall not be accessed or used for any purpose except as expressly provided herein.

Copyright
Our and third-party products hereunder may contain copyrighted material. Such copyrighted material
shall not be copied, reproduced, distributed, merged, published, translated, or modified without prior
written consent. We and the third party have exclusive rights over copyrighted material. No license shall
be granted or conveyed under any patents, copyrights, trademarks, or service mark rights. To avoid
ambiguities, purchasing in any form cannot be deemed as granting a license other than the normal
non-exclusive, royalty-free license to use the material. We reserve the right to take legal action for
noncompliance with abovementioned requirements, unauthorized use, or other illegal or malicious use of
the material.

EC2x&EG2x&EG9x&EM05_Series_FILE_Application_Note 1 / 35
LTE Standard Module Series

Trademarks
Except as otherwise set forth herein, nothing in this document shall be construed as conferring any rights
to use any trademark, trade name or name, abbreviation, or counterfeit product thereof owned by Quectel
or any third party in advertising, publicity, or other aspects.

Third-Party Rights
This document may refer to hardware, software and/or documentation owned by one or more third parties
(“third-party materials”). Use of such third-party materials shall be governed by all restrictions and
obligations applicable thereto.

We make no warranty or representation, either express or implied, regarding the third-party materials,
including but not limited to any implied or statutory, warranties of merchantability or fitness for a particular
purpose, quiet enjoyment, system integration, information accuracy, and non-infringement of any
third-party intellectual property rights with regard to the licensed technology or use thereof. Nothing herein
constitutes a representation or warranty by us to either develop, enhance, modify, distribute, market, sell,
offer for sale, or otherwise maintain production of any our products or any other hardware, software,
device, tool, information, or product. We moreover disclaim any and all warranties arising from the course
of dealing or usage of trade.

Privacy Policy
To implement module functionality, certain device data are uploaded to Quectel’s or third-party’s servers,
including carriers, chipset suppliers or customer-designated servers. Quectel, strictly abiding by the
relevant laws and regulations, shall retain, use, disclose or otherwise process relevant data for the
purpose of performing the service only or as permitted by applicable laws. Before data interaction with
third parties, please be informed of their privacy and data security policy.

Disclaimer
a) We acknowledge no liability for any injury or damage arising from the reliance upon the information.
b) We shall bear no liability resulting from any inaccuracies or omissions, or from the use of the
information contained herein.
c) While we have made every effort to ensure that the functions and features under development are
free from errors, it is possible that they could contain errors, inaccuracies, and omissions. Unless
otherwise provided by valid agreement, we make no warranties of any kind, either implied or express,
and exclude all liability for any loss or damage suffered in connection with the use of features and
functions under development, to the maximum extent permitted by law, regardless of whether such
loss or damage may have been foreseeable.
d) We are not responsible for the accessibility, safety, accuracy, availability, legality, or completeness of
information, advertising, commercial offers, products, services, and materials on third-party websites
and third-party resources.

Copyright © Quectel Wireless Solutions Co., Ltd. 2023. All rights reserved.

EC2x&EG2x&EG9x&EM05_Series_FILE_Application_Note 2 / 35
LTE Standard Module Series

About the Document

Revision History
Revision Date Author Description

Wayne WEI/
1.0 2019-07-05 Asa WANG/ Initial
Mandy WANG
1.1 2020-01-10 Wayne WEI Added applicable module EG21-G.
1. Updated the applicable modules:
⚫ Added EG21-GL and EG25-GL.
⚫ Updated EC20 R2.1 to EC20-CE.
⚫ Deleted EC20 R2.0.
2. Added the supported storage medium EFS and
relevant information.
3. Added AT command introduction and declaration
of AT command examples (Chapters 2.1 and 2.2).
4. Updated the values of <name_pattern> and
<filename> (Chapters 2.3.3–2.3.6).
5. Added Read Command of AT+QFUPL and
1.2 2023-06-13 Josiah LI AT+QFDWL (Chapters 2.3.4 and 2.3.5).
6. Added the examples of AT+QFDWL,
AT+QFOPEN and AT+QFMOV (Chapters 2.3.3
2.3.6 and 2.3.13).
7. Added the following commands and relevant
examples (Chapters 2.3.14–2.3.18 and 3.3):
⚫ AT+QFFLUSH
⚫ AT+QUSBWAITTIME
⚫ AT+QFCWD
⚫ AT+QFMKD
⚫ AT+QFPWD
8. Added the new error code 404 (Chapter 4).

EC2x&EG2x&EG9x&EM05_Series_FILE_Application_Note 3 / 35
LTE Standard Module Series

Contents

About the Document ................................................................................................................................... 3


Contents ....................................................................................................................................................... 4
Table Index ................................................................................................................................................... 6

1 Introduction .......................................................................................................................................... 7
1.1. Applicable Modules ................................................................................................................. 7
1.2. Using File AT Commands ........................................................................................................ 8
1.3. Description of Data Mode ........................................................................................................ 9

2 Description of FILE AT Commands ................................................................................................. 10


2.1. AT Command Introduction ..................................................................................................... 10
2.1.1. Definitions....................................................................................................................... 10
2.1.2. AT Command Syntax ..................................................................................................... 10
2.2. Declaration of AT Command Examples ................................................................................ 11
2.3. AT Command Description ..................................................................................................... 11
2.3.1. AT+QFLDS Get Space Information of Storage Medium ............................................. 11
2.3.2. AT+QFLST List File Information on Storage Medium ................................................. 12
2.3.3. AT+QFDEL Delete File(s) on Storage Medium ........................................................... 14
2.3.4. AT+QFUPL Upload File to Storage Medium ............................................................... 15
2.3.5. AT+QFDWL Download File(s) from Storage Medium ................................................. 17
2.3.6. AT+QFOPEN Open a File ........................................................................................... 18
2.3.7. AT+QFREAD Read a File ............................................................................................ 19
2.3.8. AT+QFWRITE Write Data into a File ........................................................................... 20
2.3.9. AT+QFSEEK Set File Pointer to Specified Position .................................................... 21
2.3.10. AT+QFPOSITION Get Offset of File Pointer ............................................................... 22
2.3.11. AT+QFTUCAT Truncate File from File Pointer ............................................................ 22
2.3.12. AT+QFCLOSE Close a File......................................................................................... 23
2.3.13. AT+QFMOV Move a File ............................................................................................. 23
2.3.14. AT+QFFLUSH Force Buffer Content to File................................................................ 25
2.3.15. AT+QUSBWAITTIME Set USB Waiting Time ............................................................. 26
2.3.16. AT+QFCWD Set Current Working Folder or Directory ............................................... 27
2.3.17. AT+QFMKD Create a Folder or Directory ................................................................... 27
2.3.18. AT+QFPWD Display Path of Current Folder or Directory ........................................... 28
3 Examples ............................................................................................................................................ 29
3.1. Upload and Download Files .................................................................................................. 29
3.1.1. Upload a File .................................................................................................................. 29
3.1.1.1. Non-ACK Mode..................................................................................................... 29
3.1.1.2. ACK Mode ............................................................................................................ 29
3.1.2. Download a File ............................................................................................................. 30
3.2. Write to and Read Files ......................................................................................................... 30
3.2.1. Write to and Read a UFS File ........................................................................................ 30
3.2.2. Write to and Read a RAM File ....................................................................................... 31

EC2x&EG2x&EG9x&EM05_Series_FILE_Application_Note 4 / 35
LTE Standard Module Series

3.2.3. Write to and Read an EFS File ...................................................................................... 31


3.3. Set Current Working Folder or Directory and Display Path .................................................. 32

4 Summary of ERROR Codes .............................................................................................................. 33

5 Appendix References ........................................................................................................................ 35

EC2x&EG2x&EG9x&EM05_Series_FILE_Application_Note 5 / 35
LTE Standard Module Series

Table Index

Table 1: Applicable Modules......................................................................................................................... 7


Table 2: Types of AT Commands ............................................................................................................... 10
Table 3: Summary of Error Codes .............................................................................................................. 33
Table 4: Terms and Abbreviations .............................................................................................................. 35

EC2x&EG2x&EG9x&EM05_Series_FILE_Application_Note 6 / 35
LTE Standard Module Series

1 Introduction
Quectel EC2x, EG2x, EG9x family and EM05 modules support AT commands for operating files on
different physical storage mediums. This document is a reference guide to these commands.

The supported storage mediums are as follows:

⚫ UFS: User File Storage directory, which is a special directory on the flash file system.
⚫ SD: SD card directory.
⚫ RAM: Random Access Memory, which is faster but much smaller than the UFS. Files stored in RAM
will be lost when the module is rebooted.
⚫ EFS: Encrypted File System

The storage location is indicated by the file name. If the file name begins with “RAM:”, it means that the
file is stored in RAM. If it begins with “SD:”, it means that the file is stored in SD card. If it begins with
“EFS:”, it means that the file is stored in EFS. If there are no prefix characters in the file name, then the file
is stored in UFS.

NOTE

SD storage medium is not supported on EG9x (EG95 and EG91) modules.

1.1. Applicable Modules

Table 1: Applicable Modules

Module Family Module

EC20-CE

EC2x EC21 Series

EC25 Series

EG2x EG21-G

EC2x&EG2x&EG9x&EM05_Series_FILE_Application_Note 7 / 35
LTE Standard Module Series

EG25-G

EG21-GL

EG25-GL

EG91 Series
EG9x
EG95 Series

- EM05 Series

1.2. Using File AT Commands

The procedures for creating, reading and writing a file in the storage:

1. Upload a file to the storage with AT+QFUPL, and output/download the file through the serial interface
with AT+QFDWL.

2. Open the file with AT+QFOPEN, and then the file can be written to or read from at any time and
location until it is closed with AT+QFCLOSE.

⚫ When the file is opened with AT+QFOPEN, you can set it to overwrite mode, read-only mode or
other modes with <mode>. (For more information about <mode>, please refer to Chapter 2.3.6).
After the file is opened, <filehandle> is assigned to it, allowing you to carry out various file
operations.

⚫ After the file is opened, you can write to it with AT+QFWRITE and read the data content from the
current file pointer position with AT+QFREAD.

⚫ You can set the file position with AT+QFSEEK and query the current file position with
AT+QFPOSITION.
⚫ AT+QFTUCAT is used to truncate a file from the file pointer.
⚫ Close the file with AT+QFCLOSE, after which <filehandle> becomes invalid.

Commonly used commands to manage files in the storage:

1. AT+QFLDS: get storage space information.


2. AT+QFLST: list the file information in the specified storage.
3. AT+QFDEL: delete the file(s) in the specified storage.

EC2x&EG2x&EG9x&EM05_Series_FILE_Application_Note 8 / 35
LTE Standard Module Series

1.3. Description of Data Mode

The COM port of EC2x, EG2x, EG9x family and EM05 modules have two working modes: AT command
mode and data mode. In AT command mode, the data inputted via COM port will be interpreted as AT
command; while in data mode, it will be interpreted as data.

⚫ Enter Data Mode

Once AT+QFUPL, AT+QFDWL, AT+QFREAD or AT+QFWRITE is executed, the module returns


CONNECT and the COM port enters data mode. Or you can enter date mode again by executing ATO.

⚫ Exit Data Mode

If you input +++ or pull up the DTR pin (AT&D1 must be executed first) to make the port exit data mode,
the execution of these commands will be interrupted before the response is returned. In such a case, the
COM port cannot re-enter data mode if you execute ATO.

To prevent +++ from being misinterpreted as data, the following sequence should be followed:

1) Do not input any data for at least 1 s after inputting +++.


2) Input +++ within 1 s and any other data cannot be inputted.
3) Input +++ and wait until OK is returned. Once OK is returned, the COM port exits the data mode.

EC2x&EG2x&EG9x&EM05_Series_FILE_Application_Note 9 / 35
LTE Standard Module Series

2 Description of FILE AT Commands

2.1. AT Command Introduction

2.1.1. Definitions

⚫ <CR> Carriage return character.


⚫ <LF> Line feed character.
⚫ <...> Parameter name. Angle brackets do not appear on the command line.
⚫ [...] Optional parameter of a command or an optional part of TA information response.
Square brackets do not appear on the command line. When an optional parameter is
not given in a command, the new value equals its previous value or the default settings,
unless otherwise specified.
⚫ Underline Default setting of a parameter.

2.1.2. AT Command Syntax

All command lines must start with AT or at and end with <CR>. Information responses and result codes
always start and end with a carriage return character and a line feed character:
<CR><LF><response><CR><LF>. In tables presenting commands and responses throughout this
document, only the commands and responses are presented, and <CR> and <LF> are deliberately
omitted.

Table 2: Types of AT Commands

Command Type Syntax Description

Test the existence of the corresponding


Test Command AT+<cmd>=? command and return information about the
type, value, or range of its parameter.
Check the current parameter value of the
Read Command AT+<cmd>?
corresponding command.

Write Command AT+<cmd>=<p1>[,<p2>[,<p3>[...]]] Set user-definable parameter value.

Return a specific information parameter or


Execution Command AT+<cmd>
perform a specific action.

EC2x&EG2x&EG9x&EM05_Series_FILE_Application_Note 10 / 35
LTE Standard Module Series

2.2. Declaration of AT Command Examples

The AT command examples in this document are provided to help you learn about the use of the AT
commands introduced herein. The examples, however, should not be taken as Quectel’s
recommendations or suggestions about how to design a program flow or what status to set the module
into. Sometimes multiple examples may be provided for one AT command. However, this does not mean
that there is a correlation among these examples, or that they should be executed in a given sequence.

2.3. AT Command Description

2.3.1. AT+QFLDS Get Space Information of Storage Medium

The command gets the space information of the specified storage.

AT+QFLDS Get Space Information of Storage Medium


Test Command Response
AT+QFLDS=? OK
Write Command Response
AT+QFLDS=<name_pattern> +QFLDS: <free_size>,<total_size>

OK

If there is an error related to ME functionality:


+CME ERROR: <err>
Execution Command Response
AT+QFLDS Return the UFS information
+QFLDS: <UFS_file_size>,<UFS_file_number>

OK

If there is an error related to ME functionality:


+CME ERROR: <err>
The command takes effect immediately.
Characteristics
The configurations are not saved.

Parameter

<name_pattern> Storage pattern.


"UFS" UFS
"RAM" RAM

EC2x&EG2x&EG9x&EM05_Series_FILE_Application_Note 11 / 35
LTE Standard Module Series

"SD" SD card
"EFS" EFS
<free_size> Free space size of <name_pattern>. Unit: byte.
<total_size> Total space size of <name_pattern>. Unit: byte.
<UFS_file_size> Size of all files in UFS. Unit: byte.
<UFS_file_number> Number of files in UFS.
<err> Error code. See Chapter 4 for details.

Example
AT+QFLDS="RAM" //Query the free space and total space information of RAM.
+QFLDS: 2616320,2621440

OK
AT+QFLDS="UFS" //Query the free space and total space information of UFS.
+QFLDS: 49180672,49205248

OK
AT+QFLDS="SD" //Query the free space and total space information of SD card.
+QFLDS: 251920384,253132800

OK
AT+QFLDS="EFS" //Query the free space and total space information of EFS.
+QFLDS: 6852032,9000960

OK

2.3.2. AT+QFLST List File Information on Storage Medium

The command lists the information of a single file or all files on the specified storage medium.

AT+QFLST List File Information on Storage Medium


Test Command Response
AT+QFLST=? OK
Write Command Response
AT+QFLST=<name_pattern> +QFLST: <filename>,<file_size>
[+QFLST: <filename>,<file_size>
[…]]

OK

If there is an error related to ME functionality:


+CME ERROR: <err>

EC2x&EG2x&EG9x&EM05_Series_FILE_Application_Note 12 / 35
LTE Standard Module Series

Execution Command Response


AT+QFLST Return the information of UFS files:
+QFLST: <filename>,<file_size>
[+QFLST: <filename>,<file_size>
[…]]

OK

If there is an error related to ME functionality:


+CME ERROR: <err>
The command takes effect immediately.
Characteristics
The configurations are not saved.

Parameter

<name_pattern> File to be listed.


"*" All files in UFS.
"<filename>" Specified file <filename> in UFS
"RAM:*" All files in RAM
"RAM:<filename>" Specified file <filename> in RAM
"SD:*" All files in SD card
"SD:<filename>" Specified file <filename> in SD card
"EFS:*" All the files in EFS
"EFS:<filename>" Specified file <filename> in EFS
<filename> Exact name of file. Max. length: 80 bytes.
<file_size> Size of the file. Unit: byte.
<err> Error code. See Chapter 4 for details.

Example
AT+QFLST="*" //List all files in UFS.
+QFLST: "UFS:F_M12-1.bmp",562554
+QFLST: "UFS:F_M12-10.bmp",562554
+QFLST: "UFS:F_M12-11.bmp",562554

OK
AT+QFLST="RAM:*" //List all files in RAM.
+QFLST: "RAM:F_EM05-1.bmp",56554
+QFLST: "RAM:F_EM05-10.bmp",56554
+QFLST: "RAM:F_EM05-11.bmp",56554

OK
AT+QFLST="SD:*" //List all files in SD card.
+QFLST: "SD:10b.txt",10

EC2x&EG2x&EG9x&EM05_Series_FILE_Application_Note 13 / 35
LTE Standard Module Series

+QFLST: "SD:50K.txt",51209
+QFLST: "SD:94k.jpg",95811

OK
AT+QFLST="EFS:*" // List all files in EFS.
+QFLST: "EFS:quecsdkConfig_BAK.ini",200

OK

2.3.3. AT+QFDEL Delete File(s) on Storage Medium

The command deletes a single file or all the files from the specified storage medium.

AT+QFDEL Delete File(s) on Storage Medium


Test Command Response
AT+QFDEL=? +QFDEL: <filename>

OK
Write Command Response
AT+QFDEL=<filename> OK

If there is an error related to ME functionality:


+CME ERROR: <err>
The command takes effect immediately.
Characteristics
the configuration is not saved.

Parameter
<filename> Name of file to be deleted. Max. length: 80 bytes.
"*" Delete all files in UFS (do not delete the directory)
"<filename>" Delete the specified file <filename> in UFS
"RAM:*" Delete all files in RAM
"RAM:<filename>" Delete the specified file <filename> in RAM
"SD:*" Delete all files in SD card (do not delete the directory)
"SD:<filename>" Delete the specified file <filename> in SD card
"EFS:*" Delete all files in EFS
"EFS:<filename>" Delete the specified file <filename> in EFS
<err> Error code. See Chapter 4 for details.

EC2x&EG2x&EG9x&EM05_Series_FILE_Application_Note 14 / 35
LTE Standard Module Series

Example
AT+QFDEL=?
+QFDEL: <filename>

OK
AT+QFDEL="*"
OK
AT+QFDEL="RAM:*"
OK
AT+QFDEL="SD:*"
OK
AT+QFDEL="EFS:*"
OK

2.3.4. AT+QFUPL Upload File to Storage Medium

The command uploads a file to a storage medium. If any file on the storage medium has the same name
as the file to be uploaded, an error will be reported.

After the Write Command is executed and CONNECT is returned, the module will switch to data mode.
When the uploaded data reaches <file_size>, or if no other data are inputted when <timeout> is reached,
the module exits data mode automatically. During data transmission, you can send +++ or pull DTR pin
high to make the module exit data mode. For more details, see Chapter 1.3.

AT+QFUPL Upload File to Storage Medium


Test Command Response
AT+QFUPL=? +QFUPL: <filename>[,(1-<freesize>)[,(range of supported
<timeout>s)[,(list of supported <ackmode>s)]]]

OK
Read Command Response
AT+QFUPL? ERROR
Write Command Response
AT+QFUPL=<filename>[,<file_size>[, CONNECT
<timeout>[,<ackmode>]]] TA switches to the data mode (transparent transmission
mode), so the binary data of the file can be inputted. When
the total size of the inputted data reaches <file_size> or no
data is inputted when <timeout> is reached, TA will return to
command mode and return the following code:
+QFUPL: <upload_size>,<checksum>

OK

EC2x&EG2x&EG9x&EM05_Series_FILE_Application_Note 15 / 35
LTE Standard Module Series

If there is an error related to ME functionality:


+CME ERROR: <err>
The command takes effect immediately.
Characteristics
The configurations are not saved.

Parameter

<freesize> Free space size of <name_pattern>. See Chapter 2.3.1 for more details.
<filename> Name of file to be uploaded. Maximum length: 80 bytes.
"<filename>" Name of file to be uploaded to UFS
"RAM:<filename>" Name of file to be uploaded to RAM
"SD:<filename>" Name of file to be uploaded to SD card
"EFS:<filename>" Name of file to be uploaded to EFS
<file_size> File size expected to be uploaded. Default value: 10240. Unit: byte. Maximum length
is not greater than <freesize>.
<upload_size> Actual size of uploaded data. Unit: byte.
<timeout> Waiting time for inputting data to USB/UART. Range: 1–65535. Default value: 5.
Unit: s.
<ackmode> Determines whether to use ACK mode.
0 Turn off the ACK mode.
1 Turn on the ACK mode.
<checksum> Checksum of uploaded data.
<err> Error code. See Chapter 4 for details.

NOTE
1. It is strongly recommended to use DOS 8.3 file name format for <filename>.
2. <checksum> is a 16-bit checksum calculated using bitwise XOR.
If the number of characters is odd, set the high 8 bits of the checksum as the value of the last
character, and set the low 8 bits to 0. Use an XOR operator to calculate the checksum. Inputting +++
sequence will end the data transmission and switch to command mode. However, previously
uploaded data will be preserved and stored in the file.
3. When executing the command, the data must be inputted after “CONNECT” is returned.
4. The ACK mode is a safeguard against data loss when uploading large files, if hardware flow control is
not functioning properly. The ACK mode works as follows:
1) Run AT+QFUPL=<filename>,<file_size>,<timeout>,1 to enable the ACK mode.
2) The module outputs “CONNECT”.
3) MCU sends 1 KB bytes of data, to which the module responds with an A.
4) MCU receives the A and then sends the next 1 KB bytes of data;
5) Repeat steps 3) and 4) until the transfer is completed.

EC2x&EG2x&EG9x&EM05_Series_FILE_Application_Note 16 / 35
LTE Standard Module Series

2.3.5. AT+QFDWL Download File(s) from Storage Medium

The command downloads a specified file from a storage medium.

AT+QFDWL Download File(s) from Storage Medium


Test Command Response
AT+QFDWL=? +QFDWL: <filename>

OK
Write Command Response
AT+QFDWL=<filename> CONNECT
TA switches to data mode, and the binary data of the file will be outputted.
When the content of the file is read, the TA will return to the command
mode and report the following code:
+QFDWL: <download_size>,<checksum>

OK

If there is an error related to ME functionality:


+CME ERROR: <err>
Read Command Response
AT+QFDWL? ERROR
The command takes effect immediately.
Characteristics
the configuration is not saved.

Parameter

<filename> Name of the file to be downloaded. Maximum length: 80 bytes.


"<filename>" Name of UFS file to be downloaded
"RAM:<filename>" Name of RAM file to be downloaded
"SD:<filename>" Name of SD file to be downloaded
"EFS:<filename>" Name of EFS file to be downloaded
<download_size> Size of downloaded data. Unit: byte.
<checksum> Checksum of downloaded data.
<err> Error code. See Chapter 4 for details.

NOTE

1. Inputting +++ sequence causes the TA to end the data transmission and switch to command mode.
2. <checksum> is a 16-bit checksum calculated using bitwise XOR.

EC2x&EG2x&EG9x&EM05_Series_FILE_Application_Note 17 / 35
LTE Standard Module Series

Example
AT+QFDWL=?
+QFDWL: <filename>

OK
AT+QFDWL="EFS:quecsdkConfig_BAK.ini"
CONNECT
+QFDWL: 200,fe57

OK

2.3.6. AT+QFOPEN Open a File

The command opens a file and gets the file handle to be used in commands such as AT+QFREAD,
AT+QFWRITE, AT+QFSEEK, AT+QFPOSITION, AT+QFTUCAT and AT+QFCLOSE.

AT+QFOPEN Open a File


Test Command Response
AT+QFOPEN=? +QFOPEN: <filename>[,(range of supported <mode>s)]

OK
Read Command Response
AT+QFOPEN? +QFOPEN: <filename>,<filehandle>,<mode>
[+QFOPEN: <filename>,<filehandle>,<mode>
[…]]

OK
Write Command Response
AT+QFOPEN=<filename>[,<mode>] +QFOPEN: <filehandle>

OK

If there is an error related to ME functionality:


+CME ERROR: <err>
The command takes effect immediately.
Characteristics
The configurations are not saved.

Parameter

<filename> Name of file to be opened. Maximum length: 80 bytes.


"<filename>" Name of the UFS file to be opened
"RAM:<filename>" Name of the RAM file to be opened

EC2x&EG2x&EG9x&EM05_Series_FILE_Application_Note 18 / 35
LTE Standard Module Series

"SD:<filename>" Name of the SD file to be opened


"EFS:<filename>" Name of the EFS file to be opened
<filehandle> File handle. Data type: 4 bytes.
<mode> File opening mode.
0 If the file does not exist, it will be created. If the file exists, it will be opened
directly. In both cases, the file can be read and written to.
1 If the file does not exist, it will be created. If the file exists, it will be
overwritten and cleared. In both cases, the file can be read and written to.
2 If the file exists, will be opened directly as a read-only file. Otherwise, an
error will be returned.
<err> Error code. See Chapter 4 for details.

Example
AT+QFOPEN=?
+QFOPEN: <filename>[,(0-2)]

OK
AT+QFOPEN?
OK
AT+QFOPEN="1.txt",0 //Open the existing file 1.txt and get the file handle.
+QFOPEN: 0

OK

2.3.7. AT+QFREAD Read a File

The command reads the data of a file specified by the file handle. The data starts from the current position
of the file pointer that belongs to the file handle.

AT+QFREAD Read a File


Test Command Response
AT+QFREAD=? +QFREAD: <filehandle>[,<length>]

OK
Write Command Response
AT+QFREAD=<filehandle>[,<length>] CONNECT <read_length>
TA switches to data mode. When the total size of the data
reaches <length>, TA will return to the command mode and
report the following code:
OK

If there is an error related to ME functionality:

EC2x&EG2x&EG9x&EM05_Series_FILE_Application_Note 19 / 35
LTE Standard Module Series

+CME ERROR: <err>

The command takes effect immediately.


Characteristics
the configuration is not saved.

Parameter

<filehandle> Handle of the file to be read.


<length> Length of the file to be read. Default value: file length. Unit: byte.
<read_length> Actual read length. Unit: byte.
<err> Error code. See Chapter 4 for details.

2.3.8. AT+QFWRITE Write Data into a File

The command writes data into a file. The data is written starting from the current position of the file pointer
associated with the file handle.

AT+QFWRITE Write Data into a File


Test Command Response
AT+QFWRITE=? +QFWRITE: <filehandle>[,<length>[,<timeout>]]

OK
Write Command Response
AT+QFWRITE=<filehandle>[,<length> CONNECT
[,<timeout>]] TA switches to data mode. When the total size of the written
data reaches <length> or the time reaches <timeout>, TA
will return to command mode and report the following code:
+QFWRITE: <written_length>,<total_length>

OK

If there is an error related to ME functionality:


+CME ERROR: <err>
The command takes effect immediately.
Characteristics
The configurations are not saved.

Parameter

<filehandle> Handle of the file to be operated.


<length> Length of the file to be written to. Default length: 10 KB. Unit: byte.
Maximum value of this parameter is determined by <freesize> of AT+QFUPL.
<timeout> Waiting time for inputting data to USB/UART. Default value: 5.

EC2x&EG2x&EG9x&EM05_Series_FILE_Application_Note 20 / 35
LTE Standard Module Series

Unit: s.
<written_length> Actual written length. Unit: byte.
<total_length> Total file length. Unit: byte.
<err> See Chapter 4 for details.

2.3.9. AT+QFSEEK Set File Pointer to Specified Position

The command sets a file pointer to the specified position. This will decide the starting position of
commands such as AT+QFREAD, AT+QFWRITE, AT+QFPOSITION and AT+QFTUCAT.

AT+QFSEEK Set File Pointer to Specified Position


Test Command Response
AT+QFSEEK=? +QFSEEK: <filehandle>,<offset>[,<position>]

OK
Write Command Response
AT+QFSEEK=<filehandle>,<offset>[,< OK
position>]
If there is an error related to ME functionality:
+CME ERROR: <err>
The command takes effect immediately.
Characteristics
The configurations are not saved.

Parameter

<filehandle> Handle of the file to be operated.


<offset> Number of bytes of the file pointer movement.
<position> Pointer movement mode.
0 The beginning of the file
1 The current position of the pointer
2 The end of the file
<err> Error code. See Chapter 4 for details.

NOTE

1. If <position> 0 and <offset> exceeds file size, the command will return “ERROR”.
2. If <position> 1 and the total size of <offset> and the current position of the pointer exceed the file
size, the command will return “ERROR”.
3. If <position> 2, the handle will move forward.

EC2x&EG2x&EG9x&EM05_Series_FILE_Application_Note 21 / 35
LTE Standard Module Series

2.3.10. AT+QFPOSITION Get Offset of File Pointer

The command gets the offset of a file pointer from the beginning of the file.

AT+QFPOSITION Get Offset of File Pointer


Test Command Response
AT+QFPOSITION=? +QFPOSITION: <filehandle>

OK
Write Command Response
AT+QFPOSITION=<filehandle> +QFPOSITION: <offset>
OK

If there is an error related to ME functionality:


+CME ERROR: <err>
The command takes effect immediately.
Characteristics
The Configuration is not saved.

Parameter

<filehandle> Handle of the file to be operated.


<offset> Offset from the beginning of the file.
<err> Error code. See Chapter 4 for details.

2.3.11. AT+QFTUCAT Truncate File from File Pointer

The command truncates the file from the current pointer position to the end of the file.

AT+QFTUCAT Truncate File from File Pointer


Test Command Response
AT+QFTUCAT=? +QFTUCAT: <filehandle>

OK
Write Command Response
AT+QFTUCAT=<filehandle> OK

If there is an error related to ME functionality:


+CME ERROR: <err>
The command takes effect immediately.
Characteristics
The Configuration is not saved.

EC2x&EG2x&EG9x&EM05_Series_FILE_Application_Note 22 / 35
LTE Standard Module Series

Parameter

<filehandle> Handle of the file to be operated.


<err> Error code. See Chapter 4 for details.

2.3.12. AT+QFCLOSE Close a File

The command closes a file and ends all file operations. After that, the file handle is released and should
not be used again, unless the file is re-opened with AT+QFOPEN.

AT+QFCLOSE Close a File


Test Command Response
AT+QFCLOSE=? +QFCLOSE: <filehandle>

OK
Write Command Response
AT+QFCLOSE=<filehandle> OK

If there is an error related to ME functionality:


+CME ERROR: <err>
The command takes effect immediately.
Characteristics
The Configuration is not saved.

Parameter

<filehandle> Handle of the file to be operated.


<err> Error code. See Chapter 4 for details.

2.3.13. AT+QFMOV Move a File

The command moves a file from one storage medium to another. It only supports moving the file from
UFS or SD to RAM, not from RAM to UFS or SD.

AT+QFMOV Move a File


Test Command Response
AT+QFMOV=? +QFMOV: <srcfilename>,<destfilename>,(list of supported
<copy>s),(list of supported <overwrite>s)

OK
Write Command Response
AT+QFMOV=<srcfilename>,<destfilen OK
ame>,<copy>,<overwrite>

EC2x&EG2x&EG9x&EM05_Series_FILE_Application_Note 23 / 35
LTE Standard Module Series

If there is an error related to ME functionality:


+CME ERROR: <err>
The command takes effect immediately.
Characteristics
The configurations are not saved.

Parameter

<srcfilename> Source file. Max. length: 80 bytes.


"<srcfilename>" Source file named <srcfilename> in the UFS
"SD:<srcfilename>" Source file named <srcfilename> in the SD
<destfilename> Destination file. Max. length: 80 bytes.
"RAM:<destfilename>” Destination file named <destfilename> in the RAM
<copy> Determines whether to delete the source file after the file is moved.
0 Delete the source file after it is moved, i.e., cut this file
1 Do not delete the source file after it is moved, i.e., copy this file
<overwrite> Whether or not to overwrite the file if the destination file exists.
0 Do not overwrite the destination file if it exists
1 Overwrite the destination file if it exists
<err> Error code. See Chapter 4 for details.

NOTE

When executing AT+QFMOV="filenamea", "RAM:flienameb",<copy>,<overwrite>, it means moving


a single file, and users can move the file named filenamea from UFS to RAM, and rename it as
filenameb.

Example
AT+QFMOV=?
+QFMOV: <srcfilename>,<destfilename>,(0,1),(0,1)

OK
AT+QFMOV="1.txt","RAM:2.txt",1,1
OK

EC2x&EG2x&EG9x&EM05_Series_FILE_Application_Note 24 / 35
LTE Standard Module Series

2.3.14. AT+QFFLUSH Force Buffer Content to File

This command forces the buffer content to a file.

AT+QFFLUSH Force Buffer Content to File

Test Command Response


AT+QFFLUSH=? +QFFLUSH: <filehandle>

OK
Write Command Response
AT+QFFLUSH=<filehandle> OK

If there is an error related to ME functionality:


+CME ERROR: <err>
The command takes effect immediately.
Characteristics
The Configuration is not saved.

Parameter

<filehandle> Handle of the file to be operated.


<err> Error code. See Chapter 4 for details.

Example
AT+QFOPEN="1.txt",0
+QFOPEN: 4 //Get the handle of 1.txt file in UFS.

OK
AT+QFFLUSH=?
+QFFLUSH: <filehandle>

OK
AT+QFFLUSH=4
OK

AT+QFCLOSE=4 //Close the file.


OK

EC2x&EG2x&EG9x&EM05_Series_FILE_Application_Note 25 / 35
LTE Standard Module Series

2.3.15. AT+QUSBWAITTIME Set USB Waiting Time

This command sets the USB waiting time.

AT+QUSBWAITTIME Set USB Waiting Time

Write Command Response


AT+QUSBWAITTIME=[<waittimes>] 1) If <waittimes> < 4 or <waittimes>> 100:
ERROR
1) If 4<= <waittimes> <= 100:
OK
Execution Command Response
AT+QUSBWAITTIME +QUSBWAITTIME: <waittimes>

OK
The command takes effect immediately.
Characteristics
The Configuration is not saved.

Parameter

<waittimes> USB waiting time. Range: 4–100. Default value: 10. Unit: ms. Error is returned
when the parameter is out of range.

NOTE

If the optional parameter <waittimes> is omitted, set USB waiting time according to the last configured
value. If there is no previous setting, then set this time as the default.

Example
AT+QUSBWAITTIME
+QUSBWAITTIME: 10 //Initial USB waiting time is set to 10 ms.

OK
AT+QUSBWAITTIME=6 //Set USB waiting time to 6 ms.
OK
AT+QUSBWAITTIME
+QUSBWAITTIME: 6 //Verify that USB waiting time is now 6 ms.

OK
AT+QUSBWAITTIME=2 //Attempt to set USB waiting time to 2 ms. An error is returned since the USB
ERROR waiting time is outside the allowed range (4–100).

EC2x&EG2x&EG9x&EM05_Series_FILE_Application_Note 26 / 35
LTE Standard Module Series

2.3.16. AT+QFCWD Set Current Working Folder or Directory

This command sets the current working folder or directory. By default it operates in UFS, while RAM, SD,
or EFS are not supported.

AT+QFCWD Set Current Working Folder or Directory


Test Command Response
AT+QFCWD=? +QFCWD:<DIR name>

OK
Write Command Response
AT+QFCWD=<DIR name> OK

If there is an error related to ME functionality:


+CME ERROR: <err>
The command takes effect immediately.
Characteristics
The configuration is not saved.

Parameter

<DIR name> Folder or directory name.


<err> Error code. See Chapter 4 for details.

2.3.17. AT+QFMKD Create a Folder or Directory

This command creates a new folder or directory. By default it operates in UFS, while RAM, SD, or EFS
are not supported. +CME ERROR: 405 is returned if the folder or directory already exists.

AT+QFMKD Create a Folder or Directory


Test Command Response
AT+QFMKD=? +QFMKD:<DIR name>

OK
Write Command Response
AT+QFMKD=<DIR name> OK

If there is an error related to ME functionality:


+CME ERROR: <err>
The command takes effect immediately.
Characteristics
The configuration is not saved.

EC2x&EG2x&EG9x&EM05_Series_FILE_Application_Note 27 / 35
LTE Standard Module Series

Parameter

<DIR name> Folder or directory name.


<err> Error code. See Chapter 4 for details.

Example
AT+QFMKD="EG91" //Create a folder or directory named EG91 in UFS.
OK
AT+QFLST //List the information of the new file or directory.
+QFLST: "EG91",160

OK

2.3.18. AT+QFPWD Display Path of Current Folder or Directory

This command displays the path of the current folder or directory. By default it operates in UFS, while
RAM, SD, or EFS are not supported.

AT+QFPWD Display Path of Current Folder or Directory


Test Command Response
AT+QFPWD=? +QFPWD:<DIR name>

OK
Write Command Response
AT+QFPWD=<DIR name> +QFPWD: "<DIR path>"

OK
If there is an error related to ME functionality:
+CME ERROR: <err>
The command takes effect immediately.
Characteristics
The configuration is not saved.

Parameter

<DIR name> Folder or directory name.


<DIR path> Path of the current folder or directory.
<err> Error code. See Chapter 4 for details.

EC2x&EG2x&EG9x&EM05_Series_FILE_Application_Note 28 / 35
LTE Standard Module Series

3 Examples

3.1. Upload and Download Files

3.1.1. Upload a File

3.1.1.1. Non-ACK Mode

AT+QFUPL="test1.txt",10 //Upload the text file test1.txt to UFS.


CONNECT
<Input file bin data>
+QFUPL: 10,3938

OK
AT+QFUPL="RAM:test1.txt",10 //Upload the text file RAM:test1.txt to RAM.
CONNECT
<Input file bin data>
+QFUPL: 10,6466 //Size and checksum value of uploaded data are returned.

OK

3.1.1.2. ACK Mode

The ACK mode can make the data transmission more reliable. When transmitting a large file without
hardware flow control, the ACK mode is recommended to prevent data loss. For more details about ACK
mode, please refer to AT+QFUPL.

AT+QFUPL="RAM:test.txt",3000,5,1 //Upload the text file RAM:test.txt to RAM.


CONNECT
<input file bin data of 1024bytes>
A //After receiving 1024 bytes of data, the module will
return A. And then the next 1024 bytes of data can be
inputted.
<input file bin data of 1024bytes>
A
<input the rest file bin data>

EC2x&EG2x&EG9x&EM05_Series_FILE_Application_Note 29 / 35
LTE Standard Module Series

+QFUPL: 3000,B34A

OK

3.1.2. Download a File

AT+QFDWL="RAM:test.txt" //Download the text file RAM:test.txt from RAM.


CONNECT
<Output Data>
+QFDWL: 10,613e //Size and checksum value of downloaded data are returned.

OK

3.2. Write to and Read Files

3.2.1. Write to and Read a UFS File

AT+QFOPEN="test",0 //Open the file to get the file handle.


+QFOPEN: 0

OK
AT+QFWRITE=0,10 //Write 10 bytes to the file.
CONNECT
<Write Data>
+QFWRITE: 10,10 //The actual written bytes and the size of the file are returned.

OK
AT+QFSEEK=0,0,0 //Set the file pointer to the beginning of the file.
OK
AT+QFREAD=0,10 //Read 10 bytes from the file.
CONNECT 10
<Read Data>

OK
AT+QFCLOSE=0 //Close the file.
OK

EC2x&EG2x&EG9x&EM05_Series_FILE_Application_Note 30 / 35
LTE Standard Module Series

3.2.2. Write to and Read a RAM File

AT+QFLDS="RAM" //Query the space information of RAM.


+QFLDS: 2606080,2621440

OK
AT+QFOPEN="RAM:1",0 //Open the file in RAM.
+QFOPEN: 3000

OK
AT+QFWRITE=3000,10 //Write 10 bytes to the file.
CONNECT
<Write Data>
+QFWRITE: 10,10 //The actual written bytes and the size of the file are returned.

OK
AT+QFSEEK=3000,0,0 //Set the file pointer to the beginning of the file.
OK
AT+QFREAD=3000,10 //Read the data.
CONNECT
<Read Data>

OK
AT+QFCLOSE=3000 //Close the file.
OK

3.2.3. Write to and Read an EFS File

AT+QFOPEN="EFS:TEST",0 //Open the file in EFS.


+QFOPEN: 3

OK
AT+QFWRITE=3,9 //Write 9 bytes to the file.
CONNECT
<Write Data>
+QFWRITE: 9,9 //The actual written bytes and the size of the file are returned.

OK
AT+QFSEEK=3,0,0 //Set the file pointer to the beginning of the file.
OK
AT+QFREAD=3,9 //Read the data.
CONNECT 9
<Read Data>

EC2x&EG2x&EG9x&EM05_Series_FILE_Application_Note 31 / 35
LTE Standard Module Series

OK
AT+QFCLOSE=3 //Close the file.
OK

3.3. Set Current Working Folder or Directory and Display Path

AT+QFMKD="EG91" //Create a folder or directory named "EG91" in UFS.


OK
AT+QFCWD="EG91" //Set UFS:\EG91 as the current working folder or directory.
OK
AT+QFPWD="UFS" //Display the current working folder or directory as UFS: \EG91.
+QFPWD: "UFS: \EG91"

OK
AT+QFMKD="EG92" //Create a folder or directory named "EG92" in UFS:\EG91.
OK
AT+QFCWD="EG92" //Set UFS:\EG91\EG92 as the current working folder or directory.
OK
AT+QFPWD="UFS" // Display the current working folder or directory as UFS: \EG91\EG92.
+QFPWD: "UFS: \EG91\EG92"

OK

EC2x&EG2x&EG9x&EM05_Series_FILE_Application_Note 32 / 35
LTE Standard Module Series

4 Summary of ERROR Codes


The error code <err> indicates an error related to mobile equipment or network. The following table
provides the details about <err> codes, which are only related to file operations.

Table 3: Summary of Error Codes

<err> Meaning

400 Invalid input value

401 Larger than the size of the file

402 Read zero byte

403 Drive full

404 Not supported

405 File not found

406 Invalid file name

407 File already exists

409 Fail to write the file

410 Fail to open the file

411 Fail to read the file

413 Reach the max number of file allowed to be opened

414 The file read-only

416 Invalid file descriptor

417 Fail to list the file

418 Fail to delete the file

419 Fail to get disk info

EC2x&EG2x&EG9x&EM05_Series_FILE_Application_Note 33 / 35
LTE Standard Module Series

420 No space

421 Time out

423 File too large

425 Invalid parameter

426 File already opened

EC2x&EG2x&EG9x&EM05_Series_FILE_Application_Note 34 / 35
LTE Standard Module Series

5 Appendix References

Table 4: Terms and Abbreviations

Abbreviation Description

ACK Acknowledgement

COM Communication Port

DOS Disk Operating System

DTR Data Terminal Ready

ME Mobile Equipment

RAM Random Access Memory

SD Secure Digital

TA Terminal Adapter

UART Universal Asynchronous Receiver Transmitter

UFS User File Storage

USB Universal Serial Bus

XOR Exclusive OR

EC2x&EG2x&EG9x&EM05_Series_FILE_Application_Note 35 / 35

You might also like