InitPacket constructor
InitPacket({
- List<
int> ? fromBytes, - List<
int> ? hashBytes, - HashType hashType = HashType.noHash,
- List<
List< ? bootValidationBytes,int> > - List<
ValidationType> ? bootValidationType, - FwType dfuType = FwType.application,
- bool isDebug = false,
- int fwVersion = 0xffffffff,
- int hwVersion = 0xffffffff,
- int sdSize = 0,
- int appSize = 0,
- int blSize = 0,
- List<
int> sdReq = const [0xfffe],
Implementation
InitPacket({
this.fromBytes,
this.hashBytes,
this.hashType = HashType.noHash,
this.bootValidationBytes,
this.bootValidationType,
this.dfuType = FwType.application,
this.isDebug = false,
this.fwVersion = 0xffffffff,
this.hwVersion = 0xffffffff,
this.sdSize = 0,
this.appSize = 0,
this.blSize = 0,
this.sdReq = const [0xfffe]
}){
bootValidationBytes ??= [];
bootValidationType ??= [];
if(fromBytes != null){
//construct from a protobuf string/buffer
packet = pb.Packet();
packet.mergeFromBuffer(fromBytes!); //packet.parseFromString(fromBytes);
if(packet.hasField(1)){
initCommand = packet.signedCommand.command.init;
}
else{
initCommand = packet.command.init;
}
}
else{
//construct from input variables
bootValidation = [];
for(int i = 0; i < bootValidationType!.length;i++){
ValidationType x = bootValidationType![i];
bootValidation!.add(
pb.BootValidation(
type: x,
bytes: bootValidationBytes![i]
)
);
}
//By default, set the packet's command to an unsigned command
//If a signature is set (via setSignature), this will get overwritten
//with an instance of SignedCommand instead.
pb.Hash hash = pb.Hash(
hashType: hashType,
hash: hashBytes!
);
initCommand = pb.InitCommand(
sdReq: sdReq,
bootValidation: bootValidation,
type: dfuType,
isDebug: isDebug,
fwVersion: fwVersion,
hwVersion: hwVersion,
sdSize: sdSize,
blSize: blSize,
appSize: appSize,
hash: hash
);
packet = pb.Packet(
command: pb.Command(
opCode: OpCode.init,
init: initCommand
)
);
}
_validate();
}