Host library for controlling a WiConnect enabled Wi-Fi module.
Dependents: wiconnect-ota_example wiconnect-web_setup_example wiconnect-test-console wiconnect-tcp_server_example ... more
types/Socket.h
- Committer:
- dan_ackme
- Date:
- 2014-08-13
- Revision:
- 13:2b51f5267c92
- Parent:
- 11:ea484e1b7fc4
- Child:
- 16:7f1d6d359787
File content as of revision 13:2b51f5267c92:
/* * Copyright 2014, ACKme Networks * All Rights Reserved. * * This is UNPUBLISHED PROPRIETARY SOURCE CODE of ACKme Networks; * the contents of this file may not be disclosed to third parties, copied * or duplicated in any form, in whole or in part, without the prior * written permission of ACKme Networks. */ #pragma once #include "WiconnectTypes.h" namespace wiconnect { /** * @ingroup api_socket_types * * @brief Connection object to remote server. * */ class Socket { public: Socket(int rxBufferLen = 0, void *rxBuffer = NULL, int txBufferLen = 0, void *txBuffer = NULL); ~Socket(); WiconnectResult close(); WiconnectResult poll(bool *rxDataAvailablePtr); WiconnectResult write(const void* buffer, int length, bool flush = false); WiconnectResult write(int length, bool flush = true); WiconnectResult read(void* buffer, uint16_t maxLength, uint16_t *bytesRead); WiconnectResult read(uint8_t **bufferPtr = NULL, uint16_t *bytesReadPtr = NULL); WiconnectResult putc(uint8_t c, bool flush = false); WiconnectResult puts(const char *s, bool flush = false); WiconnectResult getc(uint8_t *c); WiconnectResult printf(const char* format, ...); WiconnectResult flushTxBuffer(); void clearRxBuffer(); uint8_t *getTxBuffer(); int getTxBufferSize(); int getTxBufferBytesPending(); uint8_t *getRxBuffer(); int getRxBufferSize(); int getRxBufferBytesPending(); bool isConnected(); SocketType getType(); const char* getHost(); uint16_t getLocalPort(); uint16_t getRemotePort(); uint8_t getHandle(); protected: bool connected; SocketType type; uint8_t handle; char host[WICONNECT_MAX_HOST_SIZE]; uint16_t localPort; uint16_t remotePort; Wiconnect *wiconnect; Buffer txBuffer; Buffer rxBuffer; WiconnectResult init(uint8_t handle, SocketType type, const char *host, uint16_t remotePort, uint16_t localPort); WiconnectResult writeDataCallback(void *user, void *data, int maxReadSize, int *bytesRead); friend class SocketInterface; }; }