| /////////////////////////////////////////////////////////////////////////////// |
| // |
| // Copyright (c) 2000-2021 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: LWM2M_Opaque_EncDec.ttcn |
| // Description: |
| // Rev: R1B |
| // Prodnr: CNL 113 859 |
| // Updated: 2021-02-03 |
| // Contact: http://ttcn.ericsson.se |
| /////////////////////////////////////////////////////////////////////////////// |
| module LWM2M_Opaque_EncDec |
| { |
| import from LightweightM2M_Types all; |
| |
| function f_enc_LwM2M_Resources_to_Opaque(in LwM2M_Resource_List p_res_list) return octetstring |
| { |
| var octetstring v_result := ''O; |
| |
| if (sizeof(p_res_list) >= 1) |
| { |
| if (ischosen(p_res_list[0].val.intValue)) { |
| v_result := int2oct(p_res_list[0].val.intValue, 4); |
| } |
| else if (ischosen(p_res_list[0].val.floatValue)) { |
| v_result := int2oct(float2int(p_res_list[0].val.floatValue), 4); |
| } |
| else if (ischosen(p_res_list[0].val.strValue)) { |
| v_result := str2oct(p_res_list[0].val.strValue); |
| } |
| else if (ischosen(p_res_list[0].val.opaqueValue)) { |
| v_result := p_res_list[0].val.opaqueValue; |
| } |
| } |
| |
| return v_result; |
| } |
| |
| function f_dec_LwM2M_Resources_from_Opaque(in octetstring p_payload, inout LwM2M_Resource_List p_resources) |
| return boolean |
| { |
| p_resources[0] := c_LwM2M_Resource_init; |
| |
| p_resources[0].val.opaqueValue := p_payload; |
| |
| return true; |
| } |
| } |