Skip to content

Commit e6ca1bf

Browse files
committed
【添加】network 例程
1 parent 28b82f3 commit e6ca1bf

File tree

4 files changed

+67
-0
lines changed

4 files changed

+67
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/*
2+
* Copyright (c) 2006-2019, RT-Thread Development Team
3+
*
4+
* SPDX-License-Identifier: MIT License
5+
*
6+
* Change Logs:
7+
* Date Author Notes
8+
* 2019-06-13 SummerGift first version
9+
*/
10+
11+
import network
12+
13+
ap = network.WLAN(network.AP_IF)
14+
ap.config(essid="hello_rt-thread", password="88888888")
15+
ap.active(True)
16+
ap.config("essid")
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/*
2+
* Copyright (c) 2006-2019, RT-Thread Development Team
3+
*
4+
* SPDX-License-Identifier: MIT License
5+
*
6+
* Change Logs:
7+
* Date Author Notes
8+
* 2019-06-13 SummerGift first version
9+
*/
10+
11+
import network
12+
13+
wlan = network.WLAN(network.STA_IF)
14+
wlan.scan()
15+
wlan.connect("rtthread","02188888888")
16+
wlan.isconnected()

examples/network/tcp_client.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/*
2+
* Copyright (c) 2006-2019, RT-Thread Development Team
3+
*
4+
* SPDX-License-Identifier: MIT License
5+
*
6+
* Change Logs:
7+
* Date Author Notes
8+
* 2019-06-13 SummerGift first version
9+
*/
10+
11+
import usocket
12+
13+
s = usocket.socket(usocket.AF_INET,usocket.SOCK_STREAM)
14+
s.connect(("192.168.10.110",6000))
15+
s.send("micropython")
16+
s.close()

examples/network/tcp_server.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/*
2+
* Copyright (c) 2006-2019, RT-Thread Development Team
3+
*
4+
* SPDX-License-Identifier: MIT License
5+
*
6+
* Change Logs:
7+
* Date Author Notes
8+
* 2019-06-13 SummerGift first version
9+
*/
10+
11+
import usocket
12+
13+
s = usocket.socket(usocket.AF_INET,usocket.SOCK_STREAM) # Create STREAM TCP socket
14+
s.bind(('192.168.12.32', 6001))
15+
s.listen(5)
16+
s.setblocking(True)
17+
sock,addr=s.accept()
18+
sock.recv(10)
19+
s.close()

0 commit comments

Comments
 (0)