Device class

The device resource.

Inheritance
  • Object
  • GeneratedMessage
  • Device

Constructors

Device({String? id, String? name, Int64? numId, Timestamp? lastHeartbeatTime, Timestamp? lastEventTime, Timestamp? lastErrorTime, Status? lastErrorStatus, Iterable<DeviceCredential>? credentials, DeviceConfig? config, Timestamp? lastConfigAckTime, DeviceState? state, Map<String, String>? metadata, Timestamp? lastConfigSendTime, bool? blocked, Timestamp? lastStateTime, LogLevel? logLevel, GatewayConfig? gatewayConfig})
factory
Device.fromBuffer(List<int> i, [ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY])
factory
Device.fromJson(String i, [ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY])
factory

Properties

blocked bool
If a device is blocked, connections or requests from this device will fail. Can be used to temporarily prevent the device from connecting if, for example, the sensor is generating bad data and needs maintenance.
getter/setter pair
config DeviceConfig
The most recent device configuration, which is eventually sent from Cloud IoT Core to the device. If not present on creation, the configuration will be initialized with an empty payload and version value of 1. To update this field after creation, use the DeviceManager.ModifyCloudToDeviceConfig method.
getter/setter pair
credentials List<DeviceCredential>
The credentials used to authenticate this device. To allow credential rotation without interruption, multiple device credentials can be bound to this device. No more than 3 credentials can be bound to a single device at a time. When new credentials are added to a device, they are verified against the registry credentials. For details, see the description of the DeviceRegistry.credentials field.
no setter
eventPlugin → EventPlugin?
Subclasses can override this getter to be notified of changes to protobuf fields.
no setterinherited
gatewayConfig GatewayConfig
Gateway-related configuration and state.
getter/setter pair
hashCode int
Calculates a hash code based on the contents of the protobuf.
no setterinherited
id String
The user-defined device identifier. The device ID must be unique within a device registry.
getter/setter pair
info_ → BuilderInfo
no setteroverride
isFrozen bool
Returns true if this message is marked read-only. Otherwise false.
no setterinherited
lastConfigAckTime Timestamp
Output only The last time a cloud-to-device config version acknowledgment was received from the device. This field is only for configurations sent through MQTT.
getter/setter pair
lastConfigSendTime Timestamp
Output only The last time a cloud-to-device config version was sent to the device.
getter/setter pair
lastErrorStatus Status
Output only The error message of the most recent error, such as a failure to publish to Cloud Pub/Sub. 'last_error_time' is the timestamp of this field. If no errors have occurred, this field has an empty message and the status code 0 == OK. Otherwise, this field is expected to have a status code other than OK.
getter/setter pair
lastErrorTime Timestamp
Output only The time the most recent error occurred, such as a failure to publish to Cloud Pub/Sub. This field is the timestamp of 'last_error_status'.
getter/setter pair
lastEventTime Timestamp
Output only The last time a telemetry event was received. Timestamps are periodically collected and written to storage; they may be stale by a few minutes.
getter/setter pair
lastHeartbeatTime Timestamp
Output only The last time an MQTT PINGREQ was received. This field applies only to devices connecting through MQTT. MQTT clients usually only send PINGREQ messages if the connection is idle, and no other messages have been sent. Timestamps are periodically collected and written to storage; they may be stale by a few minutes.
getter/setter pair
lastStateTime Timestamp
Output only The last time a state event was received. Timestamps are periodically collected and written to storage; they may be stale by a few minutes.
getter/setter pair
logLevel LogLevel
Beta Feature
getter/setter pair
metadata Map<String, String>
The metadata key-value pairs assigned to the device. This metadata is not interpreted or indexed by Cloud IoT Core. It can be used to add contextual information for the device.
no setter
name String
The resource path name. For example, projects/p1/locations/us-central1/registries/registry0/devices/dev0 or projects/p1/locations/us-central1/registries/registry0/devices/{num_id}. When name is populated as a response from the service, it always ends in the device numeric ID.
getter/setter pair
numId ↔ Int64
Output only A server-defined unique numeric ID for the device. This is a more compact way to identify devices, and it is globally unique.
getter/setter pair
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
state DeviceState
Output only The state most recently received from the device. If no state has been reported, this field is not present.
getter/setter pair
unknownFields → UnknownFieldSet
no setterinherited

Methods

