Catie fork

Dependencies:   SDFileSystem X_NUCLEO_IKS01A1

Fork of ATT_AWS_IoT_demo by AT&T IoT

Committer:
ampembeng
Date:
Thu Dec 01 18:05:38 2016 +0000
Revision:
15:6f2798e45099
Initial commit.  Demo works with both the FRDM wired Ethernet and the Avnet Shield wireless modem.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ampembeng 15:6f2798e45099 1 /* =====================================================================
ampembeng 15:6f2798e45099 2 Copyright © 2016, Avnet (R)
ampembeng 15:6f2798e45099 3
ampembeng 15:6f2798e45099 4 Contributors:
ampembeng 15:6f2798e45099 5 * James M Flynn, www.em.avnet.com
ampembeng 15:6f2798e45099 6
ampembeng 15:6f2798e45099 7 Licensed under the Apache License, Version 2.0 (the "License");
ampembeng 15:6f2798e45099 8 you may not use this file except in compliance with the License.
ampembeng 15:6f2798e45099 9 You may obtain a copy of the License at
ampembeng 15:6f2798e45099 10
ampembeng 15:6f2798e45099 11 http://www.apache.org/licenses/LICENSE-2.0
ampembeng 15:6f2798e45099 12
ampembeng 15:6f2798e45099 13 Unless required by applicable law or agreed to in writing,
ampembeng 15:6f2798e45099 14 software distributed under the License is distributed on an
ampembeng 15:6f2798e45099 15 "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
ampembeng 15:6f2798e45099 16 either express or implied. See the License for the specific
ampembeng 15:6f2798e45099 17 language governing permissions and limitations under the License.
ampembeng 15:6f2798e45099 18
ampembeng 15:6f2798e45099 19 @file WNCInterface.cpp
ampembeng 15:6f2798e45099 20 @version 1.0
ampembeng 15:6f2798e45099 21 @date Sept 2016
ampembeng 15:6f2798e45099 22
ampembeng 15:6f2798e45099 23 ======================================================================== */
ampembeng 15:6f2798e45099 24
ampembeng 15:6f2798e45099 25
ampembeng 15:6f2798e45099 26 #ifndef WNCUDPSOCKET_H
ampembeng 15:6f2798e45099 27 #define WNCUDPSOCKET_H
ampembeng 15:6f2798e45099 28
ampembeng 15:6f2798e45099 29 #include "WNCSocket.h"
ampembeng 15:6f2798e45099 30 #include "WNCEndpoint.h"
ampembeng 15:6f2798e45099 31
ampembeng 15:6f2798e45099 32 /**
ampembeng 15:6f2798e45099 33 UDP WNCSocket
ampembeng 15:6f2798e45099 34 */
ampembeng 15:6f2798e45099 35 class WNCUDPSocket : public WNCSocket, public WNCInterface {
ampembeng 15:6f2798e45099 36
ampembeng 15:6f2798e45099 37 public:
ampembeng 15:6f2798e45099 38 WNCUDPSocket();
ampembeng 15:6f2798e45099 39 ~WNCUDPSocket();
ampembeng 15:6f2798e45099 40
ampembeng 15:6f2798e45099 41 int init(void);
ampembeng 15:6f2798e45099 42
ampembeng 15:6f2798e45099 43 /** sendTo - send data to the remote host.
ampembeng 15:6f2798e45099 44 \param remote, a pointer to the endpoint (class)
ampembeng 15:6f2798e45099 45 \param packet, pointer to the buffer to send to the host.
ampembeng 15:6f2798e45099 46 \param length The length of the buffer to send.
ampembeng 15:6f2798e45099 47 \return the number of written bytes on success (>=0) or -1 on failure
ampembeng 15:6f2798e45099 48 */
ampembeng 15:6f2798e45099 49 int sendTo(WNCEndpoint &remote, char *packet, int length);
ampembeng 15:6f2798e45099 50
ampembeng 15:6f2798e45099 51 /** receiveFrom - receive data from the remote host.
ampembeng 15:6f2798e45099 52 \param remote, a pointer to the endpoint (class)
ampembeng 15:6f2798e45099 53 \param packet, The buffer in which to store the data received from the host.
ampembeng 15:6f2798e45099 54 \param length The maximum length of the buffer.
ampembeng 15:6f2798e45099 55 \return the number of received bytes on success (>=0) or -1 on failure
ampembeng 15:6f2798e45099 56 */
ampembeng 15:6f2798e45099 57 int receiveFrom(WNCEndpoint &remote, char *buffer, int length);
ampembeng 15:6f2798e45099 58
ampembeng 15:6f2798e45099 59 /** Set blocking or non-blocking mode of the socket and a timeout
ampembeng 15:6f2798e45099 60 \param blocking true for blocking mode, false for non-blocking mode.
ampembeng 15:6f2798e45099 61 \return none.
ampembeng 15:6f2798e45099 62 */
ampembeng 15:6f2798e45099 63 void set_blocking (bool blocking, unsigned int timeout=1500);
ampembeng 15:6f2798e45099 64
ampembeng 15:6f2798e45099 65 /** Close the socket
ampembeng 15:6f2798e45099 66 \param none
ampembeng 15:6f2798e45099 67 \return 0 if closed successfully, -1 on failure
ampembeng 15:6f2798e45099 68 */
ampembeng 15:6f2798e45099 69 int close(void);
ampembeng 15:6f2798e45099 70
ampembeng 15:6f2798e45099 71 private:
ampembeng 15:6f2798e45099 72 bool _is_blocking;
ampembeng 15:6f2798e45099 73 unsigned int _btimeout;
ampembeng 15:6f2798e45099 74 };
ampembeng 15:6f2798e45099 75
ampembeng 15:6f2798e45099 76 #endif
ampembeng 15:6f2798e45099 77
ampembeng 15:6f2798e45099 78