MQTT_Server component added

Signed-off-by: eantwuh <antal.wu-hen-chang@ericsson.com>
diff --git a/IFW_MQTT_Server_Definitions.ttcn b/IFW_MQTT_Server_Definitions.ttcn
new file mode 100644
index 0000000..c57ac5e
--- /dev/null
+++ b/IFW_MQTT_Server_Definitions.ttcn
@@ -0,0 +1,63 @@
+///////////////////////////////////////////////////////////////////////////////
+//
+// Copyright (c) 2000-2020 Ericsson Telecom AB
+//
+// All rights reserved. This program and the accompanying materials
+// are made available under the terms of the Eclipse Public License v2.0
+// which accompanies this distribution, and is available at
+// https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html
+///////////////////////////////////////////////////////////////////////////////
+//  File:               IFW_MQTT_Server_Definitions.ttcn
+//  Description:
+//  Rev:                <RnXnn>
+//  Prodnr:             CNL 113 910
+//  Updated:            2020-03-06
+//  Contact:            http://ttcn.ericsson.se
+///////////////////////////////////////////////////////////////////////////////
+module IFW_MQTT_Server_Definitions
+{
+  import from MQTT_v3_1_1_Types all;
+  import from IPL4asp_PortType all;
+  import from IFW_Common all;
+
+  type component IFW_MQTT_Server_CT extends IFW_BASE_CT
+  {
+    var MqttServerContext ctx := c_MqttServerContext_empty; 
+
+    var MQTT_v3_1_1_ReqResp msgToSend := c_MQTTMessage_empty;
+    var MQTT_v3_1_1_ReqResp lastReceived := c_MQTTMessage_empty;
+
+    port IPL4asp_PT IPL4_PCO;
+  }
+
+  type record MqttServerContext
+  {
+    integer serverConnId,
+    integer clientConnId,
+    charstring localHost,
+    integer localPort,
+    charstring remoteHost,
+    integer remotePort
+  }	
+  with { extension "done" }
+
+  const MqttServerContext c_MqttServerContext_empty :=
+  {
+    serverConnId := -1,
+    clientConnId := -1,
+    localHost := "",
+    localPort := -1,
+    remoteHost := "",
+    remotePort := -1
+  }
+
+  const MQTT_v3_1_1_ReqResp c_MQTTMessage_empty :=
+  {
+    pingreq :=
+    {
+      header := {
+        flags := '0000'B
+      }
+    }
+  }
+}
diff --git a/IFW_MQTT_Server_Functions.ttcn b/IFW_MQTT_Server_Functions.ttcn
new file mode 100644
index 0000000..2e92e95
--- /dev/null
+++ b/IFW_MQTT_Server_Functions.ttcn
@@ -0,0 +1,169 @@
+///////////////////////////////////////////////////////////////////////////////
+//
+// Copyright (c) 2000-2020 Ericsson Telecom AB
+//
+// All rights reserved. This program and the accompanying materials
+// are made available under the terms of the Eclipse Public License v2.0
+// which accompanies this distribution, and is available at
+// https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html
+///////////////////////////////////////////////////////////////////////////////
+//  File:               IFW_MQTT_Server_Functions.ttcn
+//  Description:
+//  Rev:                <RnXnn>
+//  Prodnr:             CNL 113 910
+//  Updated:            2020-03-06
+//  Contact:            http://ttcn.ericsson.se
+///////////////////////////////////////////////////////////////////////////////
+module IFW_MQTT_Server_Functions
+{
+  import from IFW_MQTT_Server_Definitions all;
+  import from MQTT_v3_1_1_Types all;
+  import from MQTT_v3_1_1_IPL4SizeFunction all;
+  import from IPL4asp_Types all;
+  import from IPL4asp_PortType all;
+  import from IFW_Common all;
+  import from TCCMessageHandling_Functions all;
+
+  function f_MQTT_Server_init() runs on IFW_MQTT_Server_CT
+  {
+    log(%definitionId, " started");
+    var Result vl_result;
+
+    log("Mapping started");
+    map(self:IPL4_PCO,system:IPL4_PCO);
+    var f_IPL4_getMsgLen vl_f := refers(f_GetMsgLengthMQTT);
+    f_IPL4_setGetMsgLen(IPL4_PCO, -1, vl_f, {});
+
+    log("Creating the server socket");
+    vl_result := f_IPL4_listen(IPL4_PCO, ctx.localHost, ctx.localPort, {tcp := {}}, {{reuseAddress := {enable := true}}});
+    f_checkResult(vl_result);
+    ctx.serverConnId := vl_result.connId;
+
+    log(%definitionId, " finished");
+  }	
+
+  function f_MQTT_Server_cleanUp() runs on IFW_MQTT_Server_CT
+  {
+    log(%definitionId, " started");
+    var Result vl_result;
+
+    log("Closing connection");
+    if (ctx.serverConnId >= 0)
+    {
+      vl_result := f_IPL4_close(IPL4_PCO, ctx.serverConnId, {tcp := {}});
+      //f_checkResult(vl_result);		  
+    }
+
+    log(%definitionId, " finished");
+  }
+	
+  function f_MQTT_Server_getContext() runs on IFW_MQTT_Server_CT
+  return MqttServerContext
+  {
+    return ctx;
+  }
+	
+  function f_MQTT_Server_setContext(in MqttServerContext p_ctx) runs on IFW_MQTT_Server_CT
+  {
+    ctx := p_ctx;
+  }
+	
+  function f_MQTT_Server_setMessageToSend(in MQTT_v3_1_1_ReqResp p_msg) runs on IFW_MQTT_Server_CT
+  {
+    msgToSend := p_msg;
+  }	
+	
+  function f_MQTT_Server_send() runs on IFW_MQTT_Server_CT
+  {
+    var octetstring v_encoded := ''O;
+
+    f_MQTT_v3_1_1_enc({ msg := msgToSend}, v_encoded);
+
+    var ASP_SendTo vl_send;
+
+    vl_send.connId := ctx.clientConnId;
+    vl_send.remName := ctx.remoteHost;
+    vl_send.remPort := ctx.remotePort;
+    vl_send.proto := {tcp := {}}
+
+    vl_send.msg := v_encoded;
+
+    log("MQTT PDU: ", msgToSend);
+    log("IPL4 PDU: ", vl_send);
+    IPL4_PCO.send(vl_send);
+  }
+	
+  function f_MQTT_Server_receive(in float p_maxWait := 10.0) runs on IFW_MQTT_Server_CT
+  {
+    timer t_Timeout := p_maxWait;
+    if (p_maxWait > 0.0) { t_Timeout.start; }
+
+    var ASP_RecvFrom v_ipl4Recv;
+    var ASP_Event v_ipl4Event;
+
+    alt
+    {
+      [] IPL4_PCO.receive(ASP_RecvFrom:?) -> value v_ipl4Recv
+      {
+        log("Received: ", v_ipl4Recv);
+
+        if (ispresent(v_ipl4Recv.connId)) { ctx.clientConnId := v_ipl4Recv.connId; }
+
+        var MQTT_v3_1_1_Message v_mqttMsg;
+	f_MQTT_v3_1_1_dec(v_ipl4Recv.msg, v_mqttMsg);
+
+        if (ischosen(v_mqttMsg.msg))
+        {
+          lastReceived := v_mqttMsg.msg;
+          log("MQTT PDU: ", lastReceived);          
+        }
+        else {
+          lastReceived := c_MQTTMessage_empty;
+          log("MQTT PDU [raw]:",v_mqttMsg);
+        }
+          
+        ctx.remoteHost := v_ipl4Recv.remName;
+        ctx.remotePort := v_ipl4Recv.remPort;
+        log("IPL4 PDU: ", lastReceived);
+      }
+      [] IPL4_PCO.receive(ASP_Event:?) -> value v_ipl4Event
+      {
+	log("Received: ", v_ipl4Event);
+	repeat;
+      }
+      [] t_Timeout.timeout
+      {
+	lastReceived := c_MQTTMessage_empty;
+      }
+    }
+  }
+  
+  function f_MQTT_Server_check(in template MQTT_v3_1_1_ReqResp p_expected) runs on IFW_MQTT_Server_CT
+  return ReturnBoolean
+  {
+    if (not match(lastReceived, p_expected)) 
+    {
+      log("CHECK: last received is not matching with expected template");
+      return false;
+    }
+
+    log("CHECK: return true");
+    return true;
+  }	
+
+  function f_MQTT_Server_close() runs on IFW_MQTT_Server_CT
+  {
+    log(%definitionId, " started");
+    var Result vl_result;
+
+    log("Closing connection");
+    if (ctx.serverConnId >= 0)
+    {
+      vl_result := f_IPL4_close(IPL4_PCO, ctx.serverConnId, {tcp := {}});
+      //f_checkResult(vl_result);		  
+    }
+
+    log(%definitionId, " finished");
+  }
+
+}
diff --git a/IFW_MQTT_Server_TestSteps.ttcn b/IFW_MQTT_Server_TestSteps.ttcn
new file mode 100644
index 0000000..d2e97ec
--- /dev/null
+++ b/IFW_MQTT_Server_TestSteps.ttcn
@@ -0,0 +1,143 @@
+///////////////////////////////////////////////////////////////////////////////
+//
+// Copyright (c) 2000-2020 Ericsson Telecom AB
+//
+// All rights reserved. This program and the accompanying materials
+// are made available under the terms of the Eclipse Public License v2.0
+// which accompanies this distribution, and is available at
+// https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html
+///////////////////////////////////////////////////////////////////////////////
+//  File:               IFW_MQTT_Server_TestSteps.ttcn
+//  Description:
+//  Rev:                <RnXnn>
+//  Prodnr:             CNL 113 910
+//  Updated:            2020-03-06
+//  Contact:            http://ttcn.ericsson.se
+///////////////////////////////////////////////////////////////////////////////
+module IFW_MQTT_Server_TestSteps 
+{
+
+ import from IoT_FT_Framework_Definitions all;
+ import from IFW_Common all;
+ import from IFW_MQTT_Server_Definitions all;
+ import from IFW_MQTT_Server_Functions all;
+ import from MQTT_v3_1_1_Types all;
+	
+  function f_IFW_MqttServer_init(in integer p_serverIdx) runs on IFW_MAIN_CT
+  return boolean
+  {
+    var IFW_MQTT_Server_CT v_server := mqttServers[p_serverIdx];	  
+    if (v_server == null) { log("IFW: No MQTT server found"); return false; }
+    f_isRunningGuard(v_server);
+
+    v_server.start(f_MQTT_Server_init());
+    v_server.done;
+
+    return true;	  
+  }
+	
+  function f_IFW_MqttServer_cleanUp(in integer p_serverIdx) runs on IFW_MAIN_CT
+  return boolean
+  {
+    var IFW_MQTT_Server_CT v_server := mqttServers[p_serverIdx];
+    if (v_server == null) { log("IFW: No MQTT server found"); return false; }
+    f_isRunningGuard(v_server);
+
+    v_server.start(f_MQTT_Server_cleanUp());
+    v_server.done;
+
+    return true;	  
+  }
+	
+  function f_IFW_MqttServer_getContext(in integer p_serverIdx, out MqttServerContext p_mqttServerContext) runs on IFW_MAIN_CT
+  return boolean
+  {
+    var IFW_MQTT_Server_CT v_server := mqttServers[p_serverIdx];
+    if (v_server == null) { log("IFW: No MQTT server found"); return false; }	  
+    f_isRunningGuard(v_server);
+
+    v_server.start(f_MQTT_Server_getContext());
+    v_server.done(MqttServerContext:?) -> value p_mqttServerContext;
+
+    return true;
+  }
+	
+  function f_IFW_MqttServer_setContext(in integer p_serverIdx, in MqttServerContext p_mqttServerContext) runs on IFW_MAIN_CT
+  return boolean
+  {
+    var IFW_MQTT_Server_CT v_server := mqttServers[p_serverIdx];	  
+    if (v_server == null) { log("IFW: No MQTT server found"); return false; }	  
+    f_isRunningGuard(v_server);
+
+    v_server.start(f_MQTT_Server_setContext(p_mqttServerContext));
+    v_server.done;
+
+    return true;
+  }	
+	
+  function f_IFW_MqttServer_setMessageToSend(in integer p_serverIdx, MQTT_v3_1_1_ReqResp p_msg) runs on IFW_MAIN_CT
+  return boolean
+  {
+    var IFW_MQTT_Server_CT v_server := mqttServers[p_serverIdx];	  
+    if (v_server == null) { log("IFW: No MQTT server found"); return false; }	  
+    f_isRunningGuard(v_server);
+
+    v_server.start(f_MQTT_Server_setMessageToSend(p_msg));
+    v_server.done;
+
+    return true;
+  }
+	
+  function f_IFW_MqttServer_send(in integer p_serverIdx) runs on IFW_MAIN_CT
+  return boolean
+  {
+    var IFW_MQTT_Server_CT v_server := mqttServers[p_serverIdx];	  
+    if (v_server == null) { log("IFW: No MQTT server found"); return false; }	  
+    f_isRunningGuard(v_server);
+
+    v_server.start(f_MQTT_Server_send());
+    v_server.done;
+
+    return true;
+  }
+
+  function f_IFW_MqttServer_receive(in integer p_serverIdx) runs on IFW_MAIN_CT
+  return boolean
+  {
+    var IFW_MQTT_Server_CT v_server := mqttServers[p_serverIdx];	  
+    if (v_server == null) { log("IFW: No MQTT server found"); return false; }	  
+    f_isRunningGuard(v_server);
+
+    v_server.start(f_MQTT_Server_receive());
+    v_server.done;
+
+    return true;
+  }
+
+  function f_IFW_MqttServer_check(in integer p_serverIdx, template MQTT_v3_1_1_ReqResp p_msg) runs on IFW_MAIN_CT
+  return boolean
+  {
+    var boolean v_ret;
+    var IFW_MQTT_Server_CT v_server := mqttServers[p_serverIdx];	  
+    if (v_server == null) { log("IFW: No MQTT server found"); return false; }	  
+    f_isRunningGuard(v_server);
+
+    v_server.start(f_MQTT_Server_check(p_msg));
+    v_server.done(ReturnBoolean:?) -> value v_ret; 
+
+    return v_ret;
+  }
+	
+  function f_IFW_MqttServer_close(in integer p_serverIdx) runs on IFW_MAIN_CT
+  return boolean
+  {
+    var IFW_MQTT_Server_CT v_server := mqttServers[p_serverIdx];
+    if (v_server == null) { log("IFW: No MQTT server found"); return false; }
+    f_isRunningGuard(v_server);
+
+    v_server.start(f_MQTT_Server_close());
+    v_server.done;
+
+    return true;	  
+  }
+}
diff --git a/IoT_FT_Framework_Definitions.ttcn b/IoT_FT_Framework_Definitions.ttcn
index 6445e36..a194c00 100644
--- a/IoT_FT_Framework_Definitions.ttcn
+++ b/IoT_FT_Framework_Definitions.ttcn
@@ -21,6 +21,7 @@
   import from IFW_HTTP_Client_Definitions all;
   import from IFW_HTTP_Server_Definitions all;
   import from IFW_MQTT_Client_Definitions all;
+  import from IFW_MQTT_Server_Definitions all;
 
   type component IFW_MAIN_CT
   extends IFW_BASE_CT
@@ -29,6 +30,7 @@
     var IFW_HTTP_Client_CT_List httpClients := {};
     var IFW_HTTP_Server_CT_List httpServers := {};
     var IFW_MQTT_Client_CT_List mqttClients := {};
+    var IFW_MQTT_Server_CT_List mqttServers := {};
 		
     var integer mid := 0;
   }
@@ -37,12 +39,14 @@
   type record of IFW_HTTP_Client_CT IFW_HTTP_Client_CT_List;
   type record of IFW_HTTP_Server_CT IFW_HTTP_Server_CT_List;
   type record of IFW_MQTT_Client_CT IFW_MQTT_Client_CT_List;
-	
+  type record of IFW_MQTT_Server_CT IFW_MQTT_Server_CT_List;
+
   type enumerated IFW_ComponentTypes
   {
     COAP_PEER,
     HTTP_CLIENT,
     HTTP_SERVER,
-    MQTT_CLIENT
+    MQTT_CLIENT,
+    MQTT_SERVER
   }
 }
diff --git a/IoT_FT_Framework_Functions.ttcn b/IoT_FT_Framework_Functions.ttcn
index 02681da..1dc7eb2 100644
--- a/IoT_FT_Framework_Functions.ttcn
+++ b/IoT_FT_Framework_Functions.ttcn
@@ -25,6 +25,8 @@
   import from IFW_HTTP_Server_TestSteps all;
   import from IFW_MQTT_Client_Definitions all;
   import from IFW_MQTT_Client_TestSteps all;