addExtension(Extension extension, Object? value) → void
Adds an extension field value to a repeated field.
inherited
check() → void
inherited
clear() → void
Clears all data that was set in this message.
inherited
clearBlocked() → void
clearConfig() → void
clearExtension(Extension extension) → void
Clears an extension field and also removes the extension.
inherited
clearField(int tagNumber) → void
Clears the contents of a given field.
inherited
clearGatewayConfig() → void
clearId() → void
clearLastConfigAckTime() → void
clearLastConfigSendTime() → void
clearLastErrorStatus() → void
clearLastErrorTime() → void
clearLastEventTime() → void
clearLastHeartbeatTime() → void
clearLastStateTime() → void
clearLogLevel() → void
clearName() → void
clearNumId() → void
clearState() → void
clone() Device
Creates a deep copy of the fields in this message. (The generated code uses mergeFromMessage.)
override
copyWith(void updates(Device)) Device
Apply updates to a copy of this message.
override
createEmptyInstance() Device
Creates an empty instance of the same message type as this.
override
createMapField<K, V>(int tagNumber, MapFieldInfo<K, V> fi) Map<K, V>
Creates a Map representing a map field.
inherited
createRepeatedField<T>(int tagNumber, FieldInfo<T> fi) List<T>
Creates List implementing a mutable repeated field.
inherited
ensureConfig() DeviceConfig
ensureGatewayConfig() GatewayConfig
ensureLastConfigAckTime() Timestamp
ensureLastConfigSendTime() Timestamp
ensureLastErrorStatus() Status
ensureLastErrorTime() Timestamp
ensureLastEventTime() Timestamp
ensureLastHeartbeatTime() Timestamp
ensureLastStateTime() Timestamp
ensureState() DeviceState
extensionsAreInitialized() bool
inherited
freeze() → GeneratedMessage
Make this message read-only.
inherited
getDefaultForField(int tagNumber) → dynamic
Returns the default value for the given field.
inherited
getExtension(Extension extension) → dynamic
Returns the value of extension.
inherited
getField(int tagNumber) → dynamic
Returns the value of the field associated with tagNumber, or the default value if it is not set.
inherited
getFieldOrNull(int tagNumber) → dynamic
Returns the value of a field, ignoring any defaults.
inherited
getTagNumber(String fieldName) int?
inherited
hasBlocked() bool
hasConfig() bool
hasExtension(Extension extension) bool
Returns true if a value of extension is present.
inherited
hasField(int tagNumber) bool
Whether this message has a field associated with tagNumber.
inherited
hasGatewayConfig() bool
hasId() bool
hasLastConfigAckTime() bool
hasLastConfigSendTime() bool
hasLastErrorStatus() bool
hasLastErrorTime() bool
hasLastEventTime() bool
hasLastHeartbeatTime() bool
hasLastStateTime() bool
hasLogLevel() bool
hasName() bool
hasNumId() bool
hasRequiredFields() bool
Whether the message has required fields.
inherited
hasState() bool
isInitialized() bool
Whether all required fields in the message and embedded messages are set.
inherited
mergeFromBuffer(List<int> input, [ExtensionRegistry extensionRegistry = ExtensionRegistry.EMPTY]) → void
Merges serialized protocol buffer data into this message.
inherited
mergeFromCodedBufferReader(CodedBufferReader input, [ExtensionRegistry extensionRegistry = ExtensionRegistry.EMPTY]) → void
inherited
mergeFromJson(String data, [ExtensionRegistry extensionRegistry = ExtensionRegistry.EMPTY]) → void
Merges field values from data, a JSON object, encoded as described by GeneratedMessage.writeToJson.
inherited
mergeFromJsonMap(Map<String, dynamic> json, [ExtensionRegistry extensionRegistry = ExtensionRegistry.EMPTY]) → void
Merges field values from a JSON object represented as a Dart map.
inherited
mergeFromMessage(GeneratedMessage other) → void
Merges the contents of the other into this message.
inherited
mergeFromProto3Json(Object? json, {TypeRegistry typeRegistry = const TypeRegistry.empty(), bool ignoreUnknownFields = false, bool supportNamesWithUnderscores = true, bool permissiveEnums = false}) → void
Merges field values from json, a JSON object using proto3 encoding.
inherited
mergeUnknownFields(UnknownFieldSet unknownFieldSet) → void
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
setExtension(Extension extension, Object value) → void
Sets the value of a non-repeated extension field to value.
inherited
setField(int tagNumber, Object value) → void
Sets the value of a field by its tagNumber.
inherited
toBuilder() → GeneratedMessage
Creates a writable, shallow copy of this message.
inherited
toDebugString() String
Returns a String representation of this message.
inherited
toProto3Json({TypeRegistry typeRegistry = const TypeRegistry.empty()}) Object?
Returns an Object representing Proto3 JSON serialization of this.
inherited
toString() String
Returns a String representation of this message.
inherited
writeToBuffer() Uint8List
inherited
writeToCodedBufferWriter(CodedBufferWriter output) → void
inherited
writeToJson() String
Returns a JSON string that encodes this message.
inherited
writeToJsonMap() Map<String, dynamic>
Returns the JSON encoding of this message as a Dart Map.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

create() Device
createRepeated() → PbList<Device>
getDefault() Device