ClusterPayloadWriter

interface ClusterPayloadWriter


Writes cluster payloads Oriented around the in memory type you have e.g. writer.uint.write(10u, "foo", 100u) writer.float.write(11u, "bar", 10.3f)

Summary

Nested types

Writes fields in a type safe manner

Public functions

ClusterPayloadWriter.FieldWriter<T>
<T : Any> bitmap(adapter: BitmapAdapter<T>)

Write bitmaps, using the given adapter

open ClusterPayloadWriter.FieldWriter<T>
<T : ClusterEnum> enum(adapter: EnumAdapter<T>)

Write Enums, using the given adapter

ClusterPayloadWriter.FieldWriter<T>
<T : Any> struct(adapter: StructAdapter<T>)

Write structs, using the given adapter

SerializedPayload

Output the content as a generic serialized payload.

Unit

Wraps the core payload with UDDM layers.

Unit
<T : Any?> write(adapter: StructAdapter<T>, value: T)

Write an outer struct (not a field).

Extension functions

Unit

Wraps an Attributes Payload with the given Cluster Id.

Unit

Wraps a Command/CommandResult Payload with the given Command Id.

Unit

Wraps an Event Payload with the given Event Id.

Public functions

bitmap

fun <T : Any> bitmap(adapter: BitmapAdapter<T>): ClusterPayloadWriter.FieldWriter<T>

Write bitmaps, using the given adapter

Parameters
<T : Any>

The runtime type of bitmap

enum

open fun <T : ClusterEnum> enum(adapter: EnumAdapter<T>): ClusterPayloadWriter.FieldWriter<T>

Write Enums, using the given adapter

Parameters
<T : ClusterEnum>

The runtime type of enum, must be a ClusterEnum which exposes the ULong value to be written

struct

fun <T : Any> struct(adapter: StructAdapter<T>): ClusterPayloadWriter.FieldWriter<T>

Write structs, using the given adapter

Parameters
<T : Any>

The runtime type of struct

toPayload

fun toPayload(): SerializedPayload

Output the content as a generic serialized payload.

wrapPayload

fun wrapPayload(tags: List<UInt>): Unit

Wraps the core payload with UDDM layers.

Example:

override fun write(writer: ClusterPayloadWriter, value: Attributes) {
writer.wrapPayload(ClusterId.source.toUInt(), ClusterId.id.toUInt())
}

Note: Helper functions are available and should be preferred to using this function directly. Example:

override fun write(writer: ClusterPayloadWriter, value: Attributes) {
writer.wrapPayload(ClusterId)
}

write

fun <T : Any?> write(adapter: StructAdapter<T>, value: T): Unit

Write an outer struct (not a field).

Extension functions

wrapPayload

fun ClusterPayloadWriter.wrapPayload(id: ClusterId): Unit

Wraps an Attributes Payload with the given Cluster Id.

Attribute encapsulation example:

home.uddm.traits.Trait
home.uddm.traits.VENDOR.VENDORTrait = ClusterId.source + 1
home.uddm.traits.VENDOR.CLUSTERTrait = ClusterId.id + 1
Attributes Data Payload

wrapPayload

fun ClusterPayloadWriter.wrapPayload(id: ScopedCommandId): Unit

Wraps a Command/CommandResult Payload with the given Command Id.

Command/CommandResult encapsulation example:

home.uddm.traits.Command
home.uddm.traits.VENDOR.VENDORCommand = ClusterId.source + 1
home.uddm.traits.VENDOR.CLUSTERCommand = ClusterId.id + 1
home.uddm.traits.VENDOR.CLUSTERCommand.XXXXCommand = ScopedCommandId.command + 1
Command Data Payload

wrapPayload

fun ClusterPayloadWriter.wrapPayload(id: ScopedEventId): Unit

Wraps an Event Payload with the given Event Id.

Event encapsulation example:

home.uddm.traits.Event
home.uddm.traits.VENDOR.VENDOREvent = ClusterId.source + 1
home.uddm.traits.VENDOR.CLUSTEREvent = ClusterId.id + 1
home.uddm.traits.VENDOR.CLUSTEREvent.XXXXEvent = ScopedEventId.event + 1
Event Data Payload