本文整理了Java中com.zsmartsystems.zigbee.zcl.clusters.ZclOtaUpgradeCluster
类的一些代码示例,展示了ZclOtaUpgradeCluster
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZclOtaUpgradeCluster
类的具体详情如下:
包路径:com.zsmartsystems.zigbee.zcl.clusters.ZclOtaUpgradeCluster
类名称:ZclOtaUpgradeCluster
[英]OTA Upgrade cluster implementation (Cluster ID 0x0019).
The cluster provides a standard way to upgrade devices in the network via OTA messages. Thus the upgrade process MAY be performed between two devices from different manufacturers. Devices are required to have application bootloader and additional memory space in order to successfully implement the cluster.
It is the responsibility of the server to indicate to the clients when update images are available. The client MAY be upgraded or downgraded64. The upgrade server knows which client devices to upgrade and to what file version. The upgrade server MAY be notified of such information via the backend system. For ZR clients, the server MAY send a message to notify the device when an updated image is available. It is assumed that ZED clients will not be awake to receive an unsolicited notification of an available image. All clients (ZR and ZED) SHALL query (poll) the server periodically to determine whether the server has an image update for them. Image Notify is optional.
The cluster is implemented in such a way that the client service works on both ZED and ZR devices. Being able to handle polling is mandatory for all server devices while being able to send a notify is optional. Hence, all client devices must be able to use a ‘poll’ mechanism to send query message to the server in order to see if the server has any new file for it. The polling mechanism also puts fewer resources on the upgrade server. It is ideal to have the server maintain as little state as possible since this will scale when there are hundreds of clients in the network. The upgrade server is not required to keep track of what pieces of an image that a particular client has received; instead the client SHALL do that. Lastly poll makes more sense for devices that MAY need to perform special setup to get ready to receive an image, such as unlocking flash or allocating space for the new image.
Code is auto-generated. Modifications may be overwritten!
[中]OTA升级群集实施(群集ID 0x0019)。
该集群提供了通过OTA消息升级网络设备的标准方式。因此,可以在来自不同制造商的两个设备之间执行升级过程。为了成功实现集群,设备需要有应用程序引导程序和额外的内存空间。
服务器负责向客户端指示何时有更新映像可用。客户端可能会升级或降级64。升级服务器知道要升级哪些客户端设备以及升级到哪个文件版本。可通过后端系统将此类信息通知升级服务器。对于ZR客户端,服务器可能会发送消息,在更新的映像可用时通知设备。假设ZED客户端不会被唤醒以接收可用映像的未经请求的通知。所有客户机(ZR和ZED)都应定期查询(轮询)服务器,以确定服务器是否对其进行了映像更新。图像通知是可选的。
集群的实现方式是,客户机服务可以在ZED和ZR设备上工作。所有服务器设备都必须能够处理轮询,而能够发送通知则是可选的。因此,所有客户端设备必须能够使用“轮询”机制向服务器发送查询消息,以便查看服务器是否有任何新文件。轮询机制还减少了升级服务器上的资源。让服务器保持尽可能少的状态是理想的,因为当网络中有数百个客户端时,这将扩展。升级服务器不需要跟踪特定客户机接收到的图像片段;相反,客户应这样做。最后,对于可能需要执行特殊设置以准备接收图像的设备来说,轮询更有意义,例如解锁闪存或为新图像分配空间。
代码是自动生成的。修改可能会被覆盖!
代码示例来源:origin: zsmartsystems/com.zsmartsystems.zigbee
/**
* The file version of the running firmware image on the device. The information is available for the server to
* query via ZCL read attribute command. The attribute is optional on the client.
* <p>
* This calls the synchronous method in the cluster, and always performs an update (ie will not use cached data) to
* ensure it is updated following any OTA upgrade operation.
*
* @return the current firmware version on the remote device
*/
public Integer getCurrentFileVersion() {
return cluster.getCurrentFileVersion(Long.MAX_VALUE);
}
代码示例来源:origin: zsmartsystems/com.zsmartsystems.zigbee
@Override
public void run() {
logger.debug("{}: OTA Error: Timeout - aborting transfer.", cluster.getZigBeeAddress());
updateStatus(ZigBeeOtaServerStatus.OTA_UPGRADE_FAILED);
}
}
代码示例来源:origin: zsmartsystems/com.zsmartsystems.zigbee
/**
* Get the <i>ManufacturerID</i> attribute [attribute ID <b>7</b>].
* <p>
* The attribute is of type {@link Integer}.
* <p>
* The implementation of this attribute by a device is OPTIONAL
*
* @return the {@link Future<CommandResult>} command result future
*/
public Future<CommandResult> getManufacturerIdAsync() {
return read(attributes.get(ATTR_MANUFACTURERID));
}
代码示例来源:origin: zsmartsystems/com.zsmartsystems.zigbee
@Override
public void run() {
try {
Integer statusValue = cluster.getImageUpgradeStatus(0);
if (statusValue == null) {
CommandResult response = cluster.upgradeEndResponse(otaFile.getManufacturerCode(),
otaFile.getImageType(), otaFile.getFileVersion(), 0, 0).get();
if (!(response.isSuccess() || response.isTimeout())) {
Integer fileVersion = cluster.getCurrentFileVersion(0);
if (fileVersion == null) {
continue;
代码示例来源:origin: zsmartsystems/com.zsmartsystems.zigbee
cluster.getZigBeeAddress(), status);
return;
logger.debug("{} OTA Error: Request is inconsistent with OTA file.", cluster.getZigBeeAddress());
cluster.sendDefaultResponse(command.getTransactionId(), command.getCommandId(),
ZclStatus.NO_IMAGE_AVAILABLE);
return;
if (command.getHardwareVersion() < otaFile.getMinimumHardware()
|| command.getHardwareVersion() > otaFile.getMaximumHardware()) {
cluster.sendDefaultResponse(command.getTransactionId(), command.getCommandId(),
ZclStatus.NO_IMAGE_AVAILABLE);
return;
cluster.sendDefaultResponse(command.getTransactionId(), command.getCommandId(),
ZclStatus.NO_IMAGE_AVAILABLE);
return;
startTransferTimer();
cluster.queryNextImageResponse(ZclStatus.SUCCESS, otaFile.getManufacturerCode(), otaFile.getImageType(),
otaFile.getFileVersion(), otaFile.getImageSize());
代码示例来源:origin: zsmartsystems/com.zsmartsystems.zigbee
cluster.getZigBeeAddress(), status);
return;
logger.debug("{} OTA Error: No file is set.", cluster.getZigBeeAddress());
cluster.sendDefaultResponse(command.getTransactionId(), command.getCommandId(),
ZclStatus.UNSUP_CLUSTER_COMMAND);
return;
|| !command.getFileVersion().equals(otaFile.getFileVersion())
|| !command.getImageType().equals(otaFile.getImageType())) {
logger.debug("{} OTA Error: Request is inconsistent with OTA file.", cluster.getZigBeeAddress());
cluster.sendDefaultResponse(command.getTransactionId(), command.getCommandId(),
ZclStatus.NO_IMAGE_AVAILABLE);
return;
logger.debug("{} OTA Error: Requested offset is larger than file ({}>{})", cluster.getZigBeeAddress(),
command.getFileOffset(), otaFile.getImageSize());
cluster.sendDefaultResponse(command.getTransactionId(), command.getCommandId(),
ZclStatus.MALFORMED_COMMAND);
return;
代码示例来源:origin: zsmartsystems/com.zsmartsystems.zigbee
/**
* Synchronously get the <i>ManufacturerID</i> attribute [attribute ID <b>7</b>].
* <p>
* This method can return cached data if the attribute has already been received.
* The parameter <i>refreshPeriod</i> is used to control this. If the attribute has been received
* within <i>refreshPeriod</i> milliseconds, then the method will immediately return the last value
* received. If <i>refreshPeriod</i> is set to 0, then the attribute will always be updated.
* <p>
* This method will block until the response is received or a timeout occurs unless the current value is returned.
* <p>
* The attribute is of type {@link Integer}.
* <p>
* The implementation of this attribute by a device is OPTIONAL
*
* @param refreshPeriod the maximum age of the data (in milliseconds) before an update is needed
* @return the {@link Integer} attribute value, or null on error
*/
public Integer getManufacturerId(final long refreshPeriod) {
if (attributes.get(ATTR_MANUFACTURERID).isLastValueCurrent(refreshPeriod)) {
return (Integer) attributes.get(ATTR_MANUFACTURERID).getLastValue();
}
return (Integer) readSync(attributes.get(ATTR_MANUFACTURERID));
}
代码示例来源:origin: zsmartsystems/com.zsmartsystems.zigbee
/**
* Sends an image block to the client
*
* @param fileOffset the offset into the {@link ZigBeeOtaFile} to send the block
* @param maximumDataSize the maximum data size the client can accept
* @return the number of bytes sent
*/
private int sendImageBlock(int fileOffset, int maximumDataSize) {
ByteArray imageData = otaFile.getImageData(fileOffset, Math.min(dataSize, maximumDataSize));
logger.debug("{} OTA Data: Sending {} bytes at offset {}", cluster.getZigBeeAddress(), imageData.size(),
fileOffset);
cluster.imageBlockResponse(ZclStatus.SUCCESS, otaFile.getManufacturerCode(), otaFile.getImageType(),
otaFile.getFileVersion(), fileOffset, imageData);
return imageData.size();
}
代码示例来源:origin: zsmartsystems/com.zsmartsystems.zigbee
/**
* The purpose of sending Image Notify command is so the server has a way to notify client devices of
* when the OTA upgrade images are available for them. It eliminates the need for ZR client devices
* having to check with the server periodically of when the new images are available. However, all client
* devices still need to send in Query Next Image Request command in order to officially start the OTA
* upgrade process.
*/
public void notifyClient() {
// Only send the notify if the file is set
if (otaFile == null) {
return;
}
cluster.imageNotifyCommand(0, queryJitter, otaFile.getManufacturerCode(), otaFile.getImageType(),
otaFile.getFileVersion());
}
代码示例来源:origin: zsmartsystems/com.zsmartsystems.zigbee
(ZigBeeTransactionMatcher) ArgumentMatchers.anyObject());
ZclOtaUpgradeCluster cluster = new ZclOtaUpgradeCluster(endpoint);
代码示例来源:origin: zsmartsystems/com.zsmartsystems.zigbee
cluster.getZigBeeAddress(), status);
return;
logger.debug("{} OTA Error: No file is set.", cluster.getZigBeeAddress());
cluster.sendDefaultResponse(command.getTransactionId(), command.getCommandId(),
ZclStatus.UNSUP_CLUSTER_COMMAND);
return;
|| !command.getFileVersion().equals(otaFile.getFileVersion())
|| !command.getImageType().equals(otaFile.getImageType())) {
logger.debug("{} OTA Error: Request is inconsistent with OTA file.", cluster.getZigBeeAddress());
cluster.sendDefaultResponse(command.getTransactionId(), command.getCommandId(),
ZclStatus.NO_IMAGE_AVAILABLE);
return;
logger.debug("{} OTA Error: Requested offset is larger than file ({}>{})", cluster.getZigBeeAddress(),
command.getFileOffset(), otaFile.getImageSize());
cluster.sendDefaultResponse(command.getTransactionId(), command.getCommandId(),
ZclStatus.MALFORMED_COMMAND);
return;
代码示例来源:origin: zsmartsystems/com.zsmartsystems.zigbee
/**
* Synchronously get the <i>ImageTypeID</i> attribute [attribute ID <b>8</b>].
* <p>
* This method can return cached data if the attribute has already been received.
* The parameter <i>refreshPeriod</i> is used to control this. If the attribute has been received
* within <i>refreshPeriod</i> milliseconds, then the method will immediately return the last value
* received. If <i>refreshPeriod</i> is set to 0, then the attribute will always be updated.
* <p>
* This method will block until the response is received or a timeout occurs unless the current value is returned.
* <p>
* The attribute is of type {@link Integer}.
* <p>
* The implementation of this attribute by a device is OPTIONAL
*
* @param refreshPeriod the maximum age of the data (in milliseconds) before an update is needed
* @return the {@link Integer} attribute value, or null on error
*/
public Integer getImageTypeId(final long refreshPeriod) {
if (attributes.get(ATTR_IMAGETYPEID).isLastValueCurrent(refreshPeriod)) {
return (Integer) attributes.get(ATTR_IMAGETYPEID).getLastValue();
}
return (Integer) readSync(attributes.get(ATTR_IMAGETYPEID));
}
代码示例来源:origin: openhab/org.openhab.binding.zigbee
Integer fileVersion = otaCluster.getCurrentFileVersion(Long.MAX_VALUE);
if (fileVersion != null) {
properties.put(Thing.PROPERTY_FIRMWARE_VERSION, String.format("%08X", fileVersion));
代码示例来源:origin: zsmartsystems/com.zsmartsystems.zigbee
&& status != ZigBeeOtaServerStatus.OTA_TRANSFER_COMPLETE) {
logger.debug("{} OTA Error: Invalid server state {} when handling UpgradeEndCommand.",
cluster.getZigBeeAddress(), status);
return;
|| !command.getFileVersion().equals(otaFile.getFileVersion())
|| !command.getImageType().equals(otaFile.getImageType())) {
logger.debug("{} OTA Error: Request is inconsistent with OTA file.", cluster.getZigBeeAddress());
cluster.sendDefaultResponse(command.getTransactionId(), command.getCommandId(),
ZclStatus.NO_IMAGE_AVAILABLE);
return;
代码示例来源:origin: zsmartsystems/com.zsmartsystems.zigbee
/**
* Get the <i>ImageStamp</i> attribute [attribute ID <b>10</b>].
* <p>
* The attribute is of type {@link Integer}.
* <p>
* The implementation of this attribute by a device is OPTIONAL
*
* @return the {@link Future<CommandResult>} command result future
*/
public Future<CommandResult> getImageStampAsync() {
return read(attributes.get(ATTR_IMAGESTAMP));
}
代码示例来源:origin: zsmartsystems/com.zsmartsystems.zigbee
/**
* Synchronously get the <i>DownloadedFileVersion</i> attribute [attribute ID <b>4</b>].
* <p>
* The file version of the downloaded image on additional memory space on the device. The information
* is available for the server to query via ZCL read attribute command. The information is useful for the
* OTA upgrade management, so the server shall ensure that each client has downloaded the correct file
* version before initiate the upgrade. The attribute is optional on the client.
* <p>
* This method can return cached data if the attribute has already been received.
* The parameter <i>refreshPeriod</i> is used to control this. If the attribute has been received
* within <i>refreshPeriod</i> milliseconds, then the method will immediately return the last value
* received. If <i>refreshPeriod</i> is set to 0, then the attribute will always be updated.
* <p>
* This method will block until the response is received or a timeout occurs unless the current value is returned.
* <p>
* The attribute is of type {@link Integer}.
* <p>
* The implementation of this attribute by a device is OPTIONAL
*
* @param refreshPeriod the maximum age of the data (in milliseconds) before an update is needed
* @return the {@link Integer} attribute value, or null on error
*/
public Integer getDownloadedFileVersion(final long refreshPeriod) {
if (attributes.get(ATTR_DOWNLOADEDFILEVERSION).isLastValueCurrent(refreshPeriod)) {
return (Integer) attributes.get(ATTR_DOWNLOADEDFILEVERSION).getLastValue();
}
return (Integer) readSync(attributes.get(ATTR_DOWNLOADEDFILEVERSION));
}
代码示例来源:origin: zsmartsystems/com.zsmartsystems.zigbee
/**
* Send an updated status on OTA progress to the listeners
*
* @param updatedStatus the new {@link ZigBeeOtaServerStatus}
*/
private void updateStatus(final ZigBeeOtaServerStatus updatedStatus) {
logger.debug("{} OTA status updated to {}.", cluster.getZigBeeAddress(), updatedStatus);
status = updatedStatus;
synchronized (this) {
// Notify the listeners
for (final ZigBeeOtaStatusCallback statusListener : statusListeners) {
NotificationService.execute(new Runnable() {
@Override
public void run() {
statusListener.otaStatusUpdate(updatedStatus, percentComplete);
}
});
}
}
}
代码示例来源:origin: zsmartsystems/com.zsmartsystems.zigbee
@Test
public void getCurrentFileVersion() {
ZclOtaUpgradeCluster cluster = Mockito.mock(ZclOtaUpgradeCluster.class);
Mockito.when(cluster.getCurrentFileVersion(ArgumentMatchers.anyLong())).thenReturn(1234);
ZclOtaUpgradeServer server = new ZclOtaUpgradeServer();
server.appStartup(cluster);
assertEquals(Integer.valueOf(1234), server.getCurrentFileVersion());
}
代码示例来源:origin: zsmartsystems/com.zsmartsystems.zigbee
/**
* Get the <i>ImageTypeID</i> attribute [attribute ID <b>8</b>].
* <p>
* The attribute is of type {@link Integer}.
* <p>
* The implementation of this attribute by a device is OPTIONAL
*
* @return the {@link Future<CommandResult>} command result future
*/
public Future<CommandResult> getImageTypeIdAsync() {
return read(attributes.get(ATTR_IMAGETYPEID));
}
代码示例来源:origin: zsmartsystems/com.zsmartsystems.zigbee
/**
* Synchronously get the <i>CurrentFileVersion</i> attribute [attribute ID <b>2</b>].
* <p>
* The file version of the running firmware image on the device. The information is available for the
* server to query via ZCL read attribute command. The attribute is optional on the client.
* <p>
* This method can return cached data if the attribute has already been received.
* The parameter <i>refreshPeriod</i> is used to control this. If the attribute has been received
* within <i>refreshPeriod</i> milliseconds, then the method will immediately return the last value
* received. If <i>refreshPeriod</i> is set to 0, then the attribute will always be updated.
* <p>
* This method will block until the response is received or a timeout occurs unless the current value is returned.
* <p>
* The attribute is of type {@link Integer}.
* <p>
* The implementation of this attribute by a device is OPTIONAL
*
* @param refreshPeriod the maximum age of the data (in milliseconds) before an update is needed
* @return the {@link Integer} attribute value, or null on error
*/
public Integer getCurrentFileVersion(final long refreshPeriod) {
if (attributes.get(ATTR_CURRENTFILEVERSION).isLastValueCurrent(refreshPeriod)) {
return (Integer) attributes.get(ATTR_CURRENTFILEVERSION).getLastValue();
}
return (Integer) readSync(attributes.get(ATTR_CURRENTFILEVERSION));
}
内容来源于网络,如有侵权,请联系作者删除!