Subject: [core] CoAP over Serial URLs

From: Tobias Kaupat <[email-masked]>
Date: Wed, 14 Dec 2016 19:30:00 +0100

Hi all,
I'm implementing CoAP over a serial RS232 connection and wondering about
the URL format.

For CoAP over SMS they use a separate scheme "coap+sms" (see:
https://www.ietf.org/archive/id/draft-becker-core-coap-sms-gprs-05.txt) so
I just took "coap+rs232" for my case.

So far the only question I have is: *Is there already some other URL scheme
defined that I'm not aware of?*

The actual question is regarding the Host. A serial connection is usually a
file handle. For Windows something like "COM3" is just fine. On Linux based
systems I have to connect to "/dev/ttyS3" which gets more problematic when
encoding in URLs. *What is the best way to deal with the slash characters?*

https://tools.ietf.org/html/rfc3986#page-21 restricts percent encoding of
ASCII characters in the host part but allows system specific host lookups.
Thats why I came up with an Implementation that implicitly adds the prefix
"/dev/" to the host part of the URL before opening the connection on Linux
systems.

*Any opinions and suggestions are welcome.*

Cheers,
Tobias Kaupat

-- 

Lobaro UG (haftungsbeschränkt)
Tempowerkring 21d
21079 Hamburg

040 / 22816531-0
www.lobaro.de
[email-masked]

USt.-Identifikationsnr.: DE297198645
WEEE-Reg.-Nr. DE18824018

Geschäftsführer: Dipl.-Ing. Tobias Rohde
Sitz der Gesellschaft: Hamburg
Handelsregister: HRB 134264
Amtsgericht Hamburg

---

From: Carsten Bormann <[email-masked]>
Date: Thu, 15 Dec 2016 06:47:24 +0100

Hi Tobias,

> On 14 Dec 2016, at 19:30, Tobias Kaupat <[email-masked]> wrote:
> 
> Hi all,
> I'm implementing CoAP over a serial RS232 connection

Interesting — we had a brief discussion about this at the T2TRG meeting in Ludwigsburg, and I’d sure like to know more about this.

> and wondering about the URL format.

When we started to think about the bluetooth URI format (draft-bormann-t2trg-ble-uri) we ran into a similar discussion.  A URI for a “local interconnect” isn’t really a “U”RI, as its meaning is dependent on that local context.  There is precedence in the file:// URI, but there is still some uneasiness around.  (There are also authority-based URIs with link-local addresses; similar problem.)

> For CoAP over SMS they use a separate scheme "coap+sms" (see: https://www.ietf.org/archive/id/draft-becker-core-coap-sms-gprs-05.txt) so I just took "coap+rs232" for my case.

Are the voltage levels on the serial line (which is what “RS232" is about) really important?
Do you need a different URI for TTL-level UARTs?  Maybe more like coap+serial or coap+uart.

How do you decide the bit rate?  The CoAP over Serial specification could align on a strong default (say, 115200 bit/s as in 6lobac), but there may occasionally be a need to deviate even from such a strong default.

> So far the only question I have is: Is there already some other URL scheme defined that I'm not aware of?

Not for serial.

> The actual question is regarding the Host. A serial connection is usually a file handle. For Windows something like "COM3" is just fine. On Linux based systems I have to connect to "/dev/ttyS3" which gets more problematic when encoding in URLs. What is the best way to deal with the slash characters?
> 
> 
> https://tools.ietf.org/html/rfc3986#page-21 restricts percent encoding of ASCII characters in the host part but allows system specific host lookups. Thats why I came up with an Implementation that implicitly adds the prefix "/dev/" to the host part of the URL before opening the connection on Linux systems.

That is probably the right approach.  Again, compare the link-local addresses which would need a % character (which need to percent-encoded) — endless discussion.

I’m definitely interested in also nailing down the data format over serial.  Let’s discuss this tomorrow...

Grüße, Carsten

---

From: Tobias Kaupat <[email-masked]>
Date: Fri, 16 Dec 2016 18:38:44 +0100

Hi Carsten,
it was an interesting chat today.

You can find our current Go CoAP client implementation that supports only
CoAP over URAT here: https://github.com/Lobaro/coap-go (the repo also
contains the Go warpper for our C CoAP server/client lib)
There is a basic transport implementation for the coap+uart scheme:
https://github.com/Lobaro/coap-go/blob/master/coap/transport_uart.go

Currently we use standard parameters for the uart, but let the user
override them if needed:
Baud:        115200,
Parity:      ParityNone,
Size:        0,
ReadTimeout: time.Millisecond * 500,
StopBits:    Stop1,

MessageID's are simply counted up and tokens are random 4-bytes. I'm
thinking about using a 1 Byte counter + random 3 bytes to avoid even the
chance for collisions.

I also support a special host "any" where the implementation just takes the
first free COM port oder ttyS* - in many cases you have only one serial
connection (or only one that supports CoAP) and just don't want to bother
looking it up before creating a URI. Further implementations to select the
"any" connection could be more clever, but it's a start.

The Package oriented transport is currently based on SLIP. Since I did not
found any Go implementation we made our own, it's also OpenSource:
https://github.com/Lobaro/slip
I'm looking forward to extend the (usage of the) slip library with the
ideas discussed today. Briefly: 1-Bytes packet headers and checksums.

The whole coap client is build after the go http package to make it easy to
use for developers who know the Go standard lib.
The CoAP client will be able to select the correct Transport based on the
URI scheme.

Cheers, Tobias K.

On Thu, Dec 15, 2016 at 6:47 AM, Carsten Bormann <[email-masked]> wrote:

> Interesting — we had a brief discussion about this at the T2TRG meeting in
> Ludwigsburg, and I’d sure like to know more about this.
>
> When we started to think about the bluetooth URI format
> (draft-bormann-t2trg-ble-uri) we ran into a similar discussion.  A URI for
> a “local interconnect” isn’t really a “U”RI, as its meaning is dependent on
> that local context.  There is precedence in the file:// URI, but there is
> still some uneasiness around.  (There are also authority-based URIs with
> link-local addresses; similar problem.)
>
> https://www.ietf.org/archive/id/draft-becker-core-coap-sms-gprs-05.txt)
> so I just took "coap+rs232" for my case.
>
> How do you decide the bit rate?  The CoAP over Serial specification could
> align on a strong default (say, 115200 bit/s as in 6lobac), but there may
> occasionally be a need to deviate even from such a strong default.
>
> > The actual question is regarding the Host. A serial connection is
> usually a file handle. For Windows something like "COM3" is just fine. On
> Linux based systems I have to connect to "/dev/ttyS3" which gets more
> problematic when encoding in URLs. What is the best way to deal with the
> slash characters?
> >
> >
> > https://tools.ietf.org/html/rfc3986#page-21 restricts percent encoding
> of ASCII characters in the host part but allows system specific host
> lookups. Thats why I came up with an Implementation that implicitly adds
> the prefix "/dev/" to the host part of the URL before opening the
> connection on Linux systems.
>
> That is probably the right approach.  Again, compare the link-local
> addresses which would need a % character (which need to percent-encoded) —
> endless discussion.
>

-- 

040 / 22816531-0
www.lobaro.de
[email-masked]