Merge pull request #12699 from thingsboard/fix_bug_lwm2m_object_verId
LwM2M: fix observe
This commit is contained in:
commit
9b793151b7
@ -89,6 +89,7 @@ import static org.awaitility.Awaitility.await;
|
||||
import static org.eclipse.leshan.client.object.Security.noSec;
|
||||
import static org.hamcrest.core.IsInstanceOf.instanceOf;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Mockito.timeout;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
@ -346,7 +347,7 @@ public abstract class AbstractLwM2MIntegrationTest extends AbstractTransportInte
|
||||
public void createNewClient(Security security, Security securityBs, boolean isRpc,
|
||||
String endpoint, Integer clientDtlsCidLength, boolean queueMode, String deviceIdStr) throws Exception {
|
||||
this.clientDestroy(false);
|
||||
lwM2MTestClient = new LwM2MTestClient(this.executor, endpoint);
|
||||
lwM2MTestClient = new LwM2MTestClient(this.executor, endpoint, resources);
|
||||
|
||||
try (ServerSocket socket = new ServerSocket(0)) {
|
||||
int clientPort = socket.getLocalPort();
|
||||
@ -359,7 +360,7 @@ public abstract class AbstractLwM2MIntegrationTest extends AbstractTransportInte
|
||||
|
||||
private void clientDestroy(boolean isAfter) {
|
||||
try {
|
||||
if (lwM2MTestClient != null) {
|
||||
if (lwM2MTestClient != null && lwM2MTestClient.getLeshanClient() != null) {
|
||||
if (isAfter) {
|
||||
sendObserveCancelAllWithAwait(lwM2MTestClient.getDeviceIdStr());
|
||||
awaitDeleteDevice(lwM2MTestClient.getDeviceIdStr());
|
||||
@ -457,9 +458,15 @@ public abstract class AbstractLwM2MIntegrationTest extends AbstractTransportInte
|
||||
assertEquals(ResponseCode.CONTENT.getName(), rpcActualResult.get("result").asText());
|
||||
return rpcActualResult.get("value").asText();
|
||||
}
|
||||
protected void sendRpcObserveWithContainsLwM2mSingleResource(String params) throws Exception {
|
||||
String rpcActualResult = sendRpcObserveOkWithResultValue("Observe", params);
|
||||
assertTrue(rpcActualResult.contains("LwM2mSingleResource") || rpcActualResult.contains("LwM2mMultipleResource"));
|
||||
}
|
||||
|
||||
protected String sendRpcObserveOk(String method, String params) throws Exception {
|
||||
return sendObserveOK(method, params, lwM2MTestClient.getDeviceIdStr());
|
||||
}
|
||||
|
||||
protected String sendObserveOK(String method, String params, String deviceIdStr) throws Exception {
|
||||
String sendRpcRequest;
|
||||
if (params == null) {
|
||||
|
||||
@ -17,8 +17,9 @@ package org.thingsboard.server.transport.lwm2m;
|
||||
|
||||
public class Lwm2mTestHelper {
|
||||
|
||||
public static final String[] lwm2mClientResources = new String[]{"3.xml", "5.xml", "6.xml", "9.xml", "19.xml", "3303.xml"};
|
||||
|
||||
// Models
|
||||
public static final String[] resources = new String[]{"0.xml", "1.xml", "2.xml", "3.xml", "5.xml", "6.xml", "9.xml", "19.xml", "3303.xml"};
|
||||
public static final int BINARY_APP_DATA_CONTAINER = 19;
|
||||
public static final int TEMPERATURE_SENSOR = 3303;
|
||||
|
||||
|
||||
@ -116,7 +116,7 @@ import static org.thingsboard.server.transport.lwm2m.Lwm2mTestHelper.OBJECT_INST
|
||||
import static org.thingsboard.server.transport.lwm2m.Lwm2mTestHelper.OBJECT_INSTANCE_ID_1;
|
||||
import static org.thingsboard.server.transport.lwm2m.Lwm2mTestHelper.OBJECT_INSTANCE_ID_12;
|
||||
import static org.thingsboard.server.transport.lwm2m.Lwm2mTestHelper.TEMPERATURE_SENSOR;
|
||||
import static org.thingsboard.server.transport.lwm2m.Lwm2mTestHelper.resources;
|
||||
import static org.thingsboard.server.transport.lwm2m.Lwm2mTestHelper.lwm2mClientResources;
|
||||
import static org.thingsboard.server.transport.lwm2m.utils.LwM2MTransportUtil.setDtlsConnectorConfigCidLength;
|
||||
|
||||
|
||||
@ -126,6 +126,7 @@ public class LwM2MTestClient {
|
||||
|
||||
private final ScheduledExecutorService executor;
|
||||
private final String endpoint;
|
||||
private final String[] modelResources;
|
||||
private LeshanClient leshanClient;
|
||||
private SimpleLwM2MDevice lwM2MDevice;
|
||||
private FwLwM2MDevice fwLwM2MDevice;
|
||||
@ -147,10 +148,24 @@ public class LwM2MTestClient {
|
||||
Assert.assertNull("client already initialized", leshanClient);
|
||||
this.defaultLwM2mUplinkMsgHandlerTest = defaultLwM2mUplinkMsgHandler;
|
||||
this.clientContext = clientContext;
|
||||
List<ObjectModel> models = new ArrayList<>();
|
||||
for (String resourceName : resources) {
|
||||
|
||||
List<ObjectModel> models = ObjectLoader.loadAllDefault();
|
||||
for (String resourceName : lwm2mClientResources) {
|
||||
models.addAll(ObjectLoader.loadDdfFile(LwM2MTestClient.class.getClassLoader().getResourceAsStream("lwm2m/" + resourceName), resourceName));
|
||||
}
|
||||
if (this.modelResources != null) {
|
||||
List<ObjectModel> modelsRes = new ArrayList<>();
|
||||
for (String resourceName : this.modelResources) {
|
||||
modelsRes.addAll(ObjectLoader.loadDdfFile(LwM2MTestClient.class.getClassLoader().getResourceAsStream("lwm2m/" + resourceName), resourceName));
|
||||
}
|
||||
Set<Integer> idsToRemove = new HashSet<>();
|
||||
for (ObjectModel model : modelsRes) {
|
||||
idsToRemove.add(model.id);
|
||||
}
|
||||
models.removeIf(model -> idsToRemove.contains(model.id));
|
||||
models.addAll(modelsRes);
|
||||
}
|
||||
|
||||
LwM2mModel model = new StaticModel(models);
|
||||
ObjectsInitializer initializer = new ObjectsInitializer(model);
|
||||
if (securityBs != null && security != null) {
|
||||
|
||||
@ -16,18 +16,13 @@
|
||||
package org.thingsboard.server.transport.lwm2m.rpc;
|
||||
|
||||
import org.thingsboard.server.dao.service.DaoSqlTest;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
@DaoSqlTest
|
||||
public abstract class AbstractRpcLwM2MIntegrationObserveTest extends AbstractRpcLwM2MIntegrationTest{
|
||||
private final String[] RESOURCES_RPC_MULTIPLE_19 = new String[]{"0.xml", "1.xml", "2.xml", "3.xml", "5.xml", "6.xml", "9.xml", "19.xml", "3303.xml"};
|
||||
public abstract class AbstractRpcLwM2MIntegrationObserve_Ver_1_0_Test extends AbstractRpcLwM2MIntegrationTest{
|
||||
|
||||
public AbstractRpcLwM2MIntegrationObserveTest() {
|
||||
setResources(this.RESOURCES_RPC_MULTIPLE_19);
|
||||
}
|
||||
|
||||
protected void sendRpcObserveWithContainsLwM2mSingleResource(String params) throws Exception {
|
||||
String rpcActualResult = sendRpcObserveOkWithResultValue("Observe", params);
|
||||
assertTrue(rpcActualResult.contains("LwM2mSingleResource") || rpcActualResult.contains("LwM2mMultipleResource"));
|
||||
public AbstractRpcLwM2MIntegrationObserve_Ver_1_0_Test() {
|
||||
String[] RESOURCES_RPC_VER_1_1 = new String[]{"3-1_0.xml", "5.xml", "6.xml", "9.xml", "19.xml"};
|
||||
setResources(RESOURCES_RPC_VER_1_1);
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,28 @@
|
||||
/**
|
||||
* Copyright © 2016-2024 The Thingsboard Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.thingsboard.server.transport.lwm2m.rpc;
|
||||
|
||||
import org.thingsboard.server.dao.service.DaoSqlTest;
|
||||
|
||||
@DaoSqlTest
|
||||
public abstract class AbstractRpcLwM2MIntegrationObserve_Ver_1_1_Test extends AbstractRpcLwM2MIntegrationTest{
|
||||
|
||||
public AbstractRpcLwM2MIntegrationObserve_Ver_1_1_Test() {
|
||||
String[] RESOURCES_RPC_VER_1_1 = new String[]{"3-1_1.xml", "5.xml", "6.xml", "9.xml", "19.xml"};
|
||||
setResources(RESOURCES_RPC_VER_1_1);
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,28 @@
|
||||
/**
|
||||
* Copyright © 2016-2024 The Thingsboard Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.thingsboard.server.transport.lwm2m.rpc;
|
||||
|
||||
import org.thingsboard.server.dao.service.DaoSqlTest;
|
||||
|
||||
@DaoSqlTest
|
||||
public abstract class AbstractRpcLwM2MIntegrationObserve_Ver_1_2_Test extends AbstractRpcLwM2MIntegrationTest{
|
||||
|
||||
public AbstractRpcLwM2MIntegrationObserve_Ver_1_2_Test() {
|
||||
String[] RESOURCES_RPC_VER_1_1 = new String[]{"3.xml", "5.xml", "6.xml", "9.xml", "19.xml"};
|
||||
setResources(RESOURCES_RPC_VER_1_1);
|
||||
}
|
||||
}
|
||||
|
||||
@ -63,7 +63,7 @@ import static org.thingsboard.server.transport.lwm2m.Lwm2mTestHelper.RESOURCE_ID
|
||||
import static org.thingsboard.server.transport.lwm2m.Lwm2mTestHelper.RESOURCE_ID_NAME_3_14;
|
||||
import static org.thingsboard.server.transport.lwm2m.Lwm2mTestHelper.RESOURCE_ID_NAME_3_9;
|
||||
import static org.thingsboard.server.transport.lwm2m.Lwm2mTestHelper.TEMPERATURE_SENSOR;
|
||||
import static org.thingsboard.server.transport.lwm2m.Lwm2mTestHelper.resources;
|
||||
import static org.thingsboard.server.transport.lwm2m.Lwm2mTestHelper.lwm2mClientResources;
|
||||
import static org.thingsboard.server.transport.lwm2m.utils.LwM2MTransportUtil.fromVersionedIdToObjectId;
|
||||
|
||||
@Slf4j
|
||||
@ -102,7 +102,7 @@ public abstract class AbstractRpcLwM2MIntegrationTest extends AbstractLwM2MInteg
|
||||
protected LwM2mTransportServerHelper lwM2mTransportServerHelperTest;
|
||||
|
||||
public AbstractRpcLwM2MIntegrationTest() {
|
||||
setResources(resources);
|
||||
setResources(lwm2mClientResources);
|
||||
}
|
||||
|
||||
@Before
|
||||
@ -110,7 +110,7 @@ public abstract class AbstractRpcLwM2MIntegrationTest extends AbstractLwM2MInteg
|
||||
if (this.getClass().getSimpleName().equals("RpcLwm2mIntegrationWriteCborTest")) {
|
||||
supportFormatOnly_SenMLJSON_SenMLCBOR = true;
|
||||
}
|
||||
if (this.getClass().getSimpleName().equals("RpcLwm2mIntegrationObserveTest")) {
|
||||
if (this.getClass().getSimpleName().contains("RpcLwm2mIntegrationObserve")) {
|
||||
initRpc(0);
|
||||
} else if (this.getClass().getSimpleName().equals("RpcLwm2mIntegrationReadCollectedValueTest")) {
|
||||
initRpc(3303);
|
||||
|
||||
@ -21,7 +21,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.eclipse.leshan.core.ResponseCode;
|
||||
import org.junit.Test;
|
||||
import org.thingsboard.common.util.JacksonUtil;
|
||||
import org.thingsboard.server.transport.lwm2m.rpc.AbstractRpcLwM2MIntegrationObserveTest;
|
||||
import org.thingsboard.server.transport.lwm2m.rpc.AbstractRpcLwM2MIntegrationTest;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@ -50,7 +50,7 @@ import static org.thingsboard.server.transport.lwm2m.Lwm2mTestHelper.RESOURCE_IN
|
||||
import static org.thingsboard.server.transport.lwm2m.utils.LwM2MTransportUtil.fromVersionedIdToObjectId;
|
||||
|
||||
@Slf4j
|
||||
public class RpcLwm2MIntegrationObserveCompositeTest extends AbstractRpcLwM2MIntegrationObserveTest {
|
||||
public class RpcLwm2MIntegrationObserveCompositeTest extends AbstractRpcLwM2MIntegrationTest {
|
||||
|
||||
/**
|
||||
* ObserveComposite {"ids":["5/0/7", "5/0/5", "5/0/3", "3/0/9", "19/1/0/0"]} - Ok
|
||||
|
||||
@ -24,7 +24,7 @@ import org.eclipse.leshan.server.registration.Registration;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.mockito.Mockito;
|
||||
import org.thingsboard.server.transport.lwm2m.rpc.AbstractRpcLwM2MIntegrationObserveTest;
|
||||
import org.thingsboard.server.transport.lwm2m.rpc.AbstractRpcLwM2MIntegrationTest;
|
||||
|
||||
import static org.eclipse.leshan.core.LwM2mId.ACCESS_CONTROL;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
@ -41,7 +41,7 @@ import static org.thingsboard.server.transport.lwm2m.Lwm2mTestHelper.RESOURCE_ID
|
||||
import static org.thingsboard.server.transport.lwm2m.utils.LwM2MTransportUtil.fromVersionedIdToObjectId;
|
||||
|
||||
@Slf4j
|
||||
public class RpcLwm2mIntegrationObserveTest extends AbstractRpcLwM2MIntegrationObserveTest {
|
||||
public class RpcLwm2mIntegrationObserveTest extends AbstractRpcLwM2MIntegrationTest {
|
||||
|
||||
@Before
|
||||
public void setupObserveTest() throws Exception {
|
||||
|
||||
@ -0,0 +1,48 @@
|
||||
/**
|
||||
* Copyright © 2016-2024 The Thingsboard Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.thingsboard.server.transport.lwm2m.rpc.sql;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.thingsboard.server.transport.lwm2m.rpc.AbstractRpcLwM2MIntegrationObserve_Ver_1_0_Test;
|
||||
import org.thingsboard.server.transport.lwm2m.rpc.AbstractRpcLwM2MIntegrationObserve_Ver_1_1_Test;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.thingsboard.server.transport.lwm2m.Lwm2mTestHelper.RESOURCE_ID_NAME_3_9;
|
||||
|
||||
@Slf4j
|
||||
public class RpcLwm2mIntegrationObserve_Ver_1_0_Test extends AbstractRpcLwM2MIntegrationObserve_Ver_1_0_Test {
|
||||
|
||||
@Before
|
||||
public void setupObserveTest() throws Exception {
|
||||
awaitObserveReadAll(4,lwM2MTestClient.getDeviceIdStr());
|
||||
}
|
||||
|
||||
/**
|
||||
* Observe "3_1.0/0/9"
|
||||
* @throws Exception
|
||||
*/
|
||||
@Test
|
||||
public void testObserveOneResource_Result_CONTENT_Value_Count_3_After_Cancel_Count_2() throws Exception {
|
||||
long initSendTelemetryAtCount = countSendParametersOnThingsboardTelemetryResource(RESOURCE_ID_NAME_3_9);
|
||||
sendObserveCancelAllWithAwait(lwM2MTestClient.getDeviceIdStr());
|
||||
sendRpcObserveWithContainsLwM2mSingleResource(idVer_3_0_9);
|
||||
updateRegAtLeastOnceAfterAction();
|
||||
long lastSendTelemetryAtCount = countSendParametersOnThingsboardTelemetryResource(RESOURCE_ID_NAME_3_9);
|
||||
assertTrue(lastSendTelemetryAtCount > initSendTelemetryAtCount);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,46 @@
|
||||
/**
|
||||
* Copyright © 2016-2024 The Thingsboard Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.thingsboard.server.transport.lwm2m.rpc.sql;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.thingsboard.server.transport.lwm2m.rpc.AbstractRpcLwM2MIntegrationObserve_Ver_1_1_Test;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.thingsboard.server.transport.lwm2m.Lwm2mTestHelper.RESOURCE_ID_NAME_3_9;
|
||||
|
||||
@Slf4j
|
||||
public class RpcLwm2mIntegrationObserve_Ver_1_1_Test extends AbstractRpcLwM2MIntegrationObserve_Ver_1_1_Test {
|
||||
|
||||
@Before
|
||||
public void setupObserveTest() throws Exception {
|
||||
awaitObserveReadAll(4,lwM2MTestClient.getDeviceIdStr());
|
||||
}
|
||||
|
||||
/**
|
||||
* Observe "3_1.1/0/9"
|
||||
* @throws Exception
|
||||
*/
|
||||
@Test
|
||||
public void testObserveOneResource_Result_CONTENT_Value_Count_3_After_Cancel_Count_2() throws Exception {
|
||||
long initSendTelemetryAtCount = countSendParametersOnThingsboardTelemetryResource(RESOURCE_ID_NAME_3_9);
|
||||
sendObserveCancelAllWithAwait(lwM2MTestClient.getDeviceIdStr());
|
||||
sendRpcObserveWithContainsLwM2mSingleResource(idVer_3_0_9);
|
||||
updateRegAtLeastOnceAfterAction();
|
||||
long lastSendTelemetryAtCount = countSendParametersOnThingsboardTelemetryResource(RESOURCE_ID_NAME_3_9);
|
||||
assertTrue(lastSendTelemetryAtCount > initSendTelemetryAtCount);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,48 @@
|
||||
/**
|
||||
* Copyright © 2016-2024 The Thingsboard Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.thingsboard.server.transport.lwm2m.rpc.sql;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.thingsboard.server.transport.lwm2m.rpc.AbstractRpcLwM2MIntegrationObserve_Ver_1_0_Test;
|
||||
import org.thingsboard.server.transport.lwm2m.rpc.AbstractRpcLwM2MIntegrationObserve_Ver_1_2_Test;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.thingsboard.server.transport.lwm2m.Lwm2mTestHelper.RESOURCE_ID_NAME_3_9;
|
||||
|
||||
@Slf4j
|
||||
public class RpcLwm2mIntegrationObserve_Ver_1_2_Test extends AbstractRpcLwM2MIntegrationObserve_Ver_1_2_Test {
|
||||
|
||||
@Before
|
||||
public void setupObserveTest() throws Exception {
|
||||
awaitObserveReadAll(4,lwM2MTestClient.getDeviceIdStr());
|
||||
}
|
||||
|
||||
/**
|
||||
* Observe "3_1.2/0/9"
|
||||
* @throws Exception
|
||||
*/
|
||||
@Test
|
||||
public void testObserveOneResource_Result_CONTENT_Value_Count_3_After_Cancel_Count_2() throws Exception {
|
||||
long initSendTelemetryAtCount = countSendParametersOnThingsboardTelemetryResource(RESOURCE_ID_NAME_3_9);
|
||||
sendObserveCancelAllWithAwait(lwM2MTestClient.getDeviceIdStr());
|
||||
sendRpcObserveWithContainsLwM2mSingleResource(idVer_3_0_9);
|
||||
updateRegAtLeastOnceAfterAction();
|
||||
long lastSendTelemetryAtCount = countSendParametersOnThingsboardTelemetryResource(RESOURCE_ID_NAME_3_9);
|
||||
assertTrue(lastSendTelemetryAtCount > initSendTelemetryAtCount);
|
||||
}
|
||||
}
|
||||
327
application/src/test/resources/lwm2m/3-1_0.xml
Normal file
327
application/src/test/resources/lwm2m/3-1_0.xml
Normal file
@ -0,0 +1,327 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<!--
|
||||
FILE INFORMATION
|
||||
|
||||
OMA Permanent Document
|
||||
File: OMA-SUP-XML_LWM2M_Device-V1_0_3-20180710-A
|
||||
Type: xml
|
||||
Date: 2018-07-10
|
||||
|
||||
Public Reachable Information
|
||||
Path: http://www.openmobilealliance.org/tech/profiles
|
||||
Name: LWM2M_Device-v1_0_3.xml
|
||||
|
||||
NORMATIVE INFORMATION
|
||||
|
||||
Information about this file can be found in the latest revision of
|
||||
|
||||
OMA-TS-LightweightM2M-V1_0_2
|
||||
OMA-TS-LightweightM2M_Core-V1_1
|
||||
|
||||
This is available at http://www.openmobilealliance.org/
|
||||
|
||||
Send comments to https://github.com/OpenMobileAlliance/OMA_LwM2M_for_Developers/issues
|
||||
|
||||
LEGAL DISCLAIMER
|
||||
|
||||
Copyright 2018 Open Mobile Alliance All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
3. Neither the name of the copyright holder nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
The above license is used as a license under copyright only. Please
|
||||
reference the OMA IPR Policy for patent licensing terms:
|
||||
http://www.openmobilealliance.org/ipr.html
|
||||
-->
|
||||
|
||||
<LWM2M xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://www.openmobilealliance.org/tech/profiles/LWM2M.xsd">
|
||||
<Object ObjectType="MODefinition">
|
||||
<Name>Device</Name>
|
||||
<Description1><![CDATA[This LwM2M Object provides a range of device related information which can be queried by the LwM2M Server, and a device reboot and factory reset function.]]></Description1>
|
||||
<ObjectID>3</ObjectID>
|
||||
<ObjectURN>urn:oma:lwm2m:oma:3</ObjectURN>
|
||||
<MultipleInstances>Single</MultipleInstances>
|
||||
<Mandatory>Mandatory</Mandatory>
|
||||
<Resources>
|
||||
<Item ID="0">
|
||||
<Name>Manufacturer</Name>
|
||||
<Operations>R</Operations>
|
||||
<MultipleInstances>Single</MultipleInstances>
|
||||
<Mandatory>Optional</Mandatory>
|
||||
<Type>String</Type>
|
||||
<RangeEnumeration></RangeEnumeration>
|
||||
<Units></Units>
|
||||
<Description><![CDATA[Human readable manufacturer name]]></Description>
|
||||
</Item>
|
||||
<Item ID="1">
|
||||
<Name>Model Number</Name>
|
||||
<Operations>R</Operations>
|
||||
<MultipleInstances>Single</MultipleInstances>
|
||||
<Mandatory>Optional</Mandatory>
|
||||
<Type>String</Type>
|
||||
<RangeEnumeration></RangeEnumeration>
|
||||
<Units></Units>
|
||||
<Description><![CDATA[A model identifier (manufacturer specified string)]]></Description>
|
||||
</Item>
|
||||
<Item ID="2">
|
||||
<Name>Serial Number</Name>
|
||||
<Operations>R</Operations>
|
||||
<MultipleInstances>Single</MultipleInstances>
|
||||
<Mandatory>Optional</Mandatory>
|
||||
<Type>String</Type>
|
||||
<RangeEnumeration></RangeEnumeration>
|
||||
<Units></Units>
|
||||
<Description><![CDATA[Serial Number]]></Description>
|
||||
</Item>
|
||||
<Item ID="3">
|
||||
<Name>Firmware Version</Name>
|
||||
<Operations>R</Operations>
|
||||
<MultipleInstances>Single</MultipleInstances>
|
||||
<Mandatory>Optional</Mandatory>
|
||||
<Type>String</Type>
|
||||
<RangeEnumeration></RangeEnumeration>
|
||||
<Units></Units>
|
||||
<Description><![CDATA[Current firmware version of the Device.The Firmware Management function could rely on this resource.]]></Description>
|
||||
</Item>
|
||||
<Item ID="4">
|
||||
<Name>Reboot</Name>
|
||||
<Operations>E</Operations>
|
||||
<MultipleInstances>Single</MultipleInstances>
|
||||
<Mandatory>Mandatory</Mandatory>
|
||||
<Type></Type>
|
||||
<RangeEnumeration></RangeEnumeration>
|
||||
<Units></Units>
|
||||
<Description><![CDATA[Reboot the LwM2M Device to restore the Device from unexpected firmware failure.]]></Description>
|
||||
</Item>
|
||||
<Item ID="5">
|
||||
<Name>Factory Reset</Name>
|
||||
<Operations>E</Operations>
|
||||
<MultipleInstances>Single</MultipleInstances>
|
||||
<Mandatory>Optional</Mandatory>
|
||||
<Type></Type>
|
||||
<RangeEnumeration></RangeEnumeration>
|
||||
<Units></Units>
|
||||
<Description><![CDATA[Perform factory reset of the LwM2M Device to make the LwM2M Device to go through initial deployment sequence where provisioning and bootstrap sequence is performed. This requires client ensuring post factory reset to have minimal information to allow it to carry out one of the bootstrap methods specified in section 5.2.3.
|
||||
When this Resource is executed, “De-register” operation MAY be sent to the LwM2M Server(s) before factory reset of the LwM2M Device.]]></Description>
|
||||
</Item>
|
||||
<Item ID="6">
|
||||
<Name>Available Power Sources</Name>
|
||||
<Operations>R</Operations>
|
||||
<MultipleInstances>Multiple</MultipleInstances>
|
||||
<Mandatory>Optional</Mandatory>
|
||||
<Type>Integer</Type>
|
||||
<RangeEnumeration>0-7</RangeEnumeration>
|
||||
<Units></Units>
|
||||
<Description><![CDATA[0 – DC power
|
||||
1 – Internal Battery
|
||||
2 – External Battery
|
||||
4 – Power over Ethernet
|
||||
5 – USB
|
||||
6 – AC (Mains) power
|
||||
7 – Solar
|
||||
The same Resource Instance ID MUST be used to associate a given Power Source (Resource ID:6) with its Present Voltage (Resource ID:7) and its Present Current (Resource ID:8)]]></Description>
|
||||
</Item>
|
||||
<Item ID="7">
|
||||
<Name>Power Source Voltage</Name>
|
||||
<Operations>R</Operations>
|
||||
<MultipleInstances>Multiple</MultipleInstances>
|
||||
<Mandatory>Optional</Mandatory>
|
||||
<Type>Integer</Type>
|
||||
<RangeEnumeration></RangeEnumeration>
|
||||
<Units>mV</Units>
|
||||
<Description><![CDATA[Present voltage for each Available Power Sources Resource Instance.]]></Description>
|
||||
</Item>
|
||||
<Item ID="8">
|
||||
<Name>Power Source Current</Name>
|
||||
<Operations>R</Operations>
|
||||
<MultipleInstances>Multiple</MultipleInstances>
|
||||
<Mandatory>Optional</Mandatory>
|
||||
<Type>Integer</Type>
|
||||
<RangeEnumeration></RangeEnumeration>
|
||||
<Units>mA</Units>
|
||||
<Description><![CDATA[Present current for each Available Power Source.]]></Description>
|
||||
</Item>
|
||||
<Item ID="9">
|
||||
<Name>Battery Level</Name>
|
||||
<Operations>R</Operations>
|
||||
<MultipleInstances>Single</MultipleInstances>
|
||||
<Mandatory>Optional</Mandatory>
|
||||
<Type>Integer</Type>
|
||||
<RangeEnumeration>0-100</RangeEnumeration>
|
||||
<Units>%</Units>
|
||||
<Description><![CDATA[Contains the current battery level as a percentage (with a range from 0 to 100). This value is only valid for the Device internal Battery if present (one Available Power Sources Resource Instance is 1).]]></Description>
|
||||
</Item>
|
||||
<Item ID="10">
|
||||
<Name>Memory Free</Name>
|
||||
<Operations>R</Operations>
|
||||
<MultipleInstances>Single</MultipleInstances>
|
||||
<Mandatory>Optional</Mandatory>
|
||||
<Type>Integer</Type>
|
||||
<RangeEnumeration></RangeEnumeration>
|
||||
<Units>KB</Units>
|
||||
<Description><![CDATA[Estimated current available amount of storage space which can store data and software in the LwM2M Device (expressed in kilobytes).]]></Description>
|
||||
</Item>
|
||||
<Item ID="11">
|
||||
<Name>Error Code</Name>
|
||||
<Operations>R</Operations>
|
||||
<MultipleInstances>Multiple</MultipleInstances>
|
||||
<Mandatory>Mandatory</Mandatory>
|
||||
<Type>Integer</Type>
|
||||
<RangeEnumeration>0-8</RangeEnumeration>
|
||||
<Units></Units>
|
||||
<Description><![CDATA[0=No error
|
||||
1=Low battery power
|
||||
2=External power supply off
|
||||
3=GPS module failure
|
||||
4=Low received signal strength
|
||||
5=Out of memory
|
||||
6=SMS failure
|
||||
7=IP connectivity failure
|
||||
8=Peripheral malfunction
|
||||
|
||||
When the single Device Object Instance is initiated, there is only one error code Resource Instance whose value is equal to 0 that means no error. When the first error happens, the LwM2M Client changes error code Resource Instance to any non-zero value to indicate the error type. When any other error happens, a new error code Resource Instance is created. When an error associated with a Resource Instance is no longer present, that Resource Instance is deleted. When the single existing error is no longer present, the LwM2M Client returns to the original no error state where Instance 0 has value 0.
|
||||
This error code Resource MAY be observed by the LwM2M Server. How to deal with LwM2M Client’s error report depends on the policy of the LwM2M Server.]]></Description>
|
||||
</Item>
|
||||
<Item ID="12">
|
||||
<Name>Reset Error Code</Name>
|
||||
<Operations>E</Operations>
|
||||
<MultipleInstances>Single</MultipleInstances>
|
||||
<Mandatory>Optional</Mandatory>
|
||||
<Type></Type>
|
||||
<RangeEnumeration></RangeEnumeration>
|
||||
<Units></Units>
|
||||
<Description><![CDATA[Delete all error code Resource Instances and create only one zero-value error code that implies no error, then re-evaluate all error conditions and update and create Resources Instances to capture all current error conditions.]]></Description>
|
||||
</Item>
|
||||
<Item ID="13">
|
||||
<Name>Current Time</Name>
|
||||
<Operations>RW</Operations>
|
||||
<MultipleInstances>Single</MultipleInstances>
|
||||
<Mandatory>Optional</Mandatory>
|
||||
<Type>Time</Type>
|
||||
<RangeEnumeration></RangeEnumeration>
|
||||
<Units></Units>
|
||||
<Description><![CDATA[Current UNIX time of the LwM2M Client.
|
||||
The LwM2M Client should be responsible to increase this time value as every second elapses.
|
||||
The LwM2M Server is able to write this Resource to make the LwM2M Client synchronized with the LwM2M Server.]]></Description>
|
||||
</Item>
|
||||
<Item ID="14">
|
||||
<Name>UTC Offset</Name>
|
||||
<Operations>RW</Operations>
|
||||
<MultipleInstances>Single</MultipleInstances>
|
||||
<Mandatory>Optional</Mandatory>
|
||||
<Type>String</Type>
|
||||
<RangeEnumeration></RangeEnumeration>
|
||||
<Units></Units>
|
||||
<Description><![CDATA[Indicates the UTC offset currently in effect for this LwM2M Device. UTC+X [ISO 8601].]]></Description>
|
||||
</Item>
|
||||
<Item ID="15">
|
||||
<Name>Timezone</Name>
|
||||
<Operations>RW</Operations>
|
||||
<MultipleInstances>Single</MultipleInstances>
|
||||
<Mandatory>Optional</Mandatory>
|
||||
<Type>String</Type>
|
||||
<RangeEnumeration></RangeEnumeration>
|
||||
<Units></Units>
|
||||
<Description><![CDATA[Indicates in which time zone the LwM2M Device is located, in IANA Timezone (TZ) database format.]]></Description>
|
||||
</Item>
|
||||
<Item ID="16">
|
||||
<Name>Supported Binding and Modes</Name>
|
||||
<Operations>R</Operations>
|
||||
<MultipleInstances>Single</MultipleInstances>
|
||||
<Mandatory>Mandatory</Mandatory>
|
||||
<Type>String</Type>
|
||||
<RangeEnumeration></RangeEnumeration>
|
||||
<Units></Units>
|
||||
<Description><![CDATA[Indicates which bindings and modes are supported in the LwM2M Client. The possible values are those listed in the LwM2M Core Specification.]]></Description>
|
||||
</Item>
|
||||
<Item ID="17"><Name>Device Type</Name>
|
||||
<Operations>R</Operations>
|
||||
<MultipleInstances>Single</MultipleInstances>
|
||||
<Mandatory>Optional</Mandatory>
|
||||
<Type>String</Type>
|
||||
<RangeEnumeration></RangeEnumeration>
|
||||
<Units></Units>
|
||||
<Description><![CDATA[Type of the device (manufacturer specified string: e.g. smart meters / dev Class…)]]></Description>
|
||||
</Item>
|
||||
<Item ID="18"><Name>Hardware Version</Name>
|
||||
<Operations>R</Operations>
|
||||
<MultipleInstances>Single</MultipleInstances>
|
||||
<Mandatory>Optional</Mandatory>
|
||||
<Type>String</Type>
|
||||
<RangeEnumeration></RangeEnumeration>
|
||||
<Units></Units>
|
||||
<Description><![CDATA[Current hardware version of the device]]></Description>
|
||||
</Item>
|
||||
<Item ID="19"><Name>Software Version</Name>
|
||||
<Operations>R</Operations>
|
||||
<MultipleInstances>Single</MultipleInstances>
|
||||
<Mandatory>Optional</Mandatory>
|
||||
<Type>String</Type>
|
||||
<RangeEnumeration></RangeEnumeration>
|
||||
<Units></Units>
|
||||
<Description><![CDATA[Current software version of the device (manufacturer specified string). On elaborated LwM2M device, SW could be split in 2 parts: a firmware one and a higher level software on top.
|
||||
Both pieces of Software are together managed by LwM2M Firmware Update Object (Object ID 5)]]></Description>
|
||||
</Item>
|
||||
<Item ID="20"><Name>Battery Status</Name>
|
||||
<Operations>R</Operations>
|
||||
<MultipleInstances>Single</MultipleInstances>
|
||||
<Mandatory>Optional</Mandatory>
|
||||
<Type>Integer</Type>
|
||||
<RangeEnumeration>0-6</RangeEnumeration>
|
||||
<Units></Units>
|
||||
<Description><![CDATA[This value is only valid for the Device Internal Battery if present (one Available Power Sources Resource Instance value is 1).
|
||||
Battery
|
||||
Status Meaning Description
|
||||
0 Normal The battery is operating normally and not on power.
|
||||
1 Charging The battery is currently charging.
|
||||
2 Charge Complete The battery is fully charged and still on power.
|
||||
3 Damaged The battery has some problem.
|
||||
4 Low Battery The battery is low on charge.
|
||||
5 Not Installed The battery is not installed.
|
||||
6 Unknown The battery information is not available.]]></Description>
|
||||
</Item>
|
||||
<Item ID="21"><Name>Memory Total</Name>
|
||||
<Operations>R</Operations>
|
||||
<MultipleInstances>Single</MultipleInstances>
|
||||
<Mandatory>Optional</Mandatory>
|
||||
<Type>Integer</Type>
|
||||
<RangeEnumeration></RangeEnumeration>
|
||||
<Units></Units>
|
||||
<Description><![CDATA[Total amount of storage space which can store data and software in the LwM2M Device (expressed in kilobytes).]]></Description>
|
||||
</Item>
|
||||
<Item ID="22"><Name>ExtDevInfo</Name>
|
||||
<Operations>R</Operations>
|
||||
<MultipleInstances>Multiple</MultipleInstances>
|
||||
<Mandatory>Optional</Mandatory>
|
||||
<Type>Objlnk</Type>
|
||||
<RangeEnumeration></RangeEnumeration>
|
||||
<Units></Units>
|
||||
<Description><![CDATA[Reference to external “Device” object instance containing information. For example, such an external device can be a Host Device, which is a device into which the Device containing the LwM2M client is embedded. This Resource may be used to retrieve information about the Host Device.]]></Description>
|
||||
</Item></Resources>
|
||||
<Description2></Description2>
|
||||
</Object>
|
||||
</LWM2M>
|
||||
331
application/src/test/resources/lwm2m/3-1_1.xml
Normal file
331
application/src/test/resources/lwm2m/3-1_1.xml
Normal file
@ -0,0 +1,331 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<!--
|
||||
FILE INFORMATION
|
||||
|
||||
OMA Permanent Document
|
||||
File: OMA-SUP-XML_LWM2M_Device-V1_1-20170617-A
|
||||
Type: xml
|
||||
Date: 2019-Jun-17
|
||||
|
||||
Public Reachable Information
|
||||
Path: http://www.openmobilealliance.org/tech/profiles
|
||||
Name: LWM2M_Device-v1_1.xml
|
||||
|
||||
NORMATIVE INFORMATION
|
||||
|
||||
Information about this file can be found in the latest revision of
|
||||
|
||||
OMA-TS-LightweightM2M-V1_0_2
|
||||
OMA-TS-LightweightM2M_Core-V1_1_1
|
||||
|
||||
This is available at http://www.openmobilealliance.org/
|
||||
|
||||
Send comments to https://github.com/OpenMobileAlliance/OMA_LwM2M_for_Developers/issues
|
||||
|
||||
LEGAL DISCLAIMER
|
||||
|
||||
Copyright 2019 Open Mobile Alliance.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
3. Neither the name of the copyright holder nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
The above license is used as a license under copyright only. Please
|
||||
reference the OMA IPR Policy for patent licensing terms:
|
||||
https://www.omaspecworks.org/about/intellectual-property-rights/
|
||||
|
||||
-->
|
||||
|
||||
<LWM2M xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://www.openmobilealliance.org/tech/profiles/LWM2M-v1_1.xsd">
|
||||
<Object ObjectType="MODefinition">
|
||||
<Name>Device</Name>
|
||||
<Description1><![CDATA[This LwM2M Object provides a range of device related information which can be queried by the LwM2M Server, and a device reboot and factory reset function.]]></Description1>
|
||||
<ObjectID>3</ObjectID>
|
||||
<ObjectURN>urn:oma:lwm2m:oma:3:1.1</ObjectURN>
|
||||
<LWM2MVersion>1.1</LWM2MVersion>
|
||||
<ObjectVersion>1.1</ObjectVersion>
|
||||
<MultipleInstances>Single</MultipleInstances>
|
||||
<Mandatory>Mandatory</Mandatory>
|
||||
<Resources>
|
||||
<Item ID="0">
|
||||
<Name>Manufacturer</Name>
|
||||
<Operations>R</Operations>
|
||||
<MultipleInstances>Single</MultipleInstances>
|
||||
<Mandatory>Optional</Mandatory>
|
||||
<Type>String</Type>
|
||||
<RangeEnumeration></RangeEnumeration>
|
||||
<Units></Units>
|
||||
<Description><![CDATA[Human readable manufacturer name]]></Description>
|
||||
</Item>
|
||||
<Item ID="1">
|
||||
<Name>Model Number</Name>
|
||||
<Operations>R</Operations>
|
||||
<MultipleInstances>Single</MultipleInstances>
|
||||
<Mandatory>Optional</Mandatory>
|
||||
<Type>String</Type>
|
||||
<RangeEnumeration></RangeEnumeration>
|
||||
<Units></Units>
|
||||
<Description><![CDATA[A model identifier (manufacturer specified string)]]></Description>
|
||||
</Item>
|
||||
<Item ID="2">
|
||||
<Name>Serial Number</Name>
|
||||
<Operations>R</Operations>
|
||||
<MultipleInstances>Single</MultipleInstances>
|
||||
<Mandatory>Optional</Mandatory>
|
||||
<Type>String</Type>
|
||||
<RangeEnumeration></RangeEnumeration>
|
||||
<Units></Units>
|
||||
<Description><![CDATA[Serial Number]]></Description>
|
||||
</Item>
|
||||
<Item ID="3">
|
||||
<Name>Firmware Version</Name>
|
||||
<Operations>R</Operations>
|
||||
<MultipleInstances>Single</MultipleInstances>
|
||||
<Mandatory>Optional</Mandatory>
|
||||
<Type>String</Type>
|
||||
<RangeEnumeration></RangeEnumeration>
|
||||
<Units></Units>
|
||||
<Description><![CDATA[Current firmware version of the Device.The Firmware Management function could rely on this resource.]]></Description>
|
||||
</Item>
|
||||
<Item ID="4">
|
||||
<Name>Reboot</Name>
|
||||
<Operations>E</Operations>
|
||||
<MultipleInstances>Single</MultipleInstances>
|
||||
<Mandatory>Mandatory</Mandatory>
|
||||
<Type></Type>
|
||||
<RangeEnumeration></RangeEnumeration>
|
||||
<Units></Units>
|
||||
<Description><![CDATA[Reboot the LwM2M Device to restore the Device from unexpected firmware failure.]]></Description>
|
||||
</Item>
|
||||
<Item ID="5">
|
||||
<Name>Factory Reset</Name>
|
||||
<Operations>E</Operations>
|
||||
<MultipleInstances>Single</MultipleInstances>
|
||||
<Mandatory>Optional</Mandatory>
|
||||
<Type></Type>
|
||||
<RangeEnumeration></RangeEnumeration>
|
||||
<Units></Units>
|
||||
<Description><![CDATA[Perform factory reset of the LwM2M Device to make the LwM2M Device to go through initial deployment sequence where provisioning and bootstrap sequence is performed. This requires client ensuring post factory reset to have minimal information to allow it to carry out one of the bootstrap methods specified in section 5.2.3.
|
||||
When this Resource is executed, "De-register" operation MAY be sent to the LwM2M Server(s) before factory reset of the LwM2M Device.]]></Description>
|
||||
</Item>
|
||||
<Item ID="6">
|
||||
<Name>Available Power Sources</Name>
|
||||
<Operations>R</Operations>
|
||||
<MultipleInstances>Multiple</MultipleInstances>
|
||||
<Mandatory>Optional</Mandatory>
|
||||
<Type>Integer</Type>
|
||||
<RangeEnumeration>0..7</RangeEnumeration>
|
||||
<Units></Units>
|
||||
<Description><![CDATA[0: DC power
|
||||
1: Internal Battery
|
||||
2: External Battery
|
||||
3: Fuel Cell
|
||||
4: Power over Ethernet
|
||||
5: USB
|
||||
6: AC (Mains) power
|
||||
7: Solar
|
||||
The same Resource Instance ID MUST be used to associate a given Power Source (Resource ID:6) with its Present Voltage (Resource ID:7) and its Present Current (Resource ID:8)]]></Description>
|
||||
</Item>
|
||||
<Item ID="7">
|
||||
<Name>Power Source Voltage</Name>
|
||||
<Operations>R</Operations>
|
||||
<MultipleInstances>Multiple</MultipleInstances>
|
||||
<Mandatory>Optional</Mandatory>
|
||||
<Type>Integer</Type>
|
||||
<RangeEnumeration></RangeEnumeration>
|
||||
<Units></Units>
|
||||
<Description><![CDATA[Present voltage for each Available Power Sources Resource Instance. The unit used for this resource is in mV.]]></Description>
|
||||
</Item>
|
||||
<Item ID="8">
|
||||
<Name>Power Source Current</Name>
|
||||
<Operations>R</Operations>
|
||||
<MultipleInstances>Multiple</MultipleInstances>
|
||||
<Mandatory>Optional</Mandatory>
|
||||
<Type>Integer</Type>
|
||||
<RangeEnumeration></RangeEnumeration>
|
||||
<Units></Units>
|
||||
<Description><![CDATA[Present current for each Available Power Source. The unit used for this resource is in mA.]]></Description>
|
||||
</Item>
|
||||
<Item ID="9">
|
||||
<Name>Battery Level</Name>
|
||||
<Operations>R</Operations>
|
||||
<MultipleInstances>Single</MultipleInstances>
|
||||
<Mandatory>Optional</Mandatory>
|
||||
<Type>Integer</Type>
|
||||
<RangeEnumeration>0..100</RangeEnumeration>
|
||||
<Units>%</Units>
|
||||
<Description><![CDATA[Contains the current battery level as a percentage (with a range from 0 to 100). This value is only valid for the Device internal Battery if present (one Available Power Sources Resource Instance is 1).]]></Description>
|
||||
</Item>
|
||||
<Item ID="10">
|
||||
<Name>Memory Free</Name>
|
||||
<Operations>R</Operations>
|
||||
<MultipleInstances>Single</MultipleInstances>
|
||||
<Mandatory>Optional</Mandatory>
|
||||
<Type>Integer</Type>
|
||||
<RangeEnumeration></RangeEnumeration>
|
||||
<Units></Units>
|
||||
<Description><![CDATA[Estimated current available amount of storage space which can store data and software in the LwM2M Device (expressed in kilobytes).]]></Description>
|
||||
</Item>
|
||||
<Item ID="11">
|
||||
<Name>Error Code</Name>
|
||||
<Operations>R</Operations>
|
||||
<MultipleInstances>Multiple</MultipleInstances>
|
||||
<Mandatory>Mandatory</Mandatory>
|
||||
<Type>Integer</Type>
|
||||
<RangeEnumeration>0..8</RangeEnumeration>
|
||||
<Units></Units>
|
||||
<Description><![CDATA[0=No error
|
||||
1=Low battery power
|
||||
2=External power supply off
|
||||
3=GPS module failure
|
||||
4=Low received signal strength
|
||||
5=Out of memory
|
||||
6=SMS failure
|
||||
7=IP connectivity failure
|
||||
8=Peripheral malfunction
|
||||
|
||||
When the single Device Object Instance is initiated, there is only one error code Resource Instance whose value is equal to 0 that means no error. When the first error happens, the LwM2M Client changes error code Resource Instance to any non-zero value to indicate the error type. When any other error happens, a new error code Resource Instance is created. When an error associated with a Resource Instance is no longer present, that Resource Instance is deleted. When the single existing error is no longer present, the LwM2M Client returns to the original no error state where Instance 0 has value 0.
|
||||
This error code Resource MAY be observed by the LwM2M Server. How to deal with LwM2M Client’s error report depends on the policy of the LwM2M Server.]]></Description>
|
||||
</Item>
|
||||
<Item ID="12">
|
||||
<Name>Reset Error Code</Name>
|
||||
<Operations>E</Operations>
|
||||
<MultipleInstances>Single</MultipleInstances>
|
||||
<Mandatory>Optional</Mandatory>
|
||||
<Type></Type>
|
||||
<RangeEnumeration></RangeEnumeration>
|
||||
<Units></Units>
|
||||
<Description><![CDATA[Delete all error code Resource Instances and create only one zero-value error code that implies no error, then re-evaluate all error conditions and update and create Resources Instances to capture all current error conditions.]]></Description>
|
||||
</Item>
|
||||
<Item ID="13">
|
||||
<Name>Current Time</Name>
|
||||
<Operations>RW</Operations>
|
||||
<MultipleInstances>Single</MultipleInstances>
|
||||
<Mandatory>Optional</Mandatory>
|
||||
<Type>Time</Type>
|
||||
<RangeEnumeration></RangeEnumeration>
|
||||
<Units></Units>
|
||||
<Description><![CDATA[Current UNIX time of the LwM2M Client.
|
||||
The LwM2M Client should be responsible to increase this time value as every second elapses.
|
||||
The LwM2M Server is able to write this Resource to make the LwM2M Client synchronized with the LwM2M Server.]]></Description>
|
||||
</Item>
|
||||
<Item ID="14">
|
||||
<Name>UTC Offset</Name>
|
||||
<Operations>RW</Operations>
|
||||
<MultipleInstances>Single</MultipleInstances>
|
||||
<Mandatory>Optional</Mandatory>
|
||||
<Type>String</Type>
|
||||
<RangeEnumeration></RangeEnumeration>
|
||||
<Units></Units>
|
||||
<Description><![CDATA[Indicates the UTC offset currently in effect for this LwM2M Device. UTC+X [ISO 8601].]]></Description>
|
||||
</Item>
|
||||
<Item ID="15">
|
||||
<Name>Timezone</Name>
|
||||
<Operations>RW</Operations>
|
||||
<MultipleInstances>Single</MultipleInstances>
|
||||
<Mandatory>Optional</Mandatory>
|
||||
<Type>String</Type>
|
||||
<RangeEnumeration></RangeEnumeration>
|
||||
<Units></Units>
|
||||
<Description><![CDATA[Indicates in which time zone the LwM2M Device is located, in IANA Timezone (TZ) database format.]]></Description>
|
||||
</Item>
|
||||
<Item ID="16">
|
||||
<Name>Supported Binding and Modes</Name>
|
||||
<Operations>R</Operations>
|
||||
<MultipleInstances>Single</MultipleInstances>
|
||||
<Mandatory>Mandatory</Mandatory>
|
||||
<Type>String</Type>
|
||||
<RangeEnumeration></RangeEnumeration>
|
||||
<Units></Units>
|
||||
<Description><![CDATA[Indicates which bindings and modes are supported in the LwM2M Client. The possible values are those listed in the LwM2M Core Specification.]]></Description>
|
||||
</Item>
|
||||
<Item ID="17"><Name>Device Type</Name>
|
||||
<Operations>R</Operations>
|
||||
<MultipleInstances>Single</MultipleInstances>
|
||||
<Mandatory>Optional</Mandatory>
|
||||
<Type>String</Type>
|
||||
<RangeEnumeration></RangeEnumeration>
|
||||
<Units></Units>
|
||||
<Description><![CDATA[Type of the device (manufacturer specified string: e.g. smart meters / dev Class / ...)]]></Description>
|
||||
</Item>
|
||||
<Item ID="18"><Name>Hardware Version</Name>
|
||||
<Operations>R</Operations>
|
||||
<MultipleInstances>Single</MultipleInstances>
|
||||
<Mandatory>Optional</Mandatory>
|
||||
<Type>String</Type>
|
||||
<RangeEnumeration></RangeEnumeration>
|
||||
<Units></Units>
|
||||
<Description><![CDATA[Current hardware version of the device]]></Description>
|
||||
</Item>
|
||||
<Item ID="19"><Name>Software Version</Name>
|
||||
<Operations>R</Operations>
|
||||
<MultipleInstances>Single</MultipleInstances>
|
||||
<Mandatory>Optional</Mandatory>
|
||||
<Type>String</Type>
|
||||
<RangeEnumeration></RangeEnumeration>
|
||||
<Units></Units>
|
||||
<Description><![CDATA[Current software version of the device (manufacturer specified string). On elaborated LwM2M device, SW could be split in 2 parts: a firmware one and a higher level software on top.
|
||||
Both pieces of Software are together managed by LwM2M Firmware Update Object (Object ID 5)]]></Description>
|
||||
</Item>
|
||||
<Item ID="20"><Name>Battery Status</Name>
|
||||
<Operations>R</Operations>
|
||||
<MultipleInstances>Single</MultipleInstances>
|
||||
<Mandatory>Optional</Mandatory>
|
||||
<Type>Integer</Type>
|
||||
<RangeEnumeration>0..6</RangeEnumeration>
|
||||
<Units></Units>
|
||||
<Description><![CDATA[This value is only valid for the Device Internal Battery if present (one Available Power Sources Resource Instance value is 1).
|
||||
Battery
|
||||
Status Meaning Description
|
||||
0 Normal The battery is operating normally and not on power.
|
||||
1 Charging The battery is currently charging.
|
||||
2 Charge Complete The battery is fully charged and still on power.
|
||||
3 Damaged The battery has some problem.
|
||||
4 Low Battery The battery is low on charge.
|
||||
5 Not Installed The battery is not installed.
|
||||
6 Unknown The battery information is not available.]]></Description>
|
||||
</Item>
|
||||
<Item ID="21"><Name>Memory Total</Name>
|
||||
<Operations>R</Operations>
|
||||
<MultipleInstances>Single</MultipleInstances>
|
||||
<Mandatory>Optional</Mandatory>
|
||||
<Type>Integer</Type>
|
||||
<RangeEnumeration></RangeEnumeration>
|
||||
<Units></Units>
|
||||
<Description><![CDATA[Total amount of storage space which can store data and software in the LwM2M Device (expressed in kilobytes).]]></Description>
|
||||
</Item>
|
||||
<Item ID="22"><Name>ExtDevInfo</Name>
|
||||
<Operations>R</Operations>
|
||||
<MultipleInstances>Multiple</MultipleInstances>
|
||||
<Mandatory>Optional</Mandatory>
|
||||
<Type>Objlnk</Type>
|
||||
<RangeEnumeration></RangeEnumeration>
|
||||
<Units></Units>
|
||||
<Description><![CDATA[Reference to external "Device" object instance containing information. For example, such an external device can be a Host Device, which is a device into which the Device containing the LwM2M client is embedded. This Resource may be used to retrieve information about the Host Device.]]></Description>
|
||||
</Item></Resources>
|
||||
<Description2></Description2>
|
||||
</Object>
|
||||
</LWM2M>
|
||||
@ -24,6 +24,9 @@ import org.eclipse.leshan.core.LwM2m;
|
||||
import org.eclipse.leshan.core.LwM2m.Version;
|
||||
import org.eclipse.leshan.core.link.Link;
|
||||
import org.eclipse.leshan.core.link.attributes.Attribute;
|
||||
import org.eclipse.leshan.core.link.lwm2m.MixedLwM2mLink;
|
||||
import org.eclipse.leshan.core.link.lwm2m.attributes.LwM2mAttribute;
|
||||
import org.eclipse.leshan.core.link.lwm2m.attributes.LwM2mAttributes;
|
||||
import org.eclipse.leshan.core.model.ObjectModel;
|
||||
import org.eclipse.leshan.core.model.ResourceModel;
|
||||
import org.eclipse.leshan.core.node.LwM2mMultipleResource;
|
||||
@ -453,22 +456,33 @@ public class LwM2mClient {
|
||||
}
|
||||
|
||||
private void setSupportedClientObjects(){
|
||||
this.supportedClientObjects = new ConcurrentHashMap<>();
|
||||
for (Link link: this.registration.getSortedObjectLinks()) {
|
||||
LwM2mPath lwM2mPath = new LwM2mPath(link.getUriReference());
|
||||
if (lwM2mPath.isObject()) {
|
||||
LwM2m.Version ver;
|
||||
if (link.getAttributes().get("ver")!= null) {
|
||||
ver = new LwM2m.Version(link.getAttributes().get("ver").getValue().toString());
|
||||
} else {
|
||||
ver = getDefaultObjectIDVer();
|
||||
if (this.registration.getSupportedObject() != null && this.registration.getSupportedObject().size() > 0) {
|
||||
this.supportedClientObjects = this.registration.getSupportedObject();
|
||||
} else {
|
||||
this.supportedClientObjects = new ConcurrentHashMap<>();
|
||||
for (Link link : this.registration.getSortedObjectLinks()) {
|
||||
if (link instanceof MixedLwM2mLink) {
|
||||
LwM2mPath path = ((MixedLwM2mLink) link).getPath();
|
||||
// add supported objects
|
||||
if (path.isObject() || path.isObjectInstance()) {
|
||||
int objectId = path.getObjectId();
|
||||
LwM2mAttribute<Version> versionParamValue = link.getAttributes().get(LwM2mAttributes.OBJECT_VERSION);
|
||||
if (versionParamValue != null) {
|
||||
// if there is a version attribute then use it as version for this object
|
||||
this.supportedClientObjects.put(objectId, versionParamValue.getValue());
|
||||
} else {
|
||||
// there is no version attribute attached.
|
||||
// In this case we use the DEFAULT_VERSION only if this object stored as supported object.
|
||||
Version currentVersion = this.supportedClientObjects.get(objectId);
|
||||
if (currentVersion == null) {
|
||||
this.supportedClientObjects.put(objectId, getDefaultObjectIDVer());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
this.supportedClientObjects.put(lwM2mPath.getObjectId(), ver);
|
||||
} else if (lwM2mPath.getObjectId() != null && this.supportedClientObjects.get(lwM2mPath.getObjectId()) == null){
|
||||
this.supportedClientObjects.put(lwM2mPath.getObjectId(), getDefaultObjectIDVer());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user