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

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers WiconnectFile.h Source File

WiconnectFile.h

00001 /**
00002  * ACKme WiConnect Host Library is licensed under the BSD licence: 
00003  * 
00004  * Copyright (c)2014 ACKme Networks.
00005  * All rights reserved. 
00006  * 
00007  * Redistribution and use in source and binary forms, with or without modification, 
00008  * are permitted provided that the following conditions are met: 
00009  * 
00010  * 1. Redistributions of source code must retain the above copyright notice, 
00011  * this list of conditions and the following disclaimer. 
00012  * 2. Redistributions in binary form must reproduce the above copyright notice, 
00013  * this list of conditions and the following disclaimer in the documentation 
00014  * and/or other materials provided with the distribution. 
00015  * 3. The name of the author may not be used to endorse or promote products 
00016  * derived from this software without specific prior written permission. 
00017  * 
00018  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS AND ANY EXPRESS OR IMPLIED 
00019  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
00020  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 
00021  * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
00022  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 
00023  * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
00024  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
00025  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 
00026  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 
00027  * OF SUCH DAMAGE.
00028  */
00029 #pragma once
00030 
00031 
00032 #include "Wiconnect.h"
00033 
00034 namespace wiconnect
00035 {
00036 
00037 
00038 /**
00039  * @ingroup api_file_types
00040  *
00041  * @brief WiConnect WiFi module file object.
00042  *
00043  */
00044 class WiconnectFile
00045 {
00046 public:
00047     WiconnectFile(int rxBufferLen = 0, void *rxBuffer = NULL);
00048     ~WiconnectFile();
00049 
00050     const char* getName() const;
00051     uint32_t getSize() const;
00052     FileType getType() const;
00053     FileFlags getFlags() const;
00054     uint32_t getVersion() const;
00055     const char* getVersionStr(char *buffer = NULL) const;
00056 
00057     WiconnectResult close();
00058     WiconnectResult read(void* buffer, uint16_t maxLength, uint16_t *bytesRead);
00059     WiconnectResult read(uint8_t **bufferPtr = NULL, uint16_t *bytesReadPtr = NULL);
00060     WiconnectResult getc(uint8_t *c);
00061     void clearRxBuffer();
00062 
00063     const WiconnectFile* getNext() const;
00064     const WiconnectFile* getPrevious() const;
00065 
00066 protected:
00067     WiconnectResult openForRead(uint8_t handle, const char *filename);
00068     WiconnectResult initWithListing(const char *typeStr, const char *flagsStr, const char* sizeStr, const char *versionStr, const char *nameStr);
00069 
00070     uint8_t handle;
00071     bool readEnabled;
00072     char name[WICONNECT_MAX_FILENAME_SIZE];
00073     uint32_t size;
00074     FileType type;
00075     FileFlags flags;
00076     uint32_t version;
00077     Wiconnect *wiconnect;
00078     WiconnectFile *next;
00079     WiconnectFile *previous;
00080 
00081     Buffer rxBuffer;
00082 
00083     void* operator new(size_t size);
00084     void operator delete(void*);
00085 
00086     friend class FileInterface;
00087     friend class FileList;
00088 };
00089 
00090 }