initial code commit

Signed-off-by: Eszter Susanszky <eszter.susanszky@ericsson.com>
diff --git a/IOT_App_Definitions.ttcn b/IOT_App_Definitions.ttcn
new file mode 100644
index 0000000..ae26345
--- /dev/null
+++ b/IOT_App_Definitions.ttcn
@@ -0,0 +1,33 @@
+///////////////////////////////////////////////////////////////////////////////
+//
+// Copyright (c) 2000-2017 Ericsson Telecom AB
+//
+// All rights reserved. This program and the accompanying materials
+// are made available under the terms of the Eclipse Public License v1.0
+// which accompanies this distribution, and is available at
+// http://www.eclipse.org/legal/epl-v10.html
+///////////////////////////////////////////////////////////////////////////////
+//  File:               IOT_App_Definitions.ttcn
+//  Description:
+//  Rev:                R1A
+//  Prodnr:             LPA 108 661
+//  Updated:            2017-09-01
+//  Contact:            http://ttcn.ericsson.se
+///////////////////////////////////////////////////////////////////////////////
+module IOT_App_Definitions
+{
+  import from EPTF_CLL_Base_Definitions all;
+  import from EPTF_CLL_DsRestAPI_Definitions all;
+  
+  modulepar charstring 	tsp_EPTF_DsRestAPI_HTTPServer_RemoteAddress := "127.0.0.1";
+  modulepar integer 	tsp_EPTF_DsRestAPI_HTTPServer_RemotePort := 4040;
+  modulepar charstring	tsp_EPTF_DsRestAPI_HTTPServer_directory := "./WebGUI/WebGUI_link/";
+
+  modulepar charstring 	tsp_EPTF_DsRestAPI_customizableApp_directory := "./WebGUI/GUICustomization_link";
+  modulepar charstring 	tsp_EPTF_DsRestAPI_API_directory := "./WebGUI/Js_link";  
+
+  type component IOT_App_CT extends EPTF_Base_CT, EPTF_DsRestAPI_CT
+  {
+    var boolean v_ready := false; 
+  }
+}
diff --git a/IOT_App_Functions.ttcn b/IOT_App_Functions.ttcn
new file mode 100644
index 0000000..e6c00b0
--- /dev/null
+++ b/IOT_App_Functions.ttcn
@@ -0,0 +1,142 @@
+///////////////////////////////////////////////////////////////////////////////
+//
+// Copyright (c) 2000-2017 Ericsson Telecom AB
+//
+// All rights reserved. This program and the accompanying materials
+// are made available under the terms of the Eclipse Public License v1.0
+// which accompanies this distribution, and is available at
+// http://www.eclipse.org/legal/epl-v10.html
+///////////////////////////////////////////////////////////////////////////////
+//  File:               IOT_App_Functions.ttcn
+//  Description:
+//  Rev:                R1A
+//  Prodnr:             LPA 108 661
+//  Updated:            2017-09-01
+//  Contact:            http://ttcn.ericsson.se
+///////////////////////////////////////////////////////////////////////////////
+module IOT_App_Functions 
+{
+  import from IOT_App_Definitions all;
+  import from IOT_LGen_Definitions all;
+  import from IOT_LGen_Functions all;
+  import from EPTF_CLL_Base_Functions all;
+  import from EPTF_CLL_ExecCtrl_Definitions all;
+  import from EPTF_CLL_ExecCtrl_Functions all;
+  import from EPTF_CLL_DsRestAPI_Functions all;
+  
+  import from EPTF_CLL_DataSource_Definitions all;
+  import from EPTF_CLL_DataSource_Functions all;
+
+  modulepar integer     tsp_nrOfLGens := 0;
+  modulepar charstring  tsp_LGname_prefix := "IOT_LGen";
+
+  testcase TC() runs on IOT_App_CT
+  {
+    log(%definitionId,": Creating UI");
+    //f_EPTF_UIHandler_init_CT("IOT_App", false);
+    f_EPTF_DsRestAPI_init_CT("IOT_App");
+
+    log(%definitionId,": Creating ExecCtrl");
+    var EPTF_ExecCtrl_CT vc_ExtCtrl := EPTF_ExecCtrl_CT.create;
+    vc_ExtCtrl.start(f_IOT_App_startExecCtrl("ExecCtrl", tsp_nrOfLGens, self));
+
+    f_EPTF_DataSource_registerReadyCallback(refers(f_EPTF_ExecCtrl_Test_DataSourceClientReady));
+
+    log(%definitionId,": Creating LGens");
+    var IOT_LGen_CT vc_LG;
+    for (var integer i:=0; i<tsp_nrOfLGens; i:=i+1)
+    {
+      vc_LG := IOT_LGen_CT.create;
+      vc_LG.start(f_IOT_LGen_behavior(tsp_LGname_prefix & int2str(i), i, vc_ExtCtrl));
+    }
+    
+    timer T_guard, T_alt;
+    T_alt.start( 0.0 );
+    T_guard.start( 15.0 );
+    // wait until ExecCtrl DataSource is registered
+    alt{
+      [] T_guard.timeout{
+        setverdict(fail,"Timeout during config");
+        f_EPTF_Base_stopAll();
+      }
+      [v_ready] T_alt.timeout{}
+    }
+
+    //action(" ExecCtrl ready, starting reading GUI.xml");
+    //f_EPTF_UIHandler_createGUIFromFile("gui.xml");
+    var integer vl_Ret := f_EPTF_DsRestAPI_start(
+      tsp_EPTF_DsRestAPI_HTTPServer_RemoteAddress, 
+      tsp_EPTF_DsRestAPI_HTTPServer_RemotePort, 
+      tsp_EPTF_DsRestAPI_HTTPServer_directory, 
+      tsp_EPTF_DsRestAPI_customizableApp_directory, 
+      tsp_EPTF_DsRestAPI_API_directory
+    );
+    
+    /*
+    timer t;
+    t.start(tsp_testDuration);
+
+    log(%definitionId,": IOT_App: entering main EH...")
+    alt
+    {
+      [] t.timeout
+        {
+          log(%definitionId,": IOT_App: main EH: timeout...")
+        }
+    } // alt
+
+    f_EPTF_Base_cleanup_CT();
+    log(%definitionId,": finished")
+    */
+
+	f_EPTF_Base_wait4Shutdown();
+  }
+
+  function f_IOT_App_startExecCtrl(
+    in charstring pl_selfName, 
+    in integer pl_nrOfClients,
+    in EPTF_DataSource_CT pl_datasource)
+  runs on EPTF_ExecCtrl_CT
+  {
+    var EPTF_ExecCtrl_LGenFunction_Entry_List vl_functions :=
+    {
+      { name := "RIoT.createLGen", fn  := refers(f_IOT_LGen_create) }
+    }
+
+    f_EPTF_ExecCtrl_loadConfig(
+      pl_EPTF_ExecCtrl_LGenFunction_Entry_List := vl_functions
+    );
+    
+    f_EPTF_ExecCtrl_init_CT(pl_selfName, pl_nrOfClients, pl_dataSource_compRef := pl_datasource);
+    
+    f_EPTF_Base_wait4Shutdown();
+  }
+
+  function f_IOT_LGen_create
+  (
+    in charstring pl_hostname,
+    in charstring pl_componentName  
+  )
+  runs on EPTF_ExecCtrl_CT
+  return EPTF_ExecCtrlClient_CT
+  {
+    // Create LGen instance
+    var IOT_LGen_CT vc_lgen := IOT_LGen_CT.create(pl_hostname);
+
+    // Connect and Start the LGen
+    vc_lgen.start(f_IOT_LGen_behavior(tsp_LGname_prefix & pl_componentName, 0, self));
+
+    return vc_lgen;
+  }
+  
+  function f_EPTF_ExecCtrl_Test_DataSourceClientReady(
+    in charstring pl_source,
+    in charstring pl_ptcName)
+  runs on IOT_App_CT
+  {
+    if (pl_source==c_ExecCtrl_DataSource_sourceId)
+    {
+      v_ready := true;
+    }
+  }
+}
diff --git a/IOT_LGen_Definitions.ttcn b/IOT_LGen_Definitions.ttcn
new file mode 100644
index 0000000..173fe42
--- /dev/null
+++ b/IOT_LGen_Definitions.ttcn
@@ -0,0 +1,141 @@
+///////////////////////////////////////////////////////////////////////////////
+//
+// Copyright (c) 2000-2017 Ericsson Telecom AB
+//
+// All rights reserved. This program and the accompanying materials
+// are made available under the terms of the Eclipse Public License v1.0
+// which accompanies this distribution, and is available at
+// http://www.eclipse.org/legal/epl-v10.html
+///////////////////////////////////////////////////////////////////////////////
+//  File:               IOT_LGen_Definitions.ttcn
+//  Description:
+//  Rev:                R1A
+//  Prodnr:             LPA 108 661
+//  Updated:            2017-09-01
+//  Contact:            http://ttcn.ericsson.se
+///////////////////////////////////////////////////////////////////////////////
+module IOT_LGen_Definitions
+{
+  import from EPTF_MQTT_LGen_Definitions all;
+  import from EPTF_MQTT_LocalTransport_Definitions all;
+  import from EPTF_COAP_LGen_Definitions all;
+  import from EPTF_COAP_LocalTransport_Definitions all;
+  import from EPTF_LwM2M_LGen_Definitions all;
+  import from EPTF_LwM2M_CoapApplibTransport_Definitions all;
+  import from EPTF_LwM2M_Object_Definitions all;
+  import from EPTF_HTTP_Definitions all;
+  import from EPTF_HTTP_Transport_Definitions all;
+  import from EPTF_CLL_LGenBase_Definitions all;
+  import from EPTF_CLL_LGenBase_ConfigDefinitions all;
+  import from EPTF_CLL_ExecCtrl_Definitions all;
+  import from InfluxDB_Definitions all;
+
+  modulepar EPTF_LGenBase_FsmTableDeclaratorList tsp_IOT_LGen_FSMs := {}
+
+  const charstring c_IOT_entityType := "IOT_Entity";
+  const charstring c_IOT_behaviorType := "IOT_Behavior";
+
+  const integer c_IOT_LGen_Logging_WARNING := 0;
+  const integer c_IOT_LGen_Logging_DEBUG := 1;
+  const integer c_IOT_LGen_Logging_DEBUGV := 2;
+  const integer c_IOT_LGen_Logging_ERROR := 3;
+
+  const integer c_FSM_inconclusive := 0;
+  const integer c_FSM_pass := 1;
+  const integer c_FSM_fail := 2;
+  const integer c_FSM_timeout := 3;
+
+  type component IOT_LGen_CT
+  extends EPTF_LGenBase_CT, EPTF_ExecCtrlClient_CT,
+  		EPTF_MQTT_LGen_CT, EPTF_MQTT_LocalTransport_CT,
+  		EPTF_COAP_LGen_CT, EPTF_COAP_LocalTransport_CT,
+  		EPTF_LwM2M_LGen_CT, EPTF_LwM2M_CoapApplibTransport_CT,
+  		EPTF_HTTP_LGen_CT, EPTF_HTTP_LocalTransport_CT,
+  		InfluxDB_CT
+  {
+    var charstring v_IOT_LGen_name;
+    var integer v_IOT_LGen_idx;
+
+    var integer v_IOT_bIdx;
+    var integer v_IOT_LGen_loggingMaskId;
+
+    var integer v_IOT_LGen_localAddressIdx;
+    var integer v_IOT_LGen_remoteAddressIdx;
+
+    var integer v_HTTP_portGroupConnectionHandle := -1;
+
+    var LwM2M_DataSamples_DB v_IOT_LGen_DataSamples_DB := c_LwM2M_DataSamples_DB_init;
+  }
+
+    const LwM2M_DataSamples c_DataSamples_Latitude :=
+  {
+    name := "Latitude",
+    values :=
+    {
+      { floatValue := 47.475902 },
+      { floatValue := 47.476758 },
+      { floatValue := 47.477048 },
+      { floatValue := 47.477657 },
+      { floatValue := 47.478266 },
+      { floatValue := 47.478730 },
+      { floatValue := 47.479571 },
+      { floatValue := 47.480325 },
+      { floatValue := 47.481456 },
+      { floatValue := 47.482646 },
+      { floatValue := 47.484241 },
+      { floatValue := 47.484589 },
+      { floatValue := 47.485740 },
+      { floatValue := 47.485262 },
+      { floatValue := 47.484682 },
+      { floatValue := 47.484102 },
+      { floatValue := 47.483536 },
+      { floatValue := 47.482579 },
+      { floatValue := 47.482028 },
+      { floatValue := 47.481390 },
+      { floatValue := 47.480520 },
+      { floatValue := 47.479519 },
+      { floatValue := 47.478243 },
+      { floatValue := 47.477286 },
+      { floatValue := 47.476097 },
+      { floatValue := 47.475241 },
+      { floatValue := 47.474324 },
+      { floatValue := 47.473134 }
+    }
+  }
+  
+  const LwM2M_DataSamples c_DataSamples_Longitude :=
+  {
+    name := "Longitude",
+    values :=
+    {
+      { floatValue := 19.057703 },
+      { floatValue := 19.059430 },
+      { floatValue := 19.060122 },
+      { floatValue := 19.061195 },
+      { floatValue := 19.062311 },
+      { floatValue := 19.063405 },
+      { floatValue := 19.065144 },
+      { floatValue := 19.066989 },
+      { floatValue := 19.068276 },
+      { floatValue := 19.068877 },
+      { floatValue := 19.069435 },
+      { floatValue := 19.069521 },
+      { floatValue := 19.070077 },
+      { floatValue := 19.071772 },
+      { floatValue := 19.073231 },
+      { floatValue := 19.074798 },
+      { floatValue := 19.076600 },
+      { floatValue := 19.079325 },
+      { floatValue := 19.080892 },
+      { floatValue := 19.082694 },
+      { floatValue := 19.085033 },
+      { floatValue := 19.087780 },
+      { floatValue := 19.091127 },
+      { floatValue := 19.093788 },
+      { floatValue := 19.096727 },
+      { floatValue := 19.098938 },
+      { floatValue := 19.097714 },
+      { floatValue := 19.096813 }
+    }
+  }
+}
diff --git a/IOT_LGen_Functions.ttcn b/IOT_LGen_Functions.ttcn
new file mode 100644
index 0000000..18b6b86
--- /dev/null
+++ b/IOT_LGen_Functions.ttcn
@@ -0,0 +1,282 @@
+///////////////////////////////////////////////////////////////////////////////
+//
+// Copyright (c) 2000-2017 Ericsson Telecom AB
+//
+// All rights reserved. This program and the accompanying materials
+// are made available under the terms of the Eclipse Public License v1.0
+// which accompanies this distribution, and is available at
+// http://www.eclipse.org/legal/epl-v10.html
+///////////////////////////////////////////////////////////////////////////////
+//  File:               IOT_LGen_Functions.ttcn
+//  Description:
+//  Rev:                R1A
+//  Prodnr:             LPA 108 661
+//  Updated:            2017-09-01
+//  Contact:            http://ttcn.ericsson.se
+///////////////////////////////////////////////////////////////////////////////
+module IOT_LGen_Functions
+{
+  import from IOT_LGen_Definitions all;
+  import from IOT_LGen_Steps all;
+
+  import from EPTF_MQTT_LGen_Definitions all;
+  import from EPTF_MQTT_LGen_Functions all;
+  import from EPTF_MQTT_LocalTransport_Functions all;
+  import from EPTF_COAP_LGen_Definitions all;
+  import from EPTF_COAP_LGen_Functions all;
+  import from EPTF_COAP_Transport_Definitions all;
+  import from EPTF_COAP_LocalTransport_Definitions all;
+  import from EPTF_COAP_LocalTransport_Functions all;
+  import from EPTF_LwM2M_LGen_Definitions all;
+  import from EPTF_LwM2M_LGen_Functions all;
+  import from EPTF_LwM2M_CoapApplibTransport_Functions all;
+  import from EPTF_LwM2M_Object_Definitions all;
+  import from EPTF_LwM2M_Object_Functions all;
+  import from EPTF_HTTP_Definitions all;
+  import from EPTF_HTTP_Functions all;
+  import from EPTF_HTTP_Transport_Functions all;
+
+  import from EPTF_CLL_Common_Definitions all;
+  import from EPTF_CLL_Base_Functions all;
+  import from EPTF_CLL_ExecCtrl_Definitions all;
+  import from EPTF_CLL_ExecCtrlClient_Functions all;
+  import from EPTF_CLL_LGenBase_Functions all;
+  import from EPTF_CLL_LGenBase_ConfigFunctions all;
+  import from EPTF_CLL_Logging_Definitions all;
+  import from EPTF_CLL_Logging_Functions all;
+
+  import from InfluxDB_Definitions all;
+  import from InfluxDB_Functions all;
+
+  function f_IOT_LGen_behavior(in charstring pl_selfName, in integer p_idx, in EPTF_ExecCtrl_CT pl_ExecCtrlRef)
+  runs on IOT_LGen_CT
+  {
+    log(%definitionId,": started...");
+
+    f_IOT_LGen_init(pl_selfName, p_idx, pl_ExecCtrlRef);
+
+    f_EPTF_Base_wait4Shutdown();
+
+    f_EPTF_Base_cleanup_CT();
+  }
+
+  function f_IOT_LGen_init(in charstring pl_selfName, in integer p_idx, in EPTF_ExecCtrl_CT pl_ExecCtrlRef)
+  runs on IOT_LGen_CT
+  {
+    v_IOT_LGen_name := pl_selfName;
+    v_IOT_LGen_idx := p_idx;
+
+    f_EPTF_Logging_init_CT(pl_selfName);
+
+    v_IOT_LGen_loggingMaskId :=
+      f_EPTF_Logging_registerComponentMasks(
+        "IOT_LGen",
+        {"WARNING", "DEBUG", "DEBUGV" ,"ERROR" },
+        EPTF_Logging_CLL);
+
+    f_EPTF_LGenBase_init(pl_selfName, 0, "IoT_Entity#");
+
+    //v_InfluxDB_ctx.localPort := tsp_InfluxDB_client_basePort + p_idx;
+    //f_InfluxDB_init();
+    
+    f_IOT_LGen_initSamples(pl_selfName);
+
+    //////////////////////
+    // COAP applib init
+
+    f_EPTF_COAP_LGen_init(pl_selfName);
+    f_EPTF_COAP_LocalTransport_init();
+
+    vf_EPTF_COAP_Transport_send := refers(f_IOT_COAP_LocalTransport_send);
+    vf_EPTF_COAP_Transport_receiveMessage := refers(f_IOT_COAP_LGen_receiveMessage);
+    vf_EPTF_COAP_Transport_receiveEvent := refers(f_EPTF_COAP_LGen_receiveEvent);
+    vf_EPTF_COAP_Transport_apiRequest := refers(f_EPTF_COAP_LocalTransport_transportApiRequest);
+    vf_EPTF_COAP_Transport_apiResponse := refers(f_EPTF_COAP_LGen_transportApiResponse);
+
+    //////////////////////
+    // LWM2M applib init
+
+    f_EPTF_LwM2M_LGen_init(pl_selfName);
+    f_EPTF_LwM2M_CoapApplibTransport_init(pl_selfName);
+
+    vf_COAP_msgReceived := refers(f_EPTF_LwM2M_CoapApplibTransport_messageReceived);
+    vf_EPTF_LwM2M_Transport_send := refers(f_EPTF_LwM2M_CoapApplibTransport_send);
+    vf_EPTF_LwM2M_Transport_receiveMessage := refers(f_EPTF_LwM2M_LGen_receiveMessage);
+
+    //////////////////////
+    // HTTP applib init
+
+    f_EPTF_HTTP_init("HTTP", 0, "Demo Entity#");
+
+    f_EPTF_HTTP_LocalTransport_init_CT("HTTP",
+      refers(f_EPTF_HTTP_messageReceived),
+      refers(f_EPTF_HTTP_eventReceived),
+      refers(f_EPTF_HTTP_socketErrorReceived)
+    );
+
+    f_EPTF_HTTP_setSendRequestFunction(refers(f_EPTF_HTTP_LocalTransport_sendMessage));
+  	f_EPTF_HTTP_setConnectionCloseFunction(refers(f_EPTF_HTTP_LocalTransport_connectionClose));
+  	f_EPTF_HTTP_setConnectionOpenFunction(refers(f_EPTF_HTTP_LocalTransport_connectionOpen));
+  	f_EPTF_HTTP_setConnectionHalfCloseFunction(refers(f_EPTF_HTTP_LocalTransport_connectionHalfClose));
+  	f_EPTF_HTTP_setClosePortOfUserFunction(refers(f_EPTF_HTTP_LocalTransport_closePortOfUser));
+  	f_EPTF_HTTP_setFreePortOfUserFunction(refers(f_EPTF_HTTP_LocalTransport_freePortOfUser));
+
+    //////////////////////
+    // MQTT applib init
+
+    f_EPTF_MQTT_LGen_init(pl_selfName);
+    f_EPTF_MQTT_LocalTransport_init();
+
+    vf_EPTF_MQTT_Transport_send := refers(f_EPTF_MQTT_LocalTransport_send);
+    vf_EPTF_MQTT_Transport_receiveMessage := refers(f_EPTF_MQTT_LGen_receiveMessage);
+    vf_EPTF_MQTT_Transport_receiveEvent := refers(f_EPTF_MQTT_LGen_receiveEvent);
+    vf_EPTF_MQTT_Transport_apiRequest := refers(f_EPTF_MQTT_LocalTransport_transportApiRequest);
+    vf_EPTF_MQTT_Transport_apiResponse := refers(f_EPTF_MQTT_LGen_transportApiResponse);
+
+    //////////////////////
+    // CLL config
+
+    v_IOT_bIdx := f_EPTF_LGenBase_declareBehaviorType(c_IOT_behaviorType, -1, null, null, null);
+    f_EPTF_LGenBase_declareEntityType(
+      c_IOT_entityType,
+      {
+    	c_COAP_behaviorType,
+    	c_LwM2M_behaviorType,
+    	c_EPTF_HTTP_myBName,
+    	c_MQTT_behaviorType
+   	  }
+	);
+
+	// Steps
+    f_IOT_LGen_declareSteps();
+
+    // FSMs
+    f_EPTF_LGenBase_declareFSMTables(tsp_IOT_LGen_FSMs);
+
+    f_EPTF_ExecCtrlClient_init_CT(pl_selfName, pl_ExecCtrlRef);   // Only after library init(s)
+  }
+
+  function f_IOT_LGen_Logging_VERBOSE(in @lazy charstring pl_message)
+  runs on IOT_LGen_CT
+  {
+    if (c_EPTF_Common_debugSwitch) {
+    	f_EPTF_Logging_debugV2(pl_message, v_IOT_LGen_loggingMaskId, {c_IOT_LGen_Logging_DEBUGV});
+	}
+  }
+
+  function f_IOT_LGen_Logging_DEBUG(in @lazy charstring pl_message)
+  runs on IOT_LGen_CT
+  {
+    if (c_EPTF_Common_debugSwitch) {
+	    f_EPTF_Logging_debugV2(pl_message, v_IOT_LGen_loggingMaskId, {c_IOT_LGen_Logging_DEBUG});
+	}
+  }
+
+  function f_IOT_LGen_Logging_WARNING(in @lazy charstring pl_message)
+  runs on IOT_LGen_CT
+  {
+    if (c_EPTF_Common_debugSwitch) {
+	    f_EPTF_Logging_debugV2(pl_message, v_IOT_LGen_loggingMaskId, {c_IOT_LGen_Logging_WARNING});
+	}
+  }
+
+  function f_IOT_LGen_Logging_ERROR(in @lazy charstring pl_message)
+  runs on IOT_LGen_CT
+  {
+    if (c_EPTF_Common_debugSwitch) {
+    	f_EPTF_Logging_debugV2(pl_message, v_IOT_LGen_loggingMaskId, {c_IOT_LGen_Logging_ERROR});
+	}
+  }
+
+  function f_IOT_COAP_LocalTransport_send(in EPTF_COAP_PDU pl_msg)
+  runs on IOT_LGen_CT
+  {
+    f_EPTF_COAP_LocalTransport_send(pl_msg);
+
+    /*
+    f_EPTF_COAP_PDU_to_Influx(
+      v_IOT_LGen_name & int2str(v_IOT_LGen_idx),
+      "out",
+      pl_msg,
+      v_InfluxDB_msgToSend
+    );
+    f_InfluxDB_send(v_InfluxDB_msgToSend);
+    */
+  }
+
+  function f_IOT_COAP_LGen_receiveMessage(in EPTF_COAP_PDU pl_message)
+  runs on IOT_LGen_CT
+  {
+    f_EPTF_COAP_LGen_receiveMessage(pl_message);
+
+    /*
+    f_EPTF_COAP_PDU_to_Influx(
+      v_IOT_LGen_name & int2str(v_IOT_LGen_idx),
+      "in",
+      pl_message,
+      v_InfluxDB_msgToSend
+    );
+    f_InfluxDB_send(v_InfluxDB_msgToSend);
+    */
+  }
+
+  function f_EPTF_COAP_PDU_to_Influx(
+  	in charstring p_lgenId,
+  	in charstring p_direction,
+  	in EPTF_COAP_PDU p_pdu,
+  	inout InfluxLineProtocol p_influx)
+  {
+    var charstring vl_mtype := "";
+	if (p_pdu.pdu.header.msg_type == CONFIRMABLE) { vl_mtype := "CON" }
+	else if (p_pdu.pdu.header.msg_type == NON_CONFIRMABLE) { vl_mtype := "NON" }
+	else if (p_pdu.pdu.header.msg_type == ACKNOWLEDGEMENT) { vl_mtype := "ACK" }
+	else if (p_pdu.pdu.header.msg_type == RESET) { vl_mtype := "RST" }
+
+	var charstring vl_mcode := "NA";
+	if (p_pdu.pdu.header.code.class == 0)
+	{
+	  if (p_pdu.pdu.header.code.detail == 0) { vl_mcode := "EMPTY"; }
+	  else if (p_pdu.pdu.header.code.detail == 1) { vl_mcode := "GET"; }
+	  else if (p_pdu.pdu.header.code.detail == 2) { vl_mcode := "POST"; }
+	  else if (p_pdu.pdu.header.code.detail == 3) { vl_mcode := "PUT"; }
+	  else if (p_pdu.pdu.header.code.detail == 4) { vl_mcode := "DELETE"; }
+	}
+	else
+	{
+	  vl_mcode := int2str(p_pdu.pdu.header.code.class*100 + p_pdu.pdu.header.code.detail);
+	}
+
+	if (not isbound(p_pdu.fsmIdx)) { p_pdu.fsmIdx := -1 }
+
+	p_influx := c_InfluxLineProtocol_empty;
+
+    p_influx.measurement := "COAP_PDUs";
+
+    f_InfluxDB_addField(p_influx, {name := "direction", val := "\"" & p_direction & "\""});
+    f_InfluxDB_addField(p_influx, {name := "lgen", val := "\"" & p_lgenId & "\""});
+    f_InfluxDB_addField(p_influx, {name := "entity", val := int2str(p_pdu.eIdx)});
+    f_InfluxDB_addField(p_influx, {name := "fsm", val := int2str(p_pdu.fsmIdx)});
+    f_InfluxDB_addField(p_influx, {name := "ip", val := "\"" & p_pdu.transportParams.localAddress.hostName & "\""});
+    f_InfluxDB_addField(p_influx, {name := "port", val := int2str(p_pdu.transportParams.localAddress.portNumber)});
+	f_InfluxDB_addField(p_influx, {name := "token", val := "\"" & oct2str(p_pdu.pdu.token) & "\""});
+	f_InfluxDB_addField(p_influx, {name := "mid", val := int2str(p_pdu.pdu.header.message_id)});
+	f_InfluxDB_addField(p_influx, {name := "type", val := "\"" & vl_mtype & "\""});
+	f_InfluxDB_addField(p_influx, {name := "code", val := "\"" & vl_mcode & "\""});
+  }
+  
+  function f_IOT_LGen_initSamples(in charstring p_selfName)
+  runs on IOT_LGen_CT
+  {
+    f_LwM2M_DataSamples_DB_init(v_IOT_LGen_DataSamples_DB, p_selfName&"_SamplesDB");
+    
+    var LwM2M_DataSamples v_longitudes := c_DataSamples_Longitude;
+    var LwM2M_DataSamples v_latitudes := c_DataSamples_Latitude;
+    
+    if (sizeof(v_longitudes.values) != sizeof(v_latitudes.values)) {
+      f_IOT_LGen_Logging_ERROR("Data sample latitude longitude mismatch!");
+    }
+    
+    f_LwM2M_DataSamples_DB_add(v_IOT_LGen_DataSamples_DB, v_longitudes);    
+    f_LwM2M_DataSamples_DB_add(v_IOT_LGen_DataSamples_DB, v_latitudes);
+  }
+}
diff --git a/IOT_LGen_Steps.ttcn b/IOT_LGen_Steps.ttcn
new file mode 100644
index 0000000..b586130
--- /dev/null
+++ b/IOT_LGen_Steps.ttcn
@@ -0,0 +1,754 @@
+///////////////////////////////////////////////////////////////////////////////
+//
+// Copyright (c) 2000-2017 Ericsson Telecom AB
+//
+// All rights reserved. This program and the accompanying materials
+// are made available under the terms of the Eclipse Public License v1.0
+// which accompanies this distribution, and is available at
+// http://www.eclipse.org/legal/epl-v10.html
+///////////////////////////////////////////////////////////////////////////////
+//  File:               IOT_LGen_Steps.ttcn
+//  Description:
+//  Rev:                R1A
+//  Prodnr:             LPA 108 661
+//  Updated:            2017-09-01
+//  Contact:            http://ttcn.ericsson.se
+///////////////////////////////////////////////////////////////////////////////
+module IOT_LGen_Steps {
+
+  import from JSON_Types all;
+  import from General_Types all;
+  import from LightweightM2M_Types all;
+  import from IOT_LGen_Definitions all;
+  import from EPTF_COAP_LGen_Functions all;
+  import from EPTF_MQTT_LGen_Functions all;
+  import from EPTF_LwM2M_LGen_Functions all;
+  import from EPTF_LwM2M_Object_Definitions all;
+  import from EPTF_LwM2M_Object_Functions all;
+  import from EPTF_HTTP_Functions all;
+  import from EPTF_HTTP_Transport_Functions all;
+
+  import from EPTF_CLL_Common_Definitions all;
+  import from EPTF_CLL_Variable_Definitions all;
+  import from EPTF_CLL_Variable_Functions all;
+  import from EPTF_CLL_LGenBase_Definitions all;
+  import from EPTF_CLL_LGenBase_StepFunctions all;
+  import from EPTF_CLL_LGenBase_ConfigFunctions all;
+  import from EPTF_CLL_ExecCtrlClient_Functions all;
+
+
+  // Generic
+    const charstring c_IOT_stepName_tcFinished_withVerdict := "IOT App: tcFinished_withVerdict";
+    const charstring c_IOT_stepName_print_stringParam := "IOT App: print_stringParam";
+    const charstring c_IOT_stepName_genRndValue_varParams := "IOT App: genRndValue_varParams";
+  // COAP
+  const charstring c_IOT_stepName_COAP_setLocalAddress_byVars := "IOT App COAP: setLocalAddress_byVars";
+  // MQTT
+  const charstring c_IOT_stepName_MQTT_setLocalAddress_byVars := "IOT App MQTT: setLocalAddress_byVars";
+  const charstring c_IOT_stepName_MQTT_setClientId_stringParam := "IOT App MQTT: setClientId_stringParam";
+  // LwM2M
+  const charstring c_IOT_stepName_LwM2M_setClientNameInRegister := "IOT App LwM2M: setClientNameInRegister";
+  // HTTP
+  const charstring c_IOT_stepName_HTTP_initEntityContext := "IOT App HTTP: initEntityContext";  
+  const charstring c_IOT_stepName_HTTP_openConnection_byVars := "IOT App HTTP: openConnection_byVars";
+  const charstring c_IOT_stepName_HTTP_closeConnection := "IOT App HTTP: closeConnection";
+  const charstring c_IOT_stepName_HTTP_setMethod_stringParam := "IOT App HTTP: setMethod_stringParam";
+  const charstring c_IOT_stepName_HTTP_setUri_stringParam := "IOT App HTTP: setUri_stringParam";
+  const charstring c_IOT_stepName_HTTP_addToUri_stringParam := "IOT App HTTP: addToUri_stringParam";
+  const charstring c_IOT_stepName_HTTP_addToUri_byVars := "IOT App HTTP: addToUri_byVars";
+  const charstring c_IOT_stepName_HTTP_addHostHeader_byVars := "IOT App HTTP: addHostHeader_byVars";
+  // Leshan
+  const charstring c_IOT_stepName_Leshan_getClientFromResponse_intoVar := "IOT App Leshan: getClientFromResponse_intoVar";
+  //  FSM_RegDereg
+  const charstring c_IOT_stepName_FSM_RegDereg_initResourceValues := "IOT Fsm LWM2M_RegDereg: initResourceValues";
+  // FSM SimDevice
+  const charstring c_IOT_stepName_FSM_SimDevice_initResourceValues := "IOT Fsm LWM2M_SimDevice: initResourceValues";
+  const charstring c_IOT_stepName_FSM_SimDevice_updateResourceValues := "IOT Fsm LWM2M_SimDevice: updateResourceValues";
+
+  function f_IOT_LGen_declareSteps()
+  runs on IOT_LGen_CT
+  {
+    // COAP
+    f_EPTF_LGenBase_declareStep(c_IOT_behaviorType, {c_IOT_stepName_COAP_setLocalAddress_byVars, refers(f_IOT_LGen_step_COAP_setLocalAddress_byVars)});
+    // MQTT
+    f_EPTF_LGenBase_declareStep(c_IOT_behaviorType, {c_IOT_stepName_MQTT_setLocalAddress_byVars, refers(f_IOT_LGen_step_MQTT_setLocalAddress_byVars)});
+    f_EPTF_LGenBase_declareStep(c_IOT_behaviorType, {c_IOT_stepName_MQTT_setClientId_stringParam, refers(f_IOT_LGen_step_MQTT_setClientId_stringParam)});
+    // LwM2M
+    f_EPTF_LGenBase_declareStep(c_IOT_behaviorType, {c_IOT_stepName_FSM_RegDereg_initResourceValues, refers(f_IOT_LGen_step_FSM_RegDereg_initResourceValues)});
+    f_EPTF_LGenBase_declareStep(c_IOT_behaviorType, {c_IOT_stepName_LwM2M_setClientNameInRegister, refers(f_IOT_LGen_step_LwM2M_setClientNameInRegister)});
+    f_EPTF_LGenBase_declareStep(c_IOT_behaviorType, {c_IOT_stepName_FSM_SimDevice_initResourceValues, refers(f_IOT_LGen_step_FSM_SimDevice_initResourceValues)});
+    f_EPTF_LGenBase_declareStep(c_IOT_behaviorType, {c_IOT_stepName_FSM_SimDevice_updateResourceValues, refers(f_IOT_LGen_step_FSM_SimDevice_updateResourceValues)});
+    // HTTP
+    f_EPTF_LGenBase_declareStep(c_IOT_behaviorType, {c_IOT_stepName_HTTP_initEntityContext, refers(f_IOT_LGen_step_HTTP_initEntityContext)});
+    f_EPTF_LGenBase_declareStep(c_IOT_behaviorType, {c_IOT_stepName_HTTP_openConnection_byVars, refers(f_IOT_LGen_step_HTTP_openConnection_byVars)});
+    f_EPTF_LGenBase_declareStep(c_IOT_behaviorType, {c_IOT_stepName_HTTP_closeConnection, refers(f_IOT_LGen_step_HTTP_closeConnection)});
+    f_EPTF_LGenBase_declareStep(c_IOT_behaviorType, {c_IOT_stepName_HTTP_setMethod_stringParam, refers(f_IOT_LGen_step_HTTP_setMethod_stringParam)});
+    f_EPTF_LGenBase_declareStep(c_IOT_behaviorType, {c_IOT_stepName_HTTP_setUri_stringParam, refers(f_IOT_LGen_step_HTTP_setUri_stringParam)});
+    f_EPTF_LGenBase_declareStep(c_IOT_behaviorType, {c_IOT_stepName_HTTP_addToUri_stringParam, refers(f_IOT_LGen_step_HTTP_addToUri_stringParam)});
+    f_EPTF_LGenBase_declareStep(c_IOT_behaviorType, {c_IOT_stepName_HTTP_addToUri_byVars, refers(f_IOT_LGen_step_HTTP_addToUri_byVars)});
+    f_EPTF_LGenBase_declareStep(c_IOT_behaviorType, {c_IOT_stepName_HTTP_addHostHeader_byVars, refers(f_IOT_LGen_step_HTTP_addHostHeader_byVars)});
+    // Leshan
+    f_EPTF_LGenBase_declareStep(c_IOT_behaviorType, {c_IOT_stepName_Leshan_getClientFromResponse_intoVar, refers(f_IOT_LGen_step_Leshan_getClientFromResponse_intoVar)});
+    // Common
+    f_EPTF_LGenBase_declareStep(c_IOT_behaviorType, {c_IOT_stepName_tcFinished_withVerdict, refers(f_IOT_LGen_step_tcFinished_withVerdict)});
+    f_EPTF_LGenBase_declareStep(c_IOT_behaviorType, {c_IOT_stepName_print_stringParam, refers(f_IOT_LGen_step_print_stringParam)});
+    f_EPTF_LGenBase_declareStep(c_IOT_behaviorType, {c_IOT_stepName_genRndValue_varParams, refers(f_IOT_LGen_step_genRndValue_varParams)});
+  }
+  
+  function f_IOT_LGen_getEntityIdxinEntityGroup(in EPTF_LGenBase_TestStepArgs pl_ptr)
+  runs on IOT_LGen_CT
+  return integer
+  {
+    var integer vl_eGrpIdx := f_EPTF_LGenBase_getEGrpOfEntity(pl_ptr.eIdx);
+    var charstring vl_eGrpName := f_EPTF_LGenBase_entityGroupName(vl_eGrpIdx);
+    
+    var integer vl_eRelIdxInEGrp :=
+      f_EPTF_ExecCtrlClient_getFirstEntityOffsetInEGrp(vl_eGrpName) + 
+      f_EPTF_LGenBase_getERelIdx(pl_ptr.eIdx);
+      
+    //action("========================");
+    //action("f_EPTF_ExecCtrlClient_getEntityGroupSize: ", f_EPTF_ExecCtrlClient_getEntityGroupSize(eGrpName));
+    //action("f_EPTF_ExecCtrlClient_getFirstEntityGlobalOffset: ", f_EPTF_ExecCtrlClient_getFirstEntityGlobalOffset(eGrpName));
+    //action("f_EPTF_ExecCtrlClient_getEntityGroupGlobalOffset: ", f_EPTF_ExecCtrlClient_getEntityGroupGlobalOffset(eGrpName));
+    //action("f_EPTF_ExecCtrlClient_getFirstEntityOffsetInEGrp: ", f_EPTF_ExecCtrlClient_getFirstEntityOffsetInEGrp(eGrpName));
+    //action("f_EPTF_LGenBase_getERelIdx(pl_ptr.eIdx): ", f_EPTF_LGenBase_getERelIdx(pl_ptr.eIdx));    
+    //action("eIdx: ", pl_ptr.eIdx);
+      
+    return vl_eRelIdxInEGrp;
+  }
+  
+  // 1st param: localHost: charstring
+  // 2nd param: localPort: integer
+  // 3rd param: offset: integer
+  function f_IOT_LGen_step_COAP_setLocalAddress_byVars(in EPTF_LGenBase_TestStepArgs pl_ptr)
+  runs on IOT_LGen_CT
+  {
+    f_EPTF_COAP_Logging_DEBUG(log2str(%definitionId, pl_ptr));
+
+    if (not f_EPTF_COAP_setStepCtx(pl_ptr, v_COAP_ctx)) { return; }
+    
+    var integer vl_eRelIdxInEGrp := f_IOT_LGen_getEntityIdxinEntityGroup(pl_ptr);
+    
+    var EPTF_IntegerList vl_varIds := {};
+    f_EPTF_LGenBase_fsmVarIdListFromStep(pl_ptr, vl_varIds);
+    
+    if (sizeof(vl_varIds)>=2)
+    {
+      var EPTF_Var_DirectContent vl_host, vl_port, vl_offset;
+      f_EPTF_Var_getContent(vl_varIds[0], vl_host);
+      f_EPTF_Var_getContent(vl_varIds[1], vl_port);
+      if (sizeof(vl_varIds)==3) { f_EPTF_Var_getContent(vl_varIds[2], vl_offset); }
+      else { vl_offset.intVal := vl_eRelIdxInEGrp; }
+      
+      if (not ischosen(vl_host.charstringVal)) {
+        f_EPTF_COAP_Logging_WARNING(log2str(%definitionId, " first param is not charstring variable!"));
+        return;
+      }
+      if (not ischosen(vl_port.intVal)) {
+        f_EPTF_COAP_Logging_WARNING(log2str(%definitionId, " second param is not integer variable!"));
+        return;
+      }
+      if (not ischosen(vl_offset.intVal)) {
+        f_EPTF_COAP_Logging_WARNING(log2str(%definitionId, " third param is not integer variable!"));
+        return;
+      }
+      
+      var integer vl_localPort := vl_port.intVal + vl_offset.intVal;
+	  f_EPTF_COAP_Logging_VERBOSE(log2str(%definitionId, " calculated local port ",vl_localPort));
+      
+      if (vl_localPort < 65535)
+      {
+        f_EPTF_COAP_addressDB_add(
+          { 
+            hostName := vl_host.charstringVal,
+            portNumber := vl_localPort
+          },
+          v_COAP_EntityCtxDB.data[v_COAP_ctx.eCtxIdx].localAddressIdx
+        );
+      }
+      else {
+        f_EPTF_COAP_Logging_WARNING(log2str(%definitionId, " calculated local port ",vl_localPort," would be larger than 65536! step aborted."));
+      }
+    }
+    else {
+      f_EPTF_COAP_Logging_WARNING(log2str(%definitionId, " at least two variables are needed as params!"));
+    }
+  }
+  
+  // 1st param: localHost: charstring
+  // 2nd param: localPort: integer
+  // 3rd param: offset: integer
+  function f_IOT_LGen_step_MQTT_setLocalAddress_byVars(in EPTF_LGenBase_TestStepArgs pl_ptr)
+  runs on IOT_LGen_CT
+  {
+    f_EPTF_MQTT_Logging_DEBUG(log2str(%definitionId, pl_ptr));
+    
+    if (not f_EPTF_MQTT_setStepCtx(pl_ptr, v_MQTT_ctx)) { return; }
+    
+    var integer vl_eRelIdxInEGrp := f_IOT_LGen_getEntityIdxinEntityGroup(pl_ptr);
+    
+    var EPTF_IntegerList vl_varIds := {};
+    f_EPTF_LGenBase_fsmVarIdListFromStep(pl_ptr, vl_varIds);
+    
+    if (sizeof(vl_varIds)>=2)
+    {
+      var EPTF_Var_DirectContent vl_host, vl_port, vl_offset;
+      f_EPTF_Var_getContent(vl_varIds[0], vl_host);
+      f_EPTF_Var_getContent(vl_varIds[1], vl_port);
+      if (sizeof(vl_varIds)==3) { f_EPTF_Var_getContent(vl_varIds[2], vl_offset); }
+      else { vl_offset.intVal := vl_eRelIdxInEGrp; }
+      
+      if (not ischosen(vl_host.charstringVal)) {
+        f_EPTF_MQTT_Logging_WARNING(log2str(%definitionId, " first param is not charstring variable!"));
+        return;
+      }
+      if (not ischosen(vl_port.intVal)) {
+        f_EPTF_MQTT_Logging_WARNING(log2str(%definitionId, " second param is not integer variable!"));
+        return;
+      }
+      if (not ischosen(vl_offset.intVal)) {
+        f_EPTF_MQTT_Logging_WARNING(log2str(%definitionId, " third param is not integer variable!"));
+        return;
+      }
+      
+      var integer vl_localPort := vl_port.intVal + vl_offset.intVal;
+	  f_EPTF_MQTT_Logging_VERBOSE(log2str(%definitionId, " calculated local port ",vl_localPort));
+      
+      if (vl_localPort < 65535)
+      {
+        f_EPTF_MQTT_addressDB_add(
+          { 
+            hostName := vl_host.charstringVal,
+            portNumber := vl_localPort
+          },
+          v_MQTT_sessionDB.data[v_MQTT_ctx.sessionIdx].localAddrIdx
+        );
+      }
+      else {
+        f_EPTF_MQTT_Logging_WARNING(log2str(%definitionId, " calculated local port ",vl_localPort," would be larger than 65536! step aborted."));
+      }
+    }
+    else {
+      f_EPTF_MQTT_Logging_WARNING(log2str(%definitionId, " at least two variables are needed as params!"));
+    }
+  }
+  
+  function f_IOT_LGen_step_MQTT_setClientId_stringParam(in EPTF_LGenBase_TestStepArgs pl_ptr)
+  runs on IOT_LGen_CT
+  {
+    f_EPTF_MQTT_Logging_DEBUG(log2str(%definitionId));
+    
+    if (not f_EPTF_MQTT_setStepCtx(pl_ptr, v_MQTT_ctx)) { return; }
+
+	var charstring vl_clientId := f_EPTF_LGenBase_charstringValOfStep(pl_ptr);
+	
+	var integer vl_eRelIdxInEGrp := f_IOT_LGen_getEntityIdxinEntityGroup(pl_ptr);
+	
+    v_MQTT_sessionDB.data[v_MQTT_ctx.sessionIdx].clientId := vl_clientId & int2str(vl_eRelIdxInEGrp);
+  }
+  
+  function f_IOT_LGen_step_LwM2M_setClientNameInRegister(in EPTF_LGenBase_TestStepArgs pl_ptr)
+  runs on IOT_LGen_CT
+  {
+    var integer vl_eRelIdxInEGrp := f_IOT_LGen_getEntityIdxinEntityGroup(pl_ptr);
+    
+    v_LwM2M_msgToSend.pdu.Register.endpointClientName := "eantwuhDev_" & int2str(vl_eRelIdxInEGrp);
+  }
+  
+  function f_IOT_LGen_step_HTTP_initEntityContext(in EPTF_LGenBase_TestStepArgs pl_ptr)
+  runs on IOT_LGen_CT
+  {
+    f_EPTF_HTTP_setEntityContext(
+      pl_eIdx := pl_ptr.eIdx,
+      pl_method := "GET", pl_uri := "",
+      pl_version_major := 1, pl_version_minor := 1,
+      pl_headerlines := {{"Connection","Keep-Alive"}},
+      pl_connId := -1, //v_HTTP_portGroupConnectionHandle,
+      pl_authDetails := -,    
+      pl_body := { charVal := "" });
+  }  
+
+  // 1st param: localHost: charstring
+  // 2nd param: localPort: integer
+  // 3rd param: remoteHost: charstring
+  // 4th param: remotePort: integer
+  function f_IOT_LGen_step_HTTP_openConnection_byVars(in EPTF_LGenBase_TestStepArgs pl_ptr)
+  runs on IOT_LGen_CT
+  {
+    f_EPTF_COAP_Logging_DEBUG(log2str(%definitionId, pl_ptr));
+    
+    var integer vl_eRelIdxInEGrp := f_IOT_LGen_getEntityIdxinEntityGroup(pl_ptr);
+    
+    var EPTF_IntegerList vl_varIds := {};
+    f_EPTF_LGenBase_fsmVarIdListFromStep(pl_ptr, vl_varIds);
+    
+    if (sizeof(vl_varIds)==4)
+    {
+      var EPTF_Var_DirectContent vl_localHost, vl_localPort, vl_remoteHost, vl_remotePort;
+      f_EPTF_Var_getContent(vl_varIds[0], vl_localHost);
+      f_EPTF_Var_getContent(vl_varIds[1], vl_localPort);
+      f_EPTF_Var_getContent(vl_varIds[2], vl_remoteHost);
+      f_EPTF_Var_getContent(vl_varIds[3], vl_remotePort);
+      
+      if (not ischosen(vl_localHost.charstringVal)) {
+        f_EPTF_COAP_Logging_WARNING(log2str(%definitionId, " first param is not charstring variable!"));
+        return;
+      }
+      if (not ischosen(vl_localPort.intVal)) {
+        f_EPTF_COAP_Logging_WARNING(log2str(%definitionId, " second param is not integer variable!"));
+        return;
+      }      
+      if (not ischosen(vl_remoteHost.charstringVal)) {
+        f_EPTF_COAP_Logging_WARNING(log2str(%definitionId, " third param is not charstring variable!"));
+        return;
+      }
+      if (not ischosen(vl_remotePort.intVal)) {
+        f_EPTF_COAP_Logging_WARNING(log2str(%definitionId, " fourth param is not integer variable!"));
+        return;
+      }
+      
+      var integer vl_clientPort := vl_localPort.intVal + vl_eRelIdxInEGrp;
+	  f_EPTF_COAP_Logging_VERBOSE(log2str(%definitionId, " calculated local port ", vl_clientPort));
+      
+      if (vl_clientPort < 65535)
+      {
+        var integer vl_portGroupId := f_EPTF_HTTP_LocalTransport_newPort({
+          name := "httpPort_"&int2str(vl_eRelIdxInEGrp),
+          localHostInformation := { vl_localHost.charstringVal, vl_clientPort},
+	  	  remoteHostInformation := { vl_remoteHost.charstringVal, vl_remotePort.intVal},
+          instantConnOpen := true,
+          instantConnClose := false, 
+          useSSL := false, 
+          userFunctions := omit
+        });
+        
+        f_EPTF_HTTP_setEntityContextConnectionId(pl_ptr.eIdx, vl_portGroupId);
+      }
+      else {
+        f_EPTF_COAP_Logging_WARNING(log2str(%definitionId, " calculated local port ",vl_clientPort," would be larger than 65536! step aborted."));
+      }
+    }
+    else {
+      f_EPTF_COAP_Logging_WARNING(log2str(%definitionId, " exactly 4 variables are needed as params!"));
+    }
+  }
+  
+  
+  function f_IOT_LGen_step_HTTP_closeConnection(in EPTF_LGenBase_TestStepArgs pl_ptr)
+  runs on IOT_LGen_CT
+  {
+    f_EPTF_COAP_Logging_DEBUG(log2str(%definitionId, pl_ptr));
+    
+    var integer vl_portGroupId := f_EPTF_HTTP_getEntityContextConnectionId(pl_ptr.eIdx);
+
+    f_EPTF_HTTP_LocalTransport_deletePort(vl_portGroupId);
+  }
+  
+  function f_IOT_LGen_step_HTTP_setUri_stringParam(in EPTF_LGenBase_TestStepArgs pl_ptr)
+  runs on IOT_LGen_CT
+  {
+  	var charstring vl_param := f_EPTF_LGenBase_charstringValOfStep(pl_ptr);
+    f_EPTF_HTTP_setEntityContextURI(pl_ptr.eIdx, vl_param);
+  }
+  
+  function f_IOT_LGen_step_HTTP_addToUri_stringParam(in EPTF_LGenBase_TestStepArgs pl_ptr)
+  runs on IOT_LGen_CT
+  {
+  	var charstring vl_param := f_EPTF_LGenBase_charstringValOfStep(pl_ptr);
+  	var charstring vl_uri := f_EPTF_HTTP_getEntityContextURI(pl_ptr.eIdx);
+    f_EPTF_HTTP_setEntityContextURI(pl_ptr.eIdx, vl_uri & vl_param);
+  }
+  
+  function f_IOT_LGen_step_HTTP_addToUri_byVars(in EPTF_LGenBase_TestStepArgs pl_ptr)
+  runs on IOT_LGen_CT
+  { 
+  	var EPTF_IntegerList vl_varIds := {};
+    f_EPTF_LGenBase_fsmVarIdListFromStep(pl_ptr, vl_varIds);
+    
+    var EPTF_Var_DirectContent vl_var;
+    var charstring vl_vars := ""
+    
+    for (var integer i:=0; i<sizeof(vl_varIds); i:=i+1) {
+      f_EPTF_Var_getContent(vl_varIds[i], vl_var);
+      if (ischosen(vl_var.charstringVal)) {
+        vl_vars := vl_vars & vl_var.charstringVal;
+      }
+      // Could handle charstring list as well
+    }
+      
+  	var charstring vl_uri := f_EPTF_HTTP_getEntityContextURI(pl_ptr.eIdx);
+    f_EPTF_HTTP_setEntityContextURI(pl_ptr.eIdx, vl_uri & vl_vars);
+  }
+  
+  function f_IOT_LGen_step_HTTP_setMethod_stringParam(in EPTF_LGenBase_TestStepArgs pl_ptr)
+  runs on IOT_LGen_CT
+  {
+    var charstring vl_param := f_EPTF_LGenBase_charstringValOfStep(pl_ptr);
+    f_EPTF_HTTP_setEntityContextMethod(pl_ptr.eIdx, vl_param);
+  }
+  
+  // 1st param: remoteHost: charstring
+  // 2nd param: remotePort: integer
+  function f_IOT_LGen_step_HTTP_addHostHeader_byVars(in EPTF_LGenBase_TestStepArgs pl_ptr)
+  runs on IOT_LGen_CT
+  {
+    //f_EPTF_HTTP_setEntityContextMethod(pl_ptr.eIdx, vl_param);
+    
+    var EPTF_IntegerList vl_varIds := {};
+    f_EPTF_LGenBase_fsmVarIdListFromStep(pl_ptr, vl_varIds);
+    
+    if (sizeof(vl_varIds)==2)
+    {
+      var EPTF_Var_DirectContent vl_host, vl_port;
+      f_EPTF_Var_getContent(vl_varIds[0], vl_host);
+      f_EPTF_Var_getContent(vl_varIds[1], vl_port);
+      
+      if (not ischosen(vl_host.charstringVal)) {
+        f_EPTF_COAP_Logging_WARNING(log2str(%definitionId, " first param is not charstring variable!"));
+        return;
+      }
+      if (not ischosen(vl_port.intVal)) {
+        f_EPTF_COAP_Logging_WARNING(log2str(%definitionId, " second param is not integer variable!"));
+        return;
+      }
+      
+	  f_EPTF_HTTP_setEntityContextAddCustomHeader(pl_ptr.eIdx,
+	    "Host",
+	    vl_host.charstringVal & ":" & int2str(vl_port.intVal)
+	  )
+	  
+    }
+    else {
+      f_EPTF_COAP_Logging_WARNING(log2str(%definitionId, " two variables are needed as params!"));
+    }
+  }
+  
+  function f_IOT_LGen_step_Leshan_getClientFromResponse_intoVar(in EPTF_LGenBase_TestStepArgs pl_ptr)
+  runs on IOT_LGen_CT
+  {
+    var EPTF_IntegerList vl_varIds := {};
+    f_EPTF_LGenBase_fsmVarIdListFromStep(pl_ptr, vl_varIds);
+    
+    if (sizeof(vl_varIds)!=1) { 
+      f_EPTF_COAP_Logging_WARNING(log2str(%definitionId, " one variable is needed!"));
+      return;
+    } 
+    
+    //action("HTTP resp: ", v_EPTF_HTTP_incomingMessage,"\n");
+    var JSON_PDU vl_json := dec_JSON(char2oct(v_EPTF_HTTP_incomingMessage.response.body));
+    //action("JSON resp:" , vl_json,"\n");
+    
+    var EPTF_CharstringList vl_clients := {};
+    
+    // Let's fetch the first
+    if (ischosen(vl_json.json_array) and sizeof(vl_json.json_array)>0) {
+      if (ischosen(vl_json.json_array[0].json_object)) {
+        for (var integer valIdx :=0; valIdx<sizeof(vl_json.json_array[0].json_object); valIdx:=valIdx+1) {
+          if (vl_json.json_array[0].json_object[valIdx].json_name == "endpoint") {
+            vl_clients[sizeof(vl_clients)] := unichar2char(vl_json.json_array[0].json_object[valIdx].json_value.json_string);
+            break;
+          }
+        }
+      }
+    }
+    
+    /*
+    if (ischosen(vl_json.json_array)) {
+      for (var integer objIdx:=0; objIdx<sizeof(vl_json.json_array); objIdx:=objIdx+1) {
+        if (ischosen(vl_json.json_array[objIdx].json_object)) {
+          for (var integer valIdx :=0; valIdx<sizeof(vl_json.json_array[objIdx].json_object); valIdx:=valIdx+1) {
+            if (vl_json.json_array[objIdx].json_object[valIdx].json_name == "endpoint") {
+              vl_clients[sizeof(vl_clients)] := vl_json.json_array[objIdx].json_object[valIdx].json_value.json_string;
+              break;
+            }
+          }
+        }
+      }
+    }
+	*/   
+    /*
+	JSON resp:=
+	{
+      json_array :=
+	  {
+        {
+          json_object :=
+          {
+            { json_name := "endpoint",  json_value := { json_string := "client_0" } },
+            { json_name := "registrationId", json_value := { json_string := "V18qVv4RL8" } },
+            { json_name := "registrationDate", json_value := { json_string := "2017-02-01T14:20:39+01:00" } },
+            { json_name := "lastUpdate", json_value := { json_string := "2017-02-01T14:20:39+01:00" } },
+            { json_name := "address", json_value := { json_string := "127.0.0.1:30000" } },
+            { json_name := "lwM2mVersion", json_value := { json_string := "1.0" } },
+            { json_name := "lifetime", json_value := { json_number := 30 } },
+            { json_name := "bindingMode", json_value := { json_string := "U" } },
+            { json_name := "rootPath", json_value := { json_string := "/" } },
+            { json_name := "objectLinks", json_value := {
+              json_array := {
+                { json_object := {
+                  { json_name := "url", json_value := { json_string := "/3/0" } },
+                  { json_name := "attributes", json_value := { json_object := { } } }
+                } } }
+              }
+            },
+            { json_name := "secure", json_value := { json_false := { } } },
+            { json_name := "additionalRegistrationAttributes", json_value := { json_object := { } } }
+          }
+        }
+      }
+    }
+    */
+    //action("clients: ", vl_clients,"\n");
+    
+    if (sizeof(vl_clients)>0)
+	{
+      // Selecting and loading the last one:
+      //action("selected client: ", vl_clients[sizeof(vl_clients)-1],"\n");
+      f_EPTF_Var_setContent(vl_varIds[0], { charstringVal := vl_clients[0]});
+    }
+  }
+  
+  function f_IOT_LGen_step_tcFinished_withVerdict(in EPTF_LGenBase_TestStepArgs pl_ptr)
+  runs on IOT_LGen_CT
+  {
+    f_EPTF_LGenBase_step_cancelAllTimers(pl_ptr);
+    f_COAP_step_cleanUp(pl_ptr);
+    f_MQTT_step_cleanUp(pl_ptr);
+    f_LwM2M_step_cleanupDevice(pl_ptr);
+    
+    var charstring vl_reason := "";
+ 	var verdicttype vl_verdict := pass;
+ 	f_EPTF_LGenBase_verdictOfStep(pl_ptr, vl_verdict, vl_reason);
+
+	var charstring vl_state := "state ["&f_EPTF_LGenBase_getFsmStateNameByStepArgs(pl_ptr)&"]";
+	
+	var integer vl_bIdx, vl_iIdx, vl_varIdx;	
+	pl_ptr.refContext.fRefArgs[c_EPTF_LGenBase_stepArgsIdxEventOfFsmVarId0] := -1;
+	f_EPTF_LGenBase_eventOfFsmFromStep(pl_ptr, vl_bIdx, vl_iIdx, vl_varIdx);	
+	var charstring vl_behavior := "behavior ["&f_EPTF_LGenBase_bIdx2Str(vl_bIdx)&"]";
+	var charstring vl_event := "event ["&f_EPTF_LGenBase_iIdx2Str(vl_bIdx, vl_iIdx)&"]";
+
+    if (vl_verdict == pass)
+    {
+      action("=> pass");
+      f_EPTF_LGenBase_step_trafficSuccess(pl_ptr);
+    }
+    else if (vl_verdict == fail)
+    {
+      action(vl_state); action(vl_behavior); action(vl_event);
+      action("=> fail");
+      f_EPTF_LGenBase_step_trafficFailed(pl_ptr);
+    }
+    else if (vl_verdict == inconc)
+    {
+      action(vl_state); action(vl_behavior); action(vl_event);
+      action("=> inconc");
+      f_EPTF_LGenBase_step_trafficTimeout(pl_ptr);
+    }
+    else if (vl_verdict == error)
+    {
+      action(vl_state); action(vl_behavior); action(vl_event);
+      action("=> error");
+      f_EPTF_LGenBase_step_trafficError(pl_ptr);
+    }
+  }
+  
+  function f_IOT_LGen_step_print_stringParam(in EPTF_LGenBase_TestStepArgs pl_ptr)
+  runs on IOT_LGen_CT
+  {
+    f_EPTF_MQTT_Logging_DEBUG(log2str(%definitionId));
+    
+	var charstring vl_toPrint := f_EPTF_LGenBase_charstringValOfStep(pl_ptr);
+	
+    action(vl_toPrint);
+  }
+  
+  function f_IOT_LGen_step_FSM_RegDereg_initResourceValues(in EPTF_LGenBase_TestStepArgs pl_ptr)
+  runs on IOT_LGen_CT
+  {
+    f_EPTF_LwM2M_Logging_DEBUG(log2str(%definitionId));
+    f_EPTF_LwM2M_setStepCtx(pl_ptr, v_LwM2M_ctx);
+    
+    if (v_LwM2M_ctx.deviceIdx >= 0)
+    {
+      f_LwM2M_ObjectDB_setResourceValue(
+        p_db := v_LwM2M_DeviceDB.data[v_LwM2M_ctx.deviceIdx].objects, 
+        p_objId := c_LwM2M_Device_obj_id, p_objInstId := 0, p_resourceId := c_LwM2M_Device_Manufacturer,
+        p_value := { strValue := "TitanSim" }
+      );
+    }
+  }
+  
+  // 1st param: min value (in): integer
+  // 2nd param: max value (in): integer
+  // 3rd param: rnd value (out): integer
+  function f_IOT_LGen_step_genRndValue_varParams(in EPTF_LGenBase_TestStepArgs pl_ptr)
+  runs on IOT_LGen_CT
+  {
+    f_EPTF_COAP_Logging_DEBUG(log2str(%definitionId, pl_ptr));
+    
+    var EPTF_IntegerList vl_varIds := {};
+    f_EPTF_LGenBase_fsmVarIdListFromStep(pl_ptr, vl_varIds);
+    
+    if (sizeof(vl_varIds)==3)
+    {
+      var EPTF_Var_DirectContent vl_min, vl_max, vl_rnd;
+      f_EPTF_Var_getContent(vl_varIds[0], vl_min);
+      f_EPTF_Var_getContent(vl_varIds[1], vl_max);
+      f_EPTF_Var_getContent(vl_varIds[2], vl_rnd);
+      
+      if (not ischosen(vl_min.intVal)) {
+        f_EPTF_COAP_Logging_WARNING(log2str(%definitionId, " first param is not integer variable!"));
+        return;
+      }
+      if (not ischosen(vl_max.intVal)) {
+        f_EPTF_COAP_Logging_WARNING(log2str(%definitionId, " second param is not integer variable!"));
+        return;
+      }
+      
+      var integer vl_randomVal := float2int(int2float(vl_max.intVal - vl_min.intVal +1)*rnd()) + vl_min.intVal;
+	  f_EPTF_COAP_Logging_VERBOSE(log2str(%definitionId, " calculated random value ",vl_randomVal));
+      
+      f_EPTF_Var_setContent(vl_varIds[2], { intVal := vl_randomVal });
+    }
+    else {
+      f_EPTF_COAP_Logging_WARNING(log2str(%definitionId, " at least three variables are needed as params!"));
+    }
+  }
+  
+  function f_IOT_LGen_step_FSM_SimDevice_initResourceValues(in EPTF_LGenBase_TestStepArgs pl_ptr)
+  runs on IOT_LGen_CT
+  {
+    f_EPTF_LwM2M_Logging_DEBUG(log2str(%definitionId));
+    f_EPTF_LwM2M_setStepCtx(pl_ptr, v_LwM2M_ctx);
+    
+    if (v_LwM2M_ctx.deviceIdx >= 0)
+    {
+      var LwM2M_Resource v_res;
+      
+      // Manufacturer
+      f_LwM2M_ObjectDB_setResourceValue(
+        p_db := v_LwM2M_DeviceDB.data[v_LwM2M_ctx.deviceIdx].objects, 
+        p_objId := c_LwM2M_Device_obj_id, p_objInstId := 0, p_resourceId := c_LwM2M_Device_Manufacturer,
+        p_value := { strValue := "RIoT" }
+      );
+      
+      // Latitude
+      f_LwM2M_ObjectDB_getResource(
+        p_db := v_LwM2M_DeviceDB.data[v_LwM2M_ctx.deviceIdx].objects, 
+        p_objId := 6, p_objInstId := 0, p_resourceId := 0,
+        p_resource := v_res
+      );      
+      v_res.dataSample := {
+        samplesName := "Latitude",
+	    samplesPointer := -1,
+	    valuePointer := -1
+      }
+      f_LwM2M_Resource_setNextDataSample(v_res, v_IOT_LGen_DataSamples_DB);
+      f_LwM2M_ObjectDB_setResource(
+        p_db := v_LwM2M_DeviceDB.data[v_LwM2M_ctx.deviceIdx].objects, 
+        p_objId := 6, p_objInstId := 0, p_resourceId := 0,
+        p_resource := v_res
+      );     
+      
+      //Longitude
+      f_LwM2M_ObjectDB_getResource(
+        p_db := v_LwM2M_DeviceDB.data[v_LwM2M_ctx.deviceIdx].objects, 
+        p_objId := 6, p_objInstId := 0, p_resourceId := 1,
+        p_resource := v_res
+      );     
+      v_res.dataSample := {
+        samplesName := "Longitude",
+	    samplesPointer := -1,
+	    valuePointer := -1
+      }
+      f_LwM2M_Resource_setNextDataSample(v_res, v_IOT_LGen_DataSamples_DB);      
+      f_LwM2M_ObjectDB_setResource(
+        p_db := v_LwM2M_DeviceDB.data[v_LwM2M_ctx.deviceIdx].objects, 
+        p_objId := 6, p_objInstId := 0, p_resourceId := 1,
+        p_resource := v_res
+      );
+      
+      // Altitude
+      f_LwM2M_ObjectDB_setResourceValue(
+        p_db := v_LwM2M_DeviceDB.data[v_LwM2M_ctx.deviceIdx].objects, 
+        p_objId := 6, p_objInstId := 0, p_resourceId := 2,
+        p_value := { floatValue := 12.0 }
+      );
+      
+      // Temperature
+      f_LwM2M_ObjectDB_setResourceValue(
+        p_db := v_LwM2M_DeviceDB.data[v_LwM2M_ctx.deviceIdx].objects, 
+        p_objId := 3303, p_objInstId := 0, p_resourceId := 5700,
+        p_value := { floatValue := 34.35 }
+      );
+    }
+  }
+  
+  function f_IOT_LGen_step_FSM_SimDevice_updateResourceValues(in EPTF_LGenBase_TestStepArgs pl_ptr)
+  runs on IOT_LGen_CT
+  { 
+    var LwM2M_Resource v_res;
+      
+    //////////////////
+    // Temperature
+    
+    f_LwM2M_ObjectDB_getResource(
+      p_db := v_LwM2M_DeviceDB.data[v_LwM2M_ctx.deviceIdx].objects, 
+      p_objId := 3303, p_objInstId := 0, p_resourceId := 5700,
+      p_resource := v_res //{ floatValue := int2float(vl_randomVal) }
+    );
+      
+    v_res.val.floatValue := int2float(32 - 10 +1)*rnd() + 10.0;
+    if (ispresent(v_res.observe)) { v_res.observe.observe := v_res.observe.observe + 1 }
+      
+    f_LwM2M_ObjectDB_setResource(
+      p_db := v_LwM2M_DeviceDB.data[v_LwM2M_ctx.deviceIdx].objects, 
+      p_objId := 3303, p_objInstId := 0, p_resourceId := 5700,
+      p_resource := v_res
+    );
+      
+    //f_EPTF_LwM2M_sendNotificationForResource(pl_ptr, v_res);
+            
+    //////////////////
+    // Latitude
+      
+    f_LwM2M_ObjectDB_getResource(
+      p_db := v_LwM2M_DeviceDB.data[v_LwM2M_ctx.deviceIdx].objects, 
+      p_objId := 6, p_objInstId := 0, p_resourceId := 0,
+      p_resource := v_res
+    );
+    
+    f_LwM2M_Resource_setNextDataSample(v_res, v_IOT_LGen_DataSamples_DB);
+    if (ispresent(v_res.observe)) { v_res.observe.observe := v_res.observe.observe + 1 }
+      
+    f_LwM2M_ObjectDB_setResource(
+      p_db := v_LwM2M_DeviceDB.data[v_LwM2M_ctx.deviceIdx].objects, 
+      p_objId := 6, p_objInstId := 0, p_resourceId := 0,
+      p_resource := v_res
+    );
+      
+    //f_EPTF_LwM2M_sendNotificationForResource(pl_ptr, v_res);
+      
+    //////////////////
+    // Longitude
+      
+    f_LwM2M_ObjectDB_getResource(
+      p_db := v_LwM2M_DeviceDB.data[v_LwM2M_ctx.deviceIdx].objects, 
+      p_objId := 6, p_objInstId := 0, p_resourceId := 1,
+      p_resource := v_res
+    );
+      
+    f_LwM2M_Resource_setNextDataSample(v_res, v_IOT_LGen_DataSamples_DB);
+    if (ispresent(v_res.observe)) { v_res.observe.observe := v_res.observe.observe + 1 }
+      
+    f_LwM2M_ObjectDB_setResource(
+      p_db := v_LwM2M_DeviceDB.data[v_LwM2M_ctx.deviceIdx].objects, 
+      p_objId := 6, p_objInstId := 0, p_resourceId := 1,
+      p_resource := v_res
+    );
+      
+    //f_EPTF_LwM2M_sendNotificationForResource(pl_ptr, v_res);
+  }
+  
+}
diff --git a/InfluxDB_Definitions.ttcn b/InfluxDB_Definitions.ttcn
new file mode 100644
index 0000000..f981c79
--- /dev/null
+++ b/InfluxDB_Definitions.ttcn
@@ -0,0 +1,77 @@
+///////////////////////////////////////////////////////////////////////////////
+//
+// Copyright (c) 2000-2017 Ericsson Telecom AB
+//
+// All rights reserved. This program and the accompanying materials
+// are made available under the terms of the Eclipse Public License v1.0
+// which accompanies this distribution, and is available at
+// http://www.eclipse.org/legal/epl-v10.html
+///////////////////////////////////////////////////////////////////////////////
+//  File:               InfluxDB_Definitions.ttcn
+//  Description:
+//  Rev:                R1A
+//  Prodnr:             LPA 108 661
+//  Updated:            2017-09-01
+//  Contact:            http://ttcn.ericsson.se
+///////////////////////////////////////////////////////////////////////////////
+module InfluxDB_Definitions
+{
+	import from IPL4asp_Types all;
+	import from IPL4asp_PortType all;
+
+	modulepar integer tsp_InfluxDB_client_basePort := 9000;
+
+	type component InfluxDB_CT
+	{
+      var InfluxDBContext v_InfluxDB_ctx := c_InfluxDBContext_empty;
+
+      var ASP_SendTo 			v_InfluxDB_sendAsp;
+      var charstring			v_InfluxDB_msgToSend_encoded;
+      var InfluxLineProtocol    v_InfluxDB_msgToSend;
+
+	  port IPL4asp_PT INFLUXDB_PCO;
+	}
+
+	type record InfluxDBContext
+	{
+		integer connId,
+		integer connId_listen,
+		charstring remoteHost,
+		integer remotePort,
+		charstring localHost,
+		integer localPort
+	}
+	with { extension "done" }
+
+	const InfluxDBContext c_InfluxDBContext_empty :=
+	{
+		connId := -1,
+		connId_listen := -1,
+		remoteHost := "127.0.0.1",
+		remotePort := 8089,
+		localHost := "127.0.0.1",
+		localPort := 9000
+	}
+
+	type record InfluxLineProtocol
+	{
+	  charstring 			measurement,
+	  InfluxAttrValue_List	tagSet,
+	  InfluxAttrValue_List	fieldSet
+	}
+
+	const InfluxLineProtocol c_InfluxLineProtocol_empty :=
+	{
+	  measurement := "",
+	  tagSet := {},
+	  fieldSet := {}
+	}
+
+	type record of InfluxAttrValue InfluxAttrValue_List;
+
+	type record InfluxAttrValue
+	{
+	  charstring name,
+	  charstring val
+	}
+}
diff --git a/InfluxDB_Functions.ttcn b/InfluxDB_Functions.ttcn
new file mode 100644
index 0000000..664fbc6
--- /dev/null
+++ b/InfluxDB_Functions.ttcn
@@ -0,0 +1,99 @@
+///////////////////////////////////////////////////////////////////////////////
+//
+// Copyright (c) 2000-2017 Ericsson Telecom AB
+//
+// All rights reserved. This program and the accompanying materials
+// are made available under the terms of the Eclipse Public License v1.0
+// which accompanies this distribution, and is available at
+// http://www.eclipse.org/legal/epl-v10.html
+///////////////////////////////////////////////////////////////////////////////
+//  File:               InfluxDB_Functions.ttcn
+//  Description:
+//  Rev:                R1A
+//  Prodnr:             LPA 108 661
+//  Updated:            2017-09-01
+//  Contact:            http://ttcn.ericsson.se
+///////////////////////////////////////////////////////////////////////////////
+module InfluxDB_Functions {
+
+	import from InfluxDB_Definitions all;
+	import from IPL4asp_Types all;
+	import from IPL4asp_PortType all;
+
+	function f_InfluxDB_init() runs on InfluxDB_CT
+	{
+		log(%definitionId, " started");
+		var Result vl_result;
+
+		log("Mapping started");
+		map(self:INFLUXDB_PCO,system:INFLUXDB_PCO);
+
+		log("InfluxDB context: ", v_InfluxDB_ctx);
+
+		log("Setting up the listening socket");
+		vl_result := f_IPL4_listen(
+			INFLUXDB_PCO,
+			v_InfluxDB_ctx.localHost,
+			v_InfluxDB_ctx.localPort, {udp := {}},
+			{{reuseAddress := {enable := true}}}
+		);
+		v_InfluxDB_ctx.connId_listen := vl_result.connId;
+
+		log("Connecting the socket to the remote");
+		vl_result := f_IPL4_connect(
+			INFLUXDB_PCO,
+			v_InfluxDB_ctx.remoteHost,
+			v_InfluxDB_ctx.remotePort,
+			v_InfluxDB_ctx.localHost,
+			v_InfluxDB_ctx.localPort,
+			-1,	{udp := {}}, {{reuseAddress := {enable := true}}}
+		);
+		v_InfluxDB_ctx.connId := vl_result.connId;
+		log(%definitionId, " finished");
+	}
+
+	function f_InfluxDB_send(in InfluxLineProtocol p_data) runs on InfluxDB_CT
+	{
+	  	f_InfluxDB_encode(p_data, v_InfluxDB_msgToSend_encoded);
+
+		v_InfluxDB_sendAsp.connId := v_InfluxDB_ctx.connId;
+		v_InfluxDB_sendAsp.remName := v_InfluxDB_ctx.remoteHost;
+		v_InfluxDB_sendAsp.remPort := v_InfluxDB_ctx.remotePort;
+		v_InfluxDB_sendAsp.proto := {udp := {}}
+
+		v_InfluxDB_sendAsp.msg := char2oct(v_InfluxDB_msgToSend_encoded);
+
+		log("Influx: ", v_InfluxDB_msgToSend);
+		INFLUXDB_PCO.send(v_InfluxDB_sendAsp);
+	}
+
+	function f_InfluxDB_encode(in InfluxLineProtocol p_prot, out charstring p_encoded)
+	{
+	  action("influx encoding: ", p_prot);
+	  p_encoded := p_prot.measurement;
+
+	  if (sizeof(p_prot.tagSet)>0) { p_encoded := p_encoded & "," }
+
+	  for (var integer i:=0; i<sizeof(p_prot.tagSet); i:=i+1)
+	  {
+	    p_encoded := p_encoded & "," & p_prot.tagSet[i].name & "=" & p_prot.tagSet[i].val;
+	  }
+	  p_encoded := p_encoded & " "
+  	  for (var integer i:=0; i<sizeof(p_prot.fieldSet); i:=i+1)
+	  {
+	    p_encoded := p_encoded & p_prot.fieldSet[i].name & "=" & p_prot.fieldSet[i].val;
+	    if (i!=sizeof(p_prot.fieldSet)-1) { p_encoded := p_encoded & "," }
+	  }
+	  action("influx encoded: ", p_encoded);
+	}
+
+	function f_InfluxDB_addTag(inout InfluxLineProtocol p_pdu, in InfluxAttrValue p_tag)
+	{
+	  p_pdu.tagSet[sizeof(p_pdu.tagSet)] := p_tag;
+	}
+
+	function f_InfluxDB_addField(inout InfluxLineProtocol p_pdu, in InfluxAttrValue p_field)
+	{
+	  p_pdu.fieldSet[sizeof(p_pdu.fieldSet)] := p_field;
+	}
+}