Skip to content

Commit

Permalink
fixed Read Response
Browse files Browse the repository at this point in the history
  • Loading branch information
colemancda committed Apr 28, 2016
1 parent 38e3d54 commit fd0e79d
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Sources/BluetoothLinux/GATTServer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ public final class GATTServer {
guard offset <= UInt16(attribute.value.byteValue.count)
else { errorResponse(opcode, .InvalidOffset, handle); return nil }

let value: [UInt8]
var value: [UInt8]

// Guard against invalid access if offset equals to value length
if offset == UInt16(attribute.value.byteValue.count) {
Expand All @@ -250,6 +250,9 @@ public final class GATTServer {
value = attribute.value.byteValue
}

// adjust value for MTU
value = Array(value.prefix(connection.maximumTransmissionUnit - 1))

// validate application errors with read callback
if let error = willRead?(UUID: attribute.UUID, value: Data(byteValue: value), offset: Int(offset)) {

Expand Down

0 comments on commit fd0e79d

Please sign in to comment.