IOT - Bosch
  • Introduction
  • Devices
    • Bosch XDK 110
      • Introduction
      • Operating System
      • Hardware
        • Sensors
          • Accelerometer
            • C
          • Gyroscope
            • C
            • Mita
          • Magnetometer
            • C
          • Environmental
            • C
            • Mita
          • Ambient Light
            • C
            • Mita
          • Acoustic
            • C
      • Software
        • XDK WorkSpace
          • Structure
          • Debug
          • Supported languages
            • C
              • Static Library (.a)
            • XDK Live - Mita
            • MicroFlo
      • Connectivity
        • Bluetooth Low Energy (BLE)
          • Overview
          • General Info
          • Implementation
            • C
            • XDK Live
        • WI-FI
          • OverView
          • Implementation
            • C
            • XDK Live
        • WI-FI Enterprise
      • Protocols
        • CoAP
          • Overview
          • Implementation -TBD
        • HTTP
          • Overview
          • Structure and Methods
          • Implementation
            • C - Rest
            • C - Post
            • XDK Live
        • HTTPS
          • Overview
          • Implementation TBD
        • LWM2M
          • Overview
          • Implementation TBD
        • MQTT
          • Overview
          • Implementation
            • C
            • XDK Live
        • USB
          • Overview
          • Implementation TBD
      • Data Storage
      • XDK Extension Bus
      • Community
      • Applications
        • Language C
          • HomeAssitant - MQTT
            • Prerequisites
            • Server
            • Device
          • IOTA-MQTT-XDK
            • Prerequisites
            • XDK110
            • Mqtt JSON to MAM
            • SensorHub
            • Demo
        • Language XDK Live
          • MQTT
            • Hello World
            • HomeAssistant
              • Prerequisites
              • Server
              • Device
            • Docker-HomeAssistant
          • HTTP
            • Roku Remote Control
              • Roku API
              • MITA
                • Example
    • Bosch AMRA
    • Bosch GLM 100C
    • Bosch FLEXIDOME IP panoramic
    • Bosch GLM 100C
    • Bosch Rexroth Nexo
    • Bosch Rexroth PRC 7000
    • Bosch RRC / CT100
    • Bosch Rexroth IoT Gateway
  • Bosch IOT Solutions
    • Bosch IOT Projects
      • Smart Home
      • Industry 4.0
      • Smart Cities
      • Connected-mobility
    • Bosch IOT Suite
      • Bosch Analytics
      • Bosch IOT Hub
      • Bosch Iot Permission
      • IoT Remote Manager
      • IoT Rollouts
      • IoT Things
      • Demo TBD **
    • BPM and BRM
  • IOTA
    • Introduction
      • Tangle
      • Glossary
      • Differences with other tech
      • How does iota work
      • Developers
    • Qubic
      • What is Qubic?
      • Target
      • Qubic Protocol
    • Ecosystem
    • Applications
      • Python
      • XDK110
        • Prerequisites
        • XDK110
        • Mqtt JSON to MAM
        • SensorHub
    • Bosch/IOTA
  • ByteBall
    • SmartContract
    • Use Case
      • BoshCoins
Powered by GitBook
On this page
  • Setup
  • Setting up MQTT resources
  • Setting up variable topic-signals
  • Publishing on a Topic
  • Subscribing To a Topic

Was this helpful?

  1. Devices
  2. Bosch XDK 110
  3. Protocols
  4. MQTT
  5. Implementation

XDK Live

MQTT is defined as a many resource. That means, multiple instances of this resource can exist, and each is given a unique name by the developer. All possible configuration items and signals for the MQTT resource are listed below.

connectivity many HttpRestClient {
    generator "org.eclipse.mita.platform.xdk110.connectivity.RestClientGenerator"
    validator "org.eclipse.mita.platform.xdk110.connectivity.RestClientValidator"

    /**
     * The underlying transport connectivity we use to send the data out. In the future we might also
     * support LoRa here.
     */
    required configuration-item transport : WLAN

    /**
     * The part of the endpoint URL common to all requests, e.g. "http://foobar.com/api/v1"
     */
    required configuration-item endpointBase : string

    /**
     * A custom header which is added to each HTTP request. Example:
     *   "X-Auth: MySecretToken\nX-Version: 1.0"
     */
    configuration-item headerContent : string

    signal resource(endpoint : string, contentType : string = "application/json", writeMethod : HttpMethod = HttpMethod.POST, readMethod : HttpMethod = HttpMethod.GET) : string

}

Setup

HTTP requires a network connection to the destination server, to which the HTTP requests are sent. With the XDK, this network is usually established using Wi-Fi.

setup wifi : WLAN {
    connection = Personal;
    ssid = 'mySSID';
    psk = 'myPassword';
}

Setting up MQTT resources

All MQTT resources are generally set up with the required configuration-items url, clientId and transport. The first configuration-item is a URL, pointing to the desired MQTT broker, such as mqtt://my-broker.com:1883. The configuration-item clientId will identify the XDK. The configuration-item transport is the Wi-Fi resource, through which the MQTT messages are sent.

The following code can be used to create an MQTT resource:

setup hivemq : MQTT {
    transport = wifi;
    url = 'mqtt://broker.hivemq.com:1883';
    clientId = 'myXdk';
    var temperature = topic('XDK110/myXdk/temperature');
}

Setting up variable topic-signals

In the above example, temperature is a variable of type topic. This variable is a so-called signal, an MQTT instance can have multiple topic signals. For example, if it is desired to have one topic for temperature and one for light, the following code would initialize an MQTT resource with topics for light and temperature:

setup hivemq : MQTT {
    transport = wifi;
    url = 'mqtt://broker.hivemq.com:1883';
    clientId = 'myXdk';
    var light = topic('XDK110/myXdk/light');
    var temperature = topic('XDK110/myXdk/temperature');
}

Every read/write operation on one of the signals will only send or receive MQTT messages to the broker on the associated topics.

Publishing on a Topic

Assuming that the following MQTT resource has been previously set up:

setup hivemq : MQTT {
    transport = wifi;
    url = 'mqtt://broker.hivemq.com:1883';
    clientId = 'myXdk';
    var helloWorld = topic('hello/world');
}

Then the following code will publish a message on the topic hello/world at the broker broker.hivemq.com every 5 seconds, with a JSON payload.

every 5 seconds {
  hivemq.helloWorld.write('{"hello": "world"}');

Subscribing To a Topic

TBD

PreviousCNextUSB

Last updated 5 years ago

Was this helpful?