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@13:2b51f5267c92, 2014-08-13 (annotated)
- Committer:
- dan_ackme
- Date:
- Wed Aug 13 03:14:30 2014 -0700
- Revision:
- 13:2b51f5267c92
- Parent:
- 11:ea484e1b7fc4
- Child:
- 16:7f1d6d359787
doc updates
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
dan_ackme | 0:ea85c4bb5e1f | 1 | /* |
dan_ackme | 0:ea85c4bb5e1f | 2 | * Copyright 2014, ACKme Networks |
dan_ackme | 0:ea85c4bb5e1f | 3 | * All Rights Reserved. |
dan_ackme | 0:ea85c4bb5e1f | 4 | * |
dan_ackme | 0:ea85c4bb5e1f | 5 | * This is UNPUBLISHED PROPRIETARY SOURCE CODE of ACKme Networks; |
dan_ackme | 0:ea85c4bb5e1f | 6 | * the contents of this file may not be disclosed to third parties, copied |
dan_ackme | 0:ea85c4bb5e1f | 7 | * or duplicated in any form, in whole or in part, without the prior |
dan_ackme | 0:ea85c4bb5e1f | 8 | * written permission of ACKme Networks. |
dan_ackme | 0:ea85c4bb5e1f | 9 | */ |
dan_ackme | 0:ea85c4bb5e1f | 10 | |
dan_ackme | 0:ea85c4bb5e1f | 11 | #pragma once |
dan_ackme | 0:ea85c4bb5e1f | 12 | |
dan_ackme | 0:ea85c4bb5e1f | 13 | |
dan_ackme | 0:ea85c4bb5e1f | 14 | #include "WiconnectTypes.h" |
dan_ackme | 0:ea85c4bb5e1f | 15 | |
dan_ackme | 0:ea85c4bb5e1f | 16 | namespace wiconnect |
dan_ackme | 0:ea85c4bb5e1f | 17 | { |
dan_ackme | 0:ea85c4bb5e1f | 18 | |
dan_ackme | 11:ea484e1b7fc4 | 19 | /** |
dan_ackme | 13:2b51f5267c92 | 20 | * @ingroup api_socket_types |
dan_ackme | 11:ea484e1b7fc4 | 21 | * |
dan_ackme | 11:ea484e1b7fc4 | 22 | * @brief Connection object to remote server. |
dan_ackme | 11:ea484e1b7fc4 | 23 | * |
dan_ackme | 11:ea484e1b7fc4 | 24 | */ |
dan_ackme | 0:ea85c4bb5e1f | 25 | class Socket |
dan_ackme | 0:ea85c4bb5e1f | 26 | { |
dan_ackme | 0:ea85c4bb5e1f | 27 | public: |
dan_ackme | 0:ea85c4bb5e1f | 28 | Socket(int rxBufferLen = 0, void *rxBuffer = NULL, int txBufferLen = 0, void *txBuffer = NULL); |
dan_ackme | 0:ea85c4bb5e1f | 29 | ~Socket(); |
dan_ackme | 0:ea85c4bb5e1f | 30 | |
dan_ackme | 0:ea85c4bb5e1f | 31 | WiconnectResult close(); |
dan_ackme | 0:ea85c4bb5e1f | 32 | WiconnectResult poll(bool *rxDataAvailablePtr); |
dan_ackme | 0:ea85c4bb5e1f | 33 | WiconnectResult write(const void* buffer, int length, bool flush = false); |
dan_ackme | 0:ea85c4bb5e1f | 34 | WiconnectResult write(int length, bool flush = true); |
dan_ackme | 0:ea85c4bb5e1f | 35 | WiconnectResult read(void* buffer, uint16_t maxLength, uint16_t *bytesRead); |
dan_ackme | 0:ea85c4bb5e1f | 36 | WiconnectResult read(uint8_t **bufferPtr = NULL, uint16_t *bytesReadPtr = NULL); |
dan_ackme | 0:ea85c4bb5e1f | 37 | WiconnectResult putc(uint8_t c, bool flush = false); |
dan_ackme | 0:ea85c4bb5e1f | 38 | WiconnectResult puts(const char *s, bool flush = false); |
dan_ackme | 0:ea85c4bb5e1f | 39 | WiconnectResult getc(uint8_t *c); |
dan_ackme | 0:ea85c4bb5e1f | 40 | WiconnectResult printf(const char* format, ...); |
dan_ackme | 0:ea85c4bb5e1f | 41 | WiconnectResult flushTxBuffer(); |
dan_ackme | 0:ea85c4bb5e1f | 42 | void clearRxBuffer(); |
dan_ackme | 0:ea85c4bb5e1f | 43 | |
dan_ackme | 0:ea85c4bb5e1f | 44 | uint8_t *getTxBuffer(); |
dan_ackme | 0:ea85c4bb5e1f | 45 | int getTxBufferSize(); |
dan_ackme | 0:ea85c4bb5e1f | 46 | int getTxBufferBytesPending(); |
dan_ackme | 0:ea85c4bb5e1f | 47 | uint8_t *getRxBuffer(); |
dan_ackme | 0:ea85c4bb5e1f | 48 | int getRxBufferSize(); |
dan_ackme | 0:ea85c4bb5e1f | 49 | int getRxBufferBytesPending(); |
dan_ackme | 0:ea85c4bb5e1f | 50 | |
dan_ackme | 0:ea85c4bb5e1f | 51 | bool isConnected(); |
dan_ackme | 0:ea85c4bb5e1f | 52 | SocketType getType(); |
dan_ackme | 0:ea85c4bb5e1f | 53 | const char* getHost(); |
dan_ackme | 0:ea85c4bb5e1f | 54 | uint16_t getLocalPort(); |
dan_ackme | 0:ea85c4bb5e1f | 55 | uint16_t getRemotePort(); |
dan_ackme | 0:ea85c4bb5e1f | 56 | uint8_t getHandle(); |
dan_ackme | 0:ea85c4bb5e1f | 57 | |
dan_ackme | 0:ea85c4bb5e1f | 58 | protected: |
dan_ackme | 0:ea85c4bb5e1f | 59 | bool connected; |
dan_ackme | 0:ea85c4bb5e1f | 60 | SocketType type; |
dan_ackme | 0:ea85c4bb5e1f | 61 | uint8_t handle; |
dan_ackme | 0:ea85c4bb5e1f | 62 | char host[WICONNECT_MAX_HOST_SIZE]; |
dan_ackme | 0:ea85c4bb5e1f | 63 | uint16_t localPort; |
dan_ackme | 0:ea85c4bb5e1f | 64 | uint16_t remotePort; |
dan_ackme | 0:ea85c4bb5e1f | 65 | Wiconnect *wiconnect; |
dan_ackme | 0:ea85c4bb5e1f | 66 | Buffer txBuffer; |
dan_ackme | 0:ea85c4bb5e1f | 67 | Buffer rxBuffer; |
dan_ackme | 0:ea85c4bb5e1f | 68 | |
dan_ackme | 0:ea85c4bb5e1f | 69 | WiconnectResult init(uint8_t handle, SocketType type, const char *host, uint16_t remotePort, uint16_t localPort); |
dan_ackme | 0:ea85c4bb5e1f | 70 | |
dan_ackme | 0:ea85c4bb5e1f | 71 | WiconnectResult writeDataCallback(void *user, void *data, int maxReadSize, int *bytesRead); |
dan_ackme | 0:ea85c4bb5e1f | 72 | |
dan_ackme | 0:ea85c4bb5e1f | 73 | friend class SocketInterface; |
dan_ackme | 0:ea85c4bb5e1f | 74 | }; |
dan_ackme | 0:ea85c4bb5e1f | 75 | |
dan_ackme | 0:ea85c4bb5e1f | 76 | |
dan_ackme | 0:ea85c4bb5e1f | 77 | } |