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

net/nanocoap: add debug message for server #10845

Merged
merged 1 commit into from Jan 23, 2019

Conversation

kb2ma
Copy link
Member

@kb2ma kb2ma commented Jan 22, 2019

Contribution description

Adds a debug message to the nanocoap_server() function when the result of generating the response indicates an error has occurred.

Testing procedure

You can add a failing handler function to the nanocoap_server example's coap_handler.c. For example:

static ssize_t _fail(coap_pkt_t *pkt, uint8_t *buf, size_t len, void *context)
{
    (void)pkt;
    (void)buf;
    (void)len;
    (void)context;
    return -1;
}

Also add _fail to the coap_resources array at the bottom of the file, for example as the resource /fail. Of course, you'll also want to enable debugging in sock.c. :-)

Finally, start a couple of native instances -- nanocoap_server and gcoap. Then have the gcoap instance request the /fail resource from the nanocoap_server instance. In the nanocoap terminal you should see:

error handling request -1

Issues/PRs references

-none-

@kb2ma kb2ma requested review from kaspar030 and smlng January 22, 2019 20:35
@kb2ma kb2ma added Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation Area: CoAP Area: Constrained Application Protocol implementations labels Jan 22, 2019
@kaspar030 kaspar030 added the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label Jan 23, 2019
Copy link
Contributor

@kaspar030 kaspar030 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK.

@kaspar030
Copy link
Contributor

The extra message makes sense.

At some point we should maybe think about using LOG_*...

@kb2ma
Copy link
Member Author

kb2ma commented Jan 23, 2019

Thanks for the quick approval. This PR will be helpful for testing the next one. ;-)

@kb2ma kb2ma merged commit 7e77ac7 into RIOT-OS:master Jan 23, 2019
@aabadie aabadie added this to the Release 2019.01 milestone Jan 24, 2019
@kb2ma kb2ma deleted the nanocoap/server_debug_msg branch February 4, 2019 23:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: CoAP Area: Constrained Application Protocol implementations CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants