Coder Social home page Coder Social logo

insighio / microcoapy Goto Github PK

View Code? Open in Web Editor NEW
56.0 10.0 10.0 70 KB

A mini client/server implementation of CoAP (Constrained Application Protocol) into MicroPython

License: Apache License 2.0

Python 100.00%
coap micropython server client pycom coap-server coap-client esp32 esp8266

microcoapy's People

Contributors

frederic-bonjour avatar ftylitak avatar przemobe avatar talkinpotato avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

microcoapy's Issues

resposeCallback not called for NONCON requests

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

if packet.type == macros.COAP_TYPE.COAP_ACK or\
packet.method == macros.COAP_RESPONSE_CODE.COAP_NOT_FOUND:
if self.resposeCallback is not None:
self.resposeCallback(packet, remoteAddress)
else:
self.handleIncomingRequest(packet, remoteAddress[0], remoteAddress[1])

Needs to be addressed.

MessageID

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

INSTALLATION

hi have some issue installing external package on micropython.
Can yoyu give some int ?

Question about Coap.handleIncomingRequest

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

Installation issues - no setup.py nor pyproject.toml

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!

OOP

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? ๐Ÿค”

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.