Browse Source

LWM2M: del from yml

pull/4680/head
nickAS21 5 years ago
parent
commit
c3bfb7626e
  1. 6
      application/src/main/java/org/thingsboard/server/service/lwm2m/LwM2MServerSecurityInfoRepository.java
  2. 10
      application/src/main/resources/thingsboard.yml
  3. 4
      common/transport/lwm2m/src/main/java/org/thingsboard/server/transport/lwm2m/config/LwM2MSecureServerConfig.java
  4. 16
      common/transport/lwm2m/src/main/java/org/thingsboard/server/transport/lwm2m/config/LwM2MTransportServerConfig.java
  5. 4
      common/transport/lwm2m/src/main/java/org/thingsboard/server/transport/lwm2m/server/DefaultLwM2mTransportService.java
  6. 6
      common/transport/lwm2m/src/main/java/org/thingsboard/server/transport/lwm2m/server/LwM2mNetworkConfig.java
  7. 8
      common/transport/lwm2m/src/main/java/org/thingsboard/server/transport/lwm2m/server/LwM2mTransportCoapResource.java
  8. 4
      common/transport/lwm2m/src/main/java/org/thingsboard/server/transport/lwm2m/server/LwM2mTransportUtil.java
  9. 7
      common/transport/lwm2m/src/main/java/org/thingsboard/server/transport/lwm2m/server/client/LwM2mFwSwUpdate.java
  10. 10
      transport/lwm2m/src/main/resources/tb-lwm2m-transport.yml
  11. 6
      ui-ngx/src/assets/locale/locale.constant-en_US.json

6
application/src/main/java/org/thingsboard/server/service/lwm2m/LwM2MServerSecurityInfoRepository.java

@ -66,18 +66,18 @@ public class LwM2MServerSecurityInfoRepository {
bsServ.setServerId(serverConfig.getId());
switch (securityMode) {
case NO_SEC:
bsServ.setHost(serverConfig.getHostRequests());
bsServ.setHost(serverConfig.getHost());
bsServ.setPort(serverConfig.getPort());
bsServ.setServerPublicKey("");
break;
case PSK:
bsServ.setHost(serverConfig.getSecureHostRequests());
bsServ.setHost(serverConfig.getSecureHost());
bsServ.setPort(serverConfig.getSecurePort());
bsServ.setServerPublicKey("");
break;
case RPK:
case X509:
bsServ.setHost(serverConfig.getSecureHostRequests());
bsServ.setHost(serverConfig.getSecureHost());
bsServ.setPort(serverConfig.getSecurePort());
bsServ.setServerPublicKey(getPublicKey(serverConfig.getCertificateAlias(), this.serverConfig.getPublicX(), this.serverConfig.getPublicY()));
break;

10
application/src/main/resources/thingsboard.yml

@ -639,13 +639,9 @@ transport:
server:
id: "${LWM2M_SERVER_ID:123}"
bind_address: "${LWM2M_BIND_ADDRESS:0.0.0.0}"
# the host to receive requests to the server
bind_address_requests: "${LWM2M_BIND_ADDRESS_REQUESTS:0.0.0.0}"
bind_port: "${LWM2M_BIND_PORT:5685}"
security:
bind_address: "${LWM2M_BIND_ADDRESS_SECURITY:0.0.0.0}"
# the security host to receive requests to the server
bind_address_requests: "${LWM2M_BIND_ADDRESS_SECURITY_REQUESTS:0.0.0.0}"
bind_port: "${LWM2M_BIND_PORT_SECURITY:5686}"
# Only for RPK: Public & Private Key. If the keystore file is missing or not working
public_x: "${LWM2M_SERVER_PUBLIC_X:05064b9e6762dd8d8b8a52355d7b4d8b9a3d64e6d2ee277d76c248861353f358}"
@ -658,13 +654,9 @@ transport:
enable: "${LWM2M_ENABLED_BS:true}"
id: "${LWM2M_SERVER_ID_BS:111}"
bind_address: "${LWM2M_BIND_ADDRESS_BS:0.0.0.0}"
# the host to receive requests to the server
bind_address_requests: "${LWM2M_BIND_ADDRESS_REQUESTS_BS:0.0.0.0}"
bind_port: "${LWM2M_BIND_PORT_BS:5687}"
security:
bind_address: "${LWM2M_BIND_ADDRESS_SECURITY_BS:0.0.0.0}"
# the security host to receive requests to the server
bind_address_requests: "${LWM2M_BIND_ADDRESS_SECURITY_REQUESTS_BS:0.0.0.0}"
bind_port: "${LWM2M_BIND_PORT_SECURITY_BS:5688}"
# Only for RPK: Public & Private Key. If the keystore file is missing or not working
public_x: "${LWM2M_SERVER_PUBLIC_X_BS:5017c87a1c1768264656b3b355434b0def6edb8b9bf166a4762d9930cd730f91}"
@ -683,8 +675,6 @@ transport:
root_alias: "${LWM2M_SERVER_ROOT_CA:rootca}"
enable_gen_new_key_psk_rpk: "${ENABLE_GEN_NEW_KEY_PSK_RPK:false}"
timeout: "${LWM2M_TIMEOUT:120000}"
blockwise_lifetime: "${BLOCKWISE_LIFETIME:300000}"
block2_option_enable: "${BLOCK2_OPTION_ENABLED:true}"
recommended_ciphers: "${LWM2M_RECOMMENDED_CIPHERS:false}"
recommended_supported_groups: "${LWM2M_RECOMMENDED_SUPPORTED_GROUPS:true}"
response_pool_size: "${LWM2M_RESPONSE_POOL_SIZE:100}"

4
common/transport/lwm2m/src/main/java/org/thingsboard/server/transport/lwm2m/config/LwM2MSecureServerConfig.java

@ -21,14 +21,10 @@ public interface LwM2MSecureServerConfig {
String getHost();
String getHostRequests();
Integer getPort();
String getSecureHost();
String getSecureHostRequests();
Integer getSecurePort();
String getPublicX();

16
common/transport/lwm2m/src/main/java/org/thingsboard/server/transport/lwm2m/config/LwM2MTransportServerConfig.java

@ -44,14 +44,6 @@ public class LwM2MTransportServerConfig implements LwM2MSecureServerConfig {
@Value("${transport.lwm2m.timeout:}")
private Long timeout;
@Getter
@Value("${transport.lwm2m.blockwise_lifetime:}")
private Long blockwiseLifetime;
@Getter
@Value("${transport.lwm2m.block2_option_enable:}")
private boolean block2OptionEnable;
@Getter
@Value("${transport.sessions.report_timeout}")
private long sessionReportTimeout;
@ -120,10 +112,6 @@ public class LwM2MTransportServerConfig implements LwM2MSecureServerConfig {
@Value("${transport.lwm2m.server.bind_address:}")
private String host;
@Getter
@Value("${transport.lwm2m.server.bind_address_requests:}")
private String hostRequests;
@Getter
@Value("${transport.lwm2m.server.bind_port:}")
private Integer port;
@ -132,10 +120,6 @@ public class LwM2MTransportServerConfig implements LwM2MSecureServerConfig {
@Value("${transport.lwm2m.server.security.bind_address:}")
private String secureHost;
@Getter
@Value("${transport.lwm2m.server.security.bind_address_requests:}")
private String secureHostRequests;
@Getter
@Value("${transport.lwm2m.server.security.bind_port:}")
private Integer securePort;

4
common/transport/lwm2m/src/main/java/org/thingsboard/server/transport/lwm2m/server/DefaultLwM2mTransportService.java

@ -63,7 +63,7 @@ import static org.eclipse.californium.scandium.dtls.cipher.CipherSuite.TLS_ECDHE
import static org.eclipse.californium.scandium.dtls.cipher.CipherSuite.TLS_PSK_WITH_AES_128_CBC_SHA256;
import static org.eclipse.californium.scandium.dtls.cipher.CipherSuite.TLS_PSK_WITH_AES_128_CCM_8;
import static org.thingsboard.server.transport.lwm2m.server.LwM2mNetworkConfig.getCoapConfig;
import static org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil.OTA_COAP_RESOURCE;
import static org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil.FIRMWARE_UPDATE_COAP_RECOURSE;
@Slf4j
@Component
@ -103,7 +103,7 @@ public class DefaultLwM2mTransportService implements LwM2MTransportService {
*/
LwM2mTransportCoapResource otaCoapResource = new LwM2mTransportCoapResource(handler, OTA_COAP_RESOURCE);
LwM2mTransportCoapResource otaCoapResource = new LwM2mTransportCoapResource(handler, FIRMWARE_UPDATE_COAP_RECOURSE);
this.server.coap().getServer().add(otaCoapResource);
this.startLhServer();
this.context.setServer(server);

6
common/transport/lwm2m/src/main/java/org/thingsboard/server/transport/lwm2m/server/LwM2mNetworkConfig.java

@ -19,6 +19,8 @@ import org.eclipse.californium.core.network.config.NetworkConfig;
import org.eclipse.californium.core.network.config.NetworkConfigDefaults;
import org.thingsboard.server.transport.lwm2m.config.LwM2MTransportServerConfig;
import static org.eclipse.californium.core.network.config.NetworkConfigDefaults.DEFAULT_BLOCKWISE_STATUS_LIFETIME;
public class LwM2mNetworkConfig {
public static NetworkConfig getCoapConfig(Integer serverPortNoSec, Integer serverSecurePort, LwM2MTransportServerConfig config) {
@ -43,7 +45,7 @@ public class LwM2mNetworkConfig {
CoAP client will try to use block mode
or adapt the block size when receiving a 4.13 Entity too large response code
*/
coapConfig.setBoolean(NetworkConfig.Keys.BLOCKWISE_STRICT_BLOCK2_OPTION, config.isBlock2OptionEnable());
coapConfig.setBoolean(NetworkConfig.Keys.BLOCKWISE_STRICT_BLOCK2_OPTION, true);
/**
Property to indicate if the response should always include the Block2 option \
when client request early blockwise negociation but the response can be sent on one packet.
@ -59,7 +61,7 @@ public class LwM2mNetworkConfig {
* The default value of this property is
* {@link NetworkConfigDefaults#DEFAULT_BLOCKWISE_STATUS_LIFETIME} = 5 * 60 * 1000; // 5 mins [ms].
*/
coapConfig.setLong(NetworkConfig.Keys.BLOCKWISE_STATUS_LIFETIME, config.getBlockwiseLifetime());
coapConfig.setLong(NetworkConfig.Keys.BLOCKWISE_STATUS_LIFETIME, DEFAULT_BLOCKWISE_STATUS_LIFETIME);
/**
!!! REQUEST_ENTITY_TOO_LARGE CODE=4.13
The maximum size of a resource body (in bytes) that will be accepted

8
common/transport/lwm2m/src/main/java/org/thingsboard/server/transport/lwm2m/server/LwM2mTransportCoapResource.java

@ -30,7 +30,8 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.atomic.AtomicInteger;
import static org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil.OTA_COAP_RESOURCE;
import static org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil.FIRMWARE_UPDATE_COAP_RECOURSE;
import static org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil.SOFTWARE_UPDATE_COAP_RECOURSE;
@Slf4j
public class LwM2mTransportCoapResource extends AbstractLwM2mTransportResource {
@ -69,7 +70,8 @@ public class LwM2mTransportCoapResource extends AbstractLwM2mTransportResource {
protected void processHandleGet(CoapExchange exchange) {
log.warn("90) processHandleGet [{}]", exchange);
if (exchange.getRequestOptions().getUriPath().size() == 2 &&
OTA_COAP_RESOURCE.equals(exchange.getRequestOptions().getUriPath().get(0))) {
(FIRMWARE_UPDATE_COAP_RECOURSE.equals(exchange.getRequestOptions().getUriPath().get(0)) ||
SOFTWARE_UPDATE_COAP_RECOURSE.equals(exchange.getRequestOptions().getUriPath().get(0)))) {
this.sentOtaData(exchange);
}
}
@ -127,7 +129,7 @@ public class LwM2mTransportCoapResource extends AbstractLwM2mTransportResource {
}
}
private void sentOtaData (CoapExchange exchange) {
private void sentOtaData(CoapExchange exchange) {
String idStr = exchange.getRequestOptions().getUriPath().get(1);
UUID currentId = UUID.fromString(idStr);
if (exchange.getRequestOptions().getBlock2() != null) {

4
common/transport/lwm2m/src/main/java/org/thingsboard/server/transport/lwm2m/server/LwM2mTransportUtil.java

@ -139,8 +139,9 @@ public class LwM2mTransportUtil {
public static final String ERROR_KEY = "error";
public static final String METHOD_KEY = "methodName";
public static final String OTA_COAP_RESOURCE = "firmwarePackage";
// Firmware
public static final String FIRMWARE_UPDATE_COAP_RECOURSE = "firmwareUpdateCoapRecourse";
public static final String FW_UPDATE = "Firmware update";
public static final Integer FW_5_ID = 5;
public static final Integer FW_19_ID = 19;
@ -172,6 +173,7 @@ public class LwM2mTransportUtil {
public static final String FW_UPDATE_ID = "/5/0/2";
// Software
public static final String SOFTWARE_UPDATE_COAP_RECOURSE = "softwareUpdateCoapRecourse";
public static final String SW_UPDATE = "Software update";
public static final Integer SW_ID = 9;
// Package W

7
common/transport/lwm2m/src/main/java/org/thingsboard/server/transport/lwm2m/server/client/LwM2mFwSwUpdate.java

@ -43,6 +43,7 @@ import static org.thingsboard.server.common.data.ota.OtaPackageUpdateStatus.INIT
import static org.thingsboard.server.common.data.ota.OtaPackageUpdateStatus.UPDATED;
import static org.thingsboard.server.common.data.ota.OtaPackageUpdateStatus.UPDATING;
import static org.thingsboard.server.common.data.ota.OtaPackageUtil.getAttributeKey;
import static org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil.FIRMWARE_UPDATE_COAP_RECOURSE;
import static org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil.FW_3_VER_ID;
import static org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil.FW_5_VER_ID;
import static org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil.FW_NAME_ID;
@ -61,7 +62,6 @@ import static org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil.L
import static org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil.LwM2mTypeOper.EXECUTE;
import static org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil.LwM2mTypeOper.OBSERVE;
import static org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil.LwM2mTypeOper.WRITE_REPLACE;
import static org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil.OTA_COAP_RESOURCE;
import static org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil.SW_INSTALL_ID;
import static org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil.SW_NAME_ID;
import static org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil.SW_PACKAGE_ID;
@ -193,9 +193,10 @@ public class LwM2mFwSwUpdate {
firmwareChunk, handler.config.getTimeout(), this.rpcRequest);
} else if (LwM2mTransportUtil.LwM2MFirmwareUpdateStrategy.OBJ_5_TEMP_URL.code == this.updateStrategy) {
Registration registration = this.getLwM2MClient().getRegistration();
String api = handler.config.getHostRequests();
// String api = handler.config.getHostRequests();
String api = "0.0.0.0";
int port = registration.getIdentity().isSecure() ? handler.config.getSecurePort() : handler.config.getPort();
String uri = "coap://" + api + ":" + Integer.valueOf(port) + "/" + OTA_COAP_RESOURCE + "/" + this.currentId.toString();
String uri = "coap://" + api + ":" + Integer.valueOf(port) + "/" + FIRMWARE_UPDATE_COAP_RECOURSE + "/" + this.currentId.toString();
log.warn("89) coapUri: [{}]", uri);
request.sendAllRequest(this.lwM2MClient.getRegistration(), targetIdVer, WRITE_REPLACE, null,
uri, handler.config.getTimeout(), this.rpcRequest);

10
transport/lwm2m/src/main/resources/tb-lwm2m-transport.yml

@ -104,13 +104,9 @@ transport:
server:
id: "${LWM2M_SERVER_ID:123}"
bind_address: "${LWM2M_BIND_ADDRESS:0.0.0.0}"
# the host to receive requests to the server
bind_address_requests: "${LWM2M_BIND_ADDRESS_REQUESTS:0.0.0.0}"
bind_port: "${LWM2M_BIND_PORT:5685}"
security:
bind_address: "${LWM2M_BIND_ADDRESS_SECURITY:0.0.0.0}"
# the security host to receive requests to the server
bind_address_requests: "${LWM2M_BIND_ADDRESS_SECURITY_REQUESTS:0.0.0.0}"
bind_port: "${LWM2M_BIND_PORT_SECURITY:5686}"
# Only for RPK: Public & Private Key. If the keystore file is missing or not working
public_x: "${LWM2M_SERVER_PUBLIC_X:05064b9e6762dd8d8b8a52355d7b4d8b9a3d64e6d2ee277d76c248861353f358}"
@ -123,13 +119,9 @@ transport:
enable: "${LWM2M_ENABLED_BS:true}"
id: "${LWM2M_SERVER_ID_BS:111}"
bind_address: "${LWM2M_BIND_ADDRESS_BS:0.0.0.0}"
# the host to receive requests to the server
bind_address_requests: "${LWM2M_BIND_ADDRESS_REQUESTS_BS:0.0.0.0}"
bind_port: "${LWM2M_BIND_PORT_BS:5687}"
security:
bind_address: "${LWM2M_BIND_ADDRESS_SECURITY_BS:0.0.0.0}"
# the security host to receive requests to the server
bind_address_requests: "${LWM2M_BIND_ADDRESS_SECURITY_REQUESTS_BS:0.0.0.0}"
bind_port: "${LWM2M_BIND_PORT_SECURITY_BS:5688}"
# Only for RPK: Public & Private Key. If the keystore file is missing or not working
public_x: "${LWM2M_SERVER_PUBLIC_X_BS:5017c87a1c1768264656b3b355434b0def6edb8b9bf166a4762d9930cd730f91}"
@ -148,8 +140,6 @@ transport:
root_alias: "${LWM2M_SERVER_ROOT_CA:rootca}"
enable_gen_new_key_psk_rpk: "${ENABLE_GEN_NEW_KEY_PSK_RPK:false}"
timeout: "${LWM2M_TIMEOUT:120000}"
blockwise_lifetime: "${BLOCKWISE_LIFETIME:300000}"
block2_option_enable: "${BLOCK2_OPTION_ENABLED:true}"
recommended_ciphers: "${LWM2M_RECOMMENDED_CIPHERS:false}"
recommended_supported_groups: "${LWM2M_RECOMMENDED_SUPPORTED_GROUPS:true}"
response_pool_size: "${LWM2M_RESPONSE_POOL_SIZE:100}"

6
ui-ngx/src/assets/locale/locale.constant-en_US.json

@ -1255,10 +1255,16 @@
"client-strategy-label": "Strategy",
"client-strategy-connect": "{ count, plural, 1 {1: Only Observe Request to the client after the initial connection} other {2: Read All Resources & Observe Request to the client after registration} }",
"client-strategy-tip": "{ count, plural, 1 {Strategy 1: After the initial connection of the LWM2M Client, the server sends Observe resources Request to the client, those resources that are marked as observation in the Device profile and which exist on the LWM2M client.} other {Strategy 2: After the registration, request the client to read all the resource values for all objects that the LWM2M client has,\n then execute: the server sends Observe resources Request to the client, those resources that are marked as observation in the Device profile and which exist on the LWM2M client.} }",
"ota-update-strategy": "Ota update strategy",
"fw-update-strategy-label": "Firmware update strategy",
"fw-update-strategy": "{ count, plural, 1 {Push firmware update as binary file using Object 5 and Resource 0 (Package).} 2 {Auto-generate unique CoAP URL to download the package and push firmware update as Object 5 and Resource 1 (Package URI).} other {Push firmware update as binary file using Object 19 and Resource 0 (Data).} }",
"sw-update-strategy-label": "Software update strategy",
"sw-update-strategy": "{ count, plural, 1 {Push binary file using Object 9 and Resource 2 (Package).} other {Auto-generate unique CoAP URL to download the package and push software update using Object 9 and Resource 3 (Package URI).} }",
"blockwise-settings": "Blockwise settings",
"blockwise-enabled": "Enable blockwise",
"blockwise-status-lifetime": "Blockwise Status Lifetime",
"fw-update-recourse": "Firmware update Coap recourse",
"sw-update-recourse": "Software update Coap recourse",
"config-json-tab": "Json Config Profile Device"
}
},

Loading…
Cancel
Save