cc3000 hostdriver with the mbed socket interface

Fork of cc3000_hostdriver_mbedsocket by Martin Kojtal

Committer:
frankvnk
Date:
Mon Apr 06 18:23:37 2015 +0000
Revision:
51:897cfc2c7e8c
Parent:
5:245ac5b73132
Added 2 optional parameters to the constructor : set TX and RX buffer size

Who changed what in which revision?

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