websocket client for microcontroller in C

2,923 views
Skip to first unread message

Zaki Patel

unread,
Jul 26, 2013, 1:52:31 PM7/26/13
to autob...@googlegroups.com
Hi, 
I have a microcontroller that connects over wifi and sends data over http. I want to do the same using websockets i.e. implement an autobahn websocket client using C on the microcontroller?  Is this possible? I already have an autobahn websocket server running. Any guidance is much appreciated. 
Thanks
Zaki 

Tobias Oberstein

unread,
Jul 28, 2013, 4:21:34 AM7/28/13
to autob...@googlegroups.com, Zaki Patel
Am 26.07.2013 19:52, schrieb Zaki Patel:
> Hi,
> I have a microcontroller that connects over wifi and sends data over
> http. I want to do the same using websockets i.e. implement an autobahn

So you have a TCP/IP stack already on your MCU or is it an external
module with embedded TCP/IP?

> websocket client using C on the microcontroller? Is this possible? I

Weather it's feasible to implement WebSocket on the MCU will likely
depend on the available RAN. Also, are you using WAMP?

/Tobias

> already have an autobahn websocket server running. Any guidance is much
> appreciated.
> Thanks
> Zaki
>
> --
> You received this message because you are subscribed to the Google
> Groups "Autobahn" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to autobahnws+...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

Zaki Patel

unread,
Jul 29, 2013, 9:50:31 AM7/29/13
to autob...@googlegroups.com, Zaki Patel
Hi Tobias, 

It is an external module with embedded TCP/IP (CC3000 from TexasInstruments).

On the MCU we have the Unison RTOS, which offers an ultra tiny embedded Linux and POSIX compatible RTOS for 32 bit systems. 

We would like to use WAMP, and our understanding is that if we can implement a websocket client in C on the MCU, then we can reuse the existing implementation of our WAMP websocket server which ties in to the rest of our application. 

Thanks in advance for your help. 

Zaki  

Tobias Oberstein

unread,
Jul 31, 2013, 4:20:06 AM7/31/13
to autob...@googlegroups.com, Zaki Patel
Am 29.07.2013 15:50, schrieb Zaki Patel:
> Hi Tobias,
>
> It is an external module with embedded TCP/IP (CC3000 from
> TexasInstruments).

Curious: does that module also implement TLS?

>
> On the MCU we have theUnison RTOS, which offers an ultra tiny embedded
> Linux and POSIX compatible RTOS for 32 bit systems.

A 32-Bit MCU capable of providing a POSIX API should be sufficient for
WebSocket.

>
> We would like to use WAMP, and our understanding is that if we can
> implement a websocket client in C on the MCU, then we can reuse the
> existing implementation of our WAMP websocket server which ties in to
> the rest of our application.

Yep, you will need a WebSocket client implementation as basis to
implement WAMP on top.

Further considerations: What toolchain does the platform support? A gcc
one? A modern gcc one with decent c++ support? Any restrictions on the
networking framework used?

/Tobias
> > an email to autobahnws+...@googlegroups.com <javascript:>.
> > For more options, visit https://groups.google.com/groups/opt_out
> <https://groups.google.com/groups/opt_out>.

Zaki Patel

unread,
Jul 31, 2013, 9:27:17 AM7/31/13
to Tobias Oberstein, autob...@googlegroups.com
1. The CC3000 Itself does not support SSL, but it can be implemented on top of TCP on our microcontroller (STM32F3)  From documentation of the RTOS we are using (http://www.rowebots.com/embedded_system_software/security), Unison RTOS includes all the security features that you need built into the environment and tested in the environment, including TLS/SSL. Further, we are evaluating an alternative RTOS (FreeRTOS), and there is a is a lightweight TLS/SSL library called CyaSSL that we are considering (http://www.freertos.org/FreeRTOS-Plus/CyaSSL/CyaSSL.shtml). 

2. The MCU we are using is 32 bit with a RTOS that provides a POSIX API. 

3. Our objective is to implement a websocket client in C . This is where we need some help/guidance or expertise....

4. Toochain :  we are currently using IAR which provides support for C/C++. My guess is the platform (ARM Cortex M4) supports GCC toolchains. http://www.iar.com/Products/IAR-Embedded-Workbench/ARM/

Ref. networking framework, please could you clarify what you mean? 

Thanks again for your help, looking forward to continued discussion. Any guidance on how we can start, or where we can find the required expertise to implement websocket client on our embedded device would be much appreciated. 

Many thanks 
Zaki



Tobias Oberstein

unread,
Jul 31, 2013, 10:51:05 AM7/31/13
to Zaki Patel, autob...@googlegroups.com
Am 31.07.2013 15:27, schrieb Zaki Patel:
> 1. The CC3000 <http://www.ti.com/product/CC3000> Itself does not support
> SSL, but it can be implemented on top of TCP on our microcontroller

I am asking since for maximum compatibility with network environments
(e.g. Web proxies that don't understand WebSocket etc), TLS is often the
way to go. Apart from the transport layer confidentiality/integrity that
TLS provides of course. Whether you need the former depends on your
deployment scenario ..

> (STM32F3) From documentation of the RTOS we are using
> (http://www.rowebots.com/embedded_system_software/security), Unison RTOS
> includes all the security features that you need built into the
> environment and tested in the environment, including TLS/SSL. Further,

Implementing TLS from scratch is a non-trivial task both rgd. effort and
bugs that might trigger security issues ..

> we are evaluating an alternative RTOS (FreeRTOS), and there is a is a
> lightweight TLS/SSL library called CyaSSL that we are considering
> (http://www.freertos.org/FreeRTOS-Plus/CyaSSL/CyaSSL.shtml).
>
> 2. The MCU we are using is 32 bit with a RTOS that provides a POSIX API.

Great. Note that Posix does not specify TLS API .. almost all
open-source projects that do something with networking and TLS rely on
OpenSSL .. from looking at

http://www.freertos.org/FreeRTOS-Plus/CyaSSL/Using-SSL-TLS-in-a-client-site-application.shtml

CyaSSL has a different API from OpenSSL. So thats another consideration ..

>
> 3. Our objective is to implement a websocket client in C . This is where
> we need some help/guidance or expertise....

Are you looking for general guidance or for contract work (development
services) to implement that (WebSocket+WAMP on your platform)?

>
> 4. Toochain : we are currently using IAR which provides support for
> C/C++. My guess is the platform (ARM Cortex M4) supports GCC toolchains.
> http://www.iar.com/Products/IAR-Embedded-Workbench/ARM/
>
> Ref. networking framework, please could you clarify what you mean?

The Posix networking API is very low-level (and other OS, like Windows
have completely different APIs). So people today implement networking
stuff now on top of networking libraries like

Boost/ASIO for C++
http://think-async.com/

or

https://github.com/joyent/libuv

For a comparison of the above 2:
http://stackoverflow.com/questions/11423426/how-does-libuv-compare-to-boost-asio

However, these are intended for "full-blown" OSs .. and ASIO requires a
quite advanced C++ toolchain since it heavily uses templates.

Anyway: I guess in your situation these might be overkill and a more
straight to the Posix API WebSocket/WAMP client library is more appropriate.

However: how do you intend to program your actual application against
the yet-to-be-implemented WebSocket/WAMP client lib?

E.g. the convenience you have on server e.g. with AutobahnPython relies
on advanced asynchronous programming ("Twisted Deferreds").

>
> Thanks again for your help, looking forward to continued discussion. Any
> guidance on how we can start, or where we can find the required
> expertise to implement websocket client on our embedded device would be
> much appreciated.

I am not aware of something out there that fits your bill. From my
current understanding of your needs, we (Tavendo) might be able to
develop the required stuff. Whether that makes business sense for us/you
is another thing. Drop me a line at "tobias dot oberstein at tavendo dot
de" if you wanna discuss that further ..

/Tobias
> > an email to autobahnws+...@googlegroups.__com
> <mailto:autobahnws%2B...@googlegroups.com> <javascript:>.
>
> > For more options, visit
> https://groups.google.com/__groups/opt_out
> <https://groups.google.com/groups/opt_out>
> <https://groups.google.com/__groups/opt_out
> <https://groups.google.com/groups/opt_out>>.
>
> >
> >
>
> --
> You received this message because you are subscribed to the Google
> Groups "Autobahn" group.
> To unsubscribe from this group and stop receiving emails from
> it, send
> an email to autobahnws+unsubscribe@__googlegroups.com
> <mailto:autobahnws%2Bunsu...@googlegroups.com>.
>
> For more options, visit
> https://groups.google.com/__groups/opt_out
> <https://groups.google.com/groups/opt_out>.
>
>
>
>

Reply all
Reply to author
Forward
0 new messages