Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question about Coap.handleIncomingRequest #13

Open
przemobe opened this issue Nov 22, 2023 · 0 comments
Open

Question about Coap.handleIncomingRequest #13

przemobe opened this issue Nov 22, 2023 · 0 comments

Comments

@przemobe
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant