Documentation
¶
Index ¶
- Constants
- Variables
- type ModuleTransport
- func (tr *ModuleTransport) Connect(ctx context.Context, creds transport.Credentials) error
- func (tr *ModuleTransport) Send(ctx context.Context, msg *common.Message) error
- func (tr *ModuleTransport) SubscribeEvents(ctx context.Context, mux transport.MessageDispatcher) error
- func (tr *ModuleTransport) SubscribeTwinUpdates(ctx context.Context, mux transport.TwinStateDispatcher) error
- type Transport
- func (tr *Transport) Close() error
- func (tr *Transport) Connect(ctx context.Context, creds transport.Credentials) error
- func (tr *Transport) CreateModule(ctx context.Context, m *iotservice.Module) (*iotservice.Module, error)
- func (tr *Transport) DeleteModule(ctx context.Context, m *iotservice.Module) error
- func (tr *Transport) GetBlobSharedAccessSignature(ctx context.Context, blobName string) (string, string, error)
- func (tr *Transport) GetModule(ctx context.Context, moduleID string) (*iotservice.Module, error)
- func (tr *Transport) IsConnected() bool
- func (tr *Transport) IsConnectionOpen() bool
- func (tr *Transport) ListModules(ctx context.Context) ([]*iotservice.Module, error)
- func (tr *Transport) LostConnectionChan() <-chan int
- func (tr *Transport) NotifyUploadComplete(ctx context.Context, correlationID string, success bool, statusCode int, ...) error
- func (tr *Transport) OnConnectionChan() <-chan int
- func (tr *Transport) RegisterDirectMethods(ctx context.Context, mux transport.MethodDispatcher) error
- func (tr *Transport) RetrieveTwinProperties(ctx context.Context) ([]byte, error)
- func (tr *Transport) Send(ctx context.Context, msg *common.Message) error
- func (tr *Transport) SetLogger(logger logger.Logger)
- func (tr *Transport) SubscribeEvents(ctx context.Context, mux transport.MessageDispatcher) error
- func (tr *Transport) SubscribeTwinUpdates(ctx context.Context, mux transport.TwinStateDispatcher) error
- func (tr *Transport) UpdateModule(ctx context.Context, m *iotservice.Module) (*iotservice.Module, error)
- func (tr *Transport) UpdateTwinProperties(ctx context.Context, b []byte) (int, error)
- func (tr *Transport) UploadToBlob(ctx context.Context, sasURI string, file io.Reader, size int64) error
- type TransportOption
Constants ¶
const DefaultQoS = 1
DefaultQoS is the default quality of service value.
Variables ¶
var ErrNotImplemented = errors.New("not implemented")
Functions ¶
This section is empty.
Types ¶
type ModuleTransport ¶
type ModuleTransport struct { Transport // contains filtered or unexported fields }
func NewModuleTransport ¶
func NewModuleTransport(opts ...TransportOption) *ModuleTransport
New returns new Transport transport. See more: https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-mqtt-support
func (*ModuleTransport) Connect ¶
func (tr *ModuleTransport) Connect(ctx context.Context, creds transport.Credentials) error
func (*ModuleTransport) SubscribeEvents ¶
func (tr *ModuleTransport) SubscribeEvents(ctx context.Context, mux transport.MessageDispatcher) error
func (*ModuleTransport) SubscribeTwinUpdates ¶
func (tr *ModuleTransport) SubscribeTwinUpdates(ctx context.Context, mux transport.TwinStateDispatcher) error
SubscribeTwinUpdates subscribes to module desired state changes.
type Transport ¶
type Transport struct {
// contains filtered or unexported fields
}
func New ¶
func New(opts ...TransportOption) *Transport
New returns new Transport transport. See more: https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-mqtt-support
func (*Transport) CreateModule ¶
func (tr *Transport) CreateModule(ctx context.Context, m *iotservice.Module) (*iotservice.Module, error)
CreateModule Creates adds the given module to the registry.
func (*Transport) DeleteModule ¶
DeleteModule removes the named device module.
func (*Transport) GetBlobSharedAccessSignature ¶
func (tr *Transport) GetBlobSharedAccessSignature(ctx context.Context, blobName string) (string, string, error)
GetBlobSharedAccessSignature is not available in the MQTT transport.
func (*Transport) IsConnected ¶
IsConnected returns a bool signifying whether there is a connection or not.
func (*Transport) IsConnectionOpen ¶
IsConnectionOpen returns a bool signifying whether the client has an active connection to the mqtt broker, i.e. not in disconnected or reconnect mode.
func (*Transport) ListModules ¶
ListModules list all the registered modules on the device.
func (*Transport) LostConnectionChan ¶
LostConnectionChan retruns channel for listening for LostConnection events.
func (*Transport) NotifyUploadComplete ¶
func (tr *Transport) NotifyUploadComplete(ctx context.Context, correlationID string, success bool, statusCode int, statusDescription string) error
NotifyUploadComplete is not available in the MQTT transport.
func (*Transport) OnConnectionChan ¶
OnConnectionChan returns channel for listening for OnConnection events.
func (*Transport) RegisterDirectMethods ¶
func (*Transport) RetrieveTwinProperties ¶
func (*Transport) SubscribeEvents ¶
func (*Transport) SubscribeTwinUpdates ¶
func (*Transport) UpdateModule ¶
func (tr *Transport) UpdateModule(ctx context.Context, m *iotservice.Module) (*iotservice.Module, error)
UpdateModule updates the given module.
func (*Transport) UpdateTwinProperties ¶
type TransportOption ¶
type TransportOption func(tr *Transport)
TransportOption is a transport configuration option.
func WithClientOptionsConfig ¶
func WithClientOptionsConfig(fn func(opts *mqtt.ClientOptions)) TransportOption
WithClientOptionsConfig configures the mqtt client options structure, use it only when you know EXACTLY what you're doing, because changing some of opts attributes may lead to unexpected behaviour.
Typical usecase is to change adjust connect or reconnect interval.
func WithLogger ¶
func WithLogger(l logger.Logger) TransportOption
WithLogger sets logger for errors and warnings plus debug messages when it's enabled.
func WithModelID ¶
func WithModelID(modelID string) TransportOption
WithModelId makes the mqtt client register the specified DTDL modelID when a connection is established, this is useful for Azure PNP integration.
func WithWebSocket ¶
func WithWebSocket(enable bool) TransportOption
WithWebSocket makes the mqtt client use MQTT over WebSockets on port 443, which is great if e.g. port 8883 is blocked.