Domain Specific Design Tools

with application to

The Internet of Things

Benedict R. Gaster / @cuberoo_

(we mean BLE 4.2 or Bluetooth Smart)

  • Key technology in development of IoT, to date
  • Found in all modern smart phones
  • Supported in modern Macs, iPad, and Windows 10
  • WebBluetooth brings BLE to the Browser

A problem with BLE 4.2

is its Range

>100 m (>330 ft)

Limits application domains

Bluetooth 5

(Coming Q4 2016)

Bluetooth 5

  • Meshing
  • Extended range (4x)
  • Larger packet size (800%)
  • 2x bandwidth

New application domains?

  • Move phone further from speaker :-)


(an alternative)

LoRaWAN is a Low Power Wide Area Network (LPWAN)


battery operated Things

LoRa Frequency Bands

  • 868 MHz for Europe
  • 915 MHz for North America
  • 433 MHz band for Asia

Wide set of Application Domains

(outdoors, beyond the city, ...)

LoRaWAN Altitude Board

  • Current draw 200ma, for transmission
  • Goal <5ma, for transmission
  • Alternative sensor technology
    • almost passive!
  • Partnering with Altitude to develop LoRaWAN board

In Bristol

5 bikes stolen each day

Evening Post, 25th Jan 2016

Bike Tracker

Drone Swarms

(collaboration with UWE's Dr Steve Wright)

Low Cost

(~$8 for single LoRa radio!)

LoRaWAN Stack runs on microprocessor

(e.g. Cortex M-0)

Excellent range

@ UWE we are building a LoRaWAN Network

Initial Deployment Q4 2016

Open Research Platform
  • Number of concurrent connections, single gateway, multiple gateways
  • Scaling of bandwidth with respect to nodes
  • Compare with respect to Bristol City's Sigfox network (August 2016)
  • Applications
  • Programming models and domain specific design tools

Domain Specific Design Tools (DSDT)

What do I mean by DSDT and why?

The Development cliff

BBC Micro:bit

  • Given to every year 7 student
  • Amazing online programming environments
    • But limited access to low-level components
    • e.g. predefined BLE services, only!

Define new BLE Micro:bit service?

  • e.g., Apple's Bluetooth MIDI
  • e.g., Reveal.JS BLE remote

Currently restricted to C++ only

  • Microsoft Blocks to C++ is a huge leap
  • Requires considerable knowledge of BLE protocol

Limits new applications of Micro:bit in regards IoT

IoT development requires more that domain knowledge

DSDTs allow domain experts

to develop IoT applications

in their area of expertise

Local Councils

develop custom

pollution monitors

Musicians Develop Custom Control Interfaces

  • Why should a musician be required to program?

Traditional Programming Should not be a requirement

DSDTs is more than just software components


A Toolkit for Building DSDTs


  • Abstracted as three components
    • Host (local and remote)
    • Nodes (i.e. devices)
    • Plugables (h/w components)
      • Sensors
      • Buttons/switches
      • OLED screens

Host Progressive Web Apps

  • Frontend
    • HTML5/CSS
    • Typescript (TS)/Angular2
    • TS DSL for device code generation
  • Backend
    • NodeJS with TS
    • REST API for IoT, backed by MongoDB, for example


  • Devices (Arduino/Corex-M?)
    • C++ library for DSL target
    • C++ FreeRTOS library
  • Local host services
    • Haskell Library for MIDI communication
    • Node TS library for BLE
    • WebBluetooth TS library


  • Set of composible hardware components
  • Designed specifically for IoT applications
  • Extensible
    • Designed to allow user to define their own components


C++ Library

  • Template Meta Programming Library
    • static_if
    • static_whilee
    • Etc
    • To Cortex-MX and Arduino
  • Type safe API
    • Used to enforce correct pin type, for example
    • Used to derive code, avoiding indirection (e.g. digital pin read)
    • Used for "merge" code optimization

C++ Library (cond)

  • C++17, e.g. constexpr and static lambdas used extensively
  • Single instance classes, used to module controllers
    • Forms a controller (stream/emitter) Monad
    • Controller Monad implemented at the type-level
      • It seems that variadic template expansion can be seen as a form of Haskell style "do-notation"!!!
  • Exceptions used, but generally map to halt
  • Direct mapping from TS DSL Monad
    • Prove soundness of translation?

Pluggable Example

      blocks::d8_wo>> bentoFilter;


void setup() const
  // setup protocol interface

  // setup the controllers


Host Web Apps

  • Standard HTML, CSS, and Typescript development
    • High-level visual data-flow model?
    • Still early days, no clear vision, yet!

Device communicaton

  • Defined protocols, examples include
    • MIDI protocol, implemented via Haskell library
    • Apple Bluetooth MIDI, no required host code
    • Reveal.js BLE Service, implemented via NodeJS library
    • IoT protocol, forward communication as IP packets
  • Early stages, needs a lot more thought

TS DSL library for device code

  • Exposes a stream/pipe style Monad
    • data-flow model?
  • Forms a translation Monad
    • Use TS generic type variable constraints to enforce use
    • Similar goal to Haskell's Monad class
      • What about Applicative, not sure as we need state?

Visual Example of Stream Monad