Publishing over HTTP Bridge

This section explains how devices can use the HTTP bridge to communicate with OmniCore. For general information about HTTP and MQTT, see Protocols.

Be sure to refer to the API documentation for full details about each method described in this section.

Publishing telemetry events

Use the publishEvent method to publish telemetry events to OmniCore. Binary payload data must be base64-encoded.

```jsx title=""
   curl -X POST -H 'authorization: Bearer JWT' -H 'content-type: application/json' --data '{"binaryData": "DATA"}' -H 'cache-control: no-cache' 'https://demo-http.api.cloud.korewireless.com/http/subscriptions/{subscription-id}/registries/{registry-id}/devices/{device-id}/publishEvent'
```

Telemetry events are forwarded to a Cloud Pub/Sub topic, as specified in console or with the eventNotificationConfigs[i].pubsubTopicName field in the device registry resource. The publishEvent method provides an optional subFolder field for classifying telemetry events. To learn how to publish data from subfolders to separate Pub/Sub topics, see the section below.

NOTE

If you try to publish a device telemetry event without specifying a Cloud Pub/Sub topic for the device's registry, the method fails and returns an error. This applies only to telemetry events, not state data.

Publishing telemetry events to separate Pub/Sub topics

Devices can publish data to separate Pub/Sub topics by specifying a subfolder in the subFolder field in the publishEvent method.

```jsx title=""
curl -X POST -H 'authorization: Bearer JWT' -H 'content-type: application/json' --data '{"binaryData": "DATA", "subFolder": "SUBFOLDER"}' -H 'cache-control: no-cache' 'https://demo-http.api.cloud.korewireless.com/http/subscriptions/{subscription-id}/registries/{registry-id}/devices/{device-id}/publishEvent'
```

This subfolder must be configured in the device registry resource's eventNotificationConfigs.subfolderMatches field with a matching Pub/Sub topic in the eventNotificationConfigs.pubsubTopicName field. When data is sent to a subfolder, it is published to the subfolder's matching Pub/Sub topic.

As detailed in Creating a device registry, all device registries should have one default Pub/Sub topic with no matching subfolder. If a default Pub/Sub topic exists, devices automatically publish to it in the following cases:

  • No subfolder is specified in the subFolder field

  • A subfolder is specified in the subFolder field, but it doesn't have a matching Pub/Sub topic in the device registry

Excessive load and exponential backoff

OmniCore limits subscriptions that generate excessive load. When devices retry failed operations without waiting, they can trigger limits that affect all devices in the same Google Cloud project.

Configuring devices

You can use OmniCore to configure devices. A device configuration consists of binary data that can be used to update firmware, reboot a device, turn on a feature, or change other properties.

To configure a device using the HTTP bridge, first define the configuration in OmniCore, then request the configuration via the device.

Compressing HTTP requests

A device can send gzip-compressed data to OmniCore over the HTTP bridge. To send compressed data to OmniCore, each HTTP request must include the content-encoding: gzip HTTP header.

Compressing data lets you reduce bandwidth in the device-to-cloud direction. However, you cannot reduce the total cost of your OmniCore usage by compressing data. For details, see Pricing.

Updating device configuration

When using the HTTP bridge, the device must explicitly request device configurations with the API. OmniCore does not push configurations to devices over the HTTP bridge; instead, devices must poll for new configurations.

To get the device configuration that's currently available from OmniCore, use a getConfig request.

Updating device configuration

curl -H 'authorization: Bearer JWT' -H 'cache-control: no-cache' 'https://demo-http.api.cloud.korewireless.com/http/subscriptions/{subscription-id}/registries/{registry-id}/devices/{deviceid}/config?localVersion={version}'

Setting device state

Use a setState request to report device state to OmniCore. State data must be base64-encoded.

```jsx title=""
curl -X POST -H 'authorization: Bearer JWT' -H 'content-type: application/json' --data '{"state": {"binaryData": "DATA"}}' -H 'cache-control: no-cache' 'https://demo-http.api.cloud.korewireless.com/http/subscriptions/{subscription-id}/registries/{registry-id}/devices/{deviceid}/setState'
```

To retrieve device state data, view the device details in Cloud console or use the API. For more details, see the section on device state.

Last updated