Skip to content

Commit 06dd60f

Browse files
authored
Add wifi driver comboat for Elecrow W5 rp2040 and rp2350 devices (#741)
* Add wifi driver comboat for Elecrow W5 rp2040 and rp2350 devices Combo-AT driver uses AT command set to talk to onboard rtl8720d wifi device. The driver supports UDP/TCP/TLS clients in Wifi STA mode. Support for UDP/TCP servers is not supported, currently. https://aithinker-combo-guide.readthedocs.io/en/latest/docs/instruction/index.html https://aithinker-combo-guide.readthedocs.io/en/latest/docs/command-set/index.html https://aithinker-combo-guide.readthedocs.io/en/latest/docs/command-examples/index.html * Add wifi driver comboat for Elecrow W5 rp2040 and rp2350 devices Combo-AT driver uses AT command set to talk to onboard rtl8720d wifi device. The driver supports UDP/TCP/TLS clients in Wifi STA mode. Support for UDP/TCP servers is not supported, currently. https://aithinker-combo-guide.readthedocs.io/en/latest/docs/instruction/index.html https://aithinker-combo-guide.readthedocs.io/en/latest/docs/command-set/index.html https://aithinker-combo-guide.readthedocs.io/en/latest/docs/command-examples/index.html * switch to comboat_fw build tag for examples/net's that work with comboat driver
1 parent 27a7d50 commit 06dd60f

File tree

18 files changed

+840
-14
lines changed

18 files changed

+840
-14
lines changed

comboat/comboat.go

Lines changed: 711 additions & 0 deletions
Large diffs are not rendered by default.

comboat/errors.go

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
package comboat
2+
3+
import (
4+
"bytes"
5+
"strconv"
6+
)
7+
8+
var errStrings = map[int]string{
9+
10+
// System framework related error codes
11+
12+
0: "success",
13+
1: "The command is not supported (the combo framework contains the command but the current platform has not transplanted or adapted to support it)",
14+
2: "The command parameters contain unsupported operations (the current platform only supports some operations for this command)",
15+
3: "The instruction format is incorrect (this refers to the wrong number of parameters, for example, two parameters are required, but only one parameter is entered)",
16+
4: "Parameter error (the content of the parameter is wrong, for example, a number between 0 and 9 is required, but 10 or xyz is passed in, which is a parameter error)",
17+
5: "Parameter length error (command length exceeds the maximum supported length)",
18+
31: "The current command has not ended and needs to report the status asynchronously. This value is used by the state machine to determine the use of the command and no message is returned.",
19+
32: "Unknown error (or unhandled error type)",
20+
21+
// Common error codes
22+
23+
33: "malloc error",
24+
34: "Failed to read buf",
25+
35: "Failed to write buf",
26+
36: "Configuration error (configuration error loaded from memory, for example, we set port -1 for OTA upgrade, and check port error when executing AT+OTA, then configuration error will be reported)",
27+
37: "Failed to create task",
28+
38: "Flash read and write failure",
29+
39: "Serial port configuration error, unsupported baud rate",
30+
40: "Serial port configuration error, unsupported data bits",
31+
41: "Serial port configuration error, unsupported stop bit",
32+
42: "Serial port configuration error, unsupported parity bit",
33+
43: "Serial port configuration error, unsupported flow control",
34+
44: "Serial port configuration failed",
35+
45: "Wrong username/password",
36+
46: "Low power mode error or unsupported low power mode",
37+
47: "Uninitialized configuration data error (including io mapping data)",
38+
63: "General error code (without other information)",
39+
40+
// Wi-Fi related error codes
41+
42+
64: "Wi-Fi not initialized or initialization failed",
43+
65: "Wi-Fi mode error (unable to connect to Wi-Fi in single AP mode)",
44+
66: "Wi-Fi connection failed",
45+
67: "Wi-Fi connection successful, error in obtaining IP (DHCP)",
46+
68: "Failed to obtain encryption method",
47+
69: "The specified AP was not found.",
48+
70: "Wi-Fi scan start failed",
49+
71: "Wi-Fi scan timeout",
50+
72: "Failed to enable AP hotspot",
51+
73: "Failed to obtain the Wi-Fi information of the router or the AP information that you enabled yourself",
52+
74: "The network card (STA/AP) is not running",
53+
75: "Wi-Fi country code error (unsupported Wi-Fi country code)",
54+
76: "The current network configuration mode is wrong.",
55+
95: "Wi-Fi connection unknown error",
56+
57+
// Socket related error codes
58+
59+
96: "Failed to create socket",
60+
97: "Socket connection failed",
61+
98: "DNS Failure",
62+
99: "The socket status is wrong (for example, TCP is not connected yet)",
63+
100: "Socket type error",
64+
101: "Socket send failed",
65+
102: "Socket receive failed",
66+
103: "Socket monitoring thread creation failed",
67+
104: "Socket bind error",
68+
105: "The current connection cannot be transparently linked (wrong socket type or number)",
69+
106: "PING test failed (all packets lost)",
70+
107: "Wi-Fi country code error (unsupported Wi-Fi country code)",
71+
108: "SSL Config Error",
72+
109: "SSL verification error (usually caused by unsupported SSL encryption type or certificate error)",
73+
127: "Unknown socket error",
74+
}
75+
76+
func getErrStr(errLine []byte) (errStr string) {
77+
errStr = "Can't parse ERROR response"
78+
tokens := bytes.Split(errLine, []byte(":"))
79+
if len(tokens) > 1 {
80+
errCode, err := strconv.Atoi(string(tokens[1]))
81+
if err == nil {
82+
errStr = errStrings[errCode]
83+
}
84+
}
85+
return
86+
}

examples/net/http-get/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
// examples/net/webclient (for HTTP)
1010
// examples/net/tlsclient (for HTTPS)
1111

12-
//go:build ninafw || wioterminal
12+
//go:build ninafw || wioterminal || comboat_fw
1313

1414
package main
1515

examples/net/http-head/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
// examples/net/webclient (for HTTP)
1010
// examples/net/tlsclient (for HTTPS)
1111

12-
//go:build ninafw || wioterminal
12+
//go:build ninafw || wioterminal || comboat_fw
1313

1414
package main
1515

examples/net/http-post/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
// examples/net/webclient (for HTTP)
1010
// examples/net/tlsclient (for HTTPS)
1111

12-
//go:build ninafw || wioterminal
12+
//go:build ninafw || wioterminal || comboat_fw
1313

1414
package main
1515

examples/net/http-postform/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
// examples/net/webclient (for HTTP)
1010
// examples/net/tlsclient (for HTTPS)
1111

12-
//go:build ninafw || wioterminal
12+
//go:build ninafw || wioterminal || comboat_fw
1313

1414
package main
1515

examples/net/mqttclient/natiu/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// Note: It may be necessary to increase the stack size when using
55
// paho.mqtt.golang. Use the -stack-size=4KB command line option.
66

7-
//go:build ninafw || wioterminal || challenger_rp2040
7+
//go:build ninafw || wioterminal || challenger_rp2040 || comboat_fw
88

99
package main
1010

examples/net/mqttclient/paho/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// Note: It may be necessary to increase the stack size when using
55
// paho.mqtt.golang. Use the -stack-size=4KB command line option.
66

7-
//go:build ninafw || wioterminal || challenger_rp2040
7+
//go:build ninafw || wioterminal || challenger_rp2040 || comboat_fw
88

99
package main
1010

examples/net/ntpclient/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// It creates a UDP connection to request the current time and parse the
44
// response from a NTP server. The system time is set to NTP time.
55

6-
//go:build ninafw || wioterminal || challenger_rp2040
6+
//go:build ninafw || wioterminal || challenger_rp2040 || comboat_fw
77

88
package main
99

examples/net/snake/init.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//go:build ninafw || wioterminal
1+
//go:build ninafw || wioterminal || comboat_fw
22

33
package main
44

examples/net/snake/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
// func. This forces segments to connect and run concurrently, which is a good
3232
// test of the underlying driver's ability to handle concurrent connections.
3333

34-
//go:build ninafw || wioterminal
34+
//go:build ninafw || wioterminal || comboat_fw
3535

3636
package main
3737

examples/net/socket/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
//
55
// nc -lk 8080
66

7-
//go:build ninafw || wioterminal || challenger_rp2040
7+
//go:build ninafw || wioterminal || challenger_rp2040 || comboat_fw
88

99
package main
1010

examples/net/tcpclient/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
//
66
// nc -lk 8080
77

8-
//go:build ninafw || wioterminal || challenger_rp2040 || pico
8+
//go:build ninafw || wioterminal || challenger_rp2040 || comboat_fw
99

1010
package main
1111

examples/net/tlsclient/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
//
66
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Strict-Transport-Security
77

8-
//go:build ninafw || wioterminal
8+
//go:build ninafw || wioterminal || comboat_fw
99

1010
package main
1111

examples/net/webclient/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
// }
1818
// ---------------------------------------------------------------------------
1919

20-
//go:build ninafw || wioterminal
20+
//go:build ninafw || wioterminal || comboat_fw
2121

2222
package main
2323

examples/net/websocket/dial/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
// Note: It may be necessary to increase the stack size when using
77
// "golang.org/x/net/websocket". Use the -stack-size=4KB command line option.
88

9-
//go:build ninafw || wioterminal
9+
//go:build ninafw || wioterminal || comboat_fw
1010

1111
package main
1212

netlink/probe/comboat.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
//go:build comboat_fw
2+
3+
package probe
4+
5+
import (
6+
"machine"
7+
8+
"tinygo.org/x/drivers/comboat"
9+
"tinygo.org/x/drivers/netdev"
10+
"tinygo.org/x/drivers/netlink"
11+
)
12+
13+
func Probe() (netlink.Netlinker, netdev.Netdever) {
14+
15+
cfg := comboat.Config{
16+
BaudRate: 115200,
17+
Uart: machine.UART1,
18+
Tx: machine.UART1_TX_PIN,
19+
Rx: machine.UART1_RX_PIN,
20+
}
21+
22+
combo := comboat.NewDevice(&cfg)
23+
netdev.UseNetdev(combo)
24+
25+
return combo, combo
26+
}

smoketest.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,3 +154,6 @@ tinygo build -size short -o ./build/test.hex -target=nano-rp2040 -stack-size 8kb
154154
tinygo build -size short -o ./build/test.hex -target=wioterminal -stack-size 8kb ./examples/net/webclient/
155155
tinygo build -size short -o ./build/test.hex -target=wioterminal -stack-size 8kb ./examples/net/webserver/
156156
tinygo build -size short -o ./build/test.hex -target=wioterminal -stack-size 8kb ./examples/net/mqttclient/paho/
157+
# network examples (comboat)
158+
tinygo build -size short -o ./build/test.hex -target=elecrow-rp2040 -stack-size 8kb ./examples/net/tlsclient/
159+
tinygo build -size short -o ./build/test.hex -target=elecrow-rp2350 -stack-size 8kb ./examples/net/ntpclient/

0 commit comments

Comments
 (0)