+  import from IFW_MQTT_Server_Definitions all;
+  import from IFW_MQTT_Server_TestSteps all;
   import from IFW_Common all;
 	
   function f_IFW_addComponent(IFW_ComponentTypes p_componentType, charstring p_addrId := "")
@@ -47,6 +49,10 @@
     {
       return f_IFW_addMqttClientComponent(p_addrId);
     }
+    else if (p_componentType == MQTT_SERVER)
+    {
+      return f_IFW_addMqttServerComponent(p_addrId);
+    }
 
     return -1;
   }
@@ -139,6 +145,28 @@
     return v_clientIdx;
   }
 	
+  function f_IFW_addMqttServerComponent(charstring p_addrId := "") runs on IFW_MAIN_CT
+  return integer
+  {
+    var IFW_MQTT_Server_CT v_server := IFW_MQTT_Server_CT.create alive;
+    var integer v_serverIdx := sizeof(mqttServers);
+
+    mqttServers[v_serverIdx] := v_server;
+
+    var NamedHostPort v_addr;
+    if (f_lookupAddress(p_addrId, v_addr))
+    {
+      var MqttServerContext v_ctx;
+      f_IFW_MqttServer_getContext(v_serverIdx, v_ctx);
+      v_ctx.localHost := v_addr.hostName;
+      v_ctx.localPort := v_addr.portNumber;
+
+      f_IFW_MqttServer_setContext(v_serverIdx, v_ctx);
+    }
+
+    return v_serverIdx;
+  }
+	
   function f_IFW_initComponents() runs on IFW_MAIN_CT
   {
     setverdict(pass);
@@ -156,6 +184,9 @@
     for (var integer i:=0; i<sizeof(mqttClients); i:=i+1) {
       f_IFW_MqttClient_init(i);
     }
+    for (var integer i:=0; i<sizeof(mqttServers); i:=i+1) {
+      f_IFW_MqttServer_init(i);
+    }
   }
 	
   function f_IFW_cleanUp() runs on IFW_MAIN_CT
@@ -169,6 +200,9 @@
     for (var integer i:=0; i<sizeof(mqttClients); i:=i+1) {
       f_IFW_MqttClient_cleanUp(i);
     }
+    for (var integer i:=0; i<sizeof(mqttServers); i:=i+1) {
+      f_IFW_MqttServer_cleanUp(i);
+    }
     stop;
   }
 }
diff --git a/IoT_Functiontest_Framework.tpd b/IoT_Functiontest_Framework.tpd
index 92a4fbe..dbd4382 100644
--- a/IoT_Functiontest_Framework.tpd
+++ b/IoT_Functiontest_Framework.tpd
@@ -20,7 +20,9 @@
     <ReferencedProject name="LightweightM2M_EncDec" projectLocationURI="../EPTF_Applib_LWM2M_CNL113859/LightweightM2M_EncDec.tpd"/>
     <ReferencedProject name="IPL4asp_CNL113531" projectLocationURI="../../TestPorts/IPL4asp_CNL113531/IPL4asp_CNL113531.tpd"/>
     <ReferencedProject name="HTTPmsg_CNL113312" projectLocationURI="../../TestPorts/HTTPmsg_CNL113312/HTTPmsg_CNL113312.tpd"/>
-    <ReferencedProject name="MQTT_v3.1.1_CNL113831" projectLocationURI="../../ProtocolModules/MQTT_v3.1.1_CNL113831/MQTT_v3.1.1_CNL113831.tpd"/>
+    <!--
+      <ReferencedProject name="MQTT_v3.1.1_CNL113831" projectLocationURI="../../ProtocolModules/MQTT_v3.1.1_CNL113831/MQTT_v3.1.1_CNL113831.tpd"/>
+    -->
     <ReferencedProject name="TCCUsefulFunctions_CNL113472_Common" projectLocationURI="../TCCUsefulFunctions_CNL113472/TCCUsefulFunctions_CNL113472_Common.tpd"/>
   </ReferencedProjects>
   <Files>
@@ -37,6 +39,9 @@
     <FileResource projectRelativePath="IFW_MQTT_Client_Definitions.ttcn" relativeURI="IFW_MQTT_Client_Definitions.ttcn"/>
     <FileResource projectRelativePath="IFW_MQTT_Client_Functions.ttcn" relativeURI="IFW_MQTT_Client_Functions.ttcn"/>
     <FileResource projectRelativePath="IFW_MQTT_Client_TestSteps.ttcn" relativeURI="IFW_MQTT_Client_TestSteps.ttcn"/>
+    <FileResource projectRelativePath="IFW_MQTT_Server_Definitions.ttcn" relativeURI="IFW_MQTT_Server_Definitions.ttcn"/>
+    <FileResource projectRelativePath="IFW_MQTT_Server_Functions.ttcn" relativeURI="IFW_MQTT_Server_Functions.ttcn"/>
+    <FileResource projectRelativePath="IFW_MQTT_Server_TestSteps.ttcn" relativeURI="IFW_MQTT_Server_TestSteps.ttcn"/>
     <FileResource projectRelativePath="IoT_FT_Framework_Definitions.ttcn" relativeURI="IoT_FT_Framework_Definitions.ttcn"/>
     <FileResource projectRelativePath="IoT_FT_Framework_Functions.ttcn" relativeURI="IoT_FT_Framework_Functions.ttcn"/>
     <FileResource projectRelativePath="CoapTestSuite_Etsi.ttcn" relativeURI="tests/CoapTestSuite_Etsi.ttcn"/>
@@ -44,6 +49,12 @@
     <FileResource projectRelativePath="LeshanTestSuite.ttcn" relativeURI="tests/LeshanTestSuite.ttcn"/>
     <FileResource projectRelativePath="Lwm2mTestSuite.ttcn" relativeURI="tests/Lwm2mTestSuite.ttcn"/>
     <FileResource projectRelativePath="MqttTestSuite_Interop.ttcn" relativeURI="tests/MqttTestSuite_Interop.ttcn"/>
+    <!-- MQTT protocol module positive testing sources are directly included, since
+         the MQTT protocol module TPD uses the negative testing versions as default -->
+    <FileResource projectRelativePath="../../ProtocolModules/MQTT_v3.1.1_CNL113831/src/MQTT_v3_1_1_EncDec.cc" relativeURI="../../ProtocolModules/MQTT_v3.1.1_CNL113831/src/MQTT_v3_1_1_EncDec.cc"/>
+    <FileResource projectRelativePath="../../ProtocolModules/MQTT_v3.1.1_CNL113831/src/MQTT_v3_1_1_IPL4SizeFunction.ttcn" relativeURI="../../ProtocolModules/MQTT_v3.1.1_CNL113831/src/MQTT_v3_1_1_IPL4SizeFunction.ttcn"/>
+    <FileResource projectRelativePath="../../ProtocolModules/MQTT_v3.1.1_CNL113831/src/MQTT_v3_1_1_Size.cc" relativeURI="../../ProtocolModules/MQTT_v3.1.1_CNL113831/src/MQTT_v3_1_1_Size.cc"/>
+    <FileResource projectRelativePath="../../ProtocolModules/MQTT_v3.1.1_CNL113831/src/MQTT_v3_1_1_Types.ttcn" relativeURI="../../ProtocolModules/MQTT_v3.1.1_CNL113831/src/MQTT_v3_1_1_Types.ttcn"/>
   </Files>
   <ActiveConfiguration>Default</ActiveConfiguration>
   <Configurations>
diff --git a/tests/MqttTestSuite_Interop.ttcn b/tests/MqttTestSuite_Interop.ttcn
index 788a753..ff97793 100644
--- a/tests/MqttTestSuite_Interop.ttcn
+++ b/tests/MqttTestSuite_Interop.ttcn
@@ -254,9 +254,10 @@
     unsubscribe := {
       header := { flags := '0010'B },
       packet_identifier := p_id,
-      payload := {{
-    	  topic_filter := p_topic
-      }}
+      payload := { topic_filter := { p_topic } }
+      //{{
+      //	  topic_filter := p_topic
+      //}}
     }
   }
   
@@ -299,10 +300,11 @@
       },
       keep_alive := 0,
       payload := {        
-    	client_identifier := {
-    	  stringLength := 0,
-    	  stringItem := "myclientid_"&int2str(p_id)
-    	},
+        client_identifier := "",          
+        //{
+    	//  stringLength := 0,
+    	//  stringItem := "myclientid_"&int2str(p_id)
+    	//},
     	will_topic := omit,
     	will_message := omit,
     	user_name := omit,