rtl8720dn: add examples/rtl8720dn/mqtt*

This commit is contained in:
sago35
2021-07-12 20:56:20 +09:00
committed by Ron Evans
parent 6a4cd9d8e7
commit 633f19c4ac
9 changed files with 2199 additions and 310 deletions
+9 -2
View File
@@ -266,8 +266,15 @@ func (r *RTL8720DN) IsSocketDataAvailable() bool {
if r.debug {
fmt.Printf("IsSocketDataAvailable()\r\n")
}
fmt.Printf("not implemented yet\r\n")
return true
ret, err := r.Rpc_lwip_available(r.socket)
if err != nil {
fmt.Printf("error: %s\r\n", err.Error())
return false
}
if ret == 1 {
return true
}
return false
}
func (r *RTL8720DN) Response(timeout int) ([]byte, error) {
+1746 -291
View File
File diff suppressed because it is too large Load Diff
+3 -7
View File
@@ -3,7 +3,6 @@ package rtl8720dn
import (
"fmt"
"io"
"time"
)
var (
@@ -66,7 +65,7 @@ func dumpHex(b []byte) {
}
}
func (r *RTL8720DN) readThread() {
func (r *RTL8720DN) read() {
for {
n, _ := io.ReadFull(r.port, readBuf[:4])
if n == 0 {
@@ -93,13 +92,10 @@ func (r *RTL8720DN) readThread() {
crcNew := computeCRC16(payload[:n])
if g, e := crcNew, crc; g != e {
fmt.Printf("err CRC16: got %04X want %04X\n", g, e)
fmt.Printf("err CRC16: got %04X want %04X\r\n", g, e)
}
if payload[0] == 0x02 || payload[0] == 0x00 {
r.received <- true
// switch goroutine
time.Sleep(1)
return
}
}
}
+8 -10
View File
@@ -3,10 +3,10 @@ package rtl8720dn
import "io"
type RTL8720DN struct {
port io.ReadWriter
seq uint64
received chan bool
debug bool
port io.ReadWriter
seq uint64
sema chan bool
debug bool
connectionType ConnectionType
socket int32
@@ -26,14 +26,12 @@ const (
func New(r io.ReadWriter) *RTL8720DN {
ret := &RTL8720DN{
port: r,
seq: 1,
received: make(chan bool, 1),
debug: false,
port: r,
seq: 1,
sema: make(chan bool, 1),
debug: false,
}
go ret.readThread()
return ret
}