blob: 049714b625bd7e3cc71dae3a70ec5b6290d99056 [file] [log] [blame]
///////////////////////////////////////////////////////////////////////////////
//
// 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: LightweightM2M_Types.ttcn
// Description:
// Rev: R1A
// Prodnr: LPA 108 661
// Updated: 2020-03-04
// Contact: http://ttcn.ericsson.se
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
// Module: LightweightM2M_Types
//
// Purpose:
// This module contains type definitions for LWM2M PDUs
//
///////////////////////////////////////////////////////////////
module LightweightM2M_Types
{
import from CoAP_Types all;
import from LWM2M_TLV_Types all;
type universal charstring URN;
type record of universal charstring Location;
type record of integer Integer_List;
type union LWM2M_PDU
{
// -----
LWM2M_Register Register,
LWM2M_Update Update,
LWM2M_Deregister Deregister,
LWM2M_Response Response,
LWM2M_Notification Notification,
// -----
LWM2M_Read Read_,
LWM2M_Write Write,
LWM2M_Execute Execute,
// -----
LWM2M_Create Create,
LWM2M_Delete Delete,
//-----
LWM2M_BS_Request_Finish BS_Request_Finish,
LWM2M_BS_Delete BS_Delete,
LWM2M_BS_Discover BS_Discover
}
type record LWM2M_Register
{
URN endpointClientName,
integer lifetime optional,
charstring version optional,
BindingMode bindingMode optional,
integer smsNumber optional,
ObjectPath_List objectsAndObjectInstances
}
const LWM2M_PDU c_LWM2M_Register_init :=
{
Register := {
endpointClientName := "",
lifetime := omit,
version := omit,
bindingMode := omit,
smsNumber := omit,
objectsAndObjectInstances := {}
}
}
type record LWM2M_Update
{
Location location,
integer lifetime optional,
BindingMode bindingMode optional,
integer smsNumber optional,
ObjectPath_List objectsAndObjectInstances
}
const LWM2M_PDU c_LWM2M_Update_init :=
{
Update := {
location := {},
lifetime := omit,
bindingMode := omit,
smsNumber := omit,
objectsAndObjectInstances := {}
}
}
type record LWM2M_Read
{
ObjectPath path,
Integer_List accept,
boolean observe optional
}
const LWM2M_PDU c_LWM2M_Read_init :=
{
Read_ := {
path := {-1, omit, omit},
accept := {},
observe := omit
}
}
type record LWM2M_Write
{
ObjectPath path,
integer contentFormat,
LWM2M_Block block1 optional,
LwM2M_Resource_List resources
}
type record LWM2M_Block
{
BlockOption option,
octetstring content
}
const LWM2M_PDU c_LWM2M_Write_init :=
{
Write := {
path := { -1, omit, omit},
contentFormat := -1,
block1 := omit,
resources := {}
}
}
type record LWM2M_Execute
{
ObjectPath path
}
const LWM2M_PDU c_LWM2M_Execute_init :=
{
Execute := {
path := { -1, omit, omit}
}
}
type record LWM2M_Create
{
ObjectPath path,
integer contentFormat,
LwM2M_Resource_List resources
}
const LWM2M_PDU c_LWM2M_Create_init :=
{
Create := {
path := { -1, omit, omit},
contentFormat := -1,
resources := {}
}
}
type record LWM2M_Delete
{
ObjectPath path
}
const LWM2M_PDU c_LWM2M_Delete_init :=
{
Delete := {
path := { -1, omit, omit}
}
}
type record LWM2M_Deregister
{
Location location
}
type record LWM2M_Response
{
Location location,
integer code,
integer contentFormat optional,
boolean notification optional,
LwM2M_Resource_List resources
}
const LWM2M_PDU c_LWM2M_Response_init :=
{
Response := {
location := {},
code := 0,
contentFormat := omit,
notification := omit,
resources := {}
}
}
type record LWM2M_Notification
{
ObjectPath path,
integer code,
integer contentFormat optional,
LwM2M_Resource_List resources
}
const LWM2M_PDU c_LWM2M_Notification_init :=
{
Notification := {
path := { -1, omit, omit},
code := 0,
contentFormat := omit,
resources := {}
}
}
type record LWM2M_BS_Request_Finish
{
URN endpointClientName,
boolean isRequest
}
const LWM2M_PDU c_LWM2M_BS_Request_init :=
{
BS_Request_Finish :=
{
endpointClientName := "",
isRequest := true
}
}
const LWM2M_PDU c_LWM2M_BS_Finish_init :=
{
BS_Request_Finish :=
{
endpointClientName := "",
isRequest := false
}
}
type record LWM2M_BS_Delete
{
integer objectId optional,
integer objectInstanceId optional
}
const LWM2M_PDU c_LWM2M_BS_Delete_init :=
{
BS_Delete := {
objectId := omit,
objectInstanceId := omit
}
}
type record LWM2M_BS_Discover
{
integer objectId optional,
integer accept
}
const LWM2M_PDU c_LWM2M_BS_Discover_init :=
{
BS_Discover := {
objectId := omit,
accept := 40
}
}
type enumerated BindingMode
{
U, UQ, S, SQ, US, UQS
}
///////////////////////////////////////////////////////////
// Type: ObjectPath
//
// Purpose:
// Models an access path up to a resource
//
// Elements:
// objectId - *integer* - object id
// objectInstanceId - *integer* - object instance id (optional)
// resourceId - *integer* - resource id (optional)
///////////////////////////////////////////////////////////
type record ObjectPath
{
integer objectId,
integer objectInstanceId optional,
integer resourceId optional
}
///////////////////////////////////////////////////////////
// Type: ObjectPath_List
//
// Purpose:
// List of <ObjectPath>
///////////////////////////////////////////////////////////
type record of ObjectPath ObjectPath_List;
///////////////////////////////////////////////////////////
// Type: LwM2M_Resource
//
// Purpose:
// Models a smart resource
//
// Elements:
// id - *integer* - unique id of the smart resource
// objId - *integer* - object id
// objInstId - *integer* - object instance id
// observed - *boolean* - flag, true when observed
// dataSample - <LwM2M_DataSample_Information> - pointers to data sample values (optional)
// val - <LwM2M_ResourceValue> - value of the resource
//
// Related Functions:
// - <f_LwM2M_resourceHash_forResource> (*in* <LwM2M_Resource> p_res)
// - <f_LwM2M_Resource_setNextDataSample> (*inout* <LwM2M_Resource> p_res, *inout* <LwM2M_DataSamples_DB> p_db)
///////////////////////////////////////////////////////////
type record LwM2M_Resource
{
integer id,
integer objId,
integer objInstId,
boolean observed,
LwM2M_DataSample_Information dataSample optional,
LwM2M_Specification_Indices spec,
integer contentFormat optional,
LwM2M_ResourceValue val
}
type record LwM2M_Specification_Indices
{
integer objSpecIdx,
integer resSpecIdx
}
const LwM2M_Specification_Indices c_LwM2M_Specification_Indices_init :=
{
objSpecIdx := -1,
resSpecIdx := -1
}
type record LwM2M_Observe_Information
{
integer observe,
octetstring token
}
const LwM2M_Observe_Information c_LwM2M_Observe_Information_init :=
{
observe := -1,
token := ''O
}
type record LwM2M_DataSample_Information
{
charstring samplesName,
integer samplesPointer,
integer valuePointer
}
const LwM2M_DataSample_Information c_LwM2M_DataSample_Information_init :=
{
samplesName := "",
samplesPointer := -1,
valuePointer := -1
}
const LwM2M_Resource c_LwM2M_Resource_init :=
{
id := -1,
objId := -1,
objInstId := -1,
observed := false,
dataSample := omit,
spec := c_LwM2M_Specification_Indices_init,
contentFormat := omit,
val := { noValue := false }
}
template LwM2M_Resource t_LwM2M_Resource_init(
integer p_id,
integer p_objId,
integer p_objInstId,
LwM2M_ResourceValue p_val
) :=
{
id := p_id,
objId := p_objId,
objInstId := p_objInstId,
observed := false,
dataSample := omit,
spec := c_LwM2M_Specification_Indices_init,
contentFormat := omit,
val := p_val
}
///////////////////////////////////////////////////////////
// Type: LwM2M_ResourceValue
//
// Purpose:
// Union for storing the value of a smart resource
//
// Elements:
// intValue - *integer*
// strValue - *charstring*
// floatValue - *float*
// opaqueValue - *octetstring*
// boolValue - *boolean*
///////////////////////////////////////////////////////////
type union LwM2M_ResourceValue
{
TLV_integer intValue,
charstring strValue,
float floatValue,
octetstring opaqueValue,
boolean boolValue,
boolean noValue
}
///////////////////////////////////////////////////////////
// Type: LwM2M_ResourceValue_List
//
// Purpose:
// List of <LwM2M_ResourceValue>
///////////////////////////////////////////////////////////
type record of LwM2M_ResourceValue LwM2M_ResourceValue_List;
///////////////////////////////////////////////////////////
// Type: LwM2M_Resource_List
//
// Purpose:
// List of <LwM2M_Resource>
///////////////////////////////////////////////////////////
type record of LwM2M_Resource LwM2M_Resource_List;
function f_LwM2M_ObjectPath_isResource(in ObjectPath p_path)
return boolean
{
return ispresent(p_path.objectInstanceId) and ispresent(p_path.resourceId)
}
function f_LwM2M_ObjectPath_isObjectInstance(in ObjectPath p_path)
return boolean
{
return ispresent(p_path.objectInstanceId) and not ispresent(p_path.resourceId)
}
function f_LwM2M_ObjectPath_isObject(in ObjectPath p_path)
return boolean
{
return not ispresent(p_path.objectInstanceId) and not ispresent(p_path.resourceId)
}
}