From 789dc3ba736ee8d2af4f679dc3c7c6b351141c0e Mon Sep 17 00:00:00 2001 From: Friedl Ulrich Date: Fri, 20 Feb 2015 13:53:21 +0100 Subject: [PATCH] Reading RSSI before data --- device.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/device.go b/device.go index 9eb5805..a6b6609 100644 --- a/device.go +++ b/device.go @@ -360,7 +360,14 @@ func (r *Device) writeFifo(data *Data) error { } func (r *Device) readFifo() (Data, error) { + var err error data := Data{} + + data.Rssi, err = r.readRSSI(false) + if err != nil { + return data, err + } + tx := new([67]byte) tx[0] = REG_FIFO & 0x7f rx, err := r.SpiDevice.Xfer(tx[:3]) @@ -384,10 +391,5 @@ func (r *Device) readFifo() (Data, error) { data.RequestAck = bool(rx[2]&0x40 > 0) data.Data = rx[3:] - data.Rssi, err = r.readRSSI(false) - if err != nil { - return data, err - } - return data, nil }