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
  • Setting up BLE Resource
  • Setting up variable topic-signals
  • Writing on a Characteristic

Was this helpful?

  1. Devices
  2. Bosch XDK 110
  3. Connectivity
  4. Bluetooth Low Energy (BLE)
  5. Implementation

XDK Live

Mita provides the possibility to create a BLE resource. If the configuration and implementation provided by the Mita implementation are insufficient for a certain purpose, it is recommended to make adapting changes in the generated C code.

This section will demonstrate the Mita BLE API. In Mita, BLE is defined as a named singleton resource. That means, there can only be one instance of the BLE resource set up, and the name can be specified by the developer. All possible configuration items for the BLE resource are listed below.

connectivity named-singleton BLE {
    generator "org.eclipse.mita.platform.xdk110.connectivity.BleGenerator"
    validator "org.eclipse.mita.platform.xdk110.connectivity.BleValidator"

    /**
     * The name of the device as advertised via GAP.
     */
    configuration-item deviceName : string

    /**
     * MAC Address to be configured. Format: "FC:D6:BD:xx:xx:xx" or "FC-D6-BD-xx-xx-xx".
     */
    configuration-item macAddress : string

    /**
     * The last four bytes of the UUID of the GATT service we'll create.
     */
    configuration-item serviceUID : uint32

    /**
     * The advertising interval in milliseconds.
     */
    configuration-item advertisingInterval : int16 = 1000

    /**
     * Creates a boolean GATT characteristic.
     *
     * @param UUID The last four bytes of the characteristic UUID. Defaults to the hash code of the VCI name.
     */
    signal bool_characteristic(UUID : uint32) : bool

    /**
     * Creates an unsigned integer GATT characteristic.
     *
     * @param UUID The last four bytes of the characteristic UUID. Defaults to the hash code of the VCI name.
     */
    signal uint32_characteristic(UUID : uint32) : uint32

    /**
     * Creates a signed integer GATT characteristic.
     *
     * @param UUID The last four bytes of the characteristic UUID. Defaults to the hash code of the VCI name.
     */
    signal int32_characteristic(UUID : uint32) : int32

}

Setting up BLE Resource

A BLE resource is generally setup with the required configuration-item macAddress. This configuration-item is a string, which represents the resulting Mac Address. Every Mac Address must match the pattern FC:D6:BD:xx:xx:xx.

setup ble : BLE {
    macAddress = "FC:D6:BD:00:00:00";
    var light = uint32_characteristic(0x0001);
}

Setting up variable topic-signals

In the above example, light is a variable of type uint32_characteristic. This variable is a so-called signal, a BLE instance can have multiple signals, each representing a characteristic. For example, if it is desired to have one characteristic for temperature and one for light, the following code would initialize a BLE resource with characteristics for light and temperature:

setup ble : BLE {
    macAddress = "FC:D6:BD:00:00:00";
    var light = uint32_characteristic(0x0001);
  var temperature = int32_characteristic(0x0002);
}

Every read/write operation on one of the signals will send or read messages on the on the associated characteristics. The UUID of the characteristics ends with 0001 and 0002 (in hexadecimal) respectively.

Writing on a Characteristic

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

setup ble : BLE {
    macAddress = "FC:D6:BD:00:00:00";
    var light = uint32_characteristic(0x0001);
  var temperature = int32_characteristic(0x0002);
}

Then the following code will write the light and temperature values on the respective characteristics every 1 second.

every 1 second {
  ble.light.write(light.intensity.read());
  ble.temperature.write(environment.temperature.read());
}
PreviousCNextWI-FI

Last updated 5 years ago

Was this helpful?