Bosch IoT Asset Communication

Cloud Protocol Gateway example

The Cloud Protocol Gateway approach described at Basic concept allows to connect customer components to the Bosch IoT Hub. In scaling scenarios, with thousands of devices, the Cloud Protocol Gateway needs to be scaled to multiple instances and the devices can be connected to Bosch IoT Hub via many Cloud Protocol Gateways.

This example illustrates the ability to group multiple Cloud Protocol Gateway instances.

Grouping simplifies instance scaling. When adding instances, devices connected via the gateway group do not need to be reconfigured. This is only necessary when changing existing groups or adding new groups.

Digital twins are not required for gateways and gateway groups in this use case.

However, as you will use the Developer Console to provision the gateways and gateway group in this example, such digital twins for the gateway and the group are automatically created. They can be ignored.

Provision cloud protocol gateway instances

Provision two Cloud Protocol Gateway instances that shall be grouped. You can provision further instances at a later point in time.

Proceed as described in Provisioning of devices via developer console and note the following:

Provide settings for provisioning

  • Presets: Start from scratch

  • Select how the device is connected: Gateway device

  • Thing ID

    • Namespace: <your namespace>, e.g. my.ac.namespace

    • Name: <gateway_name>, e.g. cpg_gw1

images/confluence/download/attachments/1402152442/provision-cpg.png

Do the same for a second gateway cpg_gw2.

In a real-world scenario, we assume you have multiple gateways. However, for the sake of simplicity two are enough, to show how a group could work.

Provision a gateway group

We assume you have provisioned at least two gateways.

Provision the gateway group with similar settings as the gateways before, except you will manipulate the provisioning request manually, using the JSON view.

  1. Provide settings for provisioning

    1. Presets: Start from scratch

    2. Select how the device is connected: Gateway device

    3. Thing ID

    1. Namespace: <your namespace>, e.g. my.ac.namespace

    2. Name: <group_name>, e.g. cpg_gw_group

  2. Preview the provisioning request
    Add the gateways created in the previous steps into the gateway group:

    1. Select the Request body tab.

    2. Start the Edit mode and add the the gateways to be grouped to the hub.device block, e.g.:

      "devices": [
        "my.ac.namespace:cpg_gw1",
      "my.ac.namespace:cpg_gw2"
      ]

      images/confluence/download/attachments/1402152442/provision-cpg_group.png

  3. Click Send request, then you have provisioned a gateway group referencing to the gateways to be grouped.

Provision a device to be connected via a gateway group

Provision a device that shall be connected via a gateway group.

Proceed as described in the steps before, but note the following:

  1. Provide settings for provisioning

    1. Presets: Start from scratch

    2. Select how the device is connected: Edge- or virtual device via gateway

    3. Click Select gateway device and select the gateway group from the appearing Select gateway table.

    4. Thing ID

      • Namespace: <your namespace>, e.g. my.ac.namespace

      • Name: <device_name>, e.g. dev1_via_gw_group

        images/confluence/download/attachments/1402152442/provision-device_via_gw_group_b.png

        Setting device credentials is optional and can be omitted, since the device will communicate via the gateway.

  2. Preview and send the provisioning request

    1. Select the Request body tab.

    2. In the preview you can see that the following has been automatically added to the hub.device block to define which gateway (group) the device should communicate through.

      "via": [
      "my.ac.namespace:cpg_gw_group"
      ]

      images/confluence/download/attachments/1402152442/provision-device_via_gw_group_c.png

  3. Click Send request.

You have provisioned a device to be connected via a gateway group.

Possible further devices have to be provisioned accordingly.

Deviating from the description at Telemetry example, as soon as the device will try to send data to Bosch IoT Hub, it will use auth-id and the credentials of the gateway.

See details at Cloud Protocol Gateway - operated by a customer.

Please take into account that the protocol adapters of the Bosch IoT Hub have a caching mechanism in place for devices and their credentials. That means if you make changes in the device's or credentials' properties, it takes some time until the protocol adapters apply the changes. Currently the cache setting is configured to 10 minutes.