Dan Lopez / osisoft-omf
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers osisoft-omf.h Source File

osisoft-omf.h

00001 //Copyright 2018 OSIsoft, LLC
00002 //
00003 //Licensed under the Apache License, Version 2.0 (the "License");
00004 //you may not use this file except in compliance with the License.
00005 //You may obtain a copy of the License at
00006 //
00007 //<http://www.apache.org/licenses/LICENSE-2.0>
00008 //
00009 //Unless required by applicable law or agreed to in writing, software
00010 //distributed under the License is distributed on an "AS IS" BASIS,
00011 //WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00012 //See the License for the specific language governing permissions and
00013 //limitations under the License.
00014 
00015 #ifndef OSISOFT_OMF_H
00016 #define OSISOFT_OMF_H
00017  
00018 #include "mbed.h"
00019 #include "https_request.h"
00020 #include "config.deviceID.h"
00021 
00022 // ************************************************************************
00023 // Constants used to disable printing
00024 #define DO_NOT_ENABLE_PRINTOUTS 0
00025 #define YES_ENABLE_PRINTOUTS    1
00026 
00027 // Select one of the above options
00028 #define ENABLE_PRINTOUTS    YES_ENABLE_PRINTOUTS
00029 // ************************************************************************
00030 
00031 // Automatically generated OMF-SPECIFIC CONSTANTS
00032 // Similarly, specify the name of for the data values type; this should likewise be unique
00033 // for each general class of IoT device--for example, if you were running this script on two different devices,
00034 // each with different numbers and kinds of sensors, you would specify a different data values message type name
00035 // when running the script on each device.  If both devices were the same, you could use the same data_values_message_type_name
00036 const string DATA_VALUES_MESSAGE_TYPE_NAME = DEVICE_TYPE + "_data_values_type";
00037 
00038 // The unique device name will also be used as part of the container id used to send live data values
00039 const string DATA_VALUES_CONTAINER_ID = DEVICE_NAME + "_data_values_container";
00040 
00041 // The device type will also be used for the asset type constant as well
00042 const string ASSETS_MESSAGE_TYPE_NAME = DEVICE_TYPE + "_asset_type";
00043 
00044 // Constants used for setting headers when sending OMF messages
00045 const string OMF_VERSION = "1.0";
00046 const string OMF_MESSAGE_FORMAT = "JSON";
00047 const string CONTENT_TYPE = "application/json";   
00048 
00049 // ************************************************************************
00050 // Helper function that casts floats into strings
00051 // ************************************************************************
00052 
00053 string OMFLib_float_to_string(float f);
00054 
00055 // ************************************************************************
00056 // Helper function that sends an actual web request
00057 // ************************************************************************
00058 
00059 void OMFLib_sendMessageToEndpoint(TLSSocket* socket, const char* action, const char* message_type, const char* body);
00060 
00061 // ************************************************************************
00062 // Helper function that sends an actual web request; does not reuse sockets
00063 // ************************************************************************
00064 
00065 void OMFLib_sendMessageToEndpoint_NoSocketReuse(NetworkInterface* network, const char* action, const char* message_type, const char* body);
00066 
00067 // ************************************************************************
00068 // Helper function: prints out an HTTP response
00069 // ************************************************************************
00070  
00071 void OMFLib_dump_response(HttpResponse* res);
00072 
00073 // ************************************************************************
00074 // Gets the current time in the appropriate OMF format
00075 // ************************************************************************
00076 
00077 string OMFLib_getCurrentTimeString();
00078 
00079 // ************************************************************************
00080 // Sets the clock via NTP via the nwtwork
00081 // ************************************************************************
00082 
00083 void OMFLib_syncClockViaNTP(NetworkInterface* network);
00084 
00085 // ************************************************************************
00086 // Sends the dynamic types, static types, assets, and links messages
00087 // Uses the SEND_ASSETS_AND_LINKS flag found in config.egressSettings and
00088 // Uses the custom OMF JSON found in config.customOMFJSONStructures.h
00089 // ************************************************************************
00090 
00091 void OMFLib_sendInitialOMFMessages(NetworkInterface* __network_interface);
00092  
00093 #endif