From 0ad671d3f5505e2e318b73c5356e159b82a08375 Mon Sep 17 00:00:00 2001 From: Arsen Musayelyan Date: Tue, 25 Oct 2022 12:36:34 -0700 Subject: [PATCH] Assume MTU if not available from BlueZ --- blefs/fs.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/blefs/fs.go b/blefs/fs.go index 6d9d06f..6f2ade9 100644 --- a/blefs/fs.go +++ b/blefs/fs.go @@ -199,7 +199,13 @@ func decode(data []byte, vals ...interface{}) error { // to send in a packet. Subtracting 20 ensures that the MTU // is never exceeded. func (blefs *FS) maxData() uint16 { - return blefs.transferChar.Properties.MTU - 20 + mtu := blefs.transferChar.Properties.MTU + // If MTU is zero, the current version of BlueZ likely + // doesn't support the MTU property, so assume 256. + if mtu == 0 { + mtu = 256 + } + return mtu - 20 } // padding returns a slice of len amount of 0x00.