cc3100_Socket_Wifi_Server with Ethernet Interface not working

Dependencies:   EthernetInterface mbed-rtos mbed

Fork of cc3100_Test_Demo by David Fletcher

Committer:
dflet
Date:
Tue Feb 10 12:09:29 2015 +0000
Revision:
0:e89ba455dbcf
For test only! Not much has been tested, but the 2 demo apps run ok. Alot more work needs to be done!

Who changed what in which revision?

UserRevisionLine numberNew contents of line
dflet 0:e89ba455dbcf 1 /*
dflet 0:e89ba455dbcf 2 * fs.h - CC31xx/CC32xx Host Driver Implementation
dflet 0:e89ba455dbcf 3 *
dflet 0:e89ba455dbcf 4 * Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/
dflet 0:e89ba455dbcf 5 *
dflet 0:e89ba455dbcf 6 *
dflet 0:e89ba455dbcf 7 * Redistribution and use in source and binary forms, with or without
dflet 0:e89ba455dbcf 8 * modification, are permitted provided that the following conditions
dflet 0:e89ba455dbcf 9 * are met:
dflet 0:e89ba455dbcf 10 *
dflet 0:e89ba455dbcf 11 * Redistributions of source code must retain the above copyright
dflet 0:e89ba455dbcf 12 * notice, this list of conditions and the following disclaimer.
dflet 0:e89ba455dbcf 13 *
dflet 0:e89ba455dbcf 14 * Redistributions in binary form must reproduce the above copyright
dflet 0:e89ba455dbcf 15 * notice, this list of conditions and the following disclaimer in the
dflet 0:e89ba455dbcf 16 * documentation and/or other materials provided with the
dflet 0:e89ba455dbcf 17 * distribution.
dflet 0:e89ba455dbcf 18 *
dflet 0:e89ba455dbcf 19 * Neither the name of Texas Instruments Incorporated nor the names of
dflet 0:e89ba455dbcf 20 * its contributors may be used to endorse or promote products derived
dflet 0:e89ba455dbcf 21 * from this software without specific prior written permission.
dflet 0:e89ba455dbcf 22 *
dflet 0:e89ba455dbcf 23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
dflet 0:e89ba455dbcf 24 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
dflet 0:e89ba455dbcf 25 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
dflet 0:e89ba455dbcf 26 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
dflet 0:e89ba455dbcf 27 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
dflet 0:e89ba455dbcf 28 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
dflet 0:e89ba455dbcf 29 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
dflet 0:e89ba455dbcf 30 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
dflet 0:e89ba455dbcf 31 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
dflet 0:e89ba455dbcf 32 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
dflet 0:e89ba455dbcf 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
dflet 0:e89ba455dbcf 34 *
dflet 0:e89ba455dbcf 35 */
dflet 0:e89ba455dbcf 36
dflet 0:e89ba455dbcf 37 #ifndef FS_H_
dflet 0:e89ba455dbcf 38 #define FS_H_
dflet 0:e89ba455dbcf 39
dflet 0:e89ba455dbcf 40 /*****************************************************************************/
dflet 0:e89ba455dbcf 41 /* Include files */
dflet 0:e89ba455dbcf 42 /*****************************************************************************/
dflet 0:e89ba455dbcf 43
dflet 0:e89ba455dbcf 44 #include "cc3100_simplelink.h"
dflet 0:e89ba455dbcf 45
dflet 0:e89ba455dbcf 46 /*!
dflet 0:e89ba455dbcf 47
dflet 0:e89ba455dbcf 48 \addtogroup FileSystem
dflet 0:e89ba455dbcf 49 @{
dflet 0:e89ba455dbcf 50
dflet 0:e89ba455dbcf 51 */
dflet 0:e89ba455dbcf 52
dflet 0:e89ba455dbcf 53 /*****************************************************************************/
dflet 0:e89ba455dbcf 54 /* Macro declarations */
dflet 0:e89ba455dbcf 55 /*****************************************************************************/
dflet 0:e89ba455dbcf 56
dflet 0:e89ba455dbcf 57 /* FS error codes */
dflet 0:e89ba455dbcf 58 #define SL_FS_OK (0)
dflet 0:e89ba455dbcf 59 #define SL_FS_ERR_EMPTY_SFLASH (-67)
dflet 0:e89ba455dbcf 60 #define SL_FS_ERR_FILE_IS_NOT_SECURE_AND_SIGN (-66)
dflet 0:e89ba455dbcf 61 #define SL_FS_ERASING_FLASH (-65)
dflet 0:e89ba455dbcf 62 #define SL_FS_FILE_HAS_NOT_BEEN_CLOSE_CORRECTLY (-64)
dflet 0:e89ba455dbcf 63 #define SL_FS_WRONG_SIGNATURE (-63)
dflet 0:e89ba455dbcf 64 #define SL_FS_WRONG_SIGNATURE_OR_CERTIFIC_NAME_LENGTH (-62)
dflet 0:e89ba455dbcf 65 #define SL_FS_NOT_16_ALIGNED (-61)
dflet 0:e89ba455dbcf 66 #define SL_FS_CERT_CHAIN_ERROR (-60)
dflet 0:e89ba455dbcf 67 #define SL_FS_FILE_NAME_EXIST (-59)
dflet 0:e89ba455dbcf 68 #define SL_FS_SECURITY_BUF_ALREADY_ALLOC (-58)
dflet 0:e89ba455dbcf 69 #define SL_FS_SECURE_FILE_MUST_BE_COMMIT (-57)
dflet 0:e89ba455dbcf 70 #define SL_FS_ERR_INCORRECT_OFFSET_ALIGNMENT (-56)
dflet 0:e89ba455dbcf 71 #define SL_FS_ERR_FAILED_READ_NVMEM_HEADER (-55)
dflet 0:e89ba455dbcf 72 #define SL_FS_WRONG_FILE_NAME (-54)
dflet 0:e89ba455dbcf 73 #define SL_FS_FILE_SYSTEM_IS_LOCKED (-53)
dflet 0:e89ba455dbcf 74 #define SL_FS_SECURITY_ALLERT (-52)
dflet 0:e89ba455dbcf 75 #define SL_FS_FILE_UNVALID_FILE_SIZE (-51)
dflet 0:e89ba455dbcf 76 #define SL_FS_ERR_TOKEN_IS_NOT_VALID (-50)
dflet 0:e89ba455dbcf 77 #define SL_FS_NO_DEVICE_IS_LOADED (-49)
dflet 0:e89ba455dbcf 78 #define SL_FS_DATA_ADDRESS_SHOUD_BE_IN_DATA_RAM (-48)
dflet 0:e89ba455dbcf 79 #define SL_FS_DATA_IS_NOT_ALIGNED (-47)
dflet 0:e89ba455dbcf 80 #define SL_FS_ERR_OVERLAP_DETECTION_THRESHHOLD (-46)
dflet 0:e89ba455dbcf 81 #define SL_FS_FILE_HAS_RESERVED_NV_INDEX (-45)
dflet 0:e89ba455dbcf 82 #define SL_FS_ERR_MAX_FS_FILES_IS_LARGER (-44)
dflet 0:e89ba455dbcf 83 #define SL_FS_ERR_MAX_FS_FILES_IS_SMALLER (-43)
dflet 0:e89ba455dbcf 84 #define SL_FS_FILE_MAX_SIZE_EXCEEDED (-42)
dflet 0:e89ba455dbcf 85 #define SL_FS_INVALID_BUFFER_FOR_READ (-41)
dflet 0:e89ba455dbcf 86 #define SL_FS_INVALID_BUFFER_FOR_WRITE (-40)
dflet 0:e89ba455dbcf 87 #define SL_FS_ERR_FILE_IMAGE_IS_CORRUPTED (-39)
dflet 0:e89ba455dbcf 88 #define SL_FS_ERR_SIZE_OF_FILE_EXT_EXCEEDED (-38)
dflet 0:e89ba455dbcf 89 #define SL_FS_WARNING_FILE_NAME_NOT_KEPT (-37)
dflet 0:e89ba455dbcf 90 #define SL_FS_ERR_DEVICE_IS_NOT_FORMATTED (-36)
dflet 0:e89ba455dbcf 91 #define SL_FS_ERR_FAILED_WRITE_NVMEM_HEADER (-35)
dflet 0:e89ba455dbcf 92 #define SL_FS_ERR_NO_AVAILABLE_NV_INDEX (-34)
dflet 0:e89ba455dbcf 93 #define SL_FS_ERR_FAILED_TO_ALLOCATE_MEM (-33)
dflet 0:e89ba455dbcf 94 #define SL_FS_ERR_FAILED_TO_READ_INTEGRITY_HEADER_2 (-32)
dflet 0:e89ba455dbcf 95 #define SL_FS_ERR_FAILED_TO_READ_INTEGRITY_HEADER_1 (-31)
dflet 0:e89ba455dbcf 96 #define SL_FS_ERR_NO_AVAILABLE_BLOCKS (-30)
dflet 0:e89ba455dbcf 97 #define SL_FS_ERR_FILE_MAX_SIZE_BIGGER_THAN_EXISTING_FILE (-29)
dflet 0:e89ba455dbcf 98 #define SL_FS_ERR_FILE_EXISTS_ON_DIFFERENT_DEVICE_ID (-28)
dflet 0:e89ba455dbcf 99 #define SL_FS_ERR_INVALID_ACCESS_TYPE (-27)
dflet 0:e89ba455dbcf 100 #define SL_FS_ERR_FILE_ALREADY_EXISTS (-26)
dflet 0:e89ba455dbcf 101 #define SL_FS_ERR_PROGRAM (-25)
dflet 0:e89ba455dbcf 102 #define SL_FS_ERR_NO_ENTRIES_AVAILABLE (-24)
dflet 0:e89ba455dbcf 103 #define SL_FS_ERR_FILE_ACCESS_IS_DIFFERENT (-23)
dflet 0:e89ba455dbcf 104 #define SL_FS_ERR_BAD_FILE_MODE (-22)
dflet 0:e89ba455dbcf 105 #define SL_FS_ERR_FAILED_READ_NVFILE (-21)
dflet 0:e89ba455dbcf 106 #define SL_FS_ERR_FAILED_INIT_STORAGE (-20)
dflet 0:e89ba455dbcf 107 #define SL_FS_ERR_CONTINUE_WRITE_MUST_BE_MOD_4 (-19)
dflet 0:e89ba455dbcf 108 #define SL_FS_ERR_FAILED_LOAD_FILE (-18)
dflet 0:e89ba455dbcf 109 #define SL_FS_ERR_INVALID_HANDLE (-17)
dflet 0:e89ba455dbcf 110 #define SL_FS_ERR_FAILED_TO_WRITE (-16)
dflet 0:e89ba455dbcf 111 #define SL_FS_ERR_OFFSET_OUT_OF_RANGE (-15)
dflet 0:e89ba455dbcf 112 #define SL_FS_ERR_ALLOC (-14)
dflet 0:e89ba455dbcf 113 #define SL_FS_ERR_READ_DATA_LENGTH (-13)
dflet 0:e89ba455dbcf 114 #define SL_FS_ERR_INVALID_FILE_ID (-12)
dflet 0:e89ba455dbcf 115 #define SL_FS_ERR_FILE_NOT_EXISTS (-11)
dflet 0:e89ba455dbcf 116 #define SL_FS_ERR_EMPTY_ERROR (-10)
dflet 0:e89ba455dbcf 117 #define SL_FS_ERR_INVALID_ARGS (-9)
dflet 0:e89ba455dbcf 118 #define SL_FS_ERR_FAILED_TO_CREATE_FILE (-8)
dflet 0:e89ba455dbcf 119 #define SL_FS_ERR_FS_ALREADY_LOADED (-7)
dflet 0:e89ba455dbcf 120 #define SL_FS_ERR_UNKNOWN (-6)
dflet 0:e89ba455dbcf 121 #define SL_FS_ERR_FAILED_TO_CREATE_LOCK_OBJ (-5)
dflet 0:e89ba455dbcf 122 #define SL_FS_ERR_DEVICE_NOT_LOADED (-4)
dflet 0:e89ba455dbcf 123 #define SL_FS_ERR_INVALID_MAGIC_NUM (-3)
dflet 0:e89ba455dbcf 124 #define SL_FS_ERR_FAILED_TO_READ (-2)
dflet 0:e89ba455dbcf 125 #define SL_FS_ERR_NOT_SUPPORTED (-1)
dflet 0:e89ba455dbcf 126 /* end of error codes */
dflet 0:e89ba455dbcf 127
dflet 0:e89ba455dbcf 128 #define _FS_MODE_ACCESS_RESERVED_OFFSET (24)
dflet 0:e89ba455dbcf 129 #define _FS_MODE_ACCESS_RESERVED_MASK (0xFF)
dflet 0:e89ba455dbcf 130 #define _FS_MODE_ACCESS_FLAGS_OFFSET (16)
dflet 0:e89ba455dbcf 131 #define _FS_MODE_ACCESS_FLAGS_MASK (0xFF)
dflet 0:e89ba455dbcf 132 #define _FS_MODE_ACCESS_OFFSET (12)
dflet 0:e89ba455dbcf 133 #define _FS_MODE_ACCESS_MASK (0xF)
dflet 0:e89ba455dbcf 134 #define _FS_MODE_OPEN_SIZE_GRAN_OFFSET (8)
dflet 0:e89ba455dbcf 135 #define _FS_MODE_OPEN_SIZE_GRAN_MASK (0xF)
dflet 0:e89ba455dbcf 136 #define _FS_MODE_OPEN_SIZE_OFFSET (0)
dflet 0:e89ba455dbcf 137 #define _FS_MODE_OPEN_SIZE_MASK (0xFF)
dflet 0:e89ba455dbcf 138 #define MAX_MODE_SIZE (0xFF)
dflet 0:e89ba455dbcf 139 #define _FS_MODE(Access, SizeGran, Size,Flags) (uint32_t)(((uint32_t)((Access) & _FS_MODE_ACCESS_MASK)<<_FS_MODE_ACCESS_OFFSET) | \
dflet 0:e89ba455dbcf 140 ((uint32_t)((SizeGran) & _FS_MODE_OPEN_SIZE_GRAN_MASK)<<_FS_MODE_OPEN_SIZE_GRAN_OFFSET) | \
dflet 0:e89ba455dbcf 141 ((uint32_t)((Size) & _FS_MODE_OPEN_SIZE_MASK)<<_FS_MODE_OPEN_SIZE_OFFSET) | \
dflet 0:e89ba455dbcf 142 ((uint32_t)((Flags) & _FS_MODE_ACCESS_FLAGS_MASK)<<_FS_MODE_ACCESS_FLAGS_OFFSET))
dflet 0:e89ba455dbcf 143
dflet 0:e89ba455dbcf 144
dflet 0:e89ba455dbcf 145 /* sl_FsOpen options */
dflet 0:e89ba455dbcf 146 /* Open for Read */
dflet 0:e89ba455dbcf 147 #define FS_MODE_OPEN_READ _FS_MODE(_FS_MODE_OPEN_READ,0,0,0)
dflet 0:e89ba455dbcf 148 /* Open for Write (in case file exist) */
dflet 0:e89ba455dbcf 149 #define FS_MODE_OPEN_WRITE _FS_MODE(_FS_MODE_OPEN_WRITE,0,0,0)
dflet 0:e89ba455dbcf 150 /* Open for Creating a new file */
dflet 0:e89ba455dbcf 151 #define FS_MODE_OPEN_CREATE(maxSizeInBytes,accessModeFlags) _sl_GetCreateFsMode(maxSizeInBytes,accessModeFlags)
dflet 0:e89ba455dbcf 152
dflet 0:e89ba455dbcf 153 namespace mbed_cc3100 {
dflet 0:e89ba455dbcf 154
dflet 0:e89ba455dbcf 155 /*****************************************************************************/
dflet 0:e89ba455dbcf 156 /* Structure/Enum declarations */
dflet 0:e89ba455dbcf 157 /*****************************************************************************/
dflet 0:e89ba455dbcf 158 typedef struct {
dflet 0:e89ba455dbcf 159 uint16_t flags;
dflet 0:e89ba455dbcf 160 uint32_t FileLen;
dflet 0:e89ba455dbcf 161 uint32_t AllocatedLen;
dflet 0:e89ba455dbcf 162 uint32_t Token[4];
dflet 0:e89ba455dbcf 163 } SlFsFileInfo_t;
dflet 0:e89ba455dbcf 164
dflet 0:e89ba455dbcf 165 typedef enum {
dflet 0:e89ba455dbcf 166 _FS_MODE_OPEN_READ = 0,
dflet 0:e89ba455dbcf 167 _FS_MODE_OPEN_WRITE,
dflet 0:e89ba455dbcf 168 _FS_MODE_OPEN_CREATE,
dflet 0:e89ba455dbcf 169 _FS_MODE_OPEN_WRITE_CREATE_IF_NOT_EXIST
dflet 0:e89ba455dbcf 170 } SlFsFileOpenAccessType_e;
dflet 0:e89ba455dbcf 171
dflet 0:e89ba455dbcf 172 typedef enum {
dflet 0:e89ba455dbcf 173 _FS_FILE_OPEN_FLAG_COMMIT = 0x1, /* MIRROR - for fail safe */
dflet 0:e89ba455dbcf 174 _FS_FILE_OPEN_FLAG_SECURE = 0x2, /* SECURE */
dflet 0:e89ba455dbcf 175 _FS_FILE_OPEN_FLAG_NO_SIGNATURE_TEST = 0x4, /* Relevant to secure file only */
dflet 0:e89ba455dbcf 176 _FS_FILE_OPEN_FLAG_STATIC = 0x8, /* Relevant to secure file only */
dflet 0:e89ba455dbcf 177 _FS_FILE_OPEN_FLAG_VENDOR = 0x10, /* Relevant to secure file only */
dflet 0:e89ba455dbcf 178 _FS_FILE_PUBLIC_WRITE= 0x20, /* Relevant to secure file only, the file can be opened for write without Token */
dflet 0:e89ba455dbcf 179 _FS_FILE_PUBLIC_READ = 0x40 /* Relevant to secure file only, the file can be opened for read without Token */
dflet 0:e89ba455dbcf 180 } SlFileOpenFlags_e;
dflet 0:e89ba455dbcf 181
dflet 0:e89ba455dbcf 182 typedef enum {
dflet 0:e89ba455dbcf 183 _FS_MODE_SIZE_GRAN_256B = 0, /* MAX_SIZE = 64K */
dflet 0:e89ba455dbcf 184 _FS_MODE_SIZE_GRAN_1KB, /* MAX_SIZE = 256K */
dflet 0:e89ba455dbcf 185 _FS_MODE_SIZE_GRAN_4KB, /* MAX_SZIE = 1M */
dflet 0:e89ba455dbcf 186 _FS_MODE_SIZE_GRAN_16KB, /* MAX_SIZE = 4M */
dflet 0:e89ba455dbcf 187 _FS_MODE_SIZE_GRAN_64KB, /* MAX_SIZE = 16M */
dflet 0:e89ba455dbcf 188 _FS_MAX_MODE_SIZE_GRAN
dflet 0:e89ba455dbcf 189 } _SlFsFileOpenMaxSizeGran_e;
dflet 0:e89ba455dbcf 190
dflet 0:e89ba455dbcf 191 class cc3100_driver;
dflet 0:e89ba455dbcf 192
dflet 0:e89ba455dbcf 193 class cc3100_fs
dflet 0:e89ba455dbcf 194 {
dflet 0:e89ba455dbcf 195
dflet 0:e89ba455dbcf 196 public:
dflet 0:e89ba455dbcf 197
dflet 0:e89ba455dbcf 198 cc3100_fs(cc3100_driver &driver);
dflet 0:e89ba455dbcf 199
dflet 0:e89ba455dbcf 200 ~cc3100_fs();
dflet 0:e89ba455dbcf 201
dflet 0:e89ba455dbcf 202 /*****************************************************************************/
dflet 0:e89ba455dbcf 203 /* Internal Function prototypes */
dflet 0:e89ba455dbcf 204 /*****************************************************************************/
dflet 0:e89ba455dbcf 205 uint32_t _sl_GetCreateFsMode(uint32_t maxSizeInBytes,uint32_t accessFlags);
dflet 0:e89ba455dbcf 206 uint16_t _sl_Strlen(const uint8_t *buffer);
dflet 0:e89ba455dbcf 207
dflet 0:e89ba455dbcf 208 /*****************************************************************************/
dflet 0:e89ba455dbcf 209 /* Function prototypes */
dflet 0:e89ba455dbcf 210 /*****************************************************************************/
dflet 0:e89ba455dbcf 211
dflet 0:e89ba455dbcf 212 /*!
dflet 0:e89ba455dbcf 213 \brief open file for read or write from/to storage device
dflet 0:e89ba455dbcf 214
dflet 0:e89ba455dbcf 215 \param[in] pFileName File Name buffer pointer
dflet 0:e89ba455dbcf 216 \param[in] AccessModeAndMaxSize Options: As described below
dflet 0:e89ba455dbcf 217 \param[in] pToken Reserved for future use. Use NULL for this field
dflet 0:e89ba455dbcf 218 \param[out] pFileHandle Pointing on the file and used for read and write commands to the file
dflet 0:e89ba455dbcf 219
dflet 0:e89ba455dbcf 220 AccessModeAndMaxSize possible input \n
dflet 0:e89ba455dbcf 221 FS_MODE_OPEN_READ - Read a file \n
dflet 0:e89ba455dbcf 222 FS_MODE_OPEN_WRITE - Open for write for an existing file \n
dflet 0:e89ba455dbcf 223 FS_MODE_OPEN_CREATE(maxSizeInBytes,accessModeFlags) - Open for creating a new file. Max file size is defined in bytes. \n
dflet 0:e89ba455dbcf 224 For optimal FS size, use max size in 4K-512 bytes steps (e.g. 3584,7680,117760) \n
dflet 0:e89ba455dbcf 225 Several access modes bits can be combined together from SlFileOpenFlags_e enum
dflet 0:e89ba455dbcf 226
dflet 0:e89ba455dbcf 227 \return On success, zero is returned. On error, an error code is returned
dflet 0:e89ba455dbcf 228
dflet 0:e89ba455dbcf 229 \sa sl_FsRead sl_FsWrite sl_FsClose
dflet 0:e89ba455dbcf 230 \note belongs to \ref basic_api
dflet 0:e89ba455dbcf 231 \warning
dflet 0:e89ba455dbcf 232 \par Example:
dflet 0:e89ba455dbcf 233 \code
dflet 0:e89ba455dbcf 234 char* DeviceFileName = "MyFile.txt";
dflet 0:e89ba455dbcf 235 unsigned long MaxSize = 63 * 1024; //62.5K is max file size
dflet 0:e89ba455dbcf 236 long DeviceFileHandle = -1;
dflet 0:e89ba455dbcf 237 long RetVal; //negative retval is an error
dflet 0:e89ba455dbcf 238 unsigned long Offset = 0;
dflet 0:e89ba455dbcf 239 uint8_t InputBuffer[100];
dflet 0:e89ba455dbcf 240
dflet 0:e89ba455dbcf 241 // Create a file and write data. The file in this example is secured, without signature and with a fail safe commit
dflet 0:e89ba455dbcf 242 RetVal = sl_FsOpen((uint8_t *)DeviceFileName,
dflet 0:e89ba455dbcf 243 FS_MODE_OPEN_CREATE(MaxSize , _FS_FILE_OPEN_FLAG_NO_SIGNATURE_TEST | _FS_FILE_OPEN_FLAG_COMMIT ),
dflet 0:e89ba455dbcf 244 NULL, &DeviceFileHandle);
dflet 0:e89ba455dbcf 245
dflet 0:e89ba455dbcf 246 Offset = 0;
dflet 0:e89ba455dbcf 247 //Preferred in secure file that the Offset and the length will be aligned to 16 bytes.
dflet 0:e89ba455dbcf 248 RetVal = sl_FsWrite( DeviceFileHandle, Offset, (uint8_t *)"HelloWorld", strlen("HelloWorld"));
dflet 0:e89ba455dbcf 249
dflet 0:e89ba455dbcf 250 RetVal = sl_FsClose(DeviceFileHandle, NULL, NULL , 0);
dflet 0:e89ba455dbcf 251
dflet 0:e89ba455dbcf 252 // open the same file for read, using the Token we got from the creation procedure above
dflet 0:e89ba455dbcf 253 RetVal = sl_FsOpen((uint8_t *)DeviceFileName,
dflet 0:e89ba455dbcf 254 FS_MODE_OPEN_READ,
dflet 0:e89ba455dbcf 255 NULL, &DeviceFileHandle);
dflet 0:e89ba455dbcf 256
dflet 0:e89ba455dbcf 257 Offset = 0;
dflet 0:e89ba455dbcf 258 RetVal = sl_FsRead( DeviceFileHandle, Offset, (uint8_t *)InputBuffer, strlen("HelloWorld"));
dflet 0:e89ba455dbcf 259
dflet 0:e89ba455dbcf 260 RetVal = sl_FsClose(DeviceFileHandle, NULL, NULL , 0);
dflet 0:e89ba455dbcf 261
dflet 0:e89ba455dbcf 262 \endcode
dflet 0:e89ba455dbcf 263 */
dflet 0:e89ba455dbcf 264 #if _SL_INCLUDE_FUNC(sl_FsOpen)
dflet 0:e89ba455dbcf 265 int32_t sl_FsOpen(uint8_t *pFileName,uint32_t AccessModeAndMaxSize,uint32_t *pToken,int32_t *pFileHandle);
dflet 0:e89ba455dbcf 266 #endif
dflet 0:e89ba455dbcf 267
dflet 0:e89ba455dbcf 268 /*!
dflet 0:e89ba455dbcf 269 \brief close file in storage device
dflet 0:e89ba455dbcf 270
dflet 0:e89ba455dbcf 271 \param[in] FileHdl Pointer to the file (assigned from sl_FsOpen)
dflet 0:e89ba455dbcf 272 \param[in] pCeritificateFileName Reserved for future use. Use NULL.
dflet 0:e89ba455dbcf 273 \param[in] pSignature Reserved for future use. Use NULL.
dflet 0:e89ba455dbcf 274 \param[in] SignatureLen Reserved for future use. Use 0.
dflet 0:e89ba455dbcf 275
dflet 0:e89ba455dbcf 276
dflet 0:e89ba455dbcf 277 \return On success, zero is returned. On error, an error code is returned
dflet 0:e89ba455dbcf 278
dflet 0:e89ba455dbcf 279 \sa sl_FsRead sl_FsWrite sl_FsOpen
dflet 0:e89ba455dbcf 280 \note Call the fs_Close with signature = 'A' signature len = 1 for activating an abort action
dflet 0:e89ba455dbcf 281 \warning
dflet 0:e89ba455dbcf 282 \par Example:
dflet 0:e89ba455dbcf 283 \code
dflet 0:e89ba455dbcf 284 sl_FsClose(FileHandle,0,0,0);
dflet 0:e89ba455dbcf 285 \endcode
dflet 0:e89ba455dbcf 286 */
dflet 0:e89ba455dbcf 287 #if _SL_INCLUDE_FUNC(sl_FsClose)
dflet 0:e89ba455dbcf 288 int16_t sl_FsClose(int32_t FileHdl,uint8_t* pCeritificateFileName,uint8_t* pSignature,uint32_t SignatureLen);
dflet 0:e89ba455dbcf 289 #endif
dflet 0:e89ba455dbcf 290
dflet 0:e89ba455dbcf 291 /*!
dflet 0:e89ba455dbcf 292 \brief Read block of data from a file in storage device
dflet 0:e89ba455dbcf 293
dflet 0:e89ba455dbcf 294 \param[in] FileHdl Pointer to the file (assigned from sl_FsOpen)
dflet 0:e89ba455dbcf 295 \param[in] Offset Offset to specific read block
dflet 0:e89ba455dbcf 296 \param[out] pData Pointer for the received data
dflet 0:e89ba455dbcf 297 \param[in] Len Length of the received data
dflet 0:e89ba455dbcf 298
dflet 0:e89ba455dbcf 299 \return On success, returns the number of read bytes. On error, negative number is returned
dflet 0:e89ba455dbcf 300
dflet 0:e89ba455dbcf 301 \sa sl_FsClose sl_FsWrite sl_FsOpen
dflet 0:e89ba455dbcf 302 \note belongs to \ref basic_api
dflet 0:e89ba455dbcf 303 \warning
dflet 0:e89ba455dbcf 304 \par Example:
dflet 0:e89ba455dbcf 305 \code
dflet 0:e89ba455dbcf 306 Status = sl_FsRead(FileHandle, 0, &readBuff[0], readSize);
dflet 0:e89ba455dbcf 307 \endcode
dflet 0:e89ba455dbcf 308 */
dflet 0:e89ba455dbcf 309 #if _SL_INCLUDE_FUNC(sl_FsRead)
dflet 0:e89ba455dbcf 310 int32_t sl_FsRead(int32_t FileHdl,uint32_t Offset ,uint8_t* pData,uint32_t Len);
dflet 0:e89ba455dbcf 311 #endif
dflet 0:e89ba455dbcf 312
dflet 0:e89ba455dbcf 313 /*!
dflet 0:e89ba455dbcf 314 \brief write block of data to a file in storage device
dflet 0:e89ba455dbcf 315
dflet 0:e89ba455dbcf 316 \param[in] FileHdl Pointer to the file (assigned from sl_FsOpen)
dflet 0:e89ba455dbcf 317 \param[in] Offset Offset to specific block to be written
dflet 0:e89ba455dbcf 318 \param[in] pData Pointer the transmitted data to the storage device
dflet 0:e89ba455dbcf 319 \param[in] Len Length of the transmitted data
dflet 0:e89ba455dbcf 320
dflet 0:e89ba455dbcf 321 \return On success, returns the number of written bytes. On error, an error code is returned
dflet 0:e89ba455dbcf 322
dflet 0:e89ba455dbcf 323 \sa
dflet 0:e89ba455dbcf 324 \note belongs to \ref basic_api
dflet 0:e89ba455dbcf 325 \warning
dflet 0:e89ba455dbcf 326 \par Example:
dflet 0:e89ba455dbcf 327 \code
dflet 0:e89ba455dbcf 328 Status = sl_FsWrite(FileHandle, 0, &buff[0], readSize);
dflet 0:e89ba455dbcf 329 \endcode
dflet 0:e89ba455dbcf 330 */
dflet 0:e89ba455dbcf 331 #if _SL_INCLUDE_FUNC(sl_FsWrite)
dflet 0:e89ba455dbcf 332 int32_t sl_FsWrite(int32_t FileHdl,uint32_t Offset,uint8_t* pData,uint32_t Len);
dflet 0:e89ba455dbcf 333 #endif
dflet 0:e89ba455dbcf 334
dflet 0:e89ba455dbcf 335 /*!
dflet 0:e89ba455dbcf 336 \brief get info on a file
dflet 0:e89ba455dbcf 337
dflet 0:e89ba455dbcf 338 \param[in] pFileName File name
dflet 0:e89ba455dbcf 339 \param[in] Token Reserved for future use. Use 0
dflet 0:e89ba455dbcf 340 \param[out] pFsFileInfo Returns the File's Information: flags,file size, allocated size and Tokens
dflet 0:e89ba455dbcf 341
dflet 0:e89ba455dbcf 342 \return On success, zero is returned. On error, an error code is returned
dflet 0:e89ba455dbcf 343
dflet 0:e89ba455dbcf 344 \sa sl_FsOpen
dflet 0:e89ba455dbcf 345 \note belongs to \ref basic_api
dflet 0:e89ba455dbcf 346 \warning
dflet 0:e89ba455dbcf 347 \par Example:
dflet 0:e89ba455dbcf 348 \code
dflet 0:e89ba455dbcf 349 Status = sl_FsGetInfo("FileName.html",0,&FsFileInfo);
dflet 0:e89ba455dbcf 350 \endcode
dflet 0:e89ba455dbcf 351 */
dflet 0:e89ba455dbcf 352 #if _SL_INCLUDE_FUNC(sl_FsGetInfo)
dflet 0:e89ba455dbcf 353 int16_t sl_FsGetInfo(uint8_t *pFileName,uint32_t Token,SlFsFileInfo_t* pFsFileInfo);
dflet 0:e89ba455dbcf 354 #endif
dflet 0:e89ba455dbcf 355
dflet 0:e89ba455dbcf 356 /*!
dflet 0:e89ba455dbcf 357 \brief Delete specific file from a storage or all files from a storage (format)
dflet 0:e89ba455dbcf 358
dflet 0:e89ba455dbcf 359 \param[in] pFileName File Name
dflet 0:e89ba455dbcf 360 \param[in] Token Reserved for future use. Use 0
dflet 0:e89ba455dbcf 361 \return On success, zero is returned. On error, an error code is returned
dflet 0:e89ba455dbcf 362
dflet 0:e89ba455dbcf 363 \sa
dflet 0:e89ba455dbcf 364 \note belongs to \ref basic_api
dflet 0:e89ba455dbcf 365 \warning
dflet 0:e89ba455dbcf 366 \par Example:
dflet 0:e89ba455dbcf 367 \code
dflet 0:e89ba455dbcf 368 Status = sl_FsDel("FileName.html",0);
dflet 0:e89ba455dbcf 369 \endcode
dflet 0:e89ba455dbcf 370 */
dflet 0:e89ba455dbcf 371 #if _SL_INCLUDE_FUNC(sl_FsDel)
dflet 0:e89ba455dbcf 372 int16_t sl_FsDel(uint8_t *pFileName,uint32_t Token);
dflet 0:e89ba455dbcf 373 #endif
dflet 0:e89ba455dbcf 374
dflet 0:e89ba455dbcf 375 private:
dflet 0:e89ba455dbcf 376
dflet 0:e89ba455dbcf 377 cc3100_driver &_driver;
dflet 0:e89ba455dbcf 378
dflet 0:e89ba455dbcf 379 };//class
dflet 0:e89ba455dbcf 380
dflet 0:e89ba455dbcf 381 }//namespace mbed_cc3100
dflet 0:e89ba455dbcf 382
dflet 0:e89ba455dbcf 383 /*!
dflet 0:e89ba455dbcf 384
dflet 0:e89ba455dbcf 385 Close the Doxygen group.
dflet 0:e89ba455dbcf 386 @}
dflet 0:e89ba455dbcf 387
dflet 0:e89ba455dbcf 388 */
dflet 0:e89ba455dbcf 389
dflet 0:e89ba455dbcf 390 #endif /* __FS_H__ */
dflet 0:e89ba455dbcf 391
dflet 0:e89ba455dbcf 392