diff --git a/rfm69d/rfm69d.go b/rfm69d/rfm69d.go index 0741762..1094eb2 100644 --- a/rfm69d/rfm69d.go +++ b/rfm69d/rfm69d.go @@ -4,6 +4,7 @@ import ( "log" "os" "os/signal" + "time" "github.com/davecheney/gpio" "github.com/fulr/rfm69" @@ -35,7 +36,7 @@ func main() { log.Fatal(err) } - rxChan, quit := rfm.Loop() + rxChan, txChan, quit := rfm.Loop() sigint := make(chan os.Signal, 1) signal.Notify(sigint, os.Interrupt, os.Kill) @@ -49,6 +50,13 @@ func main() { quit <- 1 <-quit return + case <-time.After(10 * time.Second): + txChan <- rfm69.Data{ + ToAddress: 99, + FromAddress: 1, + Data: []byte{1, 2, 3}, + RequestAck: true, + } } } } diff --git a/rfm69handler.go b/rfm69handler.go index df9e52f..2cbb2fa 100644 --- a/rfm69handler.go +++ b/rfm69handler.go @@ -7,7 +7,7 @@ import ( ) // Loop is the main receive and transmit handling loop -func (r *Device) Loop() (chan Data, chan int) { +func (r *Device) Loop() (chan Data, chan Data, chan int) { quit := make(chan int) txChan := make(chan Data, 5) rxChan := make(chan Data, 5) @@ -106,6 +106,7 @@ func (r *Device) Loop() (chan Data, chan int) { resp := Data{ FromAddress: r.address, ToAddress: data.FromAddress, + Data: data.Data, SendAck: true, } txChan <- resp @@ -125,5 +126,5 @@ func (r *Device) Loop() (chan Data, chan int) { } }() - return rxChan, quit + return rxChan, txChan, quit }