rtl8720dn: add support for http.Get(), http.Post() and cookie

This commit is contained in:
sago35
2021-07-14 22:46:24 +09:00
committed by Ron Evans
parent 633f19c4ac
commit 2537c69b0f
15 changed files with 1997 additions and 175 deletions
+12 -10
View File
@@ -226,7 +226,12 @@ func (r *RTL8720DN) ReadSocket(b []byte) (n int, err error) {
switch r.connectionType {
case ConnectionTypeTCP:
nn, err := r.Rpc_lwip_recv(r.socket, &b, uint32(len(b)), 0x00000008, 0x00002800)
length := len(b)
if length > maxUartRecvSize-16 {
length = maxUartRecvSize - 16
}
buf := b[:length]
nn, err := r.Rpc_lwip_recv(r.socket, &buf, uint32(length), 0x00000008, 0x00002800)
if err != nil {
return 0, err
}
@@ -236,17 +241,14 @@ func (r *RTL8720DN) ReadSocket(b []byte) (n int, err error) {
} else if nn == 0 {
return 0, r.DisconnectSocket()
}
if r.length == 0 {
header := httpHeader(b[:nn])
r.length = header.ContentLength()
}
r.length -= int(nn)
if r.length == 0 {
return int(nn), r.DisconnectSocket()
}
n = int(nn)
case ConnectionTypeTLS:
nn, err := r.Rpc_wifi_get_ssl_receive(r.client, &b, int32(len(b)))
length := len(b)
if length > maxUartRecvSize-16 {
length = maxUartRecvSize - 16
}
buf := b[:length]
nn, err := r.Rpc_wifi_get_ssl_receive(r.client, &buf, int32(length))
if err != nil {
return 0, err
}
+2
View File
@@ -2,6 +2,8 @@ package rtl8720dn
import "io"
const maxUartRecvSize = 128
type RTL8720DN struct {
port io.ReadWriter
seq uint64