Separate library that holds helper functions for the main OMF code.

Committer:
danielelopez
Date:
Mon Jun 25 21:09:08 2018 +0000
Revision:
18:c6c9cce5d990
Parent:
17:cc05a00e6ee6
Child:
19:9b357e31f61d
Used #def statements to remove if statements from code; edited NTP timestamp and timestamp functions in the OMF lib to optimize code; added SSL cert for the new AWS VM

Who changed what in which revision?

UserRevisionLine numberNew contents of line
danielelopez 14:6ed67a160616 1 //Copyright 2018 OSIsoft, LLC
danielelopez 0:6156b29d3c91 2 //
danielelopez 0:6156b29d3c91 3 //Licensed under the Apache License, Version 2.0 (the "License");
danielelopez 0:6156b29d3c91 4 //you may not use this file except in compliance with the License.
danielelopez 0:6156b29d3c91 5 //You may obtain a copy of the License at
danielelopez 0:6156b29d3c91 6 //
danielelopez 0:6156b29d3c91 7 //<http://www.apache.org/licenses/LICENSE-2.0>
danielelopez 0:6156b29d3c91 8 //
danielelopez 0:6156b29d3c91 9 //Unless required by applicable law or agreed to in writing, software
danielelopez 0:6156b29d3c91 10 //distributed under the License is distributed on an "AS IS" BASIS,
danielelopez 0:6156b29d3c91 11 //WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
danielelopez 0:6156b29d3c91 12 //See the License for the specific language governing permissions and
danielelopez 0:6156b29d3c91 13 //limitations under the License.
danielelopez 0:6156b29d3c91 14
danielelopez 0:6156b29d3c91 15 #include "osisoft-omf.h"
danielelopez 0:6156b29d3c91 16 #include "mbed.h"
danielelopez 0:6156b29d3c91 17 #include "https_request.h"
danielelopez 0:6156b29d3c91 18 #include "ntp-client/NTPClient.h"
danielelopez 10:844e209f1d79 19 #include "config.egressSettings.h"
danielelopez 8:e5fe40b77f8f 20 #include "config.SSLCertificates.h"
danielelopez 8:e5fe40b77f8f 21 #include "config.producerToken.h"
danielelopez 17:cc05a00e6ee6 22 #include "config.OMFContainerAndLINKJSON.h"
danielelopez 17:cc05a00e6ee6 23 #include "config.OMFDynamicAndStaticTypesAndAssetJSON.h"
danielelopez 0:6156b29d3c91 24
danielelopez 0:6156b29d3c91 25 // ---------------------------------------------------------------------------------------------------
danielelopez 0:6156b29d3c91 26
danielelopez 0:6156b29d3c91 27 // The clock is set usign NTP; if that fails, the clock defaults to the below time
danielelopez 0:6156b29d3c91 28 const int DEFAULT_HARD_CODED_UTC_TIME = 1513175347;
danielelopez 0:6156b29d3c91 29
danielelopez 0:6156b29d3c91 30 // ---------------------------------------------------------------------------------------------------
danielelopez 0:6156b29d3c91 31
danielelopez 0:6156b29d3c91 32 // ************************************************************************
danielelopez 0:6156b29d3c91 33 // Helper function: prints out an HTTP response
danielelopez 0:6156b29d3c91 34 // ************************************************************************
danielelopez 0:6156b29d3c91 35
danielelopez 1:1c31b413ba0c 36 void OMFLib_dump_response(HttpResponse* res)
danielelopez 0:6156b29d3c91 37 {
danielelopez 1:1c31b413ba0c 38 printf("\n\r----- HTTPS POST response -----\n\r");
danielelopez 0:6156b29d3c91 39 // Print the status code
danielelopez 1:1c31b413ba0c 40 mbedtls_printf("Status: %d - %s\n\r", res->get_status_code(), res->get_status_message().c_str());
danielelopez 0:6156b29d3c91 41 // Print the headers
danielelopez 1:1c31b413ba0c 42 mbedtls_printf("Response headers:\n\r");
danielelopez 0:6156b29d3c91 43 for (size_t ix = 0; ix < res->get_headers_length(); ix++) {
danielelopez 1:1c31b413ba0c 44 mbedtls_printf("\t%s: %s\n\r", res->get_headers_fields()[ix]->c_str(), res->get_headers_values()[ix]->c_str());
danielelopez 0:6156b29d3c91 45 }
danielelopez 0:6156b29d3c91 46 // Print the body
danielelopez 0:6156b29d3c91 47 mbedtls_printf("Response body (%d bytes):\n\n%s", res->get_body_length(), res->get_body_as_string().c_str());
danielelopez 0:6156b29d3c91 48 }
danielelopez 0:6156b29d3c91 49
danielelopez 0:6156b29d3c91 50 // ************************************************************************
danielelopez 0:6156b29d3c91 51 // Helper function that casts floats into strings
danielelopez 0:6156b29d3c91 52 // ************************************************************************
danielelopez 0:6156b29d3c91 53
danielelopez 0:6156b29d3c91 54 string OMFLib_float_to_string(float f) {
danielelopez 0:6156b29d3c91 55 char buffer[20];
danielelopez 0:6156b29d3c91 56 int n = sprintf (buffer, "%f", f);
danielelopez 13:61d3de73a844 57 // Return -1 if a parse failure ocurred
danielelopez 13:61d3de73a844 58 if (string(buffer) == "NaN") {
danielelopez 13:61d3de73a844 59 return string("-1");
danielelopez 13:61d3de73a844 60 } else {
danielelopez 13:61d3de73a844 61 return string(buffer);
danielelopez 13:61d3de73a844 62 }
danielelopez 0:6156b29d3c91 63 }
danielelopez 0:6156b29d3c91 64
danielelopez 0:6156b29d3c91 65 // ************************************************************************
danielelopez 0:6156b29d3c91 66 // Helper function that sends an actual web request
danielelopez 0:6156b29d3c91 67 // ************************************************************************
danielelopez 0:6156b29d3c91 68
danielelopez 0:6156b29d3c91 69 void OMFLib_sendMessageToEndpoint(TLSSocket* socket, const char* action, const char* message_type, const char* body) {
danielelopez 1:1c31b413ba0c 70 printf("\n\r----- HTTPS POST request -----\n\r");
danielelopez 0:6156b29d3c91 71
danielelopez 0:6156b29d3c91 72 // Create the new request
danielelopez 0:6156b29d3c91 73 //HttpsRequest* post_req = new HttpsRequest(network, SSL_CA_PEM, HTTP_POST, TARGET_URL); // Old: doesn't re-use sockets
danielelopez 0:6156b29d3c91 74 HttpsRequest* post_req = new HttpsRequest(socket, HTTP_POST, TARGET_URL);
danielelopez 0:6156b29d3c91 75
danielelopez 0:6156b29d3c91 76 // Turn on debugging - this hides TLS connection information
danielelopez 0:6156b29d3c91 77 post_req->set_debug(true);
danielelopez 0:6156b29d3c91 78
danielelopez 0:6156b29d3c91 79 // Add headers: content type and authentication
danielelopez 0:6156b29d3c91 80 post_req->set_header("Content-Type", "application/json");
danielelopez 0:6156b29d3c91 81
danielelopez 0:6156b29d3c91 82 // Set OMF headers
danielelopez 0:6156b29d3c91 83 post_req->set_header("producertoken", PRODUCER_TOKEN);
danielelopez 0:6156b29d3c91 84 post_req->set_header("messagetype", message_type);
danielelopez 0:6156b29d3c91 85 post_req->set_header("action", action);
danielelopez 0:6156b29d3c91 86 post_req->set_header("messageformat", "JSON");
danielelopez 0:6156b29d3c91 87 post_req->set_header("omfversion", "1.0");
danielelopez 0:6156b29d3c91 88
danielelopez 0:6156b29d3c91 89 // Send the body
danielelopez 0:6156b29d3c91 90 printf("Now sending request...");
danielelopez 1:1c31b413ba0c 91 printf("\n\rOutgoing message headers:\n\tmessagetype: %s\n\taction: %s", message_type, action);
danielelopez 1:1c31b413ba0c 92 printf("\n\rOutgoing message body:\n\t%s\n\r", body);
danielelopez 0:6156b29d3c91 93 HttpResponse* post_res = post_req->send(body, strlen(body));
danielelopez 0:6156b29d3c91 94
danielelopez 0:6156b29d3c91 95 // Check the response for an error
danielelopez 0:6156b29d3c91 96 if (!post_res) {
danielelopez 1:1c31b413ba0c 97 printf("HttpRequest failed (error code %d)\n\r", post_req->get_error());
danielelopez 1:1c31b413ba0c 98 printf("Socket connection status after error: %d\n\r", socket->connected());
danielelopez 0:6156b29d3c91 99 //return 1;
danielelopez 0:6156b29d3c91 100 } else {
danielelopez 0:6156b29d3c91 101 // Print the response
danielelopez 1:1c31b413ba0c 102 OMFLib_dump_response(post_res);
danielelopez 1:1c31b413ba0c 103 }
danielelopez 1:1c31b413ba0c 104
danielelopez 1:1c31b413ba0c 105 // Free up the request object
danielelopez 1:1c31b413ba0c 106 delete post_req;
danielelopez 1:1c31b413ba0c 107 }
danielelopez 1:1c31b413ba0c 108
danielelopez 1:1c31b413ba0c 109 // ************************************************************************
danielelopez 1:1c31b413ba0c 110 // Helper function that sends an actual web request; does not reuse sockets
danielelopez 1:1c31b413ba0c 111 // ************************************************************************
danielelopez 1:1c31b413ba0c 112
danielelopez 18:c6c9cce5d990 113 #if ENABLE_PRINTOUTS == YES_ENABLE_PRINTOUTS
danielelopez 18:c6c9cce5d990 114 void OMFLib_sendMessageToEndpoint_NoSocketReuse(NetworkInterface* network, const char* action, const char* message_type, const char* body) {
danielelopez 18:c6c9cce5d990 115
danielelopez 18:c6c9cce5d990 116 printf("\n\r----- HTTPS POST request -----\n\r");
danielelopez 18:c6c9cce5d990 117
danielelopez 18:c6c9cce5d990 118 // Create the new request
danielelopez 18:c6c9cce5d990 119 HttpsRequest* post_req = new HttpsRequest(network, SSL_CA_PEM, HTTP_POST, TARGET_URL);
danielelopez 12:8fb2bb26528f 120
danielelopez 18:c6c9cce5d990 121 // Turn on debugging - this hides TLS connection information
danielelopez 18:c6c9cce5d990 122 //post_req->set_debug(true);
danielelopez 1:1c31b413ba0c 123
danielelopez 18:c6c9cce5d990 124 // Add headers: content type
danielelopez 18:c6c9cce5d990 125 post_req->set_header("Content-Type", CONTENT_TYPE);
danielelopez 18:c6c9cce5d990 126
danielelopez 18:c6c9cce5d990 127 // Set OMF headers
danielelopez 18:c6c9cce5d990 128 post_req->set_header("producertoken", PRODUCER_TOKEN);
danielelopez 18:c6c9cce5d990 129 post_req->set_header("messagetype", message_type);
danielelopez 18:c6c9cce5d990 130 post_req->set_header("action", action);
danielelopez 18:c6c9cce5d990 131 post_req->set_header("messageformat", OMF_MESSAGE_FORMAT);
danielelopez 18:c6c9cce5d990 132 post_req->set_header("omfversion", OMF_VERSION);
danielelopez 18:c6c9cce5d990 133
danielelopez 18:c6c9cce5d990 134 // Send the body
danielelopez 18:c6c9cce5d990 135 printf("Now sending request... ");
danielelopez 18:c6c9cce5d990 136 //printf("\n\rOutgoing message headers:\n\tmessagetype: %s\n\taction: %s", message_type, action);
danielelopez 18:c6c9cce5d990 137 //printf("\n\rOutgoing message body:\n\t%s\n\r", body);
danielelopez 18:c6c9cce5d990 138 HttpResponse* post_res = post_req->send(body, strlen(body));
danielelopez 1:1c31b413ba0c 139
danielelopez 18:c6c9cce5d990 140 // Check the response for an error
danielelopez 18:c6c9cce5d990 141 if (!post_res) {
danielelopez 18:c6c9cce5d990 142 printf("HttpRequest failed (error code %d)\n\r", post_req->get_error());
danielelopez 18:c6c9cce5d990 143 //return 1;
danielelopez 18:c6c9cce5d990 144 } else {
danielelopez 18:c6c9cce5d990 145 // Print the response
danielelopez 18:c6c9cce5d990 146 printf("Success!\n\r");
danielelopez 18:c6c9cce5d990 147 //OMFLib_dump_response(post_res);
danielelopez 18:c6c9cce5d990 148 }
danielelopez 12:8fb2bb26528f 149
danielelopez 18:c6c9cce5d990 150 // Free up the request object
danielelopez 18:c6c9cce5d990 151 delete post_req;
danielelopez 0:6156b29d3c91 152 }
danielelopez 18:c6c9cce5d990 153 #endif
danielelopez 0:6156b29d3c91 154
danielelopez 18:c6c9cce5d990 155 // Option if printouts should be hidden
danielelopez 18:c6c9cce5d990 156 #if ENABLE_PRINTOUTS == DO_NOT_ENABLE_PRINTOUTS
danielelopez 18:c6c9cce5d990 157 void OMFLib_sendMessageToEndpoint_NoSocketReuse(NetworkInterface* network, const char* action, const char* message_type, const char* body) {
danielelopez 18:c6c9cce5d990 158
danielelopez 18:c6c9cce5d990 159 // Create the new request
danielelopez 18:c6c9cce5d990 160 HttpsRequest* post_req = new HttpsRequest(network, SSL_CA_PEM, HTTP_POST, TARGET_URL);
danielelopez 18:c6c9cce5d990 161
danielelopez 18:c6c9cce5d990 162 // Turn on debugging - this hides TLS connection information
danielelopez 18:c6c9cce5d990 163 //post_req->set_debug(true);
danielelopez 18:c6c9cce5d990 164
danielelopez 18:c6c9cce5d990 165 // Add headers: content type
danielelopez 18:c6c9cce5d990 166 post_req->set_header("Content-Type", CONTENT_TYPE);
danielelopez 18:c6c9cce5d990 167
danielelopez 18:c6c9cce5d990 168 // Set OMF headers
danielelopez 18:c6c9cce5d990 169 post_req->set_header("producertoken", PRODUCER_TOKEN);
danielelopez 18:c6c9cce5d990 170 post_req->set_header("messagetype", message_type);
danielelopez 18:c6c9cce5d990 171 post_req->set_header("action", action);
danielelopez 18:c6c9cce5d990 172 post_req->set_header("messageformat", OMF_MESSAGE_FORMAT);
danielelopez 18:c6c9cce5d990 173 post_req->set_header("omfversion", OMF_VERSION);
danielelopez 18:c6c9cce5d990 174
danielelopez 18:c6c9cce5d990 175 // Send the body
danielelopez 18:c6c9cce5d990 176 HttpResponse* post_res = post_req->send(body, strlen(body));
danielelopez 18:c6c9cce5d990 177
danielelopez 18:c6c9cce5d990 178 // Free up the request object
danielelopez 18:c6c9cce5d990 179 delete post_req;
danielelopez 18:c6c9cce5d990 180 }
danielelopez 18:c6c9cce5d990 181 #endif
danielelopez 0:6156b29d3c91 182
danielelopez 0:6156b29d3c91 183 // ************************************************************************
danielelopez 0:6156b29d3c91 184 // Gets the current time in the appropriate OMF format
danielelopez 18:c6c9cce5d990 185 // See https://os.mbed.com/blog/entry/103/
danielelopez 0:6156b29d3c91 186 // ************************************************************************
danielelopez 18:c6c9cce5d990 187 const int TIMESTAMP_BUFFER_SIZE = 21;
danielelopez 0:6156b29d3c91 188 string OMFLib_getCurrentTimeString() {
danielelopez 0:6156b29d3c91 189 // Declar vars
danielelopez 18:c6c9cce5d990 190 char timestampBuffer[TIMESTAMP_BUFFER_SIZE]; // The format is YYYY-MM-DDThh:mm:ssZ
danielelopez 0:6156b29d3c91 191 time_t now;
danielelopez 18:c6c9cce5d990 192 //struct tm ts;
danielelopez 0:6156b29d3c91 193
danielelopez 18:c6c9cce5d990 194 // Set the "now" var to the current time
danielelopez 0:6156b29d3c91 195 time(&now);
danielelopez 0:6156b29d3c91 196
danielelopez 18:c6c9cce5d990 197 // Cast the current time into UTC seconds
danielelopez 18:c6c9cce5d990 198 //ts = *localtime(&now);
danielelopez 18:c6c9cce5d990 199
danielelopez 18:c6c9cce5d990 200 // Print out the time in seconds as a formatted string to the timestamp buffer
danielelopez 18:c6c9cce5d990 201 //strftime(timestampBuffer, sizeof(timestampBuffer), "%Y-%m-%dT%H:%M:%SZ", &ts);
danielelopez 18:c6c9cce5d990 202 //strftime(timestampBuffer, sizeof(timestampBuffer), "%Y-%m-%dT%H:%M:%SZ", &ts);
danielelopez 18:c6c9cce5d990 203 strftime(timestampBuffer, TIMESTAMP_BUFFER_SIZE, "%Y-%m-%dT%H:%M:%SZ", localtime(&now));
danielelopez 0:6156b29d3c91 204
danielelopez 0:6156b29d3c91 205 // Return the result
danielelopez 0:6156b29d3c91 206 return string(timestampBuffer);
danielelopez 0:6156b29d3c91 207 }
danielelopez 0:6156b29d3c91 208
danielelopez 0:6156b29d3c91 209 // ************************************************************************
danielelopez 9:e2d177cf9135 210 // Sets the clock via NTP via the nwtwork; can point to a local or internet-based server
danielelopez 0:6156b29d3c91 211 // ************************************************************************
danielelopez 0:6156b29d3c91 212
danielelopez 0:6156b29d3c91 213 void OMFLib_syncClockViaNTP(NetworkInterface* network) {
danielelopez 0:6156b29d3c91 214 // Hard-code a start time... see https://www.epochconverter.com/
danielelopez 0:6156b29d3c91 215 set_time(DEFAULT_HARD_CODED_UTC_TIME);
danielelopez 0:6156b29d3c91 216
danielelopez 1:1c31b413ba0c 217 printf("\n\r----- Setting internal clock -----\n\r");
danielelopez 0:6156b29d3c91 218 // See https://github.com/ARMmbed/ntp-client-example/blob/master/main.cpp
danielelopez 0:6156b29d3c91 219
danielelopez 9:e2d177cf9135 220 // Connect the ntp object to the network
danielelopez 0:6156b29d3c91 221 NTPClient ntp(network);
danielelopez 9:e2d177cf9135 222
danielelopez 9:e2d177cf9135 223 // Set the ntp server to either an internet-based server OR to a local server
danielelopez 9:e2d177cf9135 224 ntp.set_server("2.pool.ntp.org", 123);
danielelopez 9:e2d177cf9135 225
danielelopez 9:e2d177cf9135 226 // Get the timestamp via NTP
danielelopez 0:6156b29d3c91 227 time_t timestamp = ntp.get_timestamp();
danielelopez 18:c6c9cce5d990 228
danielelopez 18:c6c9cce5d990 229 // Set the current timestamp to the NTP timestamp
danielelopez 18:c6c9cce5d990 230 set_time(timestamp);
danielelopez 18:c6c9cce5d990 231
danielelopez 18:c6c9cce5d990 232 // Print the result
danielelopez 18:c6c9cce5d990 233 printf("Attempt done; clock set to UTC %s", ctime(&timestamp));
danielelopez 15:32ada27d82b4 234 }
danielelopez 15:32ada27d82b4 235
danielelopez 15:32ada27d82b4 236 // ************************************************************************
danielelopez 15:32ada27d82b4 237 // Sends the dynamic types, static types, assets, and links messages
danielelopez 18:c6c9cce5d990 238 // Uses the SEND_ASSETS_AND_LINKS MACRO found in config.egressSettings and
danielelopez 15:32ada27d82b4 239 // Uses the custom OMF JSON found in config.customOMFJSONStructures.h
danielelopez 15:32ada27d82b4 240 // ************************************************************************
danielelopez 15:32ada27d82b4 241
danielelopez 18:c6c9cce5d990 242 #if SEND_ASSETS_AND_LINKS == YES_SEND_ASSETS_AND_LINKS
danielelopez 18:c6c9cce5d990 243 void OMFLib_sendInitialOMFMessages(NetworkInterface* __network_interface) {
danielelopez 18:c6c9cce5d990 244 // Send the DYNAMIC types message, so that these types can be referenced in all later messages
danielelopez 18:c6c9cce5d990 245 printf("\n\r!!!!!!!! Sending DYNAMIC Types message... !!!!!!!!\n\r");
danielelopez 18:c6c9cce5d990 246 //OMFLib_sendMessageToEndpoint(socket, "create", "Type", dynamic_types_message_JSON.c_str());
danielelopez 18:c6c9cce5d990 247 //OMFLib_sendMessageToEndpoint_NoSocketReuse(network, "create", "Type", DYNAMIC_TYPES_MESSAGE_JSON.c_str());
danielelopez 18:c6c9cce5d990 248 OMFLib_sendMessageToEndpoint_NoSocketReuse(__network_interface, "create", "Type", DYNAMIC_TYPES_MESSAGE_JSON.c_str());
danielelopez 15:32ada27d82b4 249
danielelopez 18:c6c9cce5d990 250 // Send the container message, to instantiate this particular container; we can now directly start sending data to it using its Id
danielelopez 18:c6c9cce5d990 251 printf("\n\r!!!!!!!! Sending Containers message... !!!!!!!!\n\r");
danielelopez 18:c6c9cce5d990 252 //OMFLib_sendMessageToEndpoint(socket, "create", "Container", CONTAINERS_MESSAGE_JSON.c_str());
danielelopez 18:c6c9cce5d990 253 //OMFLib_sendMessageToEndpoint_NoSocketReuse(network, "create", "Container", CONTAINERS_MESSAGE_JSON.c_str());
danielelopez 18:c6c9cce5d990 254 OMFLib_sendMessageToEndpoint_NoSocketReuse(__network_interface, "create", "Container", CONTAINERS_MESSAGE_JSON.c_str());
danielelopez 18:c6c9cce5d990 255
danielelopez 15:32ada27d82b4 256 // ************************************************************************
danielelopez 15:32ada27d82b4 257 // Send the STATIC types message, so that these types can be referenced in all later messages
danielelopez 15:32ada27d82b4 258 // ************************************************************************
danielelopez 15:32ada27d82b4 259
danielelopez 15:32ada27d82b4 260 printf("\n\r!!!!!!!! Sending STATIC Types message... !!!!!!!!\n\r");
danielelopez 15:32ada27d82b4 261 //OMFLib_sendMessageToEndpoint(socket, "create", "Type", static_types_message_JSON.c_str());
danielelopez 15:32ada27d82b4 262 //OMFLib_sendMessageToEndpoint_NoSocketReuse(network, "create", "Type", STATIC_TYPES_MESSAGE_JSON.c_str());
danielelopez 15:32ada27d82b4 263 OMFLib_sendMessageToEndpoint_NoSocketReuse(__network_interface, "create", "Type", STATIC_TYPES_MESSAGE_JSON.c_str());
danielelopez 15:32ada27d82b4 264
danielelopez 15:32ada27d82b4 265 // ************************************************************************
danielelopez 15:32ada27d82b4 266 // Send the message to create the PI AF asset; it will not appear in PI AF, though, because it has not yet been positioned...
danielelopez 15:32ada27d82b4 267 // ************************************************************************
danielelopez 15:32ada27d82b4 268
danielelopez 15:32ada27d82b4 269 printf("\n\r!!!!!!!! Sending Assets message... !!!!!!!!\n\r");
danielelopez 15:32ada27d82b4 270 //OMFLib_sendMessageToEndpoint(socket, "create", "Data", assets_message_JSON.c_str());
danielelopez 15:32ada27d82b4 271 //OMFLib_sendMessageToEndpoint_NoSocketReuse(network, "create", "Data", ASSETS_MESSAGE_JSON.c_str());
danielelopez 15:32ada27d82b4 272 OMFLib_sendMessageToEndpoint_NoSocketReuse(__network_interface, "create", "Data", ASSETS_MESSAGE_JSON.c_str());
danielelopez 15:32ada27d82b4 273
danielelopez 15:32ada27d82b4 274 // ************************************************************************
danielelopez 15:32ada27d82b4 275 // Send the message to link the PI AF asset
danielelopez 15:32ada27d82b4 276 // ************************************************************************
danielelopez 15:32ada27d82b4 277
danielelopez 15:32ada27d82b4 278 printf("\n\r!!!!!!!! Sending Links message... !!!!!!!!\n\r");
danielelopez 15:32ada27d82b4 279 //OMFLib_sendMessageToEndpoint(socket, "create", "Data", LINKS_MESSAGE_JSON.c_str());
danielelopez 15:32ada27d82b4 280 //OMFLib_sendMessageToEndpoint_NoSocketReuse(network, "create", "Data", LINKS_MESSAGE_JSON.c_str());
danielelopez 15:32ada27d82b4 281 OMFLib_sendMessageToEndpoint_NoSocketReuse(__network_interface, "create", "Data", LINKS_MESSAGE_JSON.c_str());
danielelopez 15:32ada27d82b4 282 }
danielelopez 18:c6c9cce5d990 283 #endif
danielelopez 18:c6c9cce5d990 284
danielelopez 18:c6c9cce5d990 285 // If assets and links should be skipped...
danielelopez 18:c6c9cce5d990 286 #if SEND_ASSETS_AND_LINKS == DO_NOT_SEND_ASSETS_AND_LINKS
danielelopez 18:c6c9cce5d990 287 void OMFLib_sendInitialOMFMessages(NetworkInterface* __network_interface) {
danielelopez 18:c6c9cce5d990 288 // Send the DYNAMIC types message, so that these types can be referenced in all later messages
danielelopez 18:c6c9cce5d990 289 printf("\n\r!!!!!!!! Sending DYNAMIC Types message... !!!!!!!!\n\r");
danielelopez 18:c6c9cce5d990 290 //OMFLib_sendMessageToEndpoint(socket, "create", "Type", dynamic_types_message_JSON.c_str());
danielelopez 18:c6c9cce5d990 291 //OMFLib_sendMessageToEndpoint_NoSocketReuse(network, "create", "Type", DYNAMIC_TYPES_MESSAGE_JSON.c_str());
danielelopez 18:c6c9cce5d990 292 OMFLib_sendMessageToEndpoint_NoSocketReuse(__network_interface, "create", "Type", DYNAMIC_TYPES_MESSAGE_JSON.c_str());
danielelopez 18:c6c9cce5d990 293
danielelopez 18:c6c9cce5d990 294 // Send the container message, to instantiate this particular container; we can now directly start sending data to it using its Id
danielelopez 18:c6c9cce5d990 295 printf("\n\r!!!!!!!! Sending Containers message... !!!!!!!!\n\r");
danielelopez 18:c6c9cce5d990 296 //OMFLib_sendMessageToEndpoint(socket, "create", "Container", CONTAINERS_MESSAGE_JSON.c_str());
danielelopez 18:c6c9cce5d990 297 //OMFLib_sendMessageToEndpoint_NoSocketReuse(network, "create", "Container", CONTAINERS_MESSAGE_JSON.c_str());
danielelopez 18:c6c9cce5d990 298 OMFLib_sendMessageToEndpoint_NoSocketReuse(__network_interface, "create", "Container", CONTAINERS_MESSAGE_JSON.c_str());
danielelopez 18:c6c9cce5d990 299 }
danielelopez 18:c6c9cce5d990 300 #endif