-
Notifications
You must be signed in to change notification settings - Fork 12
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
MessageID #4
Comments
Hello @Trifunik You are looking for a way to get the coapPacket.messageid of a GET function and I will suppose that you require the messageid of the request packet. Correct? If this is indeed true, then the messsageid of the request packet is the integer value returned by the client.get function. Note here that the example in our source code has a typo. At the print of the return value of the get function, it is named as payload which should be replaced with messageid. example: import microcoapy
# your code to connect to the network
#...
def receivedMessageCallback(packet, sender):
print('Message received:', packet, ', from: ', sender)
print('Mesage payload: ', packet.payload.decode('unicode_escape'))
print('Response ID: ', packet.messageid.decode('unicode_escape'))
client = microcoapy.Coap()
client.resposeCallback = receivedMessageCallback
client.start()
_SERVER_IP="192.168.1.2"
_SERVER_PORT=5683
requestId= client.get(_SERVER_IP, _SERVER_PORT, "current/measure")
print("[GET] Request ID: ", requestId)
client.poll(2000)
client.stop() |
Update: according to the CoAP specification, the messageid is mainly used for duplicate message detection and optional reliability in case of losses. On the other hand, token is used for request/response matching. Based on this info, I will go over our implementation to see if it needs adjustments. |
@Trifunik The functions get, put, post have been updated to support a token parameter. Thus, if you provide as a last argument a token byte array, this exact token must exist in the corresponding response. To get the new functionality please pull the latest changes from master. Be aware of some minor breaking changes at parameter names. Does this approach solves your request? |
Thank you! |
Yes unfortunatelly it was a misleading typo. |
as soon as you test it in your project and you need no further changes, could you close the issue? Regards. |
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
The text was updated successfully, but these errors were encountered: