see http://mbed.org/users/okini3939/notebook/wattmeter-shield-on-mbed/

Dependencies:   mbed

Fork of GSwifi_xively by gs fan

Committer:
okini3939
Date:
Wed Nov 27 08:18:45 2013 +0000
Revision:
4:9a2415f2ab07
update GSwifiInterface library

Who changed what in which revision?

UserRevisionLine numberNew contents of line
okini3939 4:9a2415f2ab07 1 /* Copyright (C) 2012 mbed.org, MIT License
okini3939 4:9a2415f2ab07 2 *
okini3939 4:9a2415f2ab07 3 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
okini3939 4:9a2415f2ab07 4 * and associated documentation files (the "Software"), to deal in the Software without restriction,
okini3939 4:9a2415f2ab07 5 * including without limitation the rights to use, copy, modify, merge, publish, distribute,
okini3939 4:9a2415f2ab07 6 * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
okini3939 4:9a2415f2ab07 7 * furnished to do so, subject to the following conditions:
okini3939 4:9a2415f2ab07 8 *
okini3939 4:9a2415f2ab07 9 * The above copyright notice and this permission notice shall be included in all copies or
okini3939 4:9a2415f2ab07 10 * substantial portions of the Software.
okini3939 4:9a2415f2ab07 11 *
okini3939 4:9a2415f2ab07 12 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
okini3939 4:9a2415f2ab07 13 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
okini3939 4:9a2415f2ab07 14 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
okini3939 4:9a2415f2ab07 15 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
okini3939 4:9a2415f2ab07 16 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
okini3939 4:9a2415f2ab07 17 */
okini3939 4:9a2415f2ab07 18 /* Copyright (C) 2013 gsfan, MIT License
okini3939 4:9a2415f2ab07 19 * port to the GainSpan Wi-FI module GS1011
okini3939 4:9a2415f2ab07 20 */
okini3939 4:9a2415f2ab07 21
okini3939 4:9a2415f2ab07 22 #ifndef TCPSOCKET_H
okini3939 4:9a2415f2ab07 23 #define TCPSOCKET_H
okini3939 4:9a2415f2ab07 24
okini3939 4:9a2415f2ab07 25 #include "Socket.h"
okini3939 4:9a2415f2ab07 26 #include "Endpoint.h"
okini3939 4:9a2415f2ab07 27
okini3939 4:9a2415f2ab07 28 /**
okini3939 4:9a2415f2ab07 29 TCP socket connection
okini3939 4:9a2415f2ab07 30 */
okini3939 4:9a2415f2ab07 31 class TCPSocketConnection: public Socket, public Endpoint {
okini3939 4:9a2415f2ab07 32
okini3939 4:9a2415f2ab07 33 public:
okini3939 4:9a2415f2ab07 34 /** TCP socket connection
okini3939 4:9a2415f2ab07 35 */
okini3939 4:9a2415f2ab07 36 TCPSocketConnection();
okini3939 4:9a2415f2ab07 37
okini3939 4:9a2415f2ab07 38 /** Connects this TCP socket to the server
okini3939 4:9a2415f2ab07 39 \param host The host to connect to. It can either be an IP Address or a hostname that will be resolved with DNS.
okini3939 4:9a2415f2ab07 40 \param port The host's port to connect to.
okini3939 4:9a2415f2ab07 41 \return 0 on success, -1 on failure.
okini3939 4:9a2415f2ab07 42 */
okini3939 4:9a2415f2ab07 43 int connect(const char* host, const int port);
okini3939 4:9a2415f2ab07 44
okini3939 4:9a2415f2ab07 45 /** Check if the socket is connected
okini3939 4:9a2415f2ab07 46 \return true if connected, false otherwise.
okini3939 4:9a2415f2ab07 47 */
okini3939 4:9a2415f2ab07 48 bool is_connected(void);
okini3939 4:9a2415f2ab07 49
okini3939 4:9a2415f2ab07 50 /** Send data to the remote host.
okini3939 4:9a2415f2ab07 51 \param data The buffer to send to the host.
okini3939 4:9a2415f2ab07 52 \param length The length of the buffer to send.
okini3939 4:9a2415f2ab07 53 \return the number of written bytes on success (>=0) or -1 on failure
okini3939 4:9a2415f2ab07 54 */
okini3939 4:9a2415f2ab07 55 int send(char* data, int length);
okini3939 4:9a2415f2ab07 56
okini3939 4:9a2415f2ab07 57 /** Send all the data to the remote host.
okini3939 4:9a2415f2ab07 58 \param data The buffer to send to the host.
okini3939 4:9a2415f2ab07 59 \param length The length of the buffer to send.
okini3939 4:9a2415f2ab07 60 \return the number of written bytes on success (>=0) or -1 on failure
okini3939 4:9a2415f2ab07 61 */
okini3939 4:9a2415f2ab07 62 int send_all(char* data, int length);
okini3939 4:9a2415f2ab07 63
okini3939 4:9a2415f2ab07 64 /** Receive data from the remote host.
okini3939 4:9a2415f2ab07 65 \param data The buffer in which to store the data received from the host.
okini3939 4:9a2415f2ab07 66 \param length The maximum length of the buffer.
okini3939 4:9a2415f2ab07 67 \return the number of received bytes on success (>=0) or -1 on failure
okini3939 4:9a2415f2ab07 68 */
okini3939 4:9a2415f2ab07 69 int receive(char* data, int length);
okini3939 4:9a2415f2ab07 70
okini3939 4:9a2415f2ab07 71 /** Receive all the data from the remote host.
okini3939 4:9a2415f2ab07 72 \param data The buffer in which to store the data received from the host.
okini3939 4:9a2415f2ab07 73 \param length The maximum length of the buffer.
okini3939 4:9a2415f2ab07 74 \return the number of received bytes on success (>=0) or -1 on failure
okini3939 4:9a2415f2ab07 75 */
okini3939 4:9a2415f2ab07 76 int receive_all(char* data, int length);
okini3939 4:9a2415f2ab07 77
okini3939 4:9a2415f2ab07 78 void acceptCID (int cid);
okini3939 4:9a2415f2ab07 79 };
okini3939 4:9a2415f2ab07 80
okini3939 4:9a2415f2ab07 81 #endif