Skip to content

Commit eac4c87

Browse files
docs(network):对网卡demo进行细分,增加usbnetdemo (#15)
* (network)WLAN.py有新的修改,提交最新版本至git * network: 新增slip网卡(FC41D、ESP8266、ESP8684)的三个整合包,内含对应的wifi固件、中英文readme、WLAN.py驱动文件 * docs(network):对网卡demo进行细分,增加usbnetdemo 把网卡demo细分为各个网卡的专用demo,并对usbnet不同的应用场景增加demo 固件版本: N/A 是否需要文案翻译: 否 * docs(network):对网卡demo进行细分,增加usbnetdemo 把网卡demo细分为各个网卡的专用demo,并对usbnet不同的应用场景增加demo 固件版本: N/A 是否需要文案翻译: 否
1 parent 5d68ed2 commit eac4c87

12 files changed

+371
-0
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Copyright (c) Quectel Wireless Solution, Co., Ltd.All Rights Reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
import dataCall
16+
import ethernet
17+
18+
nic = None
19+
20+
def netStatusCallback(args):
21+
pdp = args[0]
22+
datacallState = args[1]
23+
if datacallState == 0:
24+
print('modem network {} disconnected.'.format(pdp))
25+
elif datacallState == 1:
26+
print('modem network {} connected.'.format(pdp))
27+
if nic != None:
28+
lte=dataCall.getInfo(1, 0)
29+
print(lte)
30+
nic.set_default_NIC(lte[2][2])
31+
32+
def eth_init():
33+
lte=dataCall.getInfo(1, 0)
34+
print('modem net config: {}'.format(lte))
35+
workMode=1
36+
global nic
37+
print('eth init start')
38+
nic = ethernet.CH395(b'\x12\x34\x56\x78\x9a\xbc','192.168.1.1','','',-1,-1,-1,-1, workMode)
39+
if lte != -1 and lte[2][0] == 1:
40+
print('eth set default nic {}'.format(lte[2][2]))
41+
nic.set_default_NIC(lte[2][2])
42+
nic.set_dns('8.8.8.8', '114.114.114.114')
43+
print('eth net config: {}'.format(nic.ipconfig()))
44+
nic.set_up()
45+
print('eth startup success')
46+
47+
dataCall.setCallback(netStatusCallback)
48+
eth_init()
49+
50+
51+
52+
53+
54+
55+
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Copyright (c) Quectel Wireless Solution, Co., Ltd.All Rights Reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
import ethernet
16+
17+
nic = None
18+
19+
def eth_init():
20+
print('eth init start')
21+
nic = ethernet.CH395(b'\x12\x34\x56\x78\x9a\xbc','','','',-1,-1,-1,-1)
22+
nic_info = nic.ipconfig()
23+
print('nic net config before: {}'.format(nic_info))
24+
# dhcp ip config
25+
nic.dhcp()
26+
# static ip config
27+
nic.set_addr('192.168.1.99', '255.255.255.0','192.168.1.1')
28+
nic.set_dns('8.8.8.8', '114.114.114.114')
29+
nic_info = nic.ipconfig()
30+
print('nic net config after: {}'.format(nic_info))
31+
nic.set_default_NIC(nic_info[1][1])
32+
nic.set_up()
33+
print('eth startup success')
34+
35+
eth_init()
36+
37+
# now, you can connect server by ethernet interface
38+
39+
40+
41+
42+
43+
44+
45+
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Copyright (c) Quectel Wireless Solution, Co., Ltd.All Rights Reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
import dataCall
16+
import ethernet
17+
18+
nic = None
19+
20+
def netStatusCallback(args):
21+
pdp = args[0]
22+
datacallState = args[1]
23+
if datacallState == 0:
24+
print('modem network {} disconnected.'.format(pdp))
25+
elif datacallState == 1:
26+
print('modem network {} connected.'.format(pdp))
27+
if nic != None:
28+
lte=dataCall.getInfo(1, 0)
29+
print(lte)
30+
nic.set_default_NIC(lte[2][2])
31+
32+
def eth_init():
33+
lte=dataCall.getInfo(1, 0)
34+
print('modem net config: {}'.format(lte))
35+
workMode=1
36+
global nic
37+
print('eth init start')
38+
nic = ethernet.DM9051(b'\x12\x34\x56\x78\x9a\xbc','192.168.1.1','','',-1,-1,-1,-1, workMode)
39+
if lte != -1 and lte[2][0] == 1:
40+
print('eth set default nic {}'.format(lte[2][2]))
41+
nic.set_default_NIC(lte[2][2])
42+
nic.set_dns('8.8.8.8', '114.114.114.114')
43+
print('eth net config: {}'.format(nic.ipconfig()))
44+
nic.set_up()
45+
print('eth startup success')
46+
47+
dataCall.setCallback(netStatusCallback)
48+
eth_init()
49+
50+
51+
52+
53+
54+
55+
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Copyright (c) Quectel Wireless Solution, Co., Ltd.All Rights Reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
import ethernet
16+
17+
nic = None
18+
19+
def eth_init():
20+
print('eth init start')
21+
nic = ethernet.DM9051(b'\x12\x34\x56\x78\x9a\xbc','','','',-1,-1,-1,-1)
22+
nic_info = nic.ipconfig()
23+
print('nic net config before: {}'.format(nic_info))
24+
# dhcp ip config
25+
nic.dhcp()
26+
# static ip config
27+
nic.set_addr('192.168.1.99', '255.255.255.0','192.168.1.1')
28+
nic.set_dns('8.8.8.8', '114.114.114.114')
29+
nic_info = nic.ipconfig()
30+
print('nic net config after: {}'.format(nic_info))
31+
nic.set_default_NIC(nic_info[1][1])
32+
nic.set_up()
33+
print('eth startup success')
34+
35+
eth_init()
36+
37+
# now, you can connect server by ethernet interface
38+
39+
40+
41+
42+
43+
44+
45+
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Copyright (c) Quectel Wireless Solution, Co., Ltd.All Rights Reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
import dataCall
16+
import ethernet
17+
18+
nic = None
19+
20+
def netStatusCallback(args):
21+
pdp = args[0]
22+
datacallState = args[1]
23+
if datacallState == 0:
24+
print('modem network {} disconnected.'.format(pdp))
25+
elif datacallState == 1:
26+
print('modem network {} connected.'.format(pdp))
27+
if nic != None:
28+
lte=dataCall.getInfo(1, 0)
29+
print(lte)
30+
nic.set_default_NIC(lte[2][2])
31+
32+
def eth_init():
33+
lte=dataCall.getInfo(1, 0)
34+
print('modem net config: {}'.format(lte))
35+
global nic
36+
print('eth init start')
37+
nic = ethernet.YT8512H(b'\x12\x34\x56\x78\x9a\xbc','192.168.1.1','','')
38+
if lte != -1 and lte[2][0] == 1:
39+
print('eth set default nic {}'.format(lte[2][2]))
40+
nic.set_default_NIC(lte[2][2])
41+
nic.set_dns('8.8.8.8', '114.114.114.114')
42+
print('eth net config: {}'.format(nic.ipconfig()))
43+
nic.set_up()
44+
print('eth startup success')
45+
46+
dataCall.setCallback(netStatusCallback)
47+
eth_init()
48+
49+
50+
51+
52+
53+
54+
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Copyright (c) Quectel Wireless Solution, Co., Ltd.All Rights Reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
import ethernet
16+
17+
nic = None
18+
19+
def eth_init():
20+
print('eth init start')
21+
nic = ethernet.YT8512H(b'\x12\x34\x56\x78\x9a\xbc','','','')
22+
nic_info = nic.ipconfig()
23+
print('nic net config before: {}'.format(nic_info))
24+
# dhcp ip config
25+
nic.dhcp()
26+
# static ip config
27+
nic.set_addr('192.168.1.99', '255.255.255.0','192.168.1.1')
28+
nic.set_dns('8.8.8.8', '114.114.114.114')
29+
nic_info = nic.ipconfig()
30+
print('nic net config after: {}'.format(nic_info))
31+
nic.set_default_NIC(nic_info[1][1])
32+
nic.set_up()
33+
print('eth startup success')
34+
35+
eth_init()
36+
37+
# now, you can connect server by ethernet interface
38+
39+
40+
41+
42+
43+
44+
45+
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
from misc import USBNET,Power
2+
import utime
3+
import dataCall
4+
5+
6+
if USBNET.get_worktype() != USBNET.Type_ECM:
7+
USBNET.set_worktype(USBNET.Type_ECM)
8+
Power.powerRestart()
9+
while True:
10+
info = dataCall.getInfo(1, 0)
11+
if info[2][2] != '0.0.0.0':
12+
print('data:',info)
13+
break
14+
print('Wait for data calling')
15+
utime.sleep(2)
16+
17+
USBNET.open()
18+
print('USBNET open successed.')
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
from misc import USBNET,Power
2+
import utime
3+
import dataCall
4+
5+
6+
if USBNET.get_worktype() != USBNET.Type_ECM:
7+
USBNET.set_worktype(USBNET.Type_ECM)
8+
Power.powerRestart()
9+
while True:
10+
info = dataCall.getInfo(1, 0)
11+
if info[2][2] != '0.0.0.0':
12+
print('data:',info)
13+
break
14+
print('Wait for data calling')
15+
utime.sleep(2)
16+
17+
USBNET.open()
18+
print('USBNET open successed.')

0 commit comments

Comments
 (0)