|
|
@ -7,15 +7,22 @@ import (
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
// Loop is the main receive and transmit handling loop
|
|
|
|
// Loop is the main receive and transmit handling loop
|
|
|
|
func (r *Device) Loop() error {
|
|
|
|
func (r *Device) Loop() chan int {
|
|
|
|
|
|
|
|
quit := make(chan int)
|
|
|
|
c := make(chan Data)
|
|
|
|
c := make(chan Data)
|
|
|
|
|
|
|
|
go func() {
|
|
|
|
irq := make(chan int)
|
|
|
|
irq := make(chan int)
|
|
|
|
|
|
|
|
|
|
|
|
r.gpio.Watch(embd.EdgeRising, func(pin embd.DigitalPin) {
|
|
|
|
r.gpio.Watch(embd.EdgeRising, func(pin embd.DigitalPin) {
|
|
|
|
irq <- 1
|
|
|
|
irq <- 1
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
r.SetMode(RF_OPMODE_RECEIVER)
|
|
|
|
err := r.SetMode(RF_OPMODE_RECEIVER)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
log.Print(err)
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
defer r.SetMode(RF_OPMODE_STANDBY)
|
|
|
|
|
|
|
|
|
|
|
|
for {
|
|
|
|
for {
|
|
|
|
select {
|
|
|
|
select {
|
|
|
@ -32,9 +39,14 @@ func (r *Device) Loop() error {
|
|
|
|
data, err := r.readFifo()
|
|
|
|
data, err := r.readFifo()
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
log.Print(err)
|
|
|
|
log.Print(err)
|
|
|
|
return err
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
log.Print(data)
|
|
|
|
log.Print(data)
|
|
|
|
|
|
|
|
case <-quit:
|
|
|
|
|
|
|
|
quit <- 1
|
|
|
|
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}()
|
|
|
|
|
|
|
|
return quit
|
|
|
|
}
|
|
|
|
}
|
|
|
|