@@ -78,7 +78,7 @@ cs:func("myfun") -- post coap://192.168.18.103:5683/v1/f/myfun will call myfun
...
@@ -78,7 +78,7 @@ cs:func("myfun") -- post coap://192.168.18.103:5683/v1/f/myfun will call myfun
Issues a GET request to the server.
Issues a GET request to the server.
#### Syntax
#### Syntax
`coap.client:get(type, uri, [payload])`
`coap.client:get(type, uri[, payload])`
#### Parameters
#### Parameters
-`type``coap.CON`, `coap.NON`, defaults to CON. If the type is CON and request fails, the library retries four more times before giving up.
-`type``coap.CON`, `coap.NON`, defaults to CON. If the type is CON and request fails, the library retries four more times before giving up.
...
@@ -93,7 +93,7 @@ Issues a GET request to the server.
...
@@ -93,7 +93,7 @@ Issues a GET request to the server.
Issues a PUT request to the server.
Issues a PUT request to the server.
#### Syntax
#### Syntax
`coap.client:put(type, uri, [payload])`
`coap.client:put(type, uri[, payload])`
#### Parameters
#### Parameters
-`type``coap.CON`, `coap.NON`, defaults to CON. If the type is CON and request fails, the library retries four more times before giving up.
-`type``coap.CON`, `coap.NON`, defaults to CON. If the type is CON and request fails, the library retries four more times before giving up.
...
@@ -108,7 +108,7 @@ Issues a PUT request to the server.
...
@@ -108,7 +108,7 @@ Issues a PUT request to the server.
Issues a POST request to the server.
Issues a POST request to the server.
#### Syntax
#### Syntax
`coap.client:post(type, uri, [payload])`
`coap.client:post(type, uri[, payload])`
#### Parameters
#### Parameters
-`type` coap.CON, coap.NON, defaults to CON. when type is CON, and request failed, the request will retry another 4 times before giving up.
-`type` coap.CON, coap.NON, defaults to CON. when type is CON, and request failed, the request will retry another 4 times before giving up.
...
@@ -123,7 +123,7 @@ Issues a POST request to the server.
...
@@ -123,7 +123,7 @@ Issues a POST request to the server.
Issues a DELETE request to the server.
Issues a DELETE request to the server.
#### Syntax
#### Syntax
`coap.client:delete(type, uri, [payload])`
`coap.client:delete(type, uri[, payload])`
#### Parameters
#### Parameters
-`type``coap.CON`, `coap.NON`, defaults to CON. If the type is CON and request fails, the library retries four more times before giving up.
-`type``coap.CON`, `coap.NON`, defaults to CON. If the type is CON and request fails, the library retries four more times before giving up.
...
@@ -140,7 +140,7 @@ Issues a DELETE request to the server.
...
@@ -140,7 +140,7 @@ Issues a DELETE request to the server.
Starts the CoAP server on the given port.
Starts the CoAP server on the given port.
#### Syntax
#### Syntax
`coap.server:listen(port, [ip])`
`coap.server:listen(port[, ip])`
#### Parameters
#### Parameters
-`port` server port (number)
-`port` server port (number)
...
@@ -167,7 +167,7 @@ none
...
@@ -167,7 +167,7 @@ none
Registers a Lua variable as an endpoint in the server. the variable value then can be retrieved by a client via GET method, represented as an [URI](http://tools.ietf.org/html/rfc7252#section-6) to the client. The endpoint path for varialble is '/v1/v/'.
Registers a Lua variable as an endpoint in the server. the variable value then can be retrieved by a client via GET method, represented as an [URI](http://tools.ietf.org/html/rfc7252#section-6) to the client. The endpoint path for varialble is '/v1/v/'.
#### Syntax
#### Syntax
`coap.server:var(name, [content_type])`
`coap.server:var(name[, content_type])`
#### Parameters
#### Parameters
-`name` the Lua variable's name
-`name` the Lua variable's name
...
@@ -198,7 +198,7 @@ When the client issues a POST request to this URI, the payload will be passed to
...
@@ -198,7 +198,7 @@ When the client issues a POST request to this URI, the payload will be passed to
The function registered SHOULD accept ONLY ONE string type parameter, and return ONE string value or return nothing.
The function registered SHOULD accept ONLY ONE string type parameter, and return ONE string value or return nothing.
-`function(client, [topic], [message])` callback function. The first parameter is the client. If event is "message", the 2nd and 3rd param are received topic and message (strings).
-`function(client[, topic[, message]])` callback function. The first parameter is the client. If event is "message", the 2nd and 3rd param are received topic and message (strings).
@@ -173,7 +173,7 @@ Register callback functions for specific events.
...
@@ -173,7 +173,7 @@ Register callback functions for specific events.
#### Parameters
#### Parameters
-`event` string, which can be "connection", "reconnection", "disconnection", "receive" or "sent"
-`event` string, which can be "connection", "reconnection", "disconnection", "receive" or "sent"
-`function(net.socket, [string])` callback function. The first parameter is the socket. If event is "receive", the second parameter is the received data as string.
-`function(net.socket[, string])` callback function. The first parameter is the socket. If event is "receive", the second parameter is the received data as string.