From e541265f23678b047b922fda8b04396370260a2f Mon Sep 17 00:00:00 2001 From: Friedl Ulrich Date: Sat, 7 Feb 2015 21:47:21 +0100 Subject: [PATCH] Reaktivate RX after received data --- rfm69device.go | 7 +++++++ rfm69handler.go | 12 ++++++++---- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/rfm69device.go b/rfm69device.go index e5ef3ce..c6f4b22 100644 --- a/rfm69device.go +++ b/rfm69device.go @@ -31,6 +31,7 @@ type Data struct { Data []byte RequestAck bool SendAck bool + Rssi int } // NewDevice creates a new device @@ -388,5 +389,11 @@ func (r *Device) readFifo() (Data, error) { data.SendAck = bool(rx[2]&0x80 > 0) 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 } diff --git a/rfm69handler.go b/rfm69handler.go index 4ff558e..1feff8f 100644 --- a/rfm69handler.go +++ b/rfm69handler.go @@ -72,10 +72,6 @@ func (r *Device) Loop() (chan Data, chan int) { log.Fatal(err) } case <-irq: - err = r.SetMode(RF_OPMODE_STANDBY) - if err != nil { - log.Fatal(err) - } data, err := r.readFifo() if err != nil { @@ -94,6 +90,14 @@ func (r *Device) Loop() (chan Data, chan int) { } txChan <- resp } + + rxChan <- data + + err = r.SetMode(RF_OPMODE_RECEIVER) + if err != nil { + log.Fatal(err) + } + case <-quit: quit <- 1 return