public class ArchiveInputStream
extends java.util.zip.ZipInputStream
Reads the firmware files from the a ZIP file. The ZIP file must be either created using the nrf utility tool, available together with Master Control Panel v3.8.0+, or follow the backward compatibility syntax: must contain only files with names: application.hex/bin, softdevice.hex/dat or bootloader.hex/bin, optionally also application.dat and/or system.dat with init packets.
The ArchiveInputStream will read only files with types specified by types parameter of the constructor.
CENATT, CENATX, CENCOM, CENCRC, CENDSK, CENEXT, CENFLG, CENHDR, CENHOW, CENLEN, CENNAM, CENOFF, CENSIG, CENSIZ, CENTIM, CENVEM, CENVER, ENDCOM, ENDHDR, ENDOFF, ENDSIG, ENDSIZ, ENDSUB, ENDTOT, EXTCRC, EXTHDR, EXTLEN, EXTSIG, EXTSIZ, LOCCRC, LOCEXT, LOCFLG, LOCHDR, LOCHOW, LOCLEN, LOCNAM, LOCSIG, LOCSIZ, LOCTIM, LOCVER| Constructor and Description |
|---|
ArchiveInputStream(java.io.InputStream stream,
int mbrSize,
int types)
The ArchiveInputStream read HEX or BIN files from the Zip stream.
|
| Modifier and Type | Method and Description |
|---|---|
int |
applicationImageSize()
Returns the total size of the Application firmware.
|
int |
available()
Returns the number of bytes that has not been read yet.
|
int |
bootloaderImageSize()
Returns the total size of the Bootloader firmware.
|
void |
close() |
byte[] |
getApplicationInit()
Returns the content of the init file for the Application or
null if no application file in the ZIP, or the DAT file is not provided. |
int |
getBytesRead()
Returns number of bytes read until now.
|
int |
getContentType()
Returns the content type based on the content of the ZIP file.
|
long |
getCrc32()
Returns the CRC32 of the part of the firmware that was already read.
|
byte[] |
getSystemInit()
Returns the content of the init file for SoftDevice and/or Bootloader.
|
boolean |
isSecureDfuRequired()
This method returns true if the content of the ZIP file may be sent only using Secure DFU.
|
void |
mark(int readlimit)
Marks the current position in the stream.
|
boolean |
markSupported() |
int |
read(byte[] buffer) |
void |
reset() |
int |
setContentType(int type)
Truncates the current content type.
|
int |
softDeviceImageSize()
Returns the total size of the SoftDevice firmware.
|
public ArchiveInputStream(java.io.InputStream stream,
int mbrSize,
int types)
throws java.io.IOException
The ArchiveInputStream read HEX or BIN files from the Zip stream. It may skip some of them, depending on the value of the types parameter.
This is useful if the DFU service wants to send the Soft Device and Bootloader only, and then the Application in the following connection, despite
the ZIP file contains all 3 HEX/BIN files.
When types is equal to DfuBaseService.TYPE_AUTO all present files are read.
Use bit combination of the following types:
stream - the Zip Input StreammbrSize - The size of the MRB segment (Master Boot Record) on the device. The parser will cut data from addresses below that number from all HEX files.types - File types that are to be read from the ZIP. Use DfuBaseService.TYPE_APPLICATION etc.java.io.IOExceptionpublic void close()
throws java.io.IOException
close in interface java.io.Closeableclose in interface java.lang.AutoCloseableclose in class java.util.zip.ZipInputStreamjava.io.IOExceptionpublic int read(@NonNull
byte[] buffer)
throws java.io.IOException
read in class java.io.FilterInputStreamjava.io.IOExceptionpublic boolean markSupported()
markSupported in class java.util.zip.InflaterInputStreampublic void mark(int readlimit)
mark in class java.util.zip.InflaterInputStreamreadlimit - this parameter is ignored, can be anythingpublic void reset()
throws java.io.IOException
reset in class java.util.zip.InflaterInputStreamjava.io.IOExceptionpublic int getBytesRead()
public long getCrc32()
public int getContentType()
setContentType(int).TYPE_SOFT_DEVICE, TYPE_BOOTLOADER and TYPE_APPLICATIONpublic int setContentType(int type)
type - the new typepublic int available()
setContentType(int) method.available in class java.util.zip.ZipInputStreampublic int softDeviceImageSize()
public int bootloaderImageSize()
public int applicationImageSize()
public byte[] getSystemInit()
null if there is no SoftDevice nor Bootloader in the ZIP or the DAT file is not present there.public byte[] getApplicationInit()
null if no application file in the ZIP, or the DAT file is not provided.public boolean isSecureDfuRequired()