IPWorks IoT 2020 Python Edition

Questions / Feedback?

put Method

Sends a PUT request to the server.

Syntax

def put(uri: str) -> str: ...

Remarks

This method sends the server a PUT request for the resource identified by URI. The request_data property specifies the data that will be sent in the request. If the request_content_format and/or request_e_tag properties are non-empty, their values will be used to include Content-Format and Etag options in the request (respectively). Any additional options present in the RequestOption* properties will be included as well.

The format of the URI parameter is coap://hostname:port/resource. The port is optional, and if not specified will default to 5683. For instance coap://myserver/test and coap://myserver:5683/test are equivalent.

If the use_confirmable_messages property is enabled when this method is called, the class will automatically retransmit the request message (if necessary) until it receives confirmation from the server that it was received. Note that the retransmission period is not infinite; eventually the class will assume that the message is undeliverable and time out the request.

If the timeout property is greater than 0, this method will block until either a response is received, the specified timeout interval elapses, or (if use_confirmable_messages is enabled) the retransmission period elapses; whichever occurs first. It will then return empty string.

If the timeout property is 0, a record of the request will be added to the PendingRequest* properties, and this method will finish immediately, returning an Id for the request. Passing this Id to the cancel_request method will cancel the request (assuming it is still pending at that time).

Once a response is received, or the request times out, the class will do the following:

  • Populate the Response* properties (unless the request timed out).
  • Remove the request record from the PendingRequest* properties, if necessary.
  • Fire the on_request_complete event.

Note: This method can only be called when the class is operating in client mode (i.e., when the listening property is disabled).

Copyright (c) 2022 /n software inc. - All rights reserved.
IPWorks IoT 2020 Python Edition - Version 20.0 [Build 8265]