registerStateMessage method
注册设备
Implementation
Future registerStateMessage() async {
stateMessage.value.state = StateMessageState.online;
try {
client.publish(
"${deviceType.value}/${MessageAction.state}/${deviceId.value}",
jsonEncode(stateMessage.value.toJson()),
retain: true,
);
if (renameMessage.value == null) return;
client.publish(
"${deviceType.value}/${MessageAction.rename}/${deviceId.value}",
jsonEncode(renameMessage.value!.toJson()),
retain: true,
);
} catch (e, st) {
log("注册设备失败", stackTrace: st, error: e);
}
}