insighio / microCoAPy

A mini client/server implementation of CoAP (Constrained Application Protocol) into MicroPython
Apache License 2.0
57 stars 12 forks source link

resposeCallback not called for NONCON requests #6

Closed ftylitak closed 4 years ago

ftylitak commented 4 years ago

The default options for methods get, post, delete are set to CON (confirmable) in the implementation of the microCoAPy.

To send NONCON (Non-Confirmable) message someone needs to use the generic function microcoapy.Coap.send().

#example
requestId = client.send(_SERVER_IP, _SERVER_PORT, url,  microcoapy.coap_macros.COAP_TYPE.COAP_NONCON,  microcoapy.coap_macros.COAP_METHOD.COAP_GET, bytearray(), None,  microcoapy.coap_macros.COAP_CONTENT_FORMAT.COAP_NONE, None)

When this function is used with NONCON flag, the response Callback is never called because of the following lines in the microcoapy.py

https://github.com/insighio/microCoAPy/blob/ad00d74bbe30eaa96659c243785e745c7a91eb83/microcoapy/microcoapy.py#L188-L193

Needs to be addressed.