Class OTAFile

  • java.lang.Object
    • com.zentri.zentri_ble_ota.OTAFile

public class OTAFile
extends java.lang.Object

Field Summary

Modifier and Type Field and Description
static boolean BUFFER_COPY 
static boolean BUFFER_ORIGINAL 

Constructor Summary

Constructor and Description
OTAFile(byte[] fileData) 

Method Summary

Modifier and Type Method and Description
byte[] getCRC()
Calculate CRC32 of file, not including top level header.
java.nio.ByteBuffer getData(boolean copyBuffer)
Get binary data to send to the device.
int getDataLength()
Get length of data in image (excluding headers).
byte[] getDataLengthBytes()
Get OTA data length as a byte array (used when sending size to device).
FirmwareVersion getVersion()
Get version of image.
boolean isCurrentImage()
Check if this image is a current type (support OTA2.0).
boolean isFileValid()
Check if this image is valid.
boolean isLegacyImage()
Check if this image is a legacy type.
  • Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail

Constructor Detail

  • OTAFile

    public OTAFile(byte[] fileData)

Method Detail

  • getData

    public java.nio.ByteBuffer getData(boolean copyBuffer)
    Get binary data to send to the device. Device must support OTA 2.0 (>= 1.7.x.x), otherwise it needs the 'sfx' image first.
    Parameters:
    copyBuffer - if true, returns a ByteBuffer that is a copy of the actual buffer. Note that this does NOT copy the underlying array, only the ByteBuffer object used to point to it. This is used to ensure the OTA process is not affected by changes to the buffer in the application eg position change due to buffer.getData()
    Returns:
    binary data to send to device
  • getDataLength

    public int getDataLength()
    Get length of data in image (excluding headers).
    Returns:
    length of data that will be sent to device
  • getDataLengthBytes

    public byte[] getDataLengthBytes()
    Get OTA data length as a byte array (used when sending size to device).
    Returns:
    data length as 2-byte array (little endian)
  • getVersion

    public FirmwareVersion getVersion()
    Get version of image.
    Returns:
    version
  • isLegacyImage

    public boolean isLegacyImage()
    Check if this image is a legacy type.
    Returns:
    true if legacy image
  • isCurrentImage

    public boolean isCurrentImage()
    Check if this image is a current type (support OTA2.0).
    Returns:
    true if current image
  • isFileValid

    public boolean isFileValid()
    Check if this image is valid.
    Returns:
    true if valid
  • getCRC

    public byte[] getCRC()
    Calculate CRC32 of file, not including top level header.
    Returns:
    CRC32 as byte array (little endian).