Skip to content

Commit 982a9c6

Browse files
committed
Adding documentation of Coap over DTLS
1 parent b84fdb0 commit 982a9c6

File tree

1 file changed

+11
-7
lines changed
  • content/firmwareapi/pycom/network

1 file changed

+11
-7
lines changed

content/firmwareapi/pycom/network/coap.md

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -82,16 +82,18 @@ print(id)
8282

8383
## Initialization
8484

85-
#### Coap.init(address, *, port=5683, service_discovery=False, dynamic_resources=False)
85+
#### Coap.init(address, *, port=5683, service_discovery=False, dynamic_resources=False, psk=None, hint=None)
8686

8787
Initialize the CoAp module.
8888

8989
The arguments are:
9090

9191
* `address` is the address where the CoAp module handles communication when it is a Server. If not set, the module can be used as a CoAp Client only.
92-
* `port` is the port where the CoAp Server listens. If not set, the default CoAp UDP port is 5683.
92+
* `port` is the port where the CoAp Server listens. If not set, the default CoAp UDP port 5683 is used if no PSK is given otherwise the default CoAp DTLS port 5684 is used.
9393
* `service_discovery` is a Boolean argument that enables/disables service discovery. If enabled, the CoAp Server will listen on the CoAp multicast address: 224.0.1.187. This is disabled by default.
9494
* `dynamic_resources` is a Boolean argument that enables/disables new resource creation via PUT operations. This is disabled by default.
95+
* `psk` is a String representing the Pre-Shared Key to be used for the DTLS connection.
96+
* `hint` is a String representing the hint value to be used for the DTLS connection.
9597

9698
When `dynamic_resources` is TRUE new resources can be created via PUT reqeusts, if the resource with the given URI does not already exist.
9799
The new resource is created with default properties (no mediatype, no Max-Age and no ETAG is enabled) and with default value received in the PUT request. On the new resource by default all operations (GET, PUT, POST and DELETE) are enabled.
@@ -158,13 +160,14 @@ Registers a callback function which will be called when a new resource has been
158160
* `callback` is the callback to be registered. The callback must have 1 argument:
159161
* `resource` is the new resource which has been created
160162

161-
#### Coap.new_client_session(destination, port=5683, protocol=UDP)
163+
#### Coap.new_client_session(address, *, port=5683, psk=None, identity=None)
162164

163165
Creates a new CoAp Client Session which can be used to communicate with an external CoAp Server.
164166

165-
* `destination` is the IPv4 Address of the CoAp Server to join.
166-
* `port` is the port of the CoAp Server to join. If not set, the default CoAp UDP port 5683 is used.
167-
* `protocol` is the protocol to use to communicate with the CoAp Server. If not set the protocol UDP is used. Currently no other protocols than UDP is supported.
167+
* `address` is the IPv4 Address of the CoAp Server to join.
168+
* `port` is the port of the CoAp Server to join. If not set, the default CoAp UDP port 5683 is used if no PSK is given otherwise the default CoAp DTLS port 5684 is used.
169+
* `psk` is a String representing the Pre-Shared Key to be used for the DTLS connection.
170+
* `identity` is a String representing the identity value to be used for the DTLS connection.
168171

169172

170173
#### Coap.remove_client_session(destination, port=5683, protocol=UDP)
@@ -173,7 +176,7 @@ Removes the specified CoAp Client Session.
173176

174177
* `destination` is the IPv4 Address of the CoAp Server where this CoAp Client Session has joined.
175178
* `port` is the port of the CoAp Server where this CoAp Client Session has joined. If not set, the default CoAp UDP port 5683 is used.
176-
* `protocol` is the protocol to use to communicate with the CoAp Server where this CoAp Client Session has joined. If not set the protocol UDP is used. Currently no other protocols than UDP is supported.
179+
* `protocol` is the protocol to be used to communicate with the CoAp Server where this CoAp Client Session has joined. This value can be: `Coap.PROTOCOL_UDP`,`Coap.PROTOCOL_DTLS`, if not set the protocol UDP is used.
177180

178181
#### Coap.get_client_sessions()
179182

@@ -275,3 +278,4 @@ Due to limitations of the underlying ESP-IDF/libcoap library, new resources cann
275278

276279
* Define the media type: `Coap.MEDIATYPE_TEXT_PLAIN`, `Coap.MEDIATYPE_APP_LINK_FORMAT`, `Coap.MEDIATYPE_APP_XML`, `Coap.MEDIATYPE_APP_OCTET_STREAM`, `Coap.MEDIATYPE_APP_RDF_XML`, `Coap.MEDIATYPE_APP_EXI`, `Coap.MEDIATYPE_APP_JSON`, `Coap.MEDIATYPE_APP_CBOR`
277280
* Define the operation: `Coap.REQUEST_GET`, `Coap.REQUEST_PUT`, `Coap.REQUEST_POST`, `Coap.REQUEST_DELETE`
281+
* Define the protocol: `Coap.PROTOCOL_UDP`,`Coap.PROTOCOL_DTLS`

0 commit comments

Comments
 (0)