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 UDPSOCKET_H
okini3939 4:9a2415f2ab07 23 #define UDPSOCKET_H
okini3939 4:9a2415f2ab07 24
okini3939 4:9a2415f2ab07 25 #include "Endpoint.h"
okini3939 4:9a2415f2ab07 26 #include "Socket.h"
okini3939 4:9a2415f2ab07 27
okini3939 4:9a2415f2ab07 28 #include <cstdint>
okini3939 4:9a2415f2ab07 29
okini3939 4:9a2415f2ab07 30 /**
okini3939 4:9a2415f2ab07 31 UDP Socket
okini3939 4:9a2415f2ab07 32 */
okini3939 4:9a2415f2ab07 33 class UDPSocket: public Socket {
okini3939 4:9a2415f2ab07 34
okini3939 4:9a2415f2ab07 35 public:
okini3939 4:9a2415f2ab07 36 /** Instantiate an UDP Socket.
okini3939 4:9a2415f2ab07 37 */
okini3939 4:9a2415f2ab07 38 UDPSocket();
okini3939 4:9a2415f2ab07 39
okini3939 4:9a2415f2ab07 40 /** Init the UDP Client Socket without binding it to any specific port
okini3939 4:9a2415f2ab07 41 \return 0 on success, -1 on failure.
okini3939 4:9a2415f2ab07 42 */
okini3939 4:9a2415f2ab07 43 int init(void);
okini3939 4:9a2415f2ab07 44
okini3939 4:9a2415f2ab07 45 /** Bind a UDP Server Socket to a specific port
okini3939 4:9a2415f2ab07 46 \param port The port to listen for incoming connections on
okini3939 4:9a2415f2ab07 47 \return 0 on success, -1 on failure.
okini3939 4:9a2415f2ab07 48 */
okini3939 4:9a2415f2ab07 49 int bind(int port = -1);
okini3939 4:9a2415f2ab07 50
okini3939 4:9a2415f2ab07 51 /** Send a packet to a remote endpoint
okini3939 4:9a2415f2ab07 52 \param remote The remote endpoint
okini3939 4:9a2415f2ab07 53 \param packet The packet to be sent
okini3939 4:9a2415f2ab07 54 \param length The length of the packet to be sent
okini3939 4:9a2415f2ab07 55 \return the number of written bytes on success (>=0) or -1 on failure
okini3939 4:9a2415f2ab07 56 */
okini3939 4:9a2415f2ab07 57 int sendTo(Endpoint &remote, char *packet, int length);
okini3939 4:9a2415f2ab07 58
okini3939 4:9a2415f2ab07 59 /** Receive a packet from a remote endpoint
okini3939 4:9a2415f2ab07 60 \param remote The remote endpoint
okini3939 4:9a2415f2ab07 61 \param buffer The buffer for storing the incoming packet data. If a packet
okini3939 4:9a2415f2ab07 62 is too long to fit in the supplied buffer, excess bytes are discarded
okini3939 4:9a2415f2ab07 63 \param length The length of the buffer
okini3939 4:9a2415f2ab07 64 \return the number of received bytes on success (>=0) or -1 on failure
okini3939 4:9a2415f2ab07 65 */
okini3939 4:9a2415f2ab07 66 int receiveFrom(Endpoint &remote, char *buffer, int length);
okini3939 4:9a2415f2ab07 67
okini3939 4:9a2415f2ab07 68 private:
okini3939 4:9a2415f2ab07 69 bool endpoint_connected;
okini3939 4:9a2415f2ab07 70
okini3939 4:9a2415f2ab07 71 };
okini3939 4:9a2415f2ab07 72
okini3939 4:9a2415f2ab07 73 #include "def.h"
okini3939 4:9a2415f2ab07 74
okini3939 4:9a2415f2ab07 75 #endif