dps

package
v0.0.0-test-multiarch Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 7, 2024 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Overview

Package dps implements provisioning a device using the Azure IoT Device Provisioning Service. Only flows for SAS authentication over HTTPS are implemented. Entry point is calling Register.

Based on the Azure IoT docs at https://learn.microsoft.com/en-us/azure/iot/iot-mqtt-connect-to-iot-dps

Index

Constants

View Source
const (
	DefaultHost = "global.azure-devices-provisioning.net"
	APIVersion  = "2019-03-31"
)

Variables

View Source
var ErrEnrollmentDisabled = errors.New("enrollment is disabled")

Functions

func DeriveDeviceKey

func DeriveDeviceKey(groupKey auth.SASKey, regID string) auth.SASKey

DeriveDeviceKey will derive an SAS Key for a device to use with Group Enrollment. groupKey is the Group Enrollment Key. regID is the Registration ID that the device will be registered under.

func FormatSASURI

func FormatSASURI(idScope, registrationID string) string

Types

type Client

type Client interface {
	// Register will complete a
	Register(ctx context.Context, registrationID string) (Registration, error)
	io.Closer
}

type Registration

type Registration struct {
	HostName        string // Domain name of IoT Hub to connect to.
	DeviceID        string
	SharedAccessKey auth.SASKey
}

func Register

func Register(ctx context.Context, host, idScope, regID string, key auth.SASKey) (Registration, error)

Register will attempt to register a device with the device provisioning service.

  • host is the hostname of the Device Provisioning Service. Defaults to DefaultHost if empty.
  • idScope identifies the instance of device provisioning service to register the device in. Required.
  • regID is an identifier for the registration, unique within an idScope. If using Group Enrollments, then the Registration ID becomes the new Device ID.
  • key is the shared secret used to authenticate the device. Required.

func (Registration) AsConnectionParameters

func (r Registration) AsConnectionParameters() iothub.ConnectionParameters

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL