File System AT Commands
Note
The File System AT commands are enable by default and cannot be disabled.
AT+FScommand performs corresponding operations in theATdirectory of the file system.AT+CERTandAT+CERTSETcommands perform corresponding operations in theCERTdirectory of the file system.AT+FSRGNcommand configures the file system region for the above command operations.If you want to preload files, refer to Preload Example.
Prior to performing file write operations, validate both file system available capacity and dynamic memory free space to ensure sufficient resource allocation.
AT+FS
Function Description
Perform file system operations, including deleting files, reading files, writing files, getting file sizes, and listing files.
Command Format
AT+FS=<operation>[,<filename>,<offset>,<length>]
Response Format
Successful Response:
OK
Error Response:
ERROR: <error_no>
Parameters
- <operation>:
File operation type
0: List files in directory
1: Delete file
2: Get file size
3: Read file
4: Write file
- <filename>:
File name string
Length not exceeding 253 bytes
- <offset>:
Starting position for reading or writing
- <length>:
Length to read or write
Error Codes
1: Format error
2: Operation failed
Note
When <operation> is set to write, the system will enter Transparent Transmission (TT) Mode mode.
Examples
List files in the directory:
AT+FS=0 OK
Delete the file
test.txt:AT+FS=1,"test.txt" OK
Get size of file
data.bin:AT+FS=2,"data.bin" +FS: 1024 OK
Read 50 bytes from the file
log.txtstarting at offset 100:AT+FS=3,"log.txt",100,50 +FS: <read data> OK
Write 100 bytes of data to the file
new.dat:AT+FS=4,"new.dat",0,100 >>> <send 100 bytes of data> OK
AT+CERT
Function Description
Query the certificate components of the server or client
Command Format
AT+CERT=<role>,<index>
Response Format
Successful Response:
<Certificate name 1>
<Certificate content 1>
<Certificate name 2>
<Certificate content 2>
<Certificate name 3>
<Certificate content 3>
OK
Error Response:
ERROR: <error_no>
Parameters
- <role>:
Certificate component type
0: Client1: Server
- <index>:
Certificate component index
Range: 1~10
Error Codes
1: Parameter error
AT+CERTSET
Function Description
Write the certificate components of the server or client
Command Format
AT+CERTSET=<role>,<type>,<index>,<length>
Response Format
Successful Response:
OK
Error Response:
ERROR: <error_no>
Parameters
- <role>:
Certificate component type
0: Client1: Server
- <type>:
Certificate file type
0: CA certificate, saved as<role>_ca_<index>.crt1: Certificate, saved as<role>_cert_<index>.crt2: Private key, saved as<role>_key_<index>.key
Where
<role>isclientorserver.- <index>:
Certificate component index
Range: 1~10
- <length>:
Number of bytes to write
Range: 1~4096
Error Codes
1: Parameter error
2: Operation failed, for example, the file system region does not exist, memory is insufficient, or the transparent transmission is interrupted
3: Failed to open or write the file
Note
After executing this command, the system will enter Transparent Transmission (TT) Mode mode, and
<length>bytes of certificate data need to be sent.If the
CERTdirectory does not exist, it will be created automatically. If the target file already exists, it will be overwritten.After writing, use AT+CERT to query the certificate components.
Examples
Write a 1200-byte client CA certificate with index 1, saved as CERT/client_ca_1.crt:
AT+CERTSET=0,0,1,1200
>>>
<send 1200 bytes of certificate data>
OK
AT+FSRGN
Function Description
Configure the file system command operation region.
Command Format
AT+FSRGN=<vfs region>
Response Format
Successful Response:
OK
Error Response:
ERROR: <error_no>
Parameters
- <vfs region>:
File system region
1: region 1
2: region 2
3: region 3
4: region 4
Error Codes
1: Parameter error