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

Where is the OPTION VALUE? #29

Open
Salv7 opened this issue Dec 20, 2015 · 2 comments
Open

Where is the OPTION VALUE? #29

Salv7 opened this issue Dec 20, 2015 · 2 comments

Comments

@Salv7
Copy link

Salv7 commented Dec 20, 2015

I loaded microcoap on ARDUINO DUE. When I receive a packet from a CoAP client (mozilla firefox with Copper plugin), where I can find options number and his value?
I created a resource called Alice.
I see that inpkt->opts[0].num contains this binary value: 00111011. By referring to http://tools.ietf.org/pdf/rfc7252.pdf (section 3.1) I suppose that the first four bits (0011=3 in decimal) are the OPTION DELTA, the last four bits (1011=11 in decimal) are the OPTION LENGTH. By referring to the "Table 7: CoAP Option Numbers" of the previous CoAP document, I see that this option is Uri-Host (number 3), but I don' t know where are the 11 bytes of the OPTION VALUE. Where are them? Are my assumpions right?

@LYJHub
Copy link

LYJHub commented Nov 15, 2016

How did you do to make microcoap work on ARDUINO DUE?
I do the same but it never work..

@allenhuffman
Copy link

When a packet is received, coap_parse() will break it apart and load it in to elements of the structures. The values in the structures are already decoded. In the example main.c:

    n = recvfrom(fd, (char*)buf, sizeof(buf), 0, (struct sockaddr *)&cliaddr, &len);
    if (0 != (rc = coap_parse(&pkt, buf, n)))
        printf("Bad packet rc=%d\n", rc);
    else
    {

...you can see the values of each options like this:

      int i;
      for (i=0; i<pkt.numopts; i++)
      {
        printf("Option %d is Number %d\n", i, pkt.opts[i].num);
      }

In my test, the option numbers reported were:

Option 0 is Number 11
Option 1 is Number 11
Option 2 is Number 12
Option 3 is Number 23

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

3 participants