WIP. send a large constant string twice a second, in order to test out the transport with something indicative of our required load.
Dependencies: FXOS8700CQ NTPClient azure_umqtt_c iothub_mqtt_transport mbed-rtos mbed wolfSSL Socket lwip-eth lwip-sys lwip
Fork of FXOS8700CQ_To_Azure_IoT by
azure_c_shared_utility/tcpsocketconnection_c.cpp@7:0d1a0fe537dc, 2017-01-05 (annotated)
- Committer:
- julianhigginson
- Date:
- Thu Jan 05 23:40:24 2017 +0000
- Revision:
- 7:0d1a0fe537dc
- Parent:
- 3:c0556ff7b8e3
modified dummy message for minimal data transport
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
markrad | 3:c0556ff7b8e3 | 1 | // Copyright (c) Microsoft. All rights reserved. |
markrad | 3:c0556ff7b8e3 | 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. |
markrad | 3:c0556ff7b8e3 | 3 | |
markrad | 3:c0556ff7b8e3 | 4 | #include "mbed.h" |
markrad | 3:c0556ff7b8e3 | 5 | |
markrad | 3:c0556ff7b8e3 | 6 | #include <stddef.h> |
markrad | 3:c0556ff7b8e3 | 7 | #include "TCPSocketConnection.h" |
markrad | 3:c0556ff7b8e3 | 8 | #include "azure_c_shared_utility/tcpsocketconnection_c.h" |
markrad | 3:c0556ff7b8e3 | 9 | |
markrad | 3:c0556ff7b8e3 | 10 | |
markrad | 3:c0556ff7b8e3 | 11 | TCPSOCKETCONNECTION_HANDLE tcpsocketconnection_create(void) |
markrad | 3:c0556ff7b8e3 | 12 | { |
markrad | 3:c0556ff7b8e3 | 13 | return new TCPSocketConnection(); |
markrad | 3:c0556ff7b8e3 | 14 | } |
markrad | 3:c0556ff7b8e3 | 15 | |
markrad | 3:c0556ff7b8e3 | 16 | void tcpsocketconnection_set_blocking(TCPSOCKETCONNECTION_HANDLE tcpSocketConnectionHandle, bool blocking, unsigned int timeout) |
markrad | 3:c0556ff7b8e3 | 17 | { |
markrad | 3:c0556ff7b8e3 | 18 | TCPSocketConnection* tsc = (TCPSocketConnection*)tcpSocketConnectionHandle; |
markrad | 3:c0556ff7b8e3 | 19 | tsc->set_blocking(blocking, timeout); |
markrad | 3:c0556ff7b8e3 | 20 | } |
markrad | 3:c0556ff7b8e3 | 21 | |
markrad | 3:c0556ff7b8e3 | 22 | void tcpsocketconnection_destroy(TCPSOCKETCONNECTION_HANDLE tcpSocketConnectionHandle) |
markrad | 3:c0556ff7b8e3 | 23 | { |
markrad | 3:c0556ff7b8e3 | 24 | delete (TCPSocketConnection*)tcpSocketConnectionHandle; |
markrad | 3:c0556ff7b8e3 | 25 | } |
markrad | 3:c0556ff7b8e3 | 26 | |
markrad | 3:c0556ff7b8e3 | 27 | int tcpsocketconnection_connect(TCPSOCKETCONNECTION_HANDLE tcpSocketConnectionHandle, const char* host, const int port) |
markrad | 3:c0556ff7b8e3 | 28 | { |
markrad | 3:c0556ff7b8e3 | 29 | TCPSocketConnection* tsc = (TCPSocketConnection*)tcpSocketConnectionHandle; |
markrad | 3:c0556ff7b8e3 | 30 | return tsc->connect(host, port); |
markrad | 3:c0556ff7b8e3 | 31 | } |
markrad | 3:c0556ff7b8e3 | 32 | |
markrad | 3:c0556ff7b8e3 | 33 | bool tcpsocketconnection_is_connected(TCPSOCKETCONNECTION_HANDLE tcpSocketConnectionHandle) |
markrad | 3:c0556ff7b8e3 | 34 | { |
markrad | 3:c0556ff7b8e3 | 35 | TCPSocketConnection* tsc = (TCPSocketConnection*)tcpSocketConnectionHandle; |
markrad | 3:c0556ff7b8e3 | 36 | return tsc->is_connected(); |
markrad | 3:c0556ff7b8e3 | 37 | } |
markrad | 3:c0556ff7b8e3 | 38 | |
markrad | 3:c0556ff7b8e3 | 39 | void tcpsocketconnection_close(TCPSOCKETCONNECTION_HANDLE tcpSocketConnectionHandle) |
markrad | 3:c0556ff7b8e3 | 40 | { |
markrad | 3:c0556ff7b8e3 | 41 | TCPSocketConnection* tsc = (TCPSocketConnection*)tcpSocketConnectionHandle; |
markrad | 3:c0556ff7b8e3 | 42 | tsc->close(); |
markrad | 3:c0556ff7b8e3 | 43 | } |
markrad | 3:c0556ff7b8e3 | 44 | |
markrad | 3:c0556ff7b8e3 | 45 | int tcpsocketconnection_send(TCPSOCKETCONNECTION_HANDLE tcpSocketConnectionHandle, const char* data, int length) |
markrad | 3:c0556ff7b8e3 | 46 | { |
markrad | 3:c0556ff7b8e3 | 47 | TCPSocketConnection* tsc = (TCPSocketConnection*)tcpSocketConnectionHandle; |
markrad | 3:c0556ff7b8e3 | 48 | return tsc->send((char*)data, length); |
markrad | 3:c0556ff7b8e3 | 49 | } |
markrad | 3:c0556ff7b8e3 | 50 | |
markrad | 3:c0556ff7b8e3 | 51 | int tcpsocketconnection_send_all(TCPSOCKETCONNECTION_HANDLE tcpSocketConnectionHandle, const char* data, int length) |
markrad | 3:c0556ff7b8e3 | 52 | { |
markrad | 3:c0556ff7b8e3 | 53 | TCPSocketConnection* tsc = (TCPSocketConnection*)tcpSocketConnectionHandle; |
markrad | 3:c0556ff7b8e3 | 54 | return tsc->send_all((char*)data, length); |
markrad | 3:c0556ff7b8e3 | 55 | } |
markrad | 3:c0556ff7b8e3 | 56 | |
markrad | 3:c0556ff7b8e3 | 57 | int tcpsocketconnection_receive(TCPSOCKETCONNECTION_HANDLE tcpSocketConnectionHandle, char* data, int length) |
markrad | 3:c0556ff7b8e3 | 58 | { |
markrad | 3:c0556ff7b8e3 | 59 | TCPSocketConnection* tsc = (TCPSocketConnection*)tcpSocketConnectionHandle; |
markrad | 3:c0556ff7b8e3 | 60 | return tsc->receive(data, length); |
markrad | 3:c0556ff7b8e3 | 61 | } |
markrad | 3:c0556ff7b8e3 | 62 | |
markrad | 3:c0556ff7b8e3 | 63 | int tcpsocketconnection_receive_all(TCPSOCKETCONNECTION_HANDLE tcpSocketConnectionHandle, char* data, int length) |
markrad | 3:c0556ff7b8e3 | 64 | { |
markrad | 3:c0556ff7b8e3 | 65 | TCPSocketConnection* tsc = (TCPSocketConnection*)tcpSocketConnectionHandle; |
markrad | 3:c0556ff7b8e3 | 66 | return tsc->receive_all(data, length); |
markrad | 3:c0556ff7b8e3 | 67 | } |