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

coap-chat: a simple chat application using gCoAP #44

Merged
merged 1 commit into from
Oct 13, 2018

Conversation

smlng
Copy link
Member

@smlng smlng commented Oct 2, 2018

This application allows to send (small) messages via CoAP to any
destination address. To chat locally you may use ff02::1 to reach
neighbouring nodes, or chat directly using unicast addresses. The
application provides a distinct shell command chat but also brings
standard shell commands like ifconfig to show a nodes IP addresses.

@smlng smlng added the new app This contributes a new application label Oct 2, 2018
To send messages use the `chat` shell command, it can be invoked as follows:

```
chat <destination> <nickname> <message>
Copy link
Member

Choose a reason for hiding this comment

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

Mh... I know this takes a little away from the simplicity at least implementation-wise, but maybe do a connect command that takes the <destination> <nickname> parameters (and stores them) and just keep chat <message>?

Copy link
Member Author

Choose a reason for hiding this comment

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

I would like to keep it as simple as possible, introducing another command would complicate the work flow. Also connect might imply or suggest functionality that is not there. Also you typically want to chat with different user (that is here destination addresses) and not only one specific, okay you might simply use ff02::1 ...

But again, I aimed for simplicity - for a real chat application you might want to have chat rooms, user discovery and lists and more, but that would also blow up the application.

This whole thing is a side-product of a small school project, where pupils (with no C experience) were introduced to IoT and RIOT - that's why the main goal also was to keep the code simple and with minimal LOCs.

Copy link
Member

Choose a reason for hiding this comment

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

Ok, thanks for the clarification. Then I'm for now fine with the PR as is, but maybe you want to introduce DNS, so the pupils don't need to type (rather non-descript) IPv6 addresses? For the application this would only mean maybe 5 more lines (using sock_dns), but of course a little bit more configuration in the backend (configuring the nodes' names, setting RAs to distribute the DNS server, etc).

Copy link
Member Author

Choose a reason for hiding this comment

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

Again, I'd rather not - as you already state it requires infrastructure (DNS Server) and setup.

During the school project we only had a couple of RIOT nodes (at first) and they send messages via link-local addresses and link-local multicast (ff02::1) - which might not be very IoT'ish but at least they had fun 😉

Later we added a Raspberry Pi (with crosscoap) which forwarded all multicast messages to a webserver backend where all message were put into log and could be access via a webpage.

Copy link
Member

Choose a reason for hiding this comment

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

(and in the end you still can use IPv6 addresses as a fallback)

Copy link
Member

Choose a reason for hiding this comment

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

Ok. Just a suggestion.

Copy link
Member

Choose a reason for hiding this comment

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

(gnarf, why does GitHub not live-update a page -.-)

Copy link
Member

Choose a reason for hiding this comment

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

I like the suggestion in the documentation to use ff02::1, which simplifies testing when there are only two nodes.

@smlng
Copy link
Member Author

smlng commented Oct 2, 2018

I uncrustified and remove trailing whitespaces.

@smlng smlng added the NEEDS SQUASHING Please squash before merge label Oct 2, 2018
@smlng smlng removed the NEEDS SQUASHING Please squash before merge label Oct 2, 2018
@kb2ma
Copy link
Member

kb2ma commented Oct 2, 2018

Nice idea! I think it works well with gcoap since an endpoint is both client and server. I just took a quick look at the code, and the implementation uses gcoap as I would expect. I'll play with it in the next couple of days and provide some specific feedback.

@smlng
Copy link
Member Author

smlng commented Oct 2, 2018

Cool @kb2ma, I started this by using RIOTs examples/gcoap as a template and removed all parts that are not required to make it as simple as possible.

Copy link
Member

@kb2ma kb2ma left a comment

Choose a reason for hiding this comment

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

The comments in the code are all minor. Runs fine in native and on samr21-xpro. On my workstation, either pyterm or the shell don't recognize a carriage return when the line gets long. As a result the message does not get sent until I enter another command on top of the original.

It would be nice to overcome the line length problem. You could enhance the app to use the block-wise extension to send a long line. That would be a nice demo.

Besides that, I'll wait to hear back from you. It seems to me like the app is 'good enough' for approval once we talk through the comments.

coap-chat/README.md Outdated Show resolved Hide resolved
To send messages use the `chat` shell command, it can be invoked as follows:

```
chat <destination> <nickname> <message>
Copy link
Member

Choose a reason for hiding this comment

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

I like the suggestion in the documentation to use ff02::1, which simplifies testing when there are only two nodes.

coap-chat/coap.c Outdated Show resolved Hide resolved
coap-chat/coap.c Outdated Show resolved Hide resolved
coap-chat/coap.c Show resolved Hide resolved
int chat(int argc, char **argv)
{
if (argc < 4) {
puts("usage: chat <addr> <nick> <msg>");
Copy link
Member

Choose a reason for hiding this comment

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

You could note that you can specify the interface with <addr>.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll put something in the README

@smlng smlng added the NEEDS SQUASHING Please squash before merge label Oct 9, 2018
@kb2ma
Copy link
Member

kb2ma commented Oct 10, 2018

ACK, please squash. I don't see any update for the interface for an address, but that's not worth holding this up.

This application allows to send (small) messages via CoAP to any
destination address. To chat locally you may use `ff02::1` to reach
neighbouring nodes, or chat directly using unicast addresses. The
application provides a distinct shell command `chat` but also brings
standard shell commands like `ifconfig` to show a nodes IP addresses.
@smlng smlng removed the NEEDS SQUASHING Please squash before merge label Oct 12, 2018
@kb2ma
Copy link
Member

kb2ma commented Oct 13, 2018

Looks good, let's go!

@kb2ma kb2ma merged commit 39a974e into RIOT-OS:master Oct 13, 2018
@smlng smlng deleted the coap-chat branch October 15, 2018 07:30
chrysn pushed a commit to chrysn-pull-requests/RIOT that referenced this pull request Sep 20, 2022
coap-chat: a simple chat application using gCoAP
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
new app This contributes a new application
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants