Merge pull request #10716 from thingsboard/lwm2m_default_object_id_version_front
LwM2M: default object version
This commit is contained in:
commit
a6293e8cdb
@ -33,7 +33,6 @@ import org.thingsboard.server.common.data.StringUtils;
|
||||
import org.thingsboard.server.common.data.device.credentials.BasicMqttCredentials;
|
||||
import org.thingsboard.server.common.data.device.credentials.lwm2m.LwM2MClientCredential;
|
||||
import org.thingsboard.server.common.data.device.credentials.lwm2m.LwM2MSecurityMode;
|
||||
import org.thingsboard.server.common.data.device.data.DefaultDeviceConfiguration;
|
||||
import org.thingsboard.server.common.data.device.data.DeviceData;
|
||||
import org.thingsboard.server.common.data.device.data.PowerMode;
|
||||
import org.thingsboard.server.common.data.device.data.SnmpDeviceTransportConfiguration;
|
||||
@ -68,6 +67,8 @@ import java.util.Set;
|
||||
import java.util.concurrent.locks.Lock;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
import static org.eclipse.leshan.core.LwM2m.Version.V1_0;
|
||||
|
||||
@Service
|
||||
@TbCoreComponent
|
||||
@RequiredArgsConstructor
|
||||
@ -256,7 +257,7 @@ public class DeviceBulkImportService extends AbstractBulkImportService<Device> {
|
||||
|
||||
Lwm2mDeviceProfileTransportConfiguration transportConfiguration = new Lwm2mDeviceProfileTransportConfiguration();
|
||||
transportConfiguration.setBootstrap(Collections.emptyList());
|
||||
transportConfiguration.setClientLwM2mSettings(new OtherConfiguration(1, 1, 1, PowerMode.DRX, null, null, null, null, null));
|
||||
transportConfiguration.setClientLwM2mSettings(new OtherConfiguration(1, 1, 1, PowerMode.DRX, null, null, null, null, null, V1_0.toString()));
|
||||
transportConfiguration.setObserveAttr(new TelemetryMappingConfiguration(Collections.emptyMap(), Collections.emptySet(), Collections.emptySet(), Collections.emptySet(), Collections.emptyMap()));
|
||||
|
||||
DeviceProfileData deviceProfileData = new DeviceProfileData();
|
||||
|
||||
@ -39,4 +39,5 @@ public class OtherConfiguration extends PowerSavingConfiguration {
|
||||
private Long pagingTransmissionWindow;
|
||||
private String fwUpdateResource;
|
||||
private String swUpdateResource;
|
||||
private String defaultObjectIDVer;
|
||||
}
|
||||
|
||||
@ -29,6 +29,7 @@ import org.eclipse.leshan.server.registration.Registration;
|
||||
import org.eclipse.leshan.server.registration.RegistrationListener;
|
||||
import org.eclipse.leshan.server.registration.RegistrationUpdate;
|
||||
import org.eclipse.leshan.server.send.SendListener;
|
||||
import org.thingsboard.server.transport.lwm2m.server.client.LwM2mClient;
|
||||
import org.thingsboard.server.transport.lwm2m.server.uplink.LwM2mUplinkMsgHandler;
|
||||
|
||||
import java.util.Collection;
|
||||
@ -101,7 +102,10 @@ public class LwM2mServerListener {
|
||||
@Override
|
||||
public void onResponse(SingleObservation observation, Registration registration, ObserveResponse response) {
|
||||
if (registration != null) {
|
||||
service.onUpdateValueAfterReadResponse(registration, convertObjectIdToVersionedId(observation.getPath().toString(), registration), response);
|
||||
LwM2mClient lwM2MClient = service.getClientContext().getClientByEndpoint(registration.getEndpoint());
|
||||
if (lwM2MClient != null) {
|
||||
service.onUpdateValueAfterReadResponse(registration, convertObjectIdToVersionedId(observation.getPath().toString(), lwM2MClient), response);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -27,10 +27,10 @@ import org.springframework.stereotype.Service;
|
||||
import org.thingsboard.server.common.data.TbResource;
|
||||
import org.thingsboard.server.common.data.id.TenantId;
|
||||
import org.thingsboard.server.queue.util.TbLwM2mTransportComponent;
|
||||
import org.thingsboard.server.transport.lwm2m.server.client.LwM2mClient;
|
||||
import org.thingsboard.server.transport.lwm2m.server.client.LwM2mClientContext;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Base64;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
@ -107,7 +107,8 @@ public class LwM2mVersionedModelProvider implements LwM2mModelProvider {
|
||||
|
||||
@Override
|
||||
public ObjectModel getObjectModel(int objectId) {
|
||||
String version = String.valueOf(registration.getSupportedVersion(objectId));
|
||||
LwM2mClient lwM2mClient = lwM2mClientContext.getClientByEndpoint(registration.getEndpoint());
|
||||
String version = lwM2mClient.getSupportedObjectVersion(objectId).toString();
|
||||
if (version != null) {
|
||||
return this.getObjectModelDynamic(objectId, version);
|
||||
}
|
||||
@ -116,7 +117,8 @@ public class LwM2mVersionedModelProvider implements LwM2mModelProvider {
|
||||
|
||||
@Override
|
||||
public Collection<ObjectModel> getObjectModels() {
|
||||
Map<Integer, LwM2m.Version> supportedObjects = this.registration.getSupportedObject();
|
||||
LwM2mClient lwM2mClient = lwM2mClientContext.getClientByEndpoint(registration.getEndpoint());
|
||||
Map<Integer, LwM2m.Version> supportedObjects = lwM2mClient.getSupportedClientObjects();
|
||||
Collection<ObjectModel> result = new ArrayList<>(supportedObjects.size());
|
||||
for (Map.Entry<Integer, LwM2m.Version> supportedObject : supportedObjects.entrySet()) {
|
||||
ObjectModel objectModel = this.getObjectModelDynamic(supportedObject.getKey(), String.valueOf(supportedObject.getValue()));
|
||||
|
||||
@ -21,7 +21,10 @@ import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
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.model.ObjectModel;
|
||||
import org.eclipse.leshan.core.model.ResourceModel;
|
||||
import org.eclipse.leshan.core.node.LwM2mMultipleResource;
|
||||
@ -37,6 +40,7 @@ import org.thingsboard.server.common.data.Device;
|
||||
import org.thingsboard.server.common.data.DeviceProfile;
|
||||
import org.thingsboard.server.common.data.device.data.Lwm2mDeviceTransportConfiguration;
|
||||
import org.thingsboard.server.common.data.device.data.PowerMode;
|
||||
import org.thingsboard.server.common.data.device.profile.Lwm2mDeviceProfileTransportConfiguration;
|
||||
import org.thingsboard.server.common.data.id.TenantId;
|
||||
import org.thingsboard.server.common.transport.auth.ValidateDeviceCredentialsResponse;
|
||||
import org.thingsboard.server.gen.transport.TransportProtos.SessionInfoProto;
|
||||
@ -61,8 +65,8 @@ import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static org.thingsboard.server.common.data.lwm2m.LwM2mConstants.LWM2M_SEPARATOR_PATH;
|
||||
import static org.thingsboard.server.transport.lwm2m.utils.LwM2MTransportUtil.LWM2M_OBJECT_VERSION_DEFAULT;
|
||||
import static org.thingsboard.server.transport.lwm2m.utils.LwM2MTransportUtil.convertMultiResourceValuesFromRpcBody;
|
||||
import static org.thingsboard.server.transport.lwm2m.utils.LwM2MTransportUtil.convertObjectIdToVersionedId;
|
||||
import static org.thingsboard.server.transport.lwm2m.utils.LwM2MTransportUtil.equalsResourceTypeGetSimpleName;
|
||||
import static org.thingsboard.server.transport.lwm2m.utils.LwM2MTransportUtil.fromVersionedIdToObjectId;
|
||||
import static org.thingsboard.server.transport.lwm2m.utils.LwM2MTransportUtil.getVerFromPathIdVerOrId;
|
||||
@ -129,6 +133,12 @@ public class LwM2mClient {
|
||||
@Setter
|
||||
private UUID lastSentRpcId;
|
||||
|
||||
@Setter
|
||||
private LwM2m.Version defaultObjectIDVer;
|
||||
|
||||
@Getter
|
||||
private Map<Integer, Version> supportedClientObjects;
|
||||
|
||||
public Object clone() throws CloneNotSupportedException {
|
||||
return super.clone();
|
||||
}
|
||||
@ -142,6 +152,7 @@ public class LwM2mClient {
|
||||
this.state = LwM2MClientState.CREATED;
|
||||
this.lock = new ReentrantLock();
|
||||
this.retryAttempts = new AtomicInteger(0);
|
||||
this.supportedClientObjects = null;
|
||||
}
|
||||
|
||||
public void init(ValidateDeviceCredentialsResponse credentials, UUID sessionId) {
|
||||
@ -153,12 +164,14 @@ public class LwM2mClient {
|
||||
this.edrxCycle = credentials.getDeviceInfo().getEdrxCycle();
|
||||
this.psmActivityTimer = credentials.getDeviceInfo().getPsmActivityTimer();
|
||||
this.pagingTransmissionWindow = credentials.getDeviceInfo().getPagingTransmissionWindow();
|
||||
this.defaultObjectIDVer = getObjectIDVerFromDeviceProfile(credentials.getDeviceProfile());
|
||||
}
|
||||
|
||||
public void setRegistration(Registration registration) {
|
||||
this.registration = registration;
|
||||
this.clientSupportContentFormats = clientSupportContentFormat(registration);
|
||||
this.defaultContentFormat = calculateDefaultContentFormat(registration);
|
||||
this.setSupportedClientObjects();
|
||||
}
|
||||
|
||||
public void lock() {
|
||||
@ -197,6 +210,15 @@ public class LwM2mClient {
|
||||
builder.setDeviceType(deviceProfile.getName());
|
||||
}
|
||||
|
||||
private LwM2m.Version getObjectIDVerFromDeviceProfile(DeviceProfile deviceProfile) {
|
||||
String defaultObjectIdVer = ((Lwm2mDeviceProfileTransportConfiguration)deviceProfile
|
||||
.getProfileData()
|
||||
.getTransportConfiguration())
|
||||
.getClientLwM2mSettings()
|
||||
.getDefaultObjectIDVer();
|
||||
return new Version(defaultObjectIdVer == null ? LWM2M_OBJECT_VERSION_DEFAULT : defaultObjectIdVer);
|
||||
}
|
||||
|
||||
public void refreshSessionId(String nodeId) {
|
||||
UUID newId = UUID.randomUUID();
|
||||
SessionInfoProto.Builder builder = SessionInfoProto.newBuilder().mergeFrom(session);
|
||||
@ -240,67 +262,28 @@ public class LwM2mClient {
|
||||
}
|
||||
}
|
||||
|
||||
public Object getResourceValue(String pathRezIdVer, String pathRezId) {
|
||||
String pathRez = pathRezIdVer == null ? convertObjectIdToVersionedId(pathRezId, this.registration) : pathRezIdVer;
|
||||
if (this.resources.get(pathRez) != null) {
|
||||
return this.resources.get(pathRez).getLwM2mResource().getValue();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Object getResourceNameByRezId(String pathRezIdVer, String pathRezId) {
|
||||
String pathRez = pathRezIdVer == null ? convertObjectIdToVersionedId(pathRezId, this.registration) : pathRezIdVer;
|
||||
if (this.resources.get(pathRez) != null) {
|
||||
return this.resources.get(pathRez).getResourceModel().name;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getRezIdByResourceNameAndObjectInstanceId(String resourceName, String pathObjectInstanceIdVer, LwM2mModelProvider modelProvider) {
|
||||
LwM2mPath pathIds = getLwM2mPathFromString(pathObjectInstanceIdVer);
|
||||
if (pathIds.isObjectInstance()) {
|
||||
Set<Integer> rezIds = modelProvider.getObjectModel(registration)
|
||||
.getObjectModel(pathIds.getObjectId()).resources.entrySet()
|
||||
.stream()
|
||||
.filter(map -> resourceName.equals(map.getValue().name))
|
||||
.map(map -> map.getKey())
|
||||
.collect(Collectors.toSet());
|
||||
return rezIds.size() > 0 ? String.valueOf(rezIds.stream().findFirst().get()) : null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public ResourceModel getResourceModel(String pathIdVer, LwM2mModelProvider modelProvider) {
|
||||
LwM2mPath pathIds = getLwM2mPathFromString(pathIdVer);
|
||||
String verSupportedObject = String.valueOf(registration.getSupportedObject().get(pathIds.getObjectId()));
|
||||
String verSupportedObject = String.valueOf(this.getSupportedObjectVersion(pathIds.getObjectId()));
|
||||
String verRez = getVerFromPathIdVerOrId(pathIdVer);
|
||||
return verRez != null && verRez.equals(verSupportedObject) ? modelProvider.getObjectModel(registration)
|
||||
.getResourceModel(pathIds.getObjectId(), pathIds.getResourceId()) : null;
|
||||
}
|
||||
|
||||
public boolean isResourceMultiInstances(String pathIdVer, LwM2mModelProvider modelProvider) {
|
||||
var resourceModel = getResourceModel(pathIdVer, modelProvider);
|
||||
if (resourceModel != null && resourceModel.multiple != null) {
|
||||
return resourceModel.multiple;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public ObjectModel getObjectModel(String pathIdVer, LwM2mModelProvider modelProvider) {
|
||||
try {
|
||||
LwM2mPath pathIds = getLwM2mPathFromString(pathIdVer);
|
||||
String verSupportedObject = String.valueOf(registration.getSupportedObject().get(pathIds.getObjectId()));
|
||||
String verSupportedObject = String.valueOf(this.getSupportedObjectVersion(pathIds.getObjectId()));
|
||||
String verRez = getVerFromPathIdVerOrId(pathIdVer);
|
||||
return verRez != null && verRez.equals(verSupportedObject) ? modelProvider.getObjectModel(registration)
|
||||
.getObjectModel(pathIds.getObjectId()) : null;
|
||||
} catch (Exception e) {
|
||||
if (registration == null) {
|
||||
log.error("[{}] Failed Registration is null, GetObjectModelRegistration. ", this.endpoint, e);
|
||||
} else if (registration.getSupportedObject() == null) {
|
||||
} else if (this.getSupportedClientObjects() == null) {
|
||||
log.error("[{}] Failed SupportedObject in Registration, GetObjectModelRegistration.", this.endpoint, e);
|
||||
} else {
|
||||
log.error("[{}] Failed ModelProvider.getObjectModel [{}] in Registration. ", this.endpoint, registration.getSupportedObject(), e);
|
||||
log.error("[{}] Failed ModelProvider.getObjectModel [{}] in Registration. ", this.endpoint, this.getSupportedClientObjects(), e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -371,7 +354,7 @@ public class LwM2mClient {
|
||||
|
||||
public String isValidObjectVersion(String path) {
|
||||
LwM2mPath pathIds = getLwM2mPathFromString(path);
|
||||
LwM2m.Version verSupportedObject = registration.getSupportedObject().get(pathIds.getObjectId());
|
||||
LwM2m.Version verSupportedObject = this.getSupportedObjectVersion(pathIds.getObjectId());
|
||||
if (verSupportedObject == null) {
|
||||
return String.format("Specified object id %s absent in the list supported objects of the client or is security object!", pathIds.getObjectId());
|
||||
} else {
|
||||
@ -460,5 +443,34 @@ public class LwM2mClient {
|
||||
return new LwM2mPath(fromVersionedIdToObjectId(path));
|
||||
}
|
||||
|
||||
public LwM2m.Version getDefaultObjectIDVer() {
|
||||
return this.defaultObjectIDVer == null ? new Version(LWM2M_OBJECT_VERSION_DEFAULT) : this.defaultObjectIDVer;
|
||||
}
|
||||
|
||||
public LwM2m.Version getSupportedObjectVersion(Integer objectid) {
|
||||
return this.supportedClientObjects.get(objectid);
|
||||
}
|
||||
|
||||
private void setSupportedClientObjects(){
|
||||
this.supportedClientObjects = new ConcurrentHashMap<>();
|
||||
for (Link link: this.registration.getSortedObjectLinks()) {
|
||||
MixedLwM2mLink mixedLwM2mLink = (MixedLwM2mLink)link;
|
||||
if(!mixedLwM2mLink.getPath().isRoot()){
|
||||
LwM2mPath lwM2mPath = mixedLwM2mLink.getPath();
|
||||
if (lwM2mPath.isObject()) {
|
||||
LwM2m.Version ver;
|
||||
if (mixedLwM2mLink.getAttributes().get("ver")!= null) {
|
||||
ver = (Version) mixedLwM2mLink.getAttributes().get("ver").getValue();
|
||||
} else {
|
||||
ver = getDefaultObjectIDVer();
|
||||
}
|
||||
this.supportedClientObjects.put(lwM2mPath.getObjectId(), ver);
|
||||
} else if (this.supportedClientObjects.get(lwM2mPath.getObjectId()) == null){
|
||||
this.supportedClientObjects.put(lwM2mPath.getObjectId(), getDefaultObjectIDVer());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -396,7 +396,7 @@ public class LwM2mClientContextImpl implements LwM2mClientContext {
|
||||
Arrays.stream(client.getRegistration().getObjectLinks()).forEach(link -> {
|
||||
LwM2mPath pathIds = new LwM2mPath(link.getUriReference());
|
||||
if (!pathIds.isRoot()) {
|
||||
clientObjects.add(convertObjectIdToVersionedId(link.getUriReference(), client.getRegistration()));
|
||||
clientObjects.add(convertObjectIdToVersionedId(link.getUriReference(), client));
|
||||
}
|
||||
});
|
||||
return (clientObjects.size() > 0) ? clientObjects : null;
|
||||
|
||||
@ -481,7 +481,7 @@ public class DefaultLwM2MOtaUpdateService extends LwM2MExecutorAwareService impl
|
||||
}
|
||||
|
||||
private void startUpdateUsingUrl(LwM2mClient client, String id, String url) {
|
||||
String targetIdVer = convertObjectIdToVersionedId(id, client.getRegistration());
|
||||
String targetIdVer = convertObjectIdToVersionedId(id, client);
|
||||
TbLwM2MWriteReplaceRequest request = TbLwM2MWriteReplaceRequest.builder().versionedId(targetIdVer).value(url).timeout(clientContext.getRequestTimeout(client)).build();
|
||||
downlinkHandler.sendWriteReplaceRequest(client, request, new TbLwM2MWriteResponseCallback(uplinkHandler, logService, client, targetIdVer));
|
||||
}
|
||||
@ -512,10 +512,10 @@ public class DefaultLwM2MOtaUpdateService extends LwM2MExecutorAwareService impl
|
||||
}
|
||||
switch (strategy) {
|
||||
case OBJ_5_BINARY:
|
||||
startUpdateUsingBinary(client, convertObjectIdToVersionedId(FW_PACKAGE_5_ID, client.getRegistration()), otaPackageId);
|
||||
startUpdateUsingBinary(client, convertObjectIdToVersionedId(FW_PACKAGE_5_ID, client), otaPackageId);
|
||||
break;
|
||||
case OBJ_19_BINARY:
|
||||
startUpdateUsingBinary(client, convertObjectIdToVersionedId(FW_PACKAGE_19_ID, client.getRegistration()), otaPackageId);
|
||||
startUpdateUsingBinary(client, convertObjectIdToVersionedId(FW_PACKAGE_19_ID, client), otaPackageId);
|
||||
break;
|
||||
case OBJ_5_TEMP_URL:
|
||||
startUpdateUsingUrl(client, FW_URL_ID, info.getBaseUrl() + "/" + FIRMWARE_UPDATE_COAP_RESOURCE + "/" + otaPackageId.toString());
|
||||
@ -534,7 +534,7 @@ public class DefaultLwM2MOtaUpdateService extends LwM2MExecutorAwareService impl
|
||||
LwM2MSoftwareUpdateStrategy strategy = info.getStrategy();
|
||||
switch (strategy) {
|
||||
case BINARY:
|
||||
startUpdateUsingBinary(client, convertObjectIdToVersionedId(SW_PACKAGE_ID, client.getRegistration()), otaPackageId);
|
||||
startUpdateUsingBinary(client, convertObjectIdToVersionedId(SW_PACKAGE_ID, client), otaPackageId);
|
||||
break;
|
||||
case TEMP_URL:
|
||||
startUpdateUsingUrl(client, SW_PACKAGE_URI_ID, info.getBaseUrl() + "/" + FIRMWARE_UPDATE_COAP_RESOURCE + "/" + otaPackageId.toString());
|
||||
@ -566,19 +566,19 @@ public class DefaultLwM2MOtaUpdateService extends LwM2MExecutorAwareService impl
|
||||
}
|
||||
|
||||
private void executeFwUpdate(LwM2mClient client) {
|
||||
String fwExecuteVerId = convertObjectIdToVersionedId(FW_EXECUTE_ID, client.getRegistration());
|
||||
String fwExecuteVerId = convertObjectIdToVersionedId(FW_EXECUTE_ID, client);
|
||||
TbLwM2MExecuteRequest request = TbLwM2MExecuteRequest.builder().versionedId(fwExecuteVerId).timeout(clientContext.getRequestTimeout(client)).build();
|
||||
downlinkHandler.sendExecuteRequest(client, request, new TbLwM2MExecuteCallback(logService, client, fwExecuteVerId));
|
||||
}
|
||||
|
||||
private void executeSwInstall(LwM2mClient client) {
|
||||
String swInstallVerId = convertObjectIdToVersionedId(SW_INSTALL_ID, client.getRegistration());
|
||||
String swInstallVerId = convertObjectIdToVersionedId(SW_INSTALL_ID, client);
|
||||
TbLwM2MExecuteRequest request = TbLwM2MExecuteRequest.builder().versionedId(swInstallVerId).timeout(clientContext.getRequestTimeout(client)).build();
|
||||
downlinkHandler.sendExecuteRequest(client, request, new TbLwM2MExecuteCallback(logService, client, swInstallVerId));
|
||||
}
|
||||
|
||||
private void executeSwUninstallForUpdate(LwM2mClient client) {
|
||||
String swInInstallVerId = convertObjectIdToVersionedId(SW_UN_INSTALL_ID, client.getRegistration());
|
||||
String swInInstallVerId = convertObjectIdToVersionedId(SW_UN_INSTALL_ID, client);
|
||||
TbLwM2MExecuteRequest request = TbLwM2MExecuteRequest.builder().versionedId(swInInstallVerId).params("1").timeout(clientContext.getRequestTimeout(client)).build();
|
||||
downlinkHandler.sendExecuteRequest(client, request, new TbLwM2MExecuteCallback(logService, client, swInInstallVerId));
|
||||
}
|
||||
|
||||
@ -107,6 +107,8 @@ public class LwM2MClientSerDes {
|
||||
if (client.getPagingTransmissionWindow() != null) {
|
||||
o.addProperty("pagingTransmissionWindow", client.getPagingTransmissionWindow());
|
||||
}
|
||||
o.addProperty("defaultObjectIDVer", client.getDefaultObjectIDVer().toString());
|
||||
|
||||
if (client.getRegistration() != null) {
|
||||
String registrationAddress = client.getRegistration().getAddress().toString();
|
||||
JsonNode registrationNode = registrationSerDes.jSerialize(client.getRegistration());
|
||||
@ -339,6 +341,13 @@ public class LwM2MClientSerDes {
|
||||
pagingTransmissionWindowField.set(lwM2mClient, pagingTransmissionWindow.getAsLong());
|
||||
}
|
||||
|
||||
JsonElement defaultObjectIDVer = o.get("defaultObjectIDVer");
|
||||
if (defaultObjectIDVer != null) {
|
||||
Field defaultObjectIDVerField = lwM2mClientClass.getDeclaredField("defaultObjectIDVer");
|
||||
defaultObjectIDVerField.setAccessible(true);
|
||||
defaultObjectIDVerField.set(lwM2mClient, defaultObjectIDVer.getAsString());
|
||||
}
|
||||
|
||||
JsonElement registration = o.get("registration");
|
||||
if (registration != null) {
|
||||
lwM2mClient.setRegistration(registrationSerDes.deserialize(toJsonNode(registration.getAsString())));
|
||||
|
||||
@ -368,7 +368,7 @@ public class DefaultLwM2mUplinkMsgHandler extends LwM2MExecutorAwareService impl
|
||||
LwM2mPath path = entry.getKey();
|
||||
LwM2mNode node = entry.getValue();
|
||||
LwM2mClient lwM2MClient = clientContext.getClientByEndpoint(registration.getEndpoint());
|
||||
String stringPath = convertObjectIdToVersionedId(path.toString(), registration);
|
||||
String stringPath = convertObjectIdToVersionedId(path.toString(), lwM2MClient);
|
||||
ObjectModel objectModelVersion = lwM2MClient.getObjectModel(stringPath, modelProvider);
|
||||
if (objectModelVersion != null) {
|
||||
if (node instanceof LwM2mObject) {
|
||||
@ -584,27 +584,27 @@ public class DefaultLwM2mUplinkMsgHandler extends LwM2MExecutorAwareService impl
|
||||
private void updateResourcesValue(LwM2mClient lwM2MClient, LwM2mResource lwM2mResource, String path, Mode mode, int code) {
|
||||
Registration registration = lwM2MClient.getRegistration();
|
||||
if (lwM2MClient.saveResourceValue(path, lwM2mResource, modelProvider, mode)) {
|
||||
if (path.equals(convertObjectIdToVersionedId(FW_NAME_ID, registration))) {
|
||||
if (path.equals(convertObjectIdToVersionedId(FW_NAME_ID, lwM2MClient))) {
|
||||
otaService.onCurrentFirmwareNameUpdate(lwM2MClient, (String) lwM2mResource.getValue());
|
||||
} else if (path.equals(convertObjectIdToVersionedId(FW_3_VER_ID, registration))) {
|
||||
} else if (path.equals(convertObjectIdToVersionedId(FW_3_VER_ID, lwM2MClient))) {
|
||||
otaService.onCurrentFirmwareVersion3Update(lwM2MClient, (String) lwM2mResource.getValue());
|
||||
} else if (path.equals(convertObjectIdToVersionedId(FW_VER_ID, registration))) {
|
||||
} else if (path.equals(convertObjectIdToVersionedId(FW_VER_ID, lwM2MClient))) {
|
||||
otaService.onCurrentFirmwareVersionUpdate(lwM2MClient, (String) lwM2mResource.getValue());
|
||||
} else if (path.equals(convertObjectIdToVersionedId(FW_STATE_ID, registration))) {
|
||||
} else if (path.equals(convertObjectIdToVersionedId(FW_STATE_ID, lwM2MClient))) {
|
||||
otaService.onCurrentFirmwareStateUpdate(lwM2MClient, (Long) lwM2mResource.getValue());
|
||||
} else if (path.equals(convertObjectIdToVersionedId(FW_RESULT_ID, registration))) {
|
||||
} else if (path.equals(convertObjectIdToVersionedId(FW_RESULT_ID, lwM2MClient))) {
|
||||
otaService.onCurrentFirmwareResultUpdate(lwM2MClient, (Long) lwM2mResource.getValue());
|
||||
} else if (path.equals(convertObjectIdToVersionedId(FW_DELIVERY_METHOD, registration))) {
|
||||
} else if (path.equals(convertObjectIdToVersionedId(FW_DELIVERY_METHOD, lwM2MClient))) {
|
||||
otaService.onCurrentFirmwareDeliveryMethodUpdate(lwM2MClient, (Long) lwM2mResource.getValue());
|
||||
} else if (path.equals(convertObjectIdToVersionedId(SW_NAME_ID, registration))) {
|
||||
} else if (path.equals(convertObjectIdToVersionedId(SW_NAME_ID, lwM2MClient))) {
|
||||
otaService.onCurrentSoftwareNameUpdate(lwM2MClient, (String) lwM2mResource.getValue());
|
||||
} else if (path.equals(convertObjectIdToVersionedId(SW_VER_ID, registration))) {
|
||||
} else if (path.equals(convertObjectIdToVersionedId(SW_VER_ID, lwM2MClient))) {
|
||||
otaService.onCurrentSoftwareVersionUpdate(lwM2MClient, (String) lwM2mResource.getValue());
|
||||
} else if (path.equals(convertObjectIdToVersionedId(SW_3_VER_ID, registration))) {
|
||||
} else if (path.equals(convertObjectIdToVersionedId(SW_3_VER_ID, lwM2MClient))) {
|
||||
otaService.onCurrentSoftwareVersion3Update(lwM2MClient, (String) lwM2mResource.getValue());
|
||||
} else if (path.equals(convertObjectIdToVersionedId(SW_STATE_ID, registration))) {
|
||||
} else if (path.equals(convertObjectIdToVersionedId(SW_STATE_ID, lwM2MClient))) {
|
||||
otaService.onCurrentSoftwareStateUpdate(lwM2MClient, (Long) lwM2mResource.getValue());
|
||||
} else if (path.equals(convertObjectIdToVersionedId(SW_RESULT_ID, registration))) {
|
||||
} else if (path.equals(convertObjectIdToVersionedId(SW_RESULT_ID, lwM2MClient))) {
|
||||
otaService.onCurrentSoftwareResultUpdate(lwM2MClient, (Long) lwM2mResource.getValue());
|
||||
}
|
||||
if (ResponseCode.BAD_REQUEST.getCode() > code) {
|
||||
@ -969,6 +969,10 @@ public class DefaultLwM2mUplinkMsgHandler extends LwM2MExecutorAwareService impl
|
||||
}
|
||||
}
|
||||
|
||||
public LwM2mClientContext getClientContext(){
|
||||
return this.clientContext;
|
||||
};
|
||||
|
||||
private Map<String, String> getNamesFromProfileForSharedAttributes(LwM2mClient lwM2MClient) {
|
||||
Lwm2mDeviceProfileTransportConfiguration profile = clientContext.getProfile(lwM2MClient.getProfileId());
|
||||
return profile.getObserveAttr().getKeyName();
|
||||
|
||||
@ -30,6 +30,7 @@ import org.thingsboard.server.common.data.id.DeviceId;
|
||||
import org.thingsboard.server.gen.transport.TransportProtos;
|
||||
import org.thingsboard.server.transport.lwm2m.config.LwM2MTransportServerConfig;
|
||||
import org.thingsboard.server.transport.lwm2m.server.client.LwM2mClient;
|
||||
import org.thingsboard.server.transport.lwm2m.server.client.LwM2mClientContext;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Optional;
|
||||
@ -77,4 +78,5 @@ public interface LwM2mUplinkMsgHandler {
|
||||
|
||||
LwM2mValueConverter getConverter();
|
||||
|
||||
LwM2mClientContext getClientContext();
|
||||
}
|
||||
|
||||
@ -20,16 +20,13 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.eclipse.californium.elements.config.Configuration;
|
||||
import org.eclipse.leshan.core.model.LwM2mModel;
|
||||
import org.eclipse.leshan.core.model.ObjectLoader;
|
||||
import org.eclipse.leshan.core.model.ObjectModel;
|
||||
import org.eclipse.leshan.core.model.ResourceModel;
|
||||
import org.eclipse.leshan.core.model.StaticModel;
|
||||
import org.eclipse.leshan.core.node.LwM2mMultipleResource;
|
||||
import org.eclipse.leshan.core.node.LwM2mPath;
|
||||
import org.eclipse.leshan.core.node.LwM2mResource;
|
||||
import org.eclipse.leshan.core.node.LwM2mSingleResource;
|
||||
import org.eclipse.leshan.core.node.codec.CodecException;
|
||||
import org.eclipse.leshan.core.util.Hex;
|
||||
import org.eclipse.leshan.server.registration.Registration;
|
||||
import org.thingsboard.common.util.JacksonUtil;
|
||||
import org.thingsboard.server.common.data.DeviceProfile;
|
||||
import org.thingsboard.server.common.data.DeviceTransportType;
|
||||
@ -49,8 +46,6 @@ import org.thingsboard.server.transport.lwm2m.server.ota.firmware.FirmwareUpdate
|
||||
import org.thingsboard.server.transport.lwm2m.server.ota.software.SoftwareUpdateResult;
|
||||
import org.thingsboard.server.transport.lwm2m.server.ota.software.SoftwareUpdateState;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -84,56 +79,6 @@ public class LwM2MTransportUtil {
|
||||
public static final String LOG_LWM2M_WARN = "warn";
|
||||
public static final int BOOTSTRAP_DEFAULT_SHORT_ID_0 = 0;
|
||||
|
||||
public enum LwM2MClientStrategy {
|
||||
CLIENT_STRATEGY_1(1, "Read only resources marked as observation"),
|
||||
CLIENT_STRATEGY_2(2, "Read all client resources");
|
||||
|
||||
public int code;
|
||||
public String type;
|
||||
|
||||
LwM2MClientStrategy(int code, String type) {
|
||||
this.code = code;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public static LwM2MClientStrategy fromStrategyClientByType(String type) {
|
||||
for (LwM2MClientStrategy to : LwM2MClientStrategy.values()) {
|
||||
if (to.type.equals(type)) {
|
||||
return to;
|
||||
}
|
||||
}
|
||||
throw new IllegalArgumentException(String.format("Unsupported Client Strategy type : %s", type));
|
||||
}
|
||||
|
||||
public static LwM2MClientStrategy fromStrategyClientByCode(int code) {
|
||||
for (LwM2MClientStrategy to : LwM2MClientStrategy.values()) {
|
||||
if (to.code == code) {
|
||||
return to;
|
||||
}
|
||||
}
|
||||
throw new IllegalArgumentException(String.format("Unsupported Client Strategy code : %s", code));
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean equalsResourceValue(Object valueOld, Object valueNew, ResourceModel.Type type, LwM2mPath
|
||||
resourcePath) throws CodecException {
|
||||
switch (type) {
|
||||
case BOOLEAN:
|
||||
case INTEGER:
|
||||
case FLOAT:
|
||||
return String.valueOf(valueOld).equals(String.valueOf(valueNew));
|
||||
case TIME:
|
||||
return ((Date) valueOld).getTime() == ((Date) valueNew).getTime();
|
||||
case STRING:
|
||||
case OBJLNK:
|
||||
return valueOld.equals(valueNew);
|
||||
case OPAQUE:
|
||||
return Arrays.equals(Hex.decodeHex(((String) valueOld).toCharArray()), Hex.decodeHex(((String) valueNew).toCharArray()));
|
||||
default:
|
||||
throw new CodecException("Invalid value type for resource %s, type %s", resourcePath, type);
|
||||
}
|
||||
}
|
||||
|
||||
public static LwM2mOtaConvert convertOtaUpdateValueToString(String pathIdVer, Object value, ResourceModel.Type currentType) {
|
||||
String path = fromVersionedIdToObjectId(pathIdVer);
|
||||
LwM2mOtaConvert lwM2mOtaConvert = new LwM2mOtaConvert();
|
||||
@ -210,22 +155,8 @@ public class LwM2MTransportUtil {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String validPathIdVer(String pathIdVer, Registration registration) throws
|
||||
IllegalArgumentException {
|
||||
if (!pathIdVer.contains(LWM2M_SEPARATOR_PATH)) {
|
||||
throw new IllegalArgumentException(String.format("Error:"));
|
||||
} else {
|
||||
String[] keyArray = pathIdVer.split(LWM2M_SEPARATOR_PATH);
|
||||
if (keyArray.length > 1 && keyArray[1].split(LWM2M_SEPARATOR_KEY).length == 2) {
|
||||
return pathIdVer;
|
||||
} else {
|
||||
return convertObjectIdToVersionedId(pathIdVer, registration);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static String convertObjectIdToVersionedId(String path, Registration registration) {
|
||||
String ver = String.valueOf(registration.getSupportedObject().get(new LwM2mPath(path).getObjectId()));
|
||||
public static String convertObjectIdToVersionedId(String path, LwM2mClient lwM2MClient) {
|
||||
String ver = String.valueOf(lwM2MClient.getSupportedObjectVersion(new LwM2mPath(path).getObjectId()));
|
||||
return convertObjectIdToVerId(path, ver);
|
||||
}
|
||||
public static String convertObjectIdToVerId(String path, String ver) {
|
||||
@ -243,14 +174,6 @@ public class LwM2MTransportUtil {
|
||||
}
|
||||
}
|
||||
|
||||
public static String validateObjectVerFromKey(String key) {
|
||||
try {
|
||||
return (key.split(LWM2M_SEPARATOR_PATH)[1].split(LWM2M_SEPARATOR_KEY)[1]);
|
||||
} catch (Exception e) {
|
||||
return ObjectModel.DEFAULT_VERSION;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* "UNSIGNED_INTEGER": // Number -> Integer Example:
|
||||
* Alarm Timestamp [32-bit unsigned integer]
|
||||
|
||||
@ -12,14 +12,14 @@
|
||||
"transportConfiguration": {
|
||||
"observeAttr": {
|
||||
"observe": [
|
||||
"/3_1.1/0/0"
|
||||
"/3_1.0/0/0"
|
||||
],
|
||||
"attribute": [],
|
||||
"telemetry": [
|
||||
"/3_1.1/0/0"
|
||||
"/3_1.0/0/0"
|
||||
],
|
||||
"keyName": {
|
||||
"/3_1.1/0/0": "testData"
|
||||
"/3_1.0/0/0": "testData"
|
||||
},
|
||||
"attributeLwm2m": {}
|
||||
},
|
||||
@ -44,8 +44,7 @@
|
||||
"clientOnlyObserveAfterConnect": 1,
|
||||
"fwUpdateStrategy": 1,
|
||||
"swUpdateStrategy": 1,
|
||||
"powerMode": "DRX",
|
||||
"compositeOperationsSupport": false
|
||||
"powerMode": "DRX"
|
||||
},
|
||||
"bootstrapServerUpdateEnable": false,
|
||||
"type": "LWM2M"
|
||||
|
||||
@ -23,9 +23,9 @@
|
||||
<Description1>
|
||||
<![CDATA[]]></Description1>
|
||||
<ObjectID>3</ObjectID>
|
||||
<ObjectURN>urn:oma:lwm2m:oma:3:1.1</ObjectURN>
|
||||
<ObjectURN>urn:oma:lwm2m:oma:3</ObjectURN>
|
||||
<LWM2MVersion>1.1</LWM2MVersion>
|
||||
<ObjectVersion>1.1</ObjectVersion>
|
||||
<ObjectVersion>1.0</ObjectVersion>
|
||||
<MultipleInstances>Single</MultipleInstances>
|
||||
<Mandatory>Mandatory</Mandatory>
|
||||
<Resources>
|
||||
|
||||
@ -2,5 +2,5 @@
|
||||
"title": "",
|
||||
"resourceType": "LWM2M_MODEL",
|
||||
"fileName": "test-model.xml",
|
||||
"data": "PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPCEtLQoKICAgIENvcHlyaWdodCDCqSAyMDE2LTIwMjIgVGhlIFRoaW5nc2JvYXJkIEF1dGhvcnMKCiAgICBMaWNlbnNlZCB1bmRlciB0aGUgQXBhY2hlIExpY2Vuc2UsIFZlcnNpb24gMi4wICh0aGUgIkxpY2Vuc2UiKTsKICAgIHlvdSBtYXkgbm90IHVzZSB0aGlzIGZpbGUgZXhjZXB0IGluIGNvbXBsaWFuY2Ugd2l0aCB0aGUgTGljZW5zZS4KICAgIFlvdSBtYXkgb2J0YWluIGEgY29weSBvZiB0aGUgTGljZW5zZSBhdAoKICAgICAgICBodHRwOi8vd3d3LmFwYWNoZS5vcmcvbGljZW5zZXMvTElDRU5TRS0yLjAKCiAgICBVbmxlc3MgcmVxdWlyZWQgYnkgYXBwbGljYWJsZSBsYXcgb3IgYWdyZWVkIHRvIGluIHdyaXRpbmcsIHNvZnR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Vyc2lvbj4xLjA8L09iamVjdFZlcnNpb24+CiAgICAgICAgPE11bHRpcGxlSW5zdGFuY2VzPlNpbmdsZTwvTXVsdGlwbGVJbnN0YW5jZXM+CiAgICAgICAgPE1hbmRhdG9yeT5NYW5kYXRvcnk8L01hbmRhdG9yeT4KICAgICAgICA8UmVzb3VyY2VzPgogICAgICAgICAgICA8SXRlbSBJRD0iMCI+CiAgICAgICAgICAgICAgICA8TmFtZT5UZXN0IGRhdGE8L05hbWU+CiAgICAgICAgICAgICAgICA8T3BlcmF0aW9ucz5SPC9PcGVyYXRpb25zPgogICAgICAgICAgICAgICAgPE11bHRpcGxlSW5zdGFuY2VzPlNpbmdsZTwvTXVsdGlwbGVJbnN0YW5jZXM+CiAgICAgICAgICAgICAgICA8TWFuZGF0b3J5Pk9wdGlvbmFsPC9NYW5kYXRvcnk+CiAgICAgICAgICAgICAgICA8VHlwZT5TdHJpbmc8L1R5cGU+CiAgICAgICAgICAgICAgICA8UmFuZ2VFbnVtZXJhdGlvbj48L1JhbmdlRW51bWVyYXRpb24+CiAgICAgICAgICAgICAgICA8VW5pdHM+PC9Vbml0cz4KICAgICAgICAgICAgICAgIDxEZXNjcmlwdGlvbj48IVtDREFUQVtUZXN0IGRhdGFdXT48L0Rlc2NyaXB0aW9uPgogICAgICAgICAgICA8L0l0ZW0+CiAgICAgICAgPC9SZXNvdXJjZXM+CiAgICAgICAgPERlc2NyaXB0aW9uMj48L0Rlc2NyaXB0aW9uMj4KICAgIDwvT2JqZWN0Pgo8L0xXTTJNPgo="
|
||||
}
|
||||
@ -91,26 +91,16 @@
|
||||
<tb-power-mode-settings [parentForm]="clientSettingsFormGroup">
|
||||
</tb-power-mode-settings>
|
||||
</fieldset>
|
||||
<!-- <mat-accordion multi="true">-->
|
||||
<!-- <div *ngIf="false">-->
|
||||
<!-- <mat-expansion-panel>-->
|
||||
<!-- <mat-expansion-panel-header>-->
|
||||
<!-- <mat-panel-title>{{ 'device-profile.lwm2m.client-strategy' | translate }}</mat-panel-title>-->
|
||||
<!-- </mat-expansion-panel-header>-->
|
||||
<!-- <ng-template matExpansionPanelContent>-->
|
||||
<!-- <div fxLayout="column">-->
|
||||
<!-- <mat-form-field class="mat-block">-->
|
||||
<!-- <mat-label>{{ 'device-profile.lwm2m.client-strategy-label' | translate }}</mat-label>-->
|
||||
<!-- <mat-select formControlName="clientOnlyObserveAfterConnect">-->
|
||||
<!-- <mat-option value=1>{{ 'device-profile.lwm2m.client-strategy-only-observe' | translate }}</mat-option>-->
|
||||
<!-- <mat-option value=2>{{ 'device-profile.lwm2m.client-strategy-read-all' | translate }}</mat-option>-->
|
||||
<!-- </mat-select>-->
|
||||
<!-- </mat-form-field>-->
|
||||
<!-- </div>-->
|
||||
<!-- </ng-template>-->
|
||||
<!-- </mat-expansion-panel>-->
|
||||
<!-- </div>-->
|
||||
<!-- </mat-accordion>-->
|
||||
<fieldset class="fields-group">
|
||||
<legend class="group-title" translate>device-profile.lwm2m.default-object-id</legend>
|
||||
<mat-form-field fxFlex>
|
||||
<mat-select formControlName="defaultObjectIDVer">
|
||||
<mat-option *ngFor="let objectIDVer of objectIDVers" [value]="objectIDVer">
|
||||
{{ objectIDVerTranslationMap.get(objectIDVer) | translate }}
|
||||
</mat-option>
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
</fieldset>
|
||||
</section>
|
||||
</ng-template>
|
||||
</mat-tab>
|
||||
|
||||
@ -40,9 +40,11 @@ import {
|
||||
ObjectLwM2M,
|
||||
OBSERVE,
|
||||
PowerMode,
|
||||
ObjectIDVer,
|
||||
RESOURCES,
|
||||
ServerSecurityConfig,
|
||||
TELEMETRY
|
||||
TELEMETRY,
|
||||
ObjectIDVerTranslationMap
|
||||
} from './lwm2m-profile-config.models';
|
||||
import { DeviceProfileService } from '@core/http/device-profile.service';
|
||||
import { deepClone, isDefinedAndNotNull, isEmpty, isUndefined } from '@core/utils';
|
||||
@ -80,6 +82,10 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro
|
||||
|
||||
lwm2mDeviceProfileFormGroup: UntypedFormGroup;
|
||||
configurationValue: Lwm2mProfileConfigModels;
|
||||
|
||||
objectIDVers = Object.values(ObjectIDVer) as ObjectIDVer[];
|
||||
objectIDVerTranslationMap = ObjectIDVerTranslationMap;
|
||||
|
||||
sortFunction: (key: string, value: object) => object;
|
||||
|
||||
get required(): boolean {
|
||||
@ -116,7 +122,8 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro
|
||||
powerMode: [PowerMode.DRX, Validators.required],
|
||||
edrxCycle: [{disabled: true, value: 0}, Validators.required],
|
||||
psmActivityTimer: [{disabled: true, value: 0}, Validators.required],
|
||||
pagingTransmissionWindow: [{disabled: true, value: 0}, Validators.required]
|
||||
pagingTransmissionWindow: [{disabled: true, value: 0}, Validators.required],
|
||||
defaultObjectIDVer: [ObjectIDVer.V1_0, Validators.required]
|
||||
})
|
||||
});
|
||||
|
||||
@ -274,7 +281,8 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro
|
||||
edrxCycle: this.configurationValue.clientLwM2mSettings.edrxCycle || DEFAULT_EDRX_CYCLE,
|
||||
pagingTransmissionWindow:
|
||||
this.configurationValue.clientLwM2mSettings.pagingTransmissionWindow || DEFAULT_PAGING_TRANSMISSION_WINDOW,
|
||||
psmActivityTimer: this.configurationValue.clientLwM2mSettings.psmActivityTimer || DEFAULT_PSM_ACTIVITY_TIMER
|
||||
psmActivityTimer: this.configurationValue.clientLwM2mSettings.psmActivityTimer || DEFAULT_PSM_ACTIVITY_TIMER,
|
||||
defaultObjectIDVer: this.configurationValue.clientLwM2mSettings.defaultObjectIDVer || ObjectIDVer.V1_0
|
||||
}
|
||||
},
|
||||
{emitEvent: false});
|
||||
|
||||
@ -122,6 +122,18 @@ export const PowerModeTranslationMap = new Map<PowerMode, string>(
|
||||
]
|
||||
);
|
||||
|
||||
export enum ObjectIDVer {
|
||||
V1_0 = '1.0',
|
||||
V1_1 = '1.1'
|
||||
}
|
||||
|
||||
export const ObjectIDVerTranslationMap = new Map<ObjectIDVer, string>(
|
||||
[
|
||||
[ObjectIDVer.V1_0, 'device-profile.lwm2m.default-object-id-ver.v1-0'],
|
||||
[ObjectIDVer.V1_1, 'device-profile.lwm2m.default-object-id-ver.v1-1']
|
||||
]
|
||||
);
|
||||
|
||||
export interface ServerSecurityConfig {
|
||||
host?: string;
|
||||
port?: number;
|
||||
@ -163,7 +175,7 @@ export interface ClientLwM2mSettings {
|
||||
edrxCycle?: number;
|
||||
pagingTransmissionWindow?: number;
|
||||
psmActivityTimer?: number;
|
||||
compositeOperationsSupport: boolean;
|
||||
defaultObjectIDVer: ObjectIDVer;
|
||||
}
|
||||
|
||||
export interface ObservableAttributes {
|
||||
@ -190,7 +202,7 @@ export function getDefaultProfileClientLwM2mSettingsConfig(): ClientLwM2mSetting
|
||||
fwUpdateStrategy: 1,
|
||||
swUpdateStrategy: 1,
|
||||
powerMode: PowerMode.DRX,
|
||||
compositeOperationsSupport: false
|
||||
defaultObjectIDVer: ObjectIDVer.V1_0
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -2078,8 +2078,7 @@
|
||||
"step": "خطوة",
|
||||
"min-evaluation-period": "الفترة الدنيا للتقييم",
|
||||
"max-evaluation-period": "الفترة القصوى للتقييم"
|
||||
},
|
||||
"composite-operations-support": "يدعم عمليات القراءة/الكتابة/المراقبة المركبة"
|
||||
}
|
||||
},
|
||||
"snmp": {
|
||||
"add-communication-config": "إضافة تكوين الاتصال",
|
||||
|
||||
@ -1899,6 +1899,11 @@
|
||||
"step": "Step",
|
||||
"min-evaluation-period": "Minimum evaluation period",
|
||||
"max-evaluation-period": "Maximum evaluation period"
|
||||
},
|
||||
"default-object-id": "Default Object Version (Attribute)",
|
||||
"default-object-id-ver": {
|
||||
"v1-0": "1.0",
|
||||
"v1-1": "1.1"
|
||||
}
|
||||
},
|
||||
"snmp": {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user