From a416c737285e1ceb05b3e39badc892d5a6ddd5b6 Mon Sep 17 00:00:00 2001 From: Aleksander Nowakowski Date: Tue, 7 Apr 2020 17:45:47 +0200 Subject: [PATCH] #358 fixed --- .../SecureDFU/Characteristics/SecureDFUPacket.swift | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/iOSDFULibrary/Classes/Implementation/SecureDFU/Characteristics/SecureDFUPacket.swift b/iOSDFULibrary/Classes/Implementation/SecureDFU/Characteristics/SecureDFUPacket.swift index a78922b0..9c9c2f1f 100644 --- a/iOSDFULibrary/Classes/Implementation/SecureDFU/Characteristics/SecureDFUPacket.swift +++ b/iOSDFULibrary/Classes/Implementation/SecureDFU/Characteristics/SecureDFUPacket.swift @@ -58,7 +58,8 @@ internal class SecureDFUPacket: DFUCharacteristic { self.logger = logger if #available(iOS 9.0, macOS 10.12, *) { - packetSize = UInt32(characteristic.service.peripheral.maximumWriteValueLength(for: .withoutResponse)) + // Make the packet size the first word-aligned value that's less than the maximum. + packetSize = UInt32(characteristic.service.peripheral.maximumWriteValueLength(for: .withoutResponse)) & 0xFFFFFFFC if packetSize > 20 { // MTU is 3 bytes larger than payload // (1 octet for Op-Code and 2 octets for Att Handle).