Midnight Cow / ThingerIO

Dependencies:   DHT WIZnetInterface mbed-src

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers TCPSocketConnectionArdu.h Source File

TCPSocketConnectionArdu.h

00001 /* Copyright (C) 2012 mbed.org, MIT License
00002  *
00003  * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
00004  * and associated documentation files (the "Software"), to deal in the Software without restriction,
00005  * including without limitation the rights to use, copy, modify, merge, publish, distribute,
00006  * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
00007  * furnished to do so, subject to the following conditions:
00008  *
00009  * The above copyright notice and this permission notice shall be included in all copies or
00010  * substantial portions of the Software.
00011  *
00012  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
00013  * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00014  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
00015  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
00016  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00017  */
00018 
00019 #ifndef TCPSOCKET_ARDU_H
00020 #define TCPSOCKET_ARUD_H
00021 
00022 #include "EthernetInterface.h"
00023 /**
00024 TCP socket connection for compatible Arduino
00025 */
00026 class TCPSocketConnectionArdu : public TCPSocketConnection {
00027     
00028 public:
00029     /** TCP socket connection
00030     */
00031     TCPSocketConnectionArdu() {};
00032     virtual ~TCPSocketConnectionArdu() { TCPSocketConnection::close(); };
00033      
00034     ssize_t write(uint8_t);
00035 
00036     /** Send data to the remote host.
00037     \param data The buffer to send to the host.
00038     \param length The length of the buffer to send.
00039     \return the number of written bytes on success (>=0) or -1 on failure
00040      */
00041     virtual ssize_t write(const void *buf, size_t size);
00042     virtual int available();
00043     ssize_t read();    
00044     virtual ssize_t read(void *buf, size_t size);    
00045     virtual ssize_t readBytes(uint8_t* buf, size_t size);
00046     virtual ssize_t peek();
00047     virtual void flush();
00048     virtual void stop();
00049 
00050     /** Check if the socket is connected
00051     \return true if connected, false otherwise.
00052     */
00053     virtual uint8_t connected();
00054     virtual operator bool(); 
00055        
00056     friend class TCPSocketServer;
00057     
00058 };
00059 
00060 #endif