| /////////////////////////////////////////////////////////////////////////////// |
| // |
| // 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_Plain_EncDec.ttcn |
| // Description: |
| // Rev: R1B |
| // Prodnr: CNL 113 859 |
| // Updated: 2021-02-03 |
| // Contact: http://ttcn.ericsson.se |
| /////////////////////////////////////////////////////////////////////////////// |
| module LWM2M_Plain_EncDec |
| { |
| import from LightweightM2M_Types all; |
| |
| function f_enc_LwM2M_Resources_to_Plain(in LwM2M_Resource_List p_res_list) return octetstring |
| { |
| var charstring v_result := ""; |
| |
| if (sizeof(p_res_list) >= 1) |
| { |
| if (ischosen(p_res_list[0].val.intValue)) { |
| v_result := int2str(p_res_list[0].val.intValue); |
| } |
| else if (ischosen(p_res_list[0].val.floatValue)) { |
| v_result := float2str(p_res_list[0].val.floatValue); |
| } |
| else if (ischosen(p_res_list[0].val.strValue)) { |
| v_result := p_res_list[0].val.strValue; |
| } |
| else if (ischosen(p_res_list[0].val.boolValue)) { |
| v_result := f_bool2str(p_res_list[0].val.boolValue); |
| } |
| else if (ischosen(p_res_list[0].val.opaqueValue)) { |
| v_result := oct2str(p_res_list[0].val.opaqueValue); |
| } |
| } |
| |
| return char2oct(v_result); |
| } |
| |
| function f_dec_LwM2M_Resources_from_Plain(in octetstring p_payload, inout LwM2M_Resource_List p_resources) |
| return boolean |
| { |
| p_resources[0] := c_LwM2M_Resource_init; |
| |
| p_resources[0].val.strValue := oct2char(p_payload); |
| |
| return true; |
| } |
| |
| function f_bool2str(in boolean p_b) return charstring { if (p_b) {return "true"} else {return "false" }} |
| } |