This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

LP-EM-CC1354P10: Wi-SUN CoAP GET request by node

Part Number: LP-EM-CC1354P10

Tool/software:

Hi,

How can I perform a CoAP GET request from node to border router and use the value sent in response?

I have already seem the Training example about sending a POST from node to border router, I tried to do some changes but I do not know how to get the payload from the border router's response.

Thank you in advance,
Eduardo.

  • Hi Eduardo,

    did you implement the training example from the Wi-SUN CoAP Simple Link Academy Task 3 – Send a non-confirmable request from the CoAP Node to the Border Router https://dev.ti.com/tirex/explore/content/cc13xx_cc26xx_simplelink_academy_7_41_00_00/_build_cc13xx_cc26xx_simplelink_academy_7_41_00_00/source/ti_wisunfan/wisun_coap/wisun_coap.html#task-3-send-a-non-confirmable-request-from-the-coap-node-to-the-border-router

    If you look at the modification of the wpan_callback() you see the definition of a new package type as ipv6.COAP_MESSAGE_CODE_POST. In your case you need to register it as ipv6.COAP_MESSAGE_CODE_GET and of course adjust this as well in the router node application.

    Kind regards,
    Theo

  • Hi Theo,

    Yes I have implemented the training example and it does work. I can successfully send POST requests from node to border router.

    To implement the GET functionality, these are the changes I've made in the node code:

    There is a variable timestamp defined as uint8_t *timestamp = 0;

    The changes made in spinel code are:

    As you can see I have modified it also setting payload=12345 as a test, I suppose this is the value I should receive in the node side. Please correct me if I am wrong.

    I know I am receiving the response from border router because the red led blinks twice as specified, so I know I am receiving the message but I could not get the response in the payload.

    Best regards,
    Eduardo.

  • Hi Eduardo,

    when you can see the light toggle on the border router after receiving the message it means that from what I can see the access to the payload was successful.

    How do you further use the payload? Which value has the payload? Did you check "sn_coap_hdr_s->payload_len" ? 

    Kind regards,
    Theo

  • Hi Theo,

    Actually I am facing some issues, I said that I could see the red led blinking in the node's Launchpad but it is not. I can see that the border router receives the request:

    This is the spinel code responsible for receiving the GET request and sending the response:

    Here is the code I use to send the GET request:

    And this is the callback function which should be called when I receive the response:

    I have added a breakpoint so I can confirm if the callback function is being called, and it dows not stop the program when I send a GET request, so I think the function is not being called when the border router sends the response.

    Best regards,
    Eduardo.

  • Hi Eduardo,

    1. Can you please try to send an acknowledge with payload=None.
    2. Is the callback function coap_client_response_timestamp defined before the coap message sending code?

    Kind regards,
    Theo

  • Hi Theo,

    1. Sending an acknowledge with payload=None works, I can see the led blinking in the node's Launchpad.

    2. Yes, the callback function is defined previously.

    Answering your previous question, I want to use the GET functionality to send some data from border router to coap node, such as timestamp and some other parameters is JSON format that the node must have to work properly.

    How can I implement this functionality? Is it expected that messages with some payload face this behaviour?

    Best regards,
    Eduardo.

  • Hi Eduardo,

    perfect, then it works as expected. Our stack does not support to send data directly in the acknowledgement message. Instead the receiver is supposed to respond by sending a separate message after the acknowledgement. So you can simply send another CoAP message.

    Kind regards,
    Theo 

  • Hi Theo,

    Well, this will look weird based on you response but I have managed to send data in the ACK message. This is the modification I have made in the spinel-cli.py code:

    I still did not test with higher payload data as a JSON messages as I mentioned before, but it seems to be working fine until now.

    Best regards,
    Eduardo.

  • Hi Eduardo,

    I could replicate the behavior as you can see in our other thread where I sent you my implementation: https://e2e.ti.com/support/wireless-connectivity/sub-1-ghz-group/sub-1-ghz/f/sub-1-ghz-forum/1423668/cc1352p7-is-there-maximum-coap-payload-size-in-wi-sun

    Thank you for mentioning it. I'm following up with R&D about this feature and will update you again.

    Kind regards,
    Theo