rpc-service-fs
RPC Service - Filesystem
This service provides an ability to manage device files remotely.
It is required by the , , , commands.
If this library is not included in the app, those commands won't work.
It is possible to call this service programmatically via serial, HTTP/RESTful,
Websocket, MQTT or other transports
(see RPC section) or use tool.
Below is a list of exported RPC methods and arguments:
FS.List
Get device file list. Arguments: none.
Example usage:
mos call FS.List
[
"mgos_ro_vars_schema.json",
"conf0.json",
...
]
This RPC command has a shortcut: :
mos ls
"mgos_ro_vars_schema.json",
"conf0.json",
...
FS.ListExt
Same as but also returns extra file info like file sizes.
Arguments: none.
Example usage:
mos call FS.ListExt
[
{
"name": "mgos_ro_vars_schema.json",
"size": 332
},
...
]
This RPC command has a shortcut: :
mos ls -l
api_adc.js 259
api_arch_uart.js 651
...
FS.Get
Returns file content. Arguments:
Example usage:
mos call FS.Get '{"filename": "init.js"}'
{
"data": "bG9hZCgnYXBpX2NvbmZpZ...", # Base64 encoded data
"left": 0 # How many bytes left in a file
}
This RPC command has a shortcut: :
mos get init.js
load('api_gpio.js');
...
FS.Put
Write data into file. Write is done either by overwriting an existing content, or by appending to the existing content. Arguments:
This RPC command has a shortcut: . It splits large files into
small chunks, and calls sequentially, appending content.
mos put /etc/passwd foo.txt
FS.Remove
Delete file. Arguments:
This RPC command has a shortcut: :
mos rm foo.txt
FS.Mkfs
Create filesystem. Arguments:
Example usage:
mos call FS.Mkfs '{"dev_type": "spi_flash", "dev_opts": "{\"freq\": 20000000, \"cs\": 0}", "fs_type": "SPIFFS", "fs_opts": "{\"size\": 131072}'
FS.Mount
Mount filesystem. Arguments:
mos call FS.Mount '{"path": "/mnt", "dev_type": "spi_flash", "dev_opts": "{\"freq\": 20000000, \"cs\": 0}", "fs_type": "SPIFFS", "fs_opts": "{\"size\": 131072}"}'
FS.Umount
Unmout filesystem. Arguments:
mos call FS.Mount '{"path": "/mnt"}'