Simple sample that demonstrates reading the FXOS8700CQ accelerometer, convert the data to JSON and send to an Azure IoT Hub.
Dependencies: azure_umqtt_c iothub_mqtt_transport mbed-rtos mbed wolfSSL Socket lwip-eth lwip-sys lwip
tcpsocketconnection_c.cpp
00001 // Copyright (c) Microsoft. All rights reserved. 00002 // Licensed under the MIT license. See LICENSE file in the project root for full license information. 00003 00004 #include "mbed.h" 00005 00006 #include <stddef.h> 00007 #include "TCPSocketConnection.h" 00008 #include "azure_c_shared_utility/tcpsocketconnection_c.h" 00009 00010 00011 TCPSOCKETCONNECTION_HANDLE tcpsocketconnection_create(void) 00012 { 00013 return new TCPSocketConnection(); 00014 } 00015 00016 void tcpsocketconnection_set_blocking(TCPSOCKETCONNECTION_HANDLE tcpSocketConnectionHandle, bool blocking, unsigned int timeout) 00017 { 00018 TCPSocketConnection* tsc = (TCPSocketConnection*)tcpSocketConnectionHandle; 00019 tsc->set_blocking(blocking, timeout); 00020 } 00021 00022 void tcpsocketconnection_destroy(TCPSOCKETCONNECTION_HANDLE tcpSocketConnectionHandle) 00023 { 00024 delete (TCPSocketConnection*)tcpSocketConnectionHandle; 00025 } 00026 00027 int tcpsocketconnection_connect(TCPSOCKETCONNECTION_HANDLE tcpSocketConnectionHandle, const char* host, const int port) 00028 { 00029 TCPSocketConnection* tsc = (TCPSocketConnection*)tcpSocketConnectionHandle; 00030 return tsc->connect(host, port); 00031 } 00032 00033 bool tcpsocketconnection_is_connected(TCPSOCKETCONNECTION_HANDLE tcpSocketConnectionHandle) 00034 { 00035 TCPSocketConnection* tsc = (TCPSocketConnection*)tcpSocketConnectionHandle; 00036 return tsc->is_connected(); 00037 } 00038 00039 void tcpsocketconnection_close(TCPSOCKETCONNECTION_HANDLE tcpSocketConnectionHandle) 00040 { 00041 TCPSocketConnection* tsc = (TCPSocketConnection*)tcpSocketConnectionHandle; 00042 tsc->close(); 00043 } 00044 00045 int tcpsocketconnection_send(TCPSOCKETCONNECTION_HANDLE tcpSocketConnectionHandle, const char* data, int length) 00046 { 00047 TCPSocketConnection* tsc = (TCPSocketConnection*)tcpSocketConnectionHandle; 00048 return tsc->send((char*)data, length); 00049 } 00050 00051 int tcpsocketconnection_send_all(TCPSOCKETCONNECTION_HANDLE tcpSocketConnectionHandle, const char* data, int length) 00052 { 00053 TCPSocketConnection* tsc = (TCPSocketConnection*)tcpSocketConnectionHandle; 00054 return tsc->send_all((char*)data, length); 00055 } 00056 00057 int tcpsocketconnection_receive(TCPSOCKETCONNECTION_HANDLE tcpSocketConnectionHandle, char* data, int length) 00058 { 00059 TCPSocketConnection* tsc = (TCPSocketConnection*)tcpSocketConnectionHandle; 00060 return tsc->receive(data, length); 00061 } 00062 00063 int tcpsocketconnection_receive_all(TCPSOCKETCONNECTION_HANDLE tcpSocketConnectionHandle, char* data, int length) 00064 { 00065 TCPSocketConnection* tsc = (TCPSocketConnection*)tcpSocketConnectionHandle; 00066 return tsc->receive_all(data, length); 00067 }
Generated on Wed Jul 13 2022 07:19:04 by 1.7.2