Cloud File System
Demonstrates the ZentriOS DMS Cloud File System API
- SDK directory:
- Zentri App Store:
API Features Demonstrated
- Device Management Server (DMS)/Cloud File System
This app works on:
- AMW004 - Zentri Mackerel evaluation board
- AMW106 - Zentri Moray evaluation board
- AVN4343 - Avnet IoT Starter Kit
- NXP-SCCK - NXP Secure Cloud Connectivity Kit
Requirements and Prerequisites
This app requires a ZentriOS evaluation board. See the Platforms list above.
The DMS Could File Service manages assets (product files) and device files, independently of files in product bundles. A ZentriOS device can upload device files to the Cloud File System. A device can download a product asset for the product to which it is activated, but cannot upload a product asset.
This app demonstrates using the native API Cloud File System library to upload device files and download device files and product assets.
Files are encrypted and decrypted using the system.security_key. In this demonstration the key is defined in the source code.
Files are encrypted after downloading from the Cloud File System, before storing on the device file system. Files are decrypted after reading from the device file system, before uploading to the Cloud File System.
The app defines a number of Cloud File System commands which can be used from the ZentriOS terminal.
Open a ZentriOS serial terminal to the device. See Getting Started, Opening a ZentriOS Terminal.
This app assumes your ZentriOS device is set up with the credentials to join your local network. If you have not already set up network credentials, on the ZentriOS terminal, run the commands:
network_up -s save
See the Wi-Fi Command API documentation for network_up and save.
The following notes on using the app are based on an app compiled for ZentriOS-WZ-3.1.
We recommend setting the device to autorun this app:
> set zap.auto_run cloudfs.zap Set OK > save Saved Success > reboot
The app displays output similar to the following:
[2017-02-27 | 00:14:10: Disassociated] JTAG debug enabled ZENTRI-CLOUDFS-220.127.116.11, 2017-02-23T01:38:20Z, ZentriOS-WZ-18.104.22.168, Board:AMW004-E03.3 [Ready] > Cloud File System Example Starting... User key Set Available commands: stat <device/product> <filename> -------- Return information about existing file in cloud delete <filename> -------- Delete file on Device's cloudFS list <device/product> [<filter>] -------- Returns file listing for device OR device's product download <device/product> <remote> [<local>] -------- Download file from device's cloudFS OR device's product's cloudFS to local FS upload <local> [<remote>] -------- Upload file from local FS to device's cloudFS claim <username> <password> -------- 'Claim' this device with your DMS account activate <product-code> -------- 'Activate' this device with the specified product [Associating to Zentri_Guest] > Obtaining IPv4 address via DHCP IPv4 address: 192.168.6.21 [Associated]
Now you can use the commands the app has created. List device files associated with your device on the DMS. Sample output shows demonstration files created for this purpose:
> list device Request GET /files Connecting (https): ota.zentri.com:443 Starting TLS Name Size CRC Created testcloudfs2.txt 25 0xE458 2017-02-22T05:17:49+00:00 testcloudfs1.txt 25 0xE458 2017-02-22T05:16:40+00:00
If you log into the DMS, select this device, and choose the
Files tab, the files listed match this output:
List product files associated with your product on the DMS.
> list product Request GET /assets Connecting (https): ota.zentri.com:443 Starting TLS Name Size CRC Created zentri.png 790 0x53F4 2016-04-22T10:43:54+00:00
Download a device file:
> download device testcloudfs1.txt Request GET /files/testcloudfs1.txt Connecting (https): ota.zentri.com:443 Starting TLS File downloaded
List files using the
> ls ! # Size Version Filename ... # 1 3344 1.0.0 cloudfs.zap ... # 6 57 1.0.0 testcloudfs1.txt
Open the downloaded file for reading. Note that the local version is encrypted with the
system.security_key specified in the source code.
> fop testcloudfs1.txt [2017-02-22 | 05:29:01: Opened: 0] 0 > read 0 1000 ËSµ3S>3ëÁMßMþßêÓ,]°ÿ3u¿þrçBÂæýü¿øM®_>vî\ºµý|
To read the encrypted content, open the file using the key:
> fop testcloudfs1.txt f12ca2a9dae8bdb48d959e65ec54f6da [2017-02-22 | 05:34:37: Opened: 0] 0 > read 0 1000 Test cloud fs device file [2017-02-22 | 05:34:41: Closed: 0]
Upload a file
> upload testcloudfs1.txt Request POST /files/testcloudfs1.txt Connecting (https): ota.zentri.com:443 Starting TLS File uploaded
The cloud_filesystem.c source sets up the commands and defines their functionality using the DMS Cloud File System library (see API Features Demonstrated above).
Special points to note:
- Decoding the command arguments
productto the enumerated target values
ZOS_DMS_DEVICE(this device) and
ZOS_DMS_PRODUCT(this device's product), defined in the DMS library. See