blob: 0c1d9096970ab6423888daddd17e20a6813cb188 [file] [log] [blame]
///////////////////////////////////////////////////////////////////////////////
//
// 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: EPTF_LwM2M_CoapApplibTransport_Functions.ttcn
// Description:
// Rev: R1A
// Prodnr: CNL 113 859
// Updated: 2017-09-01
// Contact: http://ttcn.ericsson.se
///////////////////////////////////////////////////////////////////////////////
module EPTF_LwM2M_CoapApplibTransport_Functions
{
import from EPTF_LwM2M_Transport_Definitions all;
import from EPTF_LwM2M_CoapApplibTransport_Definitions all;
import from LightweightM2M_CoAP_Binding all;
import from EPTF_COAP_Transport_Definitions all;
import from EPTF_COAP_LGen_Functions all;
import from EPTF_CLL_Base_Functions all;
import from EPTF_CLL_LGenBase_Definitions all;
import from LightweightM2M_CoAP_Binding all;
modulepar boolean tsp_EPTF_LwM2M_CoapApplibTransport_enabled := true;
function f_EPTF_LwM2M_CoapApplibTransport_init(in charstring pl_name)
runs on EPTF_LwM2M_CoapApplibTransport_CT
{
if (v_EPTF_LwM2M_CoapApplibTransport_initialized) {return;}
f_EPTF_COAP_LGen_init(pl_name);
f_EPTF_Base_registerCleanup(refers(f_EPTF_LwM2M_CoapApplibTransport_cleanup));
v_EPTF_LwM2M_CoapApplibTransport_initialized := true;
}
function f_EPTF_LwM2M_CoapApplibTransport_cleanup()
runs on EPTF_LwM2M_CoapApplibTransport_CT
{
// Reset DBs, close connections
v_EPTF_LwM2M_CoapApplibTransport_initialized := false;
vf_EPTF_LwM2M_Transport_receiveMessage := null;
}
function f_EPTF_LwM2M_CoapApplibTransport_send(in EPTF_LwM2M_PDU pl_msg)
runs on EPTF_LwM2M_CoapApplibTransport_CT
{
f_EPTF_COAP_Logging_VERBOSE(log2str(%definitionId, " ", pl_msg));
if (not tsp_EPTF_LwM2M_CoapApplibTransport_enabled) { return }
var integer vl_eIdx := pl_msg.eIdx;
var integer vl_fsmIdx := pl_msg.fsmIdx;
var integer vl_newFsmCtxIdx := -1;
if (not f_EPTF_COAP_isFsmInitialized(vl_eIdx, vl_fsmIdx, vl_newFsmCtxIdx))
{
f_EPTF_COAP_Logging_WARNING(%definitionId &
": FSM has not been initialized. The f_COAP_step_init function must be called as first step in the FSMs using COAP.");
return;
}
if (tsp_EPTF_LwM2M_CoapApplibTransport_debug) { action("lwm2m sending:\n", pl_msg); }
f_enc_LWM2M_to_COAP(pl_msg.pdu, v_COAP_msgToSend.pdu);
var EPTF_LGenBase_TestStepArgs l_args := c_EPTF_LGenBase_emptyTestStepArgs;
l_args.eIdx := pl_msg.eIdx;
l_args.refContext.fCtxIdx := pl_msg.fsmIdx;
if (ischosen(pl_msg.pdu.Response))
{
f_COAP_step_sendResponse(l_args);
}
else
{
f_COAP_step_send(l_args);
}
}
function f_EPTF_LwM2M_CoapApplibTransport_messageReceived(in EPTF_COAP_PDU pl_message, in boolean p_duplicate)
runs on EPTF_LwM2M_CoapApplibTransport_CT
{
f_EPTF_COAP_Logging_VERBOSE(log2str(%definitionId, " ", pl_message));
if (not tsp_EPTF_LwM2M_CoapApplibTransport_enabled) { return }
if (p_duplicate) { return }
var EPTF_LwM2M_PDU v_pdu;
f_dec_COAP_to_LWM2M(v_COAP_msgToProcess.pdu, v_pdu.pdu);
v_pdu.eIdx := pl_message.eIdx;
v_pdu.fsmIdx := pl_message.fsmIdx;
if (tsp_EPTF_LwM2M_CoapApplibTransport_debug) { action("lwm2m receiving: ", v_pdu); }
if (vf_EPTF_LwM2M_Transport_receiveMessage != null)
{
vf_EPTF_LwM2M_Transport_receiveMessage.apply(v_pdu);
}
}
}