Applib API changes applied
Signed-off-by: Antal Wu-Hen-Chang <antal.wu-hen-chang@ericsson.com>
diff --git a/IOT_LGen_Definitions.ttcn b/IOT_LGen_Definitions.ttcn
index 173fe42..f84cea5 100644
--- a/IOT_LGen_Definitions.ttcn
+++ b/IOT_LGen_Definitions.ttcn
@@ -18,7 +18,7 @@
{
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_LGen_Definitions all;
import from EPTF_COAP_LocalTransport_Definitions all;
import from EPTF_LwM2M_LGen_Definitions all;
import from EPTF_LwM2M_CoapApplibTransport_Definitions all;
@@ -29,12 +29,12 @@
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;
@@ -45,8 +45,8 @@
const integer c_FSM_fail := 2;
const integer c_FSM_timeout := 3;
- type component IOT_LGen_CT
- extends EPTF_LGenBase_CT, EPTF_ExecCtrlClient_CT,
+ 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,
@@ -55,19 +55,19 @@
{
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 :=
+
+ const LwM2M_DataSamples c_DataSamples_Latitude :=
{
name := "Latitude",
values :=
diff --git a/IOT_LGen_Functions.ttcn b/IOT_LGen_Functions.ttcn
index 18b6b86..e8909da 100644
--- a/IOT_LGen_Functions.ttcn
+++ b/IOT_LGen_Functions.ttcn
@@ -18,14 +18,13 @@
{
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;
@@ -44,39 +43,41 @@
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;
+ //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_IOT_LGen_init(pl_selfName, p_idx, pl_ExecCtrlRef);
f_EPTF_Base_wait4Shutdown();
-
+
+ f_LwM2M_DataSamples_DB_cleanUp(v_IOT_LGen_DataSamples_DB);
+
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
+ 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 :=
+
+ v_IOT_LGen_loggingMaskId :=
f_EPTF_Logging_registerComponentMasks(
- "IOT_LGen",
+ "IOT_LGen",
{"WARNING", "DEBUG", "DEBUGV" ,"ERROR" },
- EPTF_Logging_CLL);
-
+ EPTF_Logging_CLL);
+
f_EPTF_LGenBase_init(pl_selfName, 0, "IoT_Entity#");
-
- //v_InfluxDB_ctx.localPort := tsp_InfluxDB_client_basePort + p_idx;
+
+ v_InfluxDB_ctx.localPort := tsp_InfluxDB_client_basePort + p_idx;
//f_InfluxDB_init();
f_IOT_LGen_initSamples(pl_selfName);
@@ -85,30 +86,32 @@
// COAP applib init
f_EPTF_COAP_LGen_init(pl_selfName);
- f_EPTF_COAP_LocalTransport_init();
+ 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_COAP_eventIndication := refers(f_EPTF_LwM2M_CoapApplibTransport_eventIndication);
vf_EPTF_LwM2M_Transport_send := refers(f_EPTF_LwM2M_CoapApplibTransport_send);
vf_EPTF_LwM2M_Transport_receiveMessage := refers(f_EPTF_LwM2M_LGen_receiveMessage);
+ vf_EPTF_LwM2M_Transport_receiveEvent := refers(f_EPTF_LwM2M_LGen_receiveEvent);
//////////////////////
// HTTP applib init
-
+
f_EPTF_HTTP_init("HTTP", 0, "Demo Entity#");
- f_EPTF_HTTP_LocalTransport_init_CT("HTTP",
+ f_EPTF_HTTP_LocalTransport_init_CT("HTTP",
refers(f_EPTF_HTTP_messageReceived),
refers(f_EPTF_HTTP_eventReceived),
refers(f_EPTF_HTTP_socketErrorReceived)
@@ -120,12 +123,12 @@
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();
+ 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);
@@ -135,13 +138,13 @@
//////////////////////
// CLL config
-
- v_IOT_bIdx := f_EPTF_LGenBase_declareBehaviorType(c_IOT_behaviorType, -1, null, null, null);
+
+ v_IOT_bIdx := f_EPTF_LGenBase_declareBehaviorType(c_IOT_behaviorType, -1, null, null, null);
f_EPTF_LGenBase_declareEntityType(
- c_IOT_entityType,
+ c_IOT_entityType,
{
- c_COAP_behaviorType,
- c_LwM2M_behaviorType,
+ c_COAP_behaviorType,
+ c_LwM2M_behaviorType,
c_EPTF_HTTP_myBName,
c_MQTT_behaviorType
}
@@ -155,7 +158,7 @@
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
{
@@ -187,12 +190,12 @@
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),
@@ -200,10 +203,11 @@
pl_msg,
v_InfluxDB_msgToSend
);
- f_InfluxDB_send(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
{
@@ -219,10 +223,11 @@
f_InfluxDB_send(v_InfluxDB_msgToSend);
*/
}
-
+
+ /*
function f_EPTF_COAP_PDU_to_Influx(
in charstring p_lgenId,
- in charstring p_direction,
+ in charstring p_direction,
in EPTF_COAP_PDU p_pdu,
inout InfluxLineProtocol p_influx)
{
@@ -231,9 +236,9 @@
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.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"; }
@@ -245,13 +250,13 @@
{
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)});
@@ -262,7 +267,9 @@
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
diff --git a/IOT_LGen_Steps.ttcn b/IOT_LGen_Steps.ttcn
index b586130..c639d55 100644
--- a/IOT_LGen_Steps.ttcn
+++ b/IOT_LGen_Steps.ttcn
@@ -17,14 +17,14 @@
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_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 LightweightM2M_Types all;
import from EPTF_HTTP_Functions all;
import from EPTF_HTTP_Transport_Functions all;
@@ -36,7 +36,6 @@
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";
@@ -48,6 +47,7 @@
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";
+ const charstring c_IOT_stepName_LwM2M_setClientNameInRegister_stringVar := "IOT App LwM2M: setClientNameInRegister_stringVar";
// 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";
@@ -62,8 +62,11 @@
// FSM_RegDereg
const charstring c_IOT_stepName_FSM_RegDereg_initResourceValues := "IOT Fsm LWM2M_RegDereg: initResourceValues";
// FSM SimDevice
+ const charstring c_IOT_stepName_FSM_SimDevice_createResources := "IOT Fsm LWM2M_SimDevice: createResources";
const charstring c_IOT_stepName_FSM_SimDevice_initResourceValues := "IOT Fsm LWM2M_SimDevice: initResourceValues";
+ const charstring c_IOT_stepName_FSM_SimDevice_initTransport_boolVar := "IOT Fsm LWM2M_SimDevice: initTransport_boolVar";
const charstring c_IOT_stepName_FSM_SimDevice_updateResourceValues := "IOT Fsm LWM2M_SimDevice: updateResourceValues";
+ const charstring c_IOT_stepName_FSM_SimDevice_handleExecute := "IOT Fsm LWM2M_SimDevice: handleExecute";
function f_IOT_LGen_declareSteps()
runs on IOT_LGen_CT
@@ -75,9 +78,13 @@
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_createResources, refers(f_IOT_LGen_step_FSM_SimDevice_createResources)});
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_initTransport_boolVar, refers(f_IOT_LGen_step_FSM_SimDevice_initTransport_boolVar)});
f_EPTF_LGenBase_declareStep(c_IOT_behaviorType, {c_IOT_stepName_FSM_SimDevice_updateResourceValues, refers(f_IOT_LGen_step_FSM_SimDevice_updateResourceValues)});
+ f_EPTF_LGenBase_declareStep(c_IOT_behaviorType, {c_IOT_stepName_FSM_SimDevice_handleExecute, refers(f_IOT_LGen_step_FSM_SimDevice_handleExecute)});
+ 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_LwM2M_setClientNameInRegister_stringVar, refers(f_IOT_LGen_step_LwM2M_setClientNameInRegister_stringVar)});
// 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)});
@@ -92,7 +99,7 @@
// 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)});
+ 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)
@@ -158,10 +165,13 @@
if (vl_localPort < 65535)
{
- f_EPTF_COAP_addressDB_add(
+ f_EPTF_COAP_transportEndpointDB_add(
{
- hostName := vl_host.charstringVal,
- portNumber := vl_localPort
+ socket := {
+ hostName := vl_host.charstringVal,
+ portNumber := vl_localPort
+ },
+ proto := { udp := {} }
},
v_COAP_EntityCtxDB.data[v_COAP_ctx.eCtxIdx].localAddressIdx
);
@@ -250,11 +260,39 @@
function f_IOT_LGen_step_LwM2M_setClientNameInRegister(in EPTF_LGenBase_TestStepArgs pl_ptr)
runs on IOT_LGen_CT
{
+ f_EPTF_LwM2M_Logging_DEBUG(log2str(%definitionId));
+
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_LwM2M_setClientNameInRegister_stringVar(in EPTF_LGenBase_TestStepArgs pl_ptr)
+ runs on IOT_LGen_CT
+ {
+ f_EPTF_LwM2M_Logging_DEBUG(log2str(%definitionId));
+
+ var EPTF_IntegerList vl_varIds := {};
+ f_EPTF_LGenBase_fsmVarIdListFromStep(pl_ptr, vl_varIds);
+
+ if (sizeof(vl_varIds)==1)
+ {
+ var EPTF_Var_DirectContent vl_endpoint;
+ f_EPTF_Var_getContent(vl_varIds[0], vl_endpoint);
+
+ if (not ischosen(vl_endpoint.charstringVal)) {
+ f_EPTF_COAP_Logging_WARNING(log2str(%definitionId, " first param is not charstring variable!"));
+ return;
+ }
+
+ var integer vl_eRelIdxInEGrp := f_IOT_LGen_getEntityIdxinEntityGroup(pl_ptr);
+ v_LwM2M_msgToSend.pdu.Register.endpointClientName := vl_endpoint.charstringVal & int2str(vl_eRelIdxInEGrp);
+ }
+ else {
+ f_EPTF_COAP_Logging_WARNING(log2str(%definitionId, " one variable (useDTLS) is needed as parameter!"));
+ }
+ }
+
function f_IOT_LGen_step_HTTP_initEntityContext(in EPTF_LGenBase_TestStepArgs pl_ptr)
runs on IOT_LGen_CT
{
@@ -511,22 +549,25 @@
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;
+
+ var charstring vl_behavior := "behavior ["&f_EPTF_LGenBase_bIdx2Str(pl_ptr.reportedEvent.event.bIdx)&"]";
+ var charstring vl_event := "event ["&
+ f_EPTF_LGenBase_iIdx2Str(
+ pl_ptr.reportedEvent.event.bIdx,
+ pl_ptr.reportedEvent.event.iIdx,
+ f_EPTF_LGenBase_getFsmIndexByCtxIdx(pl_ptr.eIdx, pl_ptr.refContext.fCtxIdx)
+ )&"]";
+
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)&"]";
+ 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);
if (vl_verdict == pass)
{
@@ -579,40 +620,64 @@
}
}
- // 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)
+ function f_IOT_LGen_step_FSM_SimDevice_createResources(in EPTF_LGenBase_TestStepArgs pl_ptr)
runs on IOT_LGen_CT
{
- f_EPTF_COAP_Logging_DEBUG(log2str(%definitionId, pl_ptr));
-
+ }
+
+ function f_IOT_LGen_step_FSM_SimDevice_initTransport_boolVar(in EPTF_LGenBase_TestStepArgs pl_ptr)
+ runs on IOT_LGen_CT
+ {
+ f_EPTF_COAP_Logging_DEBUG(log2str(%definitionId));
+
+ if (not f_EPTF_COAP_setStepCtx(pl_ptr, v_COAP_ctx)) { return; }
+
var EPTF_IntegerList vl_varIds := {};
f_EPTF_LGenBase_fsmVarIdListFromStep(pl_ptr, vl_varIds);
-
- if (sizeof(vl_varIds)==3)
+
+ if (sizeof(vl_varIds)==1)
{
- 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!"));
+ var EPTF_Var_DirectContent vl_dtlsOn;
+ f_EPTF_Var_getContent(vl_varIds[0], vl_dtlsOn);
+
+ if (not ischosen(vl_dtlsOn.boolVal)) {
+ f_EPTF_COAP_Logging_WARNING(log2str(%definitionId, " first param is not boolean 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 });
+ // If we have to use DTLS
+ if (vl_dtlsOn.boolVal == true)
+ {
+ // We need to adjust the local and remote protocol to dtls
+ if (v_COAP_FsmCtxDB.data[v_COAP_ctx.fsmCtxIdx].remoteAddressIdx >= 0)
+ {
+ v_COAP_transportEndpointDB.data[v_COAP_EntityCtxDB.data[v_COAP_ctx.eCtxIdx].localAddressIdx].proto :=
+ { dtls := { udp := {} }};
+ v_COAP_transportEndpointDB.data[v_COAP_FsmCtxDB.data[v_COAP_ctx.fsmCtxIdx].remoteAddressIdx].proto :=
+ { dtls := { udp := {} }};
+ }
+ // We also need to initialize the DTLS connection:
+ // - we need to set the identity and the keys first into the fsmCtx
+ // we will use the tsp_EPTF_COAP_LGen_psks module par as a base and add the entity index inside the group to create the identity
+ if (sizeof(tsp_EPTF_COAP_LGen_psks) >= 1)
+ {
+ var integer vl_eRelIdxInEGrp := f_IOT_LGen_getEntityIdxinEntityGroup(pl_ptr);
+ v_COAP_FsmCtxDB.data[v_COAP_ctx.fsmCtxIdx].psk.identity := tsp_EPTF_COAP_LGen_psks[0].identity & int2str(vl_eRelIdxInEGrp);
+ v_COAP_FsmCtxDB.data[v_COAP_ctx.fsmCtxIdx].psk.key := tsp_EPTF_COAP_LGen_psks[0].key;
+ f_COAP_step_startDTLS(pl_ptr);
+ }
+ else {
+ f_EPTF_COAP_Logging_WARNING(log2str(%definitionId, " we want to use the first item in tsp_EPTF_COAP_LGen_psks to generate the identity and key!"));
+ }
+ }
+ // If we use plain UDP
+ else
+ {
+ f_COAP_step_startListening(pl_ptr);
+ }
}
else {
- f_EPTF_COAP_Logging_WARNING(log2str(%definitionId, " at least three variables are needed as params!"));
+ f_EPTF_COAP_Logging_WARNING(log2str(%definitionId, " one variable (useDTLS) is needed as parameter!"));
}
}
@@ -650,6 +715,11 @@
p_objId := 6, p_objInstId := 0, p_resourceId := 0,
p_resource := v_res
);
+ /* f_LwM2M_ObjectDB_setResourceValue(
+ p_db := v_LwM2M_DeviceDB.data[v_LwM2M_ctx.deviceIdx].objects,
+ p_objId := 6, p_objInstId := 0, p_resourceId := 0,
+ p_value := { floatValue := 47.475096 }
+ );*/
//Longitude
f_LwM2M_ObjectDB_getResource(
@@ -668,6 +738,11 @@
p_objId := 6, p_objInstId := 0, p_resourceId := 1,
p_resource := v_res
);
+ /*f_LwM2M_ObjectDB_setResourceValue(
+ p_db := v_LwM2M_DeviceDB.data[v_LwM2M_ctx.deviceIdx].objects,
+ p_objId := 6, p_objInstId := 0, p_resourceId := 1,
+ p_value := { floatValue := 19.057871 }
+ );*/
// Altitude
f_LwM2M_ObjectDB_setResourceValue(
@@ -682,73 +757,273 @@
p_objId := 3303, p_objInstId := 0, p_resourceId := 5700,
p_value := { floatValue := 34.35 }
);
+
+ // Dropped
+ f_LwM2M_ObjectDB_setResourceValue(
+ p_db := v_LwM2M_DeviceDB.data[v_LwM2M_ctx.deviceIdx].objects,
+ p_objId := 3400, p_objInstId := 0, p_resourceId := 1,
+ p_value := { boolValue := false }
+ );
}
}
function f_IOT_LGen_step_FSM_SimDevice_updateResourceValues(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);
+
var LwM2M_Resource v_res;
//////////////////
+ // Dropped
+
+ if(
+ f_LwM2M_ObjectDB_getResource(
+ p_db := v_LwM2M_DeviceDB.data[v_LwM2M_ctx.deviceIdx].objects,
+ p_objId := 3400, p_objInstId := 0, p_resourceId := 1,
+ p_resource := v_res
+ )
+ ){
+ var boolean droppableChanged := false;
+ if (v_res.val.boolValue) {
+ v_res.val.boolValue := false;
+ droppableChanged := true;
+ action("Drop cleared")
+ }
+ else {
+ var float v_rnd := rnd();
+ if (v_rnd>=0.5) {
+ v_res.val.boolValue := true;
+ droppableChanged := true;
+ action("Dropped: ",v_rnd);
+ }
+ }
+
+ if (droppableChanged)
+ {
+ f_LwM2M_ObjectDB_setResource(
+ p_db := v_LwM2M_DeviceDB.data[v_LwM2M_ctx.deviceIdx].objects,
+ p_objId := 3400, p_objInstId := 0, p_resourceId := 1,
+ p_resource := v_res
+ );
+ f_EPTF_LwM2M_sendNotificationForResource(pl_ptr, 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);
+ if (
+ 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;
+ 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);
+ if (
+ 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);
+ 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);
+ if (
+ 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);
+ 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);
+ }
}
+ function f_IOT_LGen_step_FSM_SimDevice_handleExecute(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 (ischosen(v_LwM2M_msgToProcess.pdu.Execute) and v_LwM2M_ctx.deviceIdx >= 0)
+ {
+ var LwM2M_Resource v_res;
+ var boolean vl_found := false;
+ if (f_LwM2M_ObjectPath_isResource(v_LwM2M_msgToProcess.pdu.Execute.path))
+ {
+ f_EPTF_LwM2M_Logging_DEBUG(log2str(%definitionId, " Looking up resource"));
+ vl_found := f_LwM2M_ObjectDB_getResource(
+ v_LwM2M_DeviceDB.data[v_LwM2M_ctx.deviceIdx].objects,
+ v_LwM2M_msgToProcess.pdu.Execute.path.objectId,
+ v_LwM2M_msgToProcess.pdu.Execute.path.objectInstanceId,
+ v_LwM2M_msgToProcess.pdu.Execute.path.resourceId,
+ v_res
+ );
+ f_EPTF_LwM2M_Logging_DEBUG(log2str(%definitionId, " resource found: ", v_res));
+
+ action("executed: ", v_res);
+
+ v_LwM2M_msgToSend.eIdx := v_LwM2M_ctx.eIdx;
+ v_LwM2M_msgToSend.fsmIdx := v_LwM2M_ctx.fsmIdx;
+ v_LwM2M_msgToSend.pdu :=
+ {
+ Response := {
+ location := {},
+ code := 204,
+ contentFormat := omit,
+ resources := {}
+ }
+ }
+ vf_EPTF_LwM2M_Transport_send.apply(v_LwM2M_msgToSend);
+
+ /*
+ // Execute on Reset of DropDetector
+ if (v_res.objId == 3400 and v_res.objInstId == 2)
+ {
+ f_LwM2M_ObjectDB_getResource(
+ p_db := v_LwM2M_DeviceDB.data[v_LwM2M_ctx.deviceIdx].objects,
+ p_objId := 3400, p_objInstId := 0, p_resourceId := 1,
+ p_resource := v_res
+ );
+
+ v_res.val.boolValue := false;
+ 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 := 3400, p_objInstId := 0, p_resourceId := 1,
+ p_resource := v_res
+ );
+
+ f_EPTF_LwM2M_sendNotificationForResource(pl_ptr, v_res);
+ }
+ */
+ }
+ else { f_EPTF_LwM2M_Logging_DEBUG(log2str(%definitionId, " Only resource can be executed, ignoring request")); }
+ }
+ else { f_EPTF_LwM2M_Logging_DEBUG(log2str(%definitionId, " not execute pdu, or no device available, returning")); }
+ }
+
+ // 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!"));
+ }
+ }
+
+ /*
+ // Deprecated
+
+ function f_IOT_App_step_tcFinished(in EPTF_LGenBase_TestStepArgs pl_ptr)
+ runs on IOT_LGen_CT
+ {
+ f_COAP_step_cleanUp(pl_ptr);
+ f_LwM2M_step_cleanupDevice(pl_ptr);
+
+ if(pl_ptr.refContext.fRefArgs[0]==c_FSM_pass)
+ {
+ action("=> pass");
+ f_EPTF_LGenBase_step_trafficSuccess(pl_ptr);
+ }
+ else if(pl_ptr.refContext.fRefArgs[0]==c_FSM_fail)
+ {
+ action("=> fail");
+ f_EPTF_LGenBase_step_trafficFailed(pl_ptr);
+ }
+ else//c_FSM_timeout
+ {
+ action("=> timeout");
+ f_EPTF_LGenBase_step_trafficTimeout(pl_ptr);
+ }
+ }
+
+ function f_IOT_App_step_setLocalAddress(in EPTF_LGenBase_TestStepArgs pl_ptr)
+ runs on IOT_LGen_CT
+ {
+ if (not f_EPTF_COAP_setStepCtx(pl_ptr, v_COAP_ctx)) { return; }
+
+ if (v_COAP_EntityCtxDB.data[v_COAP_ctx.eCtxIdx].localAddressIdx == -1)
+ {
+ var integer vl_localPort := -1;
+
+ if (sizeof(pl_ptr.refContext.fRefArgs)>0)
+ {
+ vl_localPort := pl_ptr.refContext.fRefArgs[0];
+ }
+ else
+ {
+ vl_localPort := tsp_localPort+v_COAP_ctx.eIdx+1;
+ }
+
+ if (vl_localPort < 65535)
+ {
+ f_EPTF_COAP_addressDB_add({tsp_remoteHost, vl_localPort}, v_COAP_EntityCtxDB.data[v_COAP_ctx.eCtxIdx].localAddressIdx);
+ }
+ else
+ {
+ v_COAP_EntityCtxDB.data[v_COAP_ctx.eCtxIdx].localAddressIdx := v_IOT_LGen_localAddressIdx;
+ }
+ }
+ }
+ */
}