diff options
-rw-r--r-- | heimdall/source/BridgeManager.cpp | 17 | ||||
-rw-r--r-- | heimdall/source/EndFileTransferPacket.h | 40 | ||||
-rw-r--r-- | heimdall/source/EndModemFileTransferPacket.h | 6 | ||||
-rw-r--r-- | heimdall/source/EndPhoneFileTransferPacket.h | 7 |
4 files changed, 22 insertions, 48 deletions
diff --git a/heimdall/source/BridgeManager.cpp b/heimdall/source/BridgeManager.cpp index 787aa88..b58ffe9 100644 --- a/heimdall/source/BridgeManager.cpp +++ b/heimdall/source/BridgeManager.cpp @@ -961,14 +961,16 @@ bool BridgeManager::SendFile(FILE *file, unsigned int destination, unsigned int unsigned int sequenceCount = fileSize / (kMaxSequenceLength * SendFilePartPacket::kDefaultPacketSize); unsigned int lastSequenceSize = kMaxSequenceLength; - unsigned int partialPacketLength = fileSize % SendFilePartPacket::kDefaultPacketSize; + unsigned int partialPacketByteCount = fileSize % SendFilePartPacket::kDefaultPacketSize; + if (fileSize % (kMaxSequenceLength * SendFilePartPacket::kDefaultPacketSize) != 0) { sequenceCount++; int lastSequenceBytes = fileSize % (kMaxSequenceLength * SendFilePartPacket::kDefaultPacketSize); lastSequenceSize = lastSequenceBytes / SendFilePartPacket::kDefaultPacketSize; - if (partialPacketLength != 0) + + if (partialPacketByteCount != 0) lastSequenceSize++; } @@ -982,6 +984,7 @@ bool BridgeManager::SendFile(FILE *file, unsigned int destination, unsigned int // Min(lastSequenceSize, 131072) bool isLastSequence = sequenceIndex == sequenceCount - 1; unsigned int sequenceSize = (isLastSequence) ? lastSequenceSize : kMaxSequenceLength; + unsigned int sequenceByteCount = ((isLastSequence) ? lastSequenceSize : kMaxSequenceLength) * SendFilePartPacket::kDefaultPacketSize + partialPacketByteCount; FlashPartFileTransferPacket *beginFileTransferPacket = new FlashPartFileTransferPacket(0, 2 * sequenceSize); success = SendPacket(beginFileTransferPacket); @@ -1118,13 +1121,10 @@ bool BridgeManager::SendFile(FILE *file, unsigned int destination, unsigned int previousPercent = currentPercent; } - unsigned int lastFullPacketIndex = 2 * ((isLastSequence && partialPacketLength != 0) ? sequenceSize - 1 : sequenceSize); - if (destination == EndFileTransferPacket::kDestinationPhone) { - EndPhoneFileTransferPacket *endPhoneFileTransferPacket = new EndPhoneFileTransferPacket( - (isLastSequence) ? partialPacketLength : 0, lastFullPacketIndex, 0, partitionType, fileIdentifier, - isLastSequence); + EndPhoneFileTransferPacket *endPhoneFileTransferPacket = new EndPhoneFileTransferPacket(sequenceByteCount, 0, partitionType, + fileIdentifier, isLastSequence); success = SendPacket(endPhoneFileTransferPacket, 3000); delete endPhoneFileTransferPacket; @@ -1138,8 +1138,7 @@ bool BridgeManager::SendFile(FILE *file, unsigned int destination, unsigned int } else // destination == EndFileTransferPacket::kDestinationModem { - EndModemFileTransferPacket *endModemFileTransferPacket = new EndModemFileTransferPacket( - (isLastSequence) ? partialPacketLength : 0, lastFullPacketIndex, 0, partitionType, isLastSequence); + EndModemFileTransferPacket *endModemFileTransferPacket = new EndModemFileTransferPacket(sequenceByteCount, 0, partitionType, isLastSequence); success = SendPacket(endModemFileTransferPacket, 3000); delete endModemFileTransferPacket; diff --git a/heimdall/source/EndFileTransferPacket.h b/heimdall/source/EndFileTransferPacket.h index 73353d5..32eee60 100644 --- a/heimdall/source/EndFileTransferPacket.h +++ b/heimdall/source/EndFileTransferPacket.h @@ -46,30 +46,17 @@ namespace Heimdall private:
unsigned int destination; // Chip identifier perhaps
- unsigned short partialPacketLength; // Length or (length - 65536) if lastFullPacket is odd.
- unsigned int lastFullPacketIndex;
- unsigned short unknown1;
+ unsigned int sequenceByteCount;
+ unsigned int unknown1;
unsigned int partitionType;
protected:
- EndFileTransferPacket(unsigned int destination, unsigned int partialPacketLength, unsigned int lastFullPacketIndex,
- unsigned short unknown1, unsigned int partitionType)
+ EndFileTransferPacket(unsigned int destination, unsigned int sequenceByteCount, unsigned int unknown1, unsigned int partitionType)
: FileTransferPacket(FileTransferPacket::kRequestEnd)
{
this->destination = destination;
-
- if (partialPacketLength > 65535)
- {
- this->partialPacketLength = (partialPacketLength - 65536);
- this->lastFullPacketIndex = lastFullPacketIndex + 1;
- }
- else
- {
- this->partialPacketLength = partialPacketLength;
- this->lastFullPacketIndex = lastFullPacketIndex;
- }
-
+ this->sequenceByteCount = sequenceByteCount;
this->unknown1 = unknown1;
this->partitionType = partitionType;
}
@@ -81,20 +68,12 @@ namespace Heimdall return (destination);
}
- unsigned int GetPartialPacketLength(void) const
- {
- if (lastFullPacketIndex % 2 == 0)
- return (partialPacketLength);
- else
- return (partialPacketLength + 65536);
- }
-
- unsigned int GetLastFullPacketIndex(void) const
+ unsigned int GetSequenceByteCount(void) const
{
- return (lastFullPacketIndex - lastFullPacketIndex % 2);
+ return (sequenceByteCount);
}
- unsigned short GetUnknown1(void) const
+ unsigned int GetUnknown1(void) const
{
return (unknown1);
}
@@ -109,9 +88,8 @@ namespace Heimdall FileTransferPacket::Pack();
PackInteger(FileTransferPacket::kDataSize, destination);
- PackShort(FileTransferPacket::kDataSize + 4, partialPacketLength);
- PackInteger(FileTransferPacket::kDataSize + 6, lastFullPacketIndex);
- PackShort(FileTransferPacket::kDataSize + 10, unknown1);
+ PackInteger(FileTransferPacket::kDataSize + 4, sequenceByteCount);
+ PackInteger(FileTransferPacket::kDataSize + 8, unknown1);
PackInteger(FileTransferPacket::kDataSize + 12, partitionType);
}
};
diff --git a/heimdall/source/EndModemFileTransferPacket.h b/heimdall/source/EndModemFileTransferPacket.h index a2d88ca..e21ad20 100644 --- a/heimdall/source/EndModemFileTransferPacket.h +++ b/heimdall/source/EndModemFileTransferPacket.h @@ -34,10 +34,8 @@ namespace Heimdall public:
- EndModemFileTransferPacket(unsigned int partialPacketLength, unsigned int lastFullPacketIndex, unsigned short unknown1,
- unsigned int partitionType, bool endOfFile)
- : EndFileTransferPacket(EndFileTransferPacket::kDestinationModem, partialPacketLength,
- lastFullPacketIndex, unknown1, partitionType)
+ EndModemFileTransferPacket(unsigned int sequenceByteCount, unsigned int unknown1, unsigned int partitionType, bool endOfFile)
+ : EndFileTransferPacket(EndFileTransferPacket::kDestinationModem, sequenceByteCount, unknown1, partitionType)
{
this->endOfFile = (endOfFile) ? 1 : 0;
}
diff --git a/heimdall/source/EndPhoneFileTransferPacket.h b/heimdall/source/EndPhoneFileTransferPacket.h index f035511..606bcd0 100644 --- a/heimdall/source/EndPhoneFileTransferPacket.h +++ b/heimdall/source/EndPhoneFileTransferPacket.h @@ -57,10 +57,9 @@ namespace Heimdall public:
- EndPhoneFileTransferPacket(unsigned int partialPacketLength, unsigned int lastFullPacketIndex, unsigned short unknown1,
- unsigned int partitionType, unsigned int fileIdentifier, bool endOfFile)
- : EndFileTransferPacket(EndFileTransferPacket::kDestinationPhone, partialPacketLength,
- lastFullPacketIndex, unknown1, partitionType)
+ EndPhoneFileTransferPacket(unsigned int sequenceByteCount, unsigned int unknown1, unsigned int partitionType,
+ unsigned int fileIdentifier, bool endOfFile)
+ : EndFileTransferPacket(EndFileTransferPacket::kDestinationPhone, sequenceByteCount, unknown1, partitionType)
{
this->fileIdentifier = fileIdentifier;
this->endOfFile = (endOfFile) ? 1 : 0;
|