crossbario / autobahn-c

Apache License 2.0
14 stars 5 forks source link

Alpha example #12

Open oberstet opened 7 years ago

oberstet commented 7 years ago

A concrete first alpha goal for the library is to support the following example program.

The program is a simple C user program exposing a hardware button and a hardware LED as a WAMP component in a Crossbar.io based IoT system.

The user program interfaces with the hardware, registers a C procedure as a WAMP procedure to control the LED, and publishes WAMP events whenever the button is pressed.

For this, the user program creates a WAMP session object and uses that for registering, subscribing, calling and publishing. The session object is attached to a transport object that is a concrete implementation of an abstract stream transport.

The concrete stream transport is implemented for two platforms: Espressif ESP32 and ST STM32 F7, and runs on top of FreeRTOS, lwIP and mbedTLS.

The session object on the other hand is implemented in pure C and completely TLS, networking, OS, platform, SoC and CPU agnostic.

The library could be structured into:

  1. platform runtime support (FreeRTOS, lwIP, mbedTLS, BLE)
  2. byte stream transport abstraction (bidirectional reliable ordered stream of bytes), for example TCP-TLS
  3. WAMP message channel transport abstraction (bidirectional reliable ordered stream of native language objects for WAMP messages), for example WAMP-RawSocket-CBOR
  4. WAMP session state machine: this is driven from and uses the byte channel or RawSocket channel abstraction above is interfaces with user code - the rest of the library above is not public API
oberstet commented 7 years ago

The platform runtime support assists in providing a TCP-TLS backed implementation of the byte stream required for the WAMP connection.

At least one concrete WAMP message channel implementation like WAMP-RawSocket-CBOR-(Client) is required. This is used together with above byte stream running over TCP-TLS, parses the byte stream into individual message according to the WAMP-RawSocket framing spec, deserializes message payloads according to CBOR and forwards the object to the WAMP session object the message channel is attached to.

The WAMP session implements the core of the WAMP protocol: the client peer side of the conversation with the WAMP router connected to, as well as the user side of app code running.