# Connecting to IoT Hub

Once your device has requested and retrieved the certificates required to ensure that the connection is to be trusted, it will be possible to connect to the IoT Hub. Connecting to the IoT Hub will allow you to begin sending data between your devices and the ABB Ability™ Platform.

The following steps detail how to register your device to ensure it is trusted and discuss what protocols will transport your data to begin communicating with the Ability Platform.

# Communicate with the IoT Hub

Before your device is allowed to communicate with the Ability Platform, it needs to be registered in Ability Management Portal. This is a job of Solution Administrator and it is described in the User Roles article. Note that the device's identity is its objectId - the same as its certificate's Subject Name and the same as registered in Global Id Generator service. The Identity Provider must match the Certificate Authority that issued the device's certificate.

# Device Provisioning Service

On first boot, register your device in the Azure Device Provisioning Service using the DPS SDK or DPS REST API. The IoT Hub URL is then returned to your device for registration to be considered successful. The DPS allows one device to request registration multiple times. For each subsequent request, the same IoT Hub details will be returned, in case your device is unable to store IoT Hub URL in its storage. You must use the certificate of your device in order to be authorized by the DPS.

The code below shows an example of communicating with the DPS using the DPS SDK (.NET C#). It is an excerpt from the Codebits project.

using var securityProvider = new SecurityProviderX509Certificate(certificate); //certificate comes from device's secure element
using var transportHandler = new ProvisioningTransportHandlerAmqp(TransportFallbackType.TcpOnly);

var provisioningClient = ProvisioningDeviceClient.Create(
  dpsUrl, //preconfigured parameter
  dpsScopeId, //preconfigured parameter
  securityProvider, 
  transportHandler);

var result = await provisioningClient.RegisterAsync();

if (result.Status != ProvisioningRegistrationStatusType.Assigned)
  throw new Exception($"Provisioning failed.");

var iotHubUrl = result.AssignedHub; //the IoT Hub URL that can be used to communicate with the Ability Platform

DPS INFORMATION

The details of the Device Provisioning Service (like its ScopeId) will be given to you by the Operations Team when your Platform instance gets deployed for you. See this article for information about all the identifying characteristics for a Platform.

# IoT Hub Device SDKs

Once your device is registered in DPS, you are given an URL to the IoT Hub service. This is the communication point between your device and the Ability Platform. Consider using SDKs if your device's firmware is written in one of the supported languages and there are no restrictions within your BL prohibiting you from embedding third-party software in your device. Continue reading to see the examples of such communication.

# SDK Protocol Options

# MQTT-WS

Use on all devices that do not require connection to other devices (each with its own per-device credentials) over the same TLS connection.

# AMQP-WS

Use on field and cloud gateways to take advantage of connection multiplexing across devices. However, if you are considering a gateway, consider using the ABB Ability™ Edge instead of implementing your own.

# HTTPS

Use for devices that cannot support other protocols.

# Non-SDK Protocol Options

Consider using one of the supported protocols directly if you either do not want to tie your device to an MS SDK or have chosen a different language which does not have an SDK from MS.

  • MQTT - preferred, well documented and simple to implement.
  • AMQP
  • HTTP - use only if MQTT is impossible to support; this option has quite a few limitations, including an inability to invoke methods.

Regardless of the option you choose, ABB Ability™ supports only devices that are using certificate-based authentication. Each device must establish an outbound mutually authenticated TLS connection with the IoT Hub. All communication must traverse this TLS tunnel.

# References

Last updated: 9/6/2021, 1:25:50 PM
Feedback