You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
*`address` is the address where Coap Module will handle the communication.
93
-
*`port` is the port where Coap Module will listen, if not given it is the default Coap UDP port: 5683.
94
-
*`service_discovery` is a boolean argument to enable/disable service discovery. If enabled, the Coap Module will listen on the Coap Multicast address too: 224.0.1.187. By default it is disabled.
92
+
*`address` is the address where the CoAp module handles communication.
93
+
*`port` is the port where the CoAp module listens. If not set, the default CoAp UDP port is 5683.
94
+
*`service_discovery` is a Boolean argument that enables/disables service discovery. If enabled, the CoAp module will listen on the CoAp multicast address: 224.0.1.187. This is disabled by default.
95
95
96
-
## Module's methods
96
+
## Methods:
97
97
98
98
#### Coap.socket()
99
99
100
-
Returns with the socket assigned to the given `address` and `port` during `Coap.init()` (= assigned to the Coap Module).
100
+
Returns with the socket assigned to the given address and port during Coap.init() (= assigned to the CoAp module).
Creates a resource object and adds it to the Coap Module to operate as a server.
104
+
Creates a resource object and adds it to the CoAp module to operate as a server.
105
105
106
106
*`uri` is the full path of the resource.
107
-
*`media_type` is the media type (Coap option: Content-Format) of the resource. If not given, no defined media type is associated with the resource.
108
-
*`max_age` is the maximum time in seconds when the value of the resource is considered fresh (Coap option: Max-Age). If not given, no fresh time is associated with the resource.
109
-
*`value` is the default value of the resource. If not given it is initialized to decimal 0.
110
-
*`etag` is a boolean argument to enable/disable entity tag calculation (Coap option: ETag). By default it is turned off.
107
+
*`media_type` is the media type (CoAp option: Content-Format) of the resource. If not given, no defined media type is associated with the resource.
108
+
*`max_age` is the maximum time in seconds that the value of the resource is considered fresh (CoAp option: Max-Age). If not given, no fresh time is associated with the resource.
109
+
*`value` is the default value of the resource. If not given, it is initialised to decimal 0.
110
+
*`etag` is a Boolean argument that enables/disables entity tag calculation (CoAp option: ETag). By default it is turned off.
111
111
112
112
113
113
{{% hint style="info" %}}
114
-
Mediatype argument should be one of the standard defined value which are available via Coap Module's constants.
114
+
Media-type argument is one of the standard defined values that is available via CoAp module's constants.
115
115
{{% /hint %}}
116
116
117
117
{{% hint style="info" %}}
118
-
Entity tag calculation is a simple counter increment between value 1-65535 with overflow but without value 0. Incremented each time the value of the resource is changed.
118
+
Entity tag calculation is a simple counter increment between value 1-65535 with overflow, it doesn't include the value 0. It is incremented each time and the value of the resource is changed.
119
119
{{% /hint %}}
120
120
121
121
122
122
#### Coap.remove_resource(uri)
123
123
124
-
Removes the resource defined by `uri` argument.
124
+
Removes the resource defined by the `uri` argument.
125
125
126
126
*`uri` is the full path of the resource to be removed.
127
127
@@ -133,11 +133,11 @@ Returns with the resource defined by `uri` argument.
133
133
134
134
#### Coap.read()
135
135
136
-
Must be called when a packet is received on the socket assigned to the Coap Module. This function parses the incoming request, composes and sends out the response if needed.
136
+
Must be called when a packet is received on the socket assigned to the CoAp module. This function passes on the incoming request, whilst also composing and sending out the response if needed.
137
137
138
138
#### Coap.register_response_handler(callback)
139
139
140
-
Registers a callback function which will be called when a remote Coap Server responses to our request.
140
+
Registers a callback function which will be called when a remote CoAp Server responses to the local CoAp client's request.
141
141
142
142
*`callback` is the callback to be registered. It must have the following arguments:
143
143
*`code` is the response code from the received message
@@ -148,20 +148,20 @@ Registers a callback function which will be called when a remote Coap Server res
*`uri_host` is the IP address of the server, included in the message as an "URI-HOST" option
154
154
*`method` is the method to be sent to the server, can be: `Coap.REQUEST_GET`, `Coap.REQUEST_PUT`, `Coap.REQUEST_POST`, `Coap.REQUEST_DELETE`
155
-
*`uri_port` is the port of the server, included in the message as an "URI-PORT" option, by default it is 5683
155
+
*`uri_port` is the port of the server, included in the message as an "URI-PORT" option. By default it is 5683
156
156
*`uri_path` is the full path of the resource in the server, included in the message as an "URI-PATH" option. If nothing is given the request will not have URI-PATH option.
157
157
*`content_format` is the Content-Format option of the request, can be: `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`. If nothing is given the request will not have Content-Format option.
158
158
*`payload` is the payload of the request. If nothing is given the request will not have payload.
159
159
*`token` is the token field of the request. If nothing is given the request will not have token field.
160
-
*`include_options` decides whether put any options (including the ones above) into the message or not. It can be used to send special requests to servers accepting Coap formed requests without options, e.g. to a Dish Telemetry server. By default the options are included.
160
+
*`include_options` decides whether put any options (including the ones above) into the message or not. It can be used to send special requests to servers accepting CoAp formed requests without options, e.g. to a Dish Telemetry server. By default, the options are included.
161
161
162
162
## Class resource
163
163
164
-
The resource class represents a resource in the scope of the Coap Module when acting as a server. A new resource can be only created with the `Coap.add_resource` function.
164
+
The resource class represents a resource in the scope of the CoAp module when acting as a server. A new resource can only be created with the `Coap.add_resource` function.
165
165
166
166
#### Class methods
167
167
@@ -175,7 +175,7 @@ Adds a new attribute to the resource. Attributes are used to explain the resourc
175
175
*`value` is the value of the resource.
176
176
177
177
{{% hint style="info" %}}
178
-
During service discovery, GET request to ".well-know/core", the attributes are returned with the belonging values.
178
+
During service discovery, GET request to ".well-know/core", the attributes are returned with the relevant values.
179
179
E.g. using the "libcoap's" command line coap-client to fetch the resource from our server:
180
180
181
181
coap-client -m get coap://<Coap-Server's address>/.well-known/core
@@ -188,22 +188,22 @@ coap-client -m get coap://<Coap-Server's address>/.well-known/core
188
188
189
189
Updates or fetches the value of the resource.
190
190
191
-
*`value` is the value to update the current value with.
192
-
If the method is called without parameter the current value is returned.
191
+
*`value` is the new value to update the current value with.
192
+
If the method is called without a parameter, the current value is returned.
193
193
194
194
#### resource.callback(operation, enable)
195
195
To enable or disable a specific operation (GET, PUT, POST, DELETE) on the resource.
196
196
197
197
*`operation` is the operation to enable/disable, can be ORED of the followings: `Coap.REQUEST_GET`, `Coap.REQUEST_PUT`, `Coap.REQUEST_POST`, `Coap.REQUEST_DELETE`
198
-
*`enable` is boolean parameter to enable/disable the operations specified by `operation`
198
+
*`enable` is Boolean parameter that enables/disables the operations specified by `operation`
199
199
200
200
201
201
{{% hint style="info" %}}
202
-
During a GET request, only the first occurance of an ETAG or Accept option is parsed and interpreted, the others of the same type are dropped (if any).
202
+
During a GET request, only the first occurrence of an ETAG or Accept option is passed on and interpreted; others of the same type are dropped (if any).
203
203
{{% /hint %}}
204
204
205
205
{{% hint style="info" %}}
206
-
During a PUT request, only the first occurance of an If-Match option is parsed and interpreted, the others of the same type are dropped (if any).
206
+
During a PUT request, only the first occurrence of an If-Match option is passed on and interpreted; others of the same type are dropped (if any).
0 commit comments