Skip to content
This repository has been archived by the owner on Sep 20, 2022. It is now read-only.

Commit

Permalink
fixup! coap-chat: a simple chat application using gCoAP
Browse files Browse the repository at this point in the history
  • Loading branch information
smlng committed Oct 9, 2018
1 parent bc30812 commit 6536724
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 7 additions & 1 deletion coap-chat/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

This application provides a simple command line chat using (g)CoAP as transport.
It allows to send (short) messages to any (IPv6) address reachable by the node.
All messages are send to and received for a CoAP resource with path `/chat`.
All messages are sent to and received for a CoAP resource with path `/chat`.

## Usage

Expand All @@ -18,9 +18,15 @@ chat <destination> <nickname> <message>

The message format is plain text and will be send as *nickname: message*, the
maximum message size is 63 chars - so keep *nickname* and *message* short :)
Please be aware that all CoAP messages are sent as non-confirmable, hence there
is no retransmission in case of packet loss.

## Notes

The code base of this application aims for simplicity, thus it only provides
a minimalistic set of functions. An advanced CoAP application can be found in
the [RIOT examples](https://github.com/RIOT-OS/RIOT/tree/master/examples/gcoap).

The application also ships with a number of standard shell commands, such as
`ifconfig` to allow for network interface configuration. Just type `help` in
the shell to see a full list and description of all available commands.
Expand Down
4 changes: 1 addition & 3 deletions coap-chat/coap.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,10 @@ int coap_post(char *addr, char *msgbuf, size_t msglen)
uint8_t buf[GCOAP_PDU_BUF_SIZE];
size_t len = 0;

gcoap_req_init(&pdu, (uint8_t *)&buf[0], GCOAP_PDU_BUF_SIZE, COAP_POST, COAP_CHAT_PATH);
gcoap_req_init(&pdu, buf, GCOAP_PDU_BUF_SIZE, COAP_POST, COAP_CHAT_PATH);

memcpy(pdu.payload, msgbuf, msglen);

coap_hdr_set_type(pdu.hdr, COAP_TYPE_NON);

len = gcoap_finish(&pdu, msglen, COAP_FORMAT_TEXT);

DEBUG("[CoAP] coap_post: sending msg ID %u, %u bytes\n",
Expand Down

0 comments on commit 6536724

Please sign in to comment.