Host library for controlling a WiConnect enabled Wi-Fi module.
Dependents: wiconnect-ota_example wiconnect-web_setup_example wiconnect-test-console wiconnect-tcp_server_example ... more
FileInterface.h
- Committer:
- dan_ackme
- Date:
- 2014-08-12
- Revision:
- 11:ea484e1b7fc4
- Parent:
- 1:6ec9998427ad
- Child:
- 13:2b51f5267c92
File content as of revision 11:ea484e1b7fc4:
/* * Copyright 2014, ACKme Networks * All Rights Reserved. * * This is UNPUBLISHED PROPRIETARY SOURCE CODE of ACKme Networks; * the contents of this file may not be disclosed to third parties, copied * or duplicated in any form, in whole or in part, without the prior * written permission of ACKme Networks. */ #pragma once #include "mbed.h" #include "WiconnectTypes.h" #include "types/FileList.h" /** * @ingroup api_file_macro * @brief The maximum filename size of a file on the WiConnect WiFi module filesystem */ #define FILE_NAME_MAX_SIZE 96 /** * @ingroup api_file_macro * @def FILE_MAKE_VERSION(major, minor, patch, rc) * @brief Combine <\a major>.<\a minor>.<\a patch>.<\a rc> and create version as a uint32_t */ #define FILE_MAKE_VERSION(major, minor, patch, rc) ((unsigned int)((major) << 27)|(unsigned int)((minor) << 21)|(unsigned int)((patch) << 8)|(unsigned int)((rc) << 0)) /** * @ingroup api_file_macro * @def FILE_VERSION_ARGS(version) * @brief Given a uint32_t \a version, return arguments for a variable argument function such as printf(). The format string is: %d.%d.%d.%d */ #define FILE_VERSION_ARGS(version) (unsigned int)((version >> 27) & 0x1F),(unsigned int)((version >> 21) & 0x3F),(unsigned int)((version >> 8) & 0x1FFF),(unsigned int)(version & 0xFF) namespace wiconnect { /** * @ingroup types_file * * @brief The provides an interface for creating TCP/UDP/TLS/HTTP client sockets. * A client socket connects to a remote server. * */ class FileInterface { public: /** * @ingroup api_file * * @brief Create a file on the Wiconnect WiFi module flash filesystem. */ WiconnectResult createFile(const ReaderFunc &reader, void *user, const char *name, uint32_t size, uint32_t version = 0, FileType type = FILE_TYPE_ANY, bool isEssential = false, int32_t checksum = -1); /** * @ingroup api_file * * @brief Open a file on the Wiconnect WiFi module flash filesystem for reading. */ WiconnectResult openFile(File &file, const char *name); /** * @ingroup api_file * * @brief Delete a file for the Wiconnect WiFi module flash filesystem. */ WiconnectResult deleteFile(const char *name); /** * @ingroup api_file * * @brief Delete a file for the Wiconnect WiFi module flash filesystem. */ WiconnectResult deleteFile(const File &file); /** * @ingroup api_file * * @brief List the files on the Wiconnect WiFi module flash filesystem. */ WiconnectResult listFiles(FileList &list, const char *name = NULL, FileType type = FILE_TYPE_ANY, uint32_t version = 0); // ------------------------------------------------------------------------ /** * @ingroup conversion_util * * @brief Convert file version uint32 to string. */ static const char* fileVersionIntToStr(uint32_t version, bool verbose = true, char *buffer = NULL); /** * @ingroup conversion_util * * @brief Convert string to file version uint32. */ static bool fileVersionStrToInt(const char *versionStr, uint32_t *versionIntPtr); /** * @ingroup conversion_util * * Convert @ref FileType to string. */ static const char* fileTypeToStr(FileType type); /** * @ingroup conversion_util * * @brief Convert @ref FileFlags to string. */ static const char* fileFlagsToStr(FileFlags flags, char *buffer = NULL); protected: FileInterface(Wiconnect *wiconnect); WiconnectResult processFileList(char *responseStr, FileList &list, const char *name, FileType type, uint32_t version); private: Wiconnect *wiconnect; }; }