SNICInterface for ThingPlug Example

Dependents:   ThingPlug_WiFi_Example ThingPlug_WiFi_Example_2

Fork of SNICInterface by muRata

Committer:
lesmin
Date:
Thu Aug 13 06:44:01 2015 +0000
Revision:
54:cb4c105a2ad2
Parent:
41:1c1b5ad4d491
retry codes are added by STKorea

Who changed what in which revision?

UserRevisionLine numberNew contents of line
kishino 20:dd736d328de6 1 /* Copyright (C) 2012 mbed.org, MIT License
kishino 20:dd736d328de6 2 *
kishino 20:dd736d328de6 3 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
kishino 20:dd736d328de6 4 * and associated documentation files (the "Software"), to deal in the Software without restriction,
kishino 20:dd736d328de6 5 * including without limitation the rights to use, copy, modify, merge, publish, distribute,
kishino 20:dd736d328de6 6 * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
kishino 20:dd736d328de6 7 * furnished to do so, subject to the following conditions:
kishino 20:dd736d328de6 8 *
kishino 20:dd736d328de6 9 * The above copyright notice and this permission notice shall be included in all copies or
kishino 20:dd736d328de6 10 * substantial portions of the Software.
kishino 20:dd736d328de6 11 *
kishino 20:dd736d328de6 12 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
kishino 20:dd736d328de6 13 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
kishino 20:dd736d328de6 14 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
kishino 20:dd736d328de6 15 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
kishino 20:dd736d328de6 16 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
kishino 20:dd736d328de6 17 */
kishino 39:a1233ca02edf 18 /* Copyright (C) 2014 Murata Manufacturing Co.,Ltd., MIT License
kishino 41:1c1b5ad4d491 19 * port to the muRata, SWITCH SCIENCE Wi-FI module TypeYD SNIC-UART.
kishino 39:a1233ca02edf 20 */
kishino 20:dd736d328de6 21 #ifndef UDPSOCKET_H
kishino 20:dd736d328de6 22 #define UDPSOCKET_H
kishino 20:dd736d328de6 23
kishino 20:dd736d328de6 24 #include "Socket.h"
kishino 20:dd736d328de6 25 #include "Endpoint.h"
kishino 20:dd736d328de6 26
kishino 20:dd736d328de6 27 /**
kishino 23:4ff2231ff9ba 28 Interface class for UDP socket of using SNIC UART.
kishino 20:dd736d328de6 29 */
kishino 20:dd736d328de6 30 class UDPSocket : public Socket {
kishino 20:dd736d328de6 31
kishino 20:dd736d328de6 32 public:
kishino 20:dd736d328de6 33 /** Instantiate an UDP Socket.
kishino 20:dd736d328de6 34 */
kishino 20:dd736d328de6 35 UDPSocket();
kishino 26:f2e1030964e4 36 virtual ~UDPSocket();
kishino 20:dd736d328de6 37
kishino 20:dd736d328de6 38 /** Init the UDP Client Socket without binding it to any specific port
kishino 20:dd736d328de6 39 \return 0 on success, -1 on failure.
kishino 20:dd736d328de6 40 */
kishino 20:dd736d328de6 41 int init(void);
kishino 20:dd736d328de6 42
kishino 20:dd736d328de6 43 /** Bind a UDP Server Socket to a specific port
kishino 20:dd736d328de6 44 \param port The port to listen for incoming connections on
kishino 20:dd736d328de6 45 \return 0 on success, -1 on failure.
kishino 20:dd736d328de6 46 */
kishino 33:33f1bc919486 47 int bind(short port);
kishino 20:dd736d328de6 48
kishino 20:dd736d328de6 49 /** Send a packet to a remote endpoint
kishino 20:dd736d328de6 50 \param remote The remote endpoint
kishino 20:dd736d328de6 51 \param packet The packet to be sent
kishino 20:dd736d328de6 52 \param length The length of the packet to be sent
kishino 20:dd736d328de6 53 \return the number of written bytes on success (>=0) or -1 on failure
kishino 20:dd736d328de6 54 */
kishino 20:dd736d328de6 55 int sendTo(Endpoint &remote, char *packet, int length);
kishino 20:dd736d328de6 56
kishino 20:dd736d328de6 57 /** Receive a packet from a remote endpoint
kishino 20:dd736d328de6 58 \param remote The remote endpoint
kishino 20:dd736d328de6 59 \param buffer The buffer for storing the incoming packet data. If a packet
kishino 20:dd736d328de6 60 is too long to fit in the supplied buffer, excess bytes are discarded
kishino 20:dd736d328de6 61 \param length The length of the buffer
kishino 20:dd736d328de6 62 \return the number of received bytes on success (>=0) or -1 on failure
kishino 20:dd736d328de6 63 */
kishino 20:dd736d328de6 64 int receiveFrom(Endpoint &remote, char *buffer, int length);
kishino 20:dd736d328de6 65 };
kishino 20:dd736d328de6 66
kishino 20:dd736d328de6 67 #endif