Merge pull request #1 from RPIZeroDuplexPOCSAG/master

update
master^2
cheetah 4 years ago
commit 7253d0e352

@ -5,7 +5,8 @@ import (
"time" "time"
"sync" "sync"
"log" "log"
"github.com/kgolding/go-pocsagencode" "github.com/RPIZeroDuplexPOCSAG/go-pocsagencode"
// "github.com/kgolding/go-pocsagencode"
"github.com/RPIZeroDuplexPOCSAG/rfm69" "github.com/RPIZeroDuplexPOCSAG/rfm69"
"github.com/davecheney/gpio" "github.com/davecheney/gpio"
@ -77,10 +78,15 @@ func main() {
for msg := range d { for msg := range d {
if msg.Headers["ric"] == nil { continue } if msg.Headers["ric"] == nil { continue }
log.Printf("ric: %s", string(msg.Headers["ric"].(int64))) if msg.Headers["function"] == nil { continue }
log.Printf("ric: %d", uint32(msg.Headers["ric"].(int64)))
log.Printf("function %d", byte(msg.Headers["function"].(int64)))
log.Printf("msg: %s", string(msg.Body)) log.Printf("msg: %s", string(msg.Body))
queueMessage(&pocsagencode.Message { queueMessage(&pocsagencode.Message {
Addr: uint32(msg.Headers["ric"].(int64)), Addr: uint32(msg.Headers["ric"].(int64)),
Function: uint8(msg.Headers["function"].(int64)),
Content: string(msg.Body), Content: string(msg.Body),
IsNumeric: (msg.Headers["numeric"] != nil), IsNumeric: (msg.Headers["numeric"] != nil),
}) })
@ -175,7 +181,7 @@ func main() {
go func() { go func() {
lastTransmitBatch = time.Now().Unix() lastTransmitBatch = time.Now().Unix()
for { for {
log.Println(time.Now().Unix(), lastTransmitBatch + 5) //log.Println(time.Now().Unix(), lastTransmitBatch + 5)
time.Sleep(500 * time.Millisecond) time.Sleep(500 * time.Millisecond)
if len(messageQueue) > 0 && (time.Now().Unix() > lastTransmitBatch + 5) { if len(messageQueue) > 0 && (time.Now().Unix() > lastTransmitBatch + 5) {
@ -187,10 +193,10 @@ func main() {
data := &rfm69.Data{ data := &rfm69.Data{
Data: burst.Bytes(), Data: burst.Bytes(),
} }
// Make Pocsag Burst
rfm.Send(data) rfm.Send(data)
messageQueue = make([]*pocsagencode.Message, 0) messageQueue = make([]*pocsagencode.Message, 0)
queueMutex.Unlock() queueMutex.Unlock()
// Make Pocsag Burst
} }
} }
}() }()

Loading…
Cancel
Save