insighio / microcoapy Goto Github PK
View Code? Open in Web Editor NEWA mini client/server implementation of CoAP (Constrained Application Protocol) into MicroPython
License: Apache License 2.0
A mini client/server implementation of CoAP (Constrained Application Protocol) into MicroPython
License: Apache License 2.0
Hello!
In an attempt to test and play around with CoAP on the ESP32 I stumbled across this project.
However, when trying to use the example files my IDEs are all unable to obtain or install the library, stating a missing setup.py or "pyproject.toml".
I have attempted to use both Thonny, vscode, and straight CLI.
Would you be able to look at the issue or provide installation instructions?
Thank you!
In case specific network interface is not mapped to internal IP stack and not available through socket module it would be beneficial if custom methods for socket operations could be used. E.g. they could make use of socket API of cellular modem controlled via AT commands.
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
microCoAPy/microcoapy/microcoapy.py
Lines 188 to 193 in ad00d74
Needs to be addressed.
Hi,
I am using your lib as a client for a small project of mine --> https://github.com/Trifunik/condensation_alert.
Do you know any elegant way to get the coapPacket.messageid from the get function?
I want to be sure that the payload is the response to the wright GET request, because I have sometimes a race condition between two GET requests.
Many thanks in advance!
Nikola
I saw a method sendPacket in the code, I wanted to use it, but I had to look at the code further, it turns out this method has privacy. Do you think this is a bad method to use? ๐ค
Hello,
I'd like to ask if there is any scenario that handleIncomingRequest
is called for client side?
It seems that function purpose is to handle requests (eg. GET) on server side. Am I right?
However handleIncomingRequest
is checking self.responseCallback
which is for client side.
If Coap
can act as an server and client in a single instance (can't it?) and if self.responseCallback
is set and if requested url is unknown (not in self.callbacks
) then the function returns False
and sendResponse
indication "not found" is not called.
if urlCallback is None:
if self.responseCallback:
# The incoming request may be a response, let the responseCallback handle it.
return False
print('Callback for url [', url, "] not found")
self.sendResponse(sourceIp, sourcePort, requestPacket.messageid,
None, macros.COAP_RESPONSE_CODE.COAP_NOT_FOUND,
macros.COAP_CONTENT_FORMAT.COAP_NONE, requestPacket.token)
So my point is that either handleIncomingRequest
shall not be called for non requests (ie. GET) or above logic shall be changed to exclude server requests:
if self.responseCallback and macros.COAP_METHOD.COAP_GET != requestPacket.method:
# The incoming request may be a response, let the responseCallback handle it.
return False
Please share your thoughts.
Best regards
hi have some issue installing external package on micropython.
Can yoyu give some int ?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.