Home Alert System

Dependencies:   PWM_Tone_Library DHT

Committer:
ethaderu
Date:
Tue Mar 05 02:34:44 2019 +0000
Revision:
3:78f223d34f36
Publish 1

Who changed what in which revision?

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