IPWorks IoT 2020 Python Edition

Questions / Feedback?

on_request_complete Event

Fires when a request completes.

Syntax

class CoAPRequestCompleteEventParams(object):
  @property
  def method() -> int: ...
  @property
  def uri() -> str: ...
  @property
  def request_id() -> str: ...
  @property
  def error_code() -> int: ...
  @property
  def error_description() -> str: ...

# In class CoAP:
@property
def on_request_complete() -> Callable[[CoAPRequestCompleteEventParams], None]: ...
@on_request_complete.setter
def on_request_complete(event_hook: Callable[[CoAPRequestCompleteEventParams], None]) -> None: ...

Remarks

This event fires when a request completes. Usually, a request is considered complete when a response has been received. However, requests can also be considered "complete" if either of the following occurs:

  • If the use_confirmable_messages property is enabled, and the class did not receive confirmation that the request was received before the retransmission period elapsed.
  • If timeout property is greater than 0, and the class did not receive a response before the timeout period elapsed.

Assuming a response was received (i.e., the ErrorCode parameter is either 0 or 709; see below), then the response code, payload, and options can be obtained by querying the response_code, response_data, response_content_format, response_e_tag, and ResponseOption* properties.

The Method parameter reflects the request method code. The following table provides a (non-exhaustive) list of some of the more common method codes; refer to the IANA's CoAP Method Codes registry for a full list.

Method Code Name
1 GET
2 POST
3 PUT
4 DELETE
5 FETCH
6 PATCH

The URI parameter reflects the requested resource's URI.

The ErrorCode parameter indicates whether the request encountered an error. If no error was encountered, it will be 0; if the server returned a non-2.xx response code, it will be 709; if some other error occurred (e.g., the request timed out), it will be another non-zero value.

The ErrorDescription parameter provides a description of the error that occurred (or, if ErrorCode is 709, a string version of the response code returned by the server). It will be empty if no error was encountered.

Note: This event is only used 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]