|
|
|
@ -23,73 +23,72 @@ public class LwM2mNetworkConfig { |
|
|
|
NetworkConfig coapConfig = new NetworkConfig(); |
|
|
|
coapConfig.setInt(NetworkConfig.Keys.COAP_PORT,serverPortNoSec); |
|
|
|
coapConfig.setInt(NetworkConfig.Keys.COAP_SECURE_PORT,serverSecurePort); |
|
|
|
/** |
|
|
|
* Example:Property for large packet: |
|
|
|
* #NetworkConfig config = new NetworkConfig(); |
|
|
|
* #config.setInt(NetworkConfig.Keys.MAX_MESSAGE_SIZE,32); |
|
|
|
* #config.setInt(NetworkConfig.Keys.PREFERRED_BLOCK_SIZE,32); |
|
|
|
* #config.setInt(NetworkConfig.Keys.MAX_RESOURCE_BODY_SIZE,2048); |
|
|
|
* #config.setInt(NetworkConfig.Keys.MAX_RETRANSMIT,3); |
|
|
|
* #config.setInt(NetworkConfig.Keys.MAX_TRANSMIT_WAIT,120000); |
|
|
|
/* |
|
|
|
Example:Property for large packet: |
|
|
|
#NetworkConfig config = new NetworkConfig(); |
|
|
|
#config.setInt(NetworkConfig.Keys.MAX_MESSAGE_SIZE,32); |
|
|
|
#config.setInt(NetworkConfig.Keys.PREFERRED_BLOCK_SIZE,32); |
|
|
|
#config.setInt(NetworkConfig.Keys.MAX_RESOURCE_BODY_SIZE,2048); |
|
|
|
#config.setInt(NetworkConfig.Keys.MAX_RETRANSMIT,3); |
|
|
|
#config.setInt(NetworkConfig.Keys.MAX_TRANSMIT_WAIT,120000); |
|
|
|
*/ |
|
|
|
|
|
|
|
/** |
|
|
|
* 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. |
|
|
|
* - value of false indicate that the server will respond without block2 option if no further blocks are required. |
|
|
|
* - value of true indicate that the server will response with block2 option event if no further blocks are required. |
|
|
|
* CoAP client will try to use block mode |
|
|
|
* or adapt the block size when receiving a 4.13 Entity too large response code |
|
|
|
/* |
|
|
|
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. |
|
|
|
- value of false indicate that the server will respond without block2 option if no further blocks are required. |
|
|
|
- value of true indicate that the server will response with block2 option event if no further blocks are required. |
|
|
|
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, 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. |
|
|
|
* - value of false indicate that the server will respond without block2 option if no further blocks are required. |
|
|
|
* - value of true indicate that the server will response with block2 option event if no further blocks are required. |
|
|
|
/* |
|
|
|
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. |
|
|
|
- value of false indicate that the server will respond without block2 option if no further blocks are required. |
|
|
|
- value of true indicate that the server will response with block2 option event if no further blocks are required. |
|
|
|
*/ |
|
|
|
coapConfig.setBoolean(NetworkConfig.Keys.BLOCKWISE_ENTITY_TOO_LARGE_AUTO_FAILOVER, true); |
|
|
|
|
|
|
|
coapConfig.setInt(NetworkConfig.Keys.BLOCKWISE_STATUS_LIFETIME, 300000); |
|
|
|
/** |
|
|
|
* !!! REQUEST_ENTITY_TOO_LARGE CODE=4.13 |
|
|
|
* The maximum size of a resource body (in bytes) that will be accepted |
|
|
|
* as the payload of a POST/PUT or the response to a GET request in a |
|
|
|
* transparent> blockwise transfer. |
|
|
|
* This option serves as a safeguard against excessive memory |
|
|
|
* consumption when many resources contain large bodies that cannot be |
|
|
|
* transferred in a single CoAP message. This option has no impact on |
|
|
|
* *manually* managed blockwise transfers in which the blocks are handled individually. |
|
|
|
* Note that this option does not prevent local clients or resource |
|
|
|
* implementations from sending large bodies as part of a request or response to a peer. |
|
|
|
* The default value of this property is DEFAULT_MAX_RESOURCE_BODY_SIZE = 8192 |
|
|
|
* A value of {@code 0} turns off transparent handling of blockwise transfers altogether. |
|
|
|
/* |
|
|
|
!!! REQUEST_ENTITY_TOO_LARGE CODE=4.13 |
|
|
|
The maximum size of a resource body (in bytes) that will be accepted |
|
|
|
as the payload of a POST/PUT or the response to a GET request in a |
|
|
|
transparent> blockwise transfer. |
|
|
|
This option serves as a safeguard against excessive memory |
|
|
|
consumption when many resources contain large bodies that cannot be |
|
|
|
transferred in a single CoAP message. This option has no impact on |
|
|
|
*manually* managed blockwise transfers in which the blocks are handled individually. |
|
|
|
Note that this option does not prevent local clients or resource |
|
|
|
implementations from sending large bodies as part of a request or response to a peer. |
|
|
|
The default value of this property is DEFAULT_MAX_RESOURCE_BODY_SIZE = 8192 |
|
|
|
A value of {@code 0} turns off transparent handling of blockwise transfers altogether. |
|
|
|
*/ |
|
|
|
// coapConfig.setInt(NetworkConfig.Keys.MAX_RESOURCE_BODY_SIZE, 8192);
|
|
|
|
coapConfig.setInt(NetworkConfig.Keys.MAX_RESOURCE_BODY_SIZE, 256 * 1024 * 1024); |
|
|
|
/** |
|
|
|
* The default DTLS response matcher. |
|
|
|
* Supported values are STRICT, RELAXED, or PRINCIPAL. |
|
|
|
* The default value is STRICT. |
|
|
|
* Create new instance of udp endpoint context matcher. |
|
|
|
* Params: |
|
|
|
* checkAddress |
|
|
|
* – true with address check, (STRICT, UDP) |
|
|
|
* - false, without |
|
|
|
/* |
|
|
|
The default DTLS response matcher. |
|
|
|
Supported values are STRICT, RELAXED, or PRINCIPAL. |
|
|
|
The default value is STRICT. |
|
|
|
Create new instance of udp endpoint context matcher. |
|
|
|
Params: |
|
|
|
checkAddress |
|
|
|
– true with address check, (STRICT, UDP) |
|
|
|
- false, without |
|
|
|
*/ |
|
|
|
coapConfig.setString(NetworkConfig.Keys.RESPONSE_MATCHING, "STRICT"); |
|
|
|
/** |
|
|
|
* https://tools.ietf.org/html/rfc7959#section-2.9.3
|
|
|
|
* The block size (number of bytes) to use when doing a blockwise transfer. \ |
|
|
|
* This value serves as the upper limit for block size in blockwise transfers |
|
|
|
/* |
|
|
|
https://tools.ietf.org/html/rfc7959#section-2.9.3
|
|
|
|
The block size (number of bytes) to use when doing a blockwise transfer. \ |
|
|
|
This value serves as the upper limit for block size in blockwise transfers |
|
|
|
*/ |
|
|
|
coapConfig.setInt(NetworkConfig.Keys.PREFERRED_BLOCK_SIZE, 1024); |
|
|
|
/** |
|
|
|
* The maximum payload size (in bytes) that can be transferred in a |
|
|
|
* single message, i.e. without requiring a blockwise transfer. |
|
|
|
* NB: this value MUST be adapted to the maximum message size supported by the transport layer. |
|
|
|
* In particular, this value cannot exceed the network's MTU if UDP is used as the transport protocol |
|
|
|
* DEFAULT_VALUE = 1024 |
|
|
|
/* |
|
|
|
The maximum payload size (in bytes) that can be transferred in a |
|
|
|
single message, i.e. without requiring a blockwise transfer. |
|
|
|
NB: this value MUST be adapted to the maximum message size supported by the transport layer. |
|
|
|
In particular, this value cannot exceed the network's MTU if UDP is used as the transport protocol |
|
|
|
DEFAULT_VALUE = 1024 |
|
|
|
*/ |
|
|
|
coapConfig.setInt(NetworkConfig.Keys.MAX_MESSAGE_SIZE, 1024); |
|
|
|
|
|
|
|
|