diff --git a/network-comm/nic/ethernet/CH395/example_network_eth_lan_ch395.py b/network-comm/nic/ethernet/CH395/example_network_eth_lan_ch395.py new file mode 100644 index 0000000..27c25e7 --- /dev/null +++ b/network-comm/nic/ethernet/CH395/example_network_eth_lan_ch395.py @@ -0,0 +1,55 @@ +# Copyright (c) Quectel Wireless Solution, Co., Ltd.All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import dataCall +import ethernet + +nic = None + +def netStatusCallback(args): + pdp = args[0] + datacallState = args[1] + if datacallState == 0: + print('modem network {} disconnected.'.format(pdp)) + elif datacallState == 1: + print('modem network {} connected.'.format(pdp)) + if nic != None: + lte=dataCall.getInfo(1, 0) + print(lte) + nic.set_default_NIC(lte[2][2]) + +def eth_init(): + lte=dataCall.getInfo(1, 0) + print('modem net config: {}'.format(lte)) + workMode=1 + global nic + print('eth init start') + nic = ethernet.CH395(b'\x12\x34\x56\x78\x9a\xbc','192.168.1.1','','',-1,-1,-1,-1, workMode) + if lte != -1 and lte[2][0] == 1: + print('eth set default nic {}'.format(lte[2][2])) + nic.set_default_NIC(lte[2][2]) + nic.set_dns('8.8.8.8', '114.114.114.114') + print('eth net config: {}'.format(nic.ipconfig())) + nic.set_up() + print('eth startup success') + +dataCall.setCallback(netStatusCallback) +eth_init() + + + + + + + diff --git a/network-comm/nic/ethernet/CH395/example_network_eth_wan_ch395.py b/network-comm/nic/ethernet/CH395/example_network_eth_wan_ch395.py new file mode 100644 index 0000000..76082cd --- /dev/null +++ b/network-comm/nic/ethernet/CH395/example_network_eth_wan_ch395.py @@ -0,0 +1,45 @@ +# Copyright (c) Quectel Wireless Solution, Co., Ltd.All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import ethernet + +nic = None + +def eth_init(): + print('eth init start') + nic = ethernet.CH395(b'\x12\x34\x56\x78\x9a\xbc','','','',-1,-1,-1,-1) + nic_info = nic.ipconfig() + print('nic net config before: {}'.format(nic_info)) + # dhcp ip config + nic.dhcp() + # static ip config + nic.set_addr('192.168.1.99', '255.255.255.0','192.168.1.1') + nic.set_dns('8.8.8.8', '114.114.114.114') + nic_info = nic.ipconfig() + print('nic net config after: {}'.format(nic_info)) + nic.set_default_NIC(nic_info[1][1]) + nic.set_up() + print('eth startup success') + +eth_init() + +# now, you can connect server by ethernet interface + + + + + + + + diff --git a/network-comm/nic/ethernet/DM9051/example_network_eth_lan_dm9051.py b/network-comm/nic/ethernet/DM9051/example_network_eth_lan_dm9051.py new file mode 100644 index 0000000..bcf193a --- /dev/null +++ b/network-comm/nic/ethernet/DM9051/example_network_eth_lan_dm9051.py @@ -0,0 +1,55 @@ +# Copyright (c) Quectel Wireless Solution, Co., Ltd.All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import dataCall +import ethernet + +nic = None + +def netStatusCallback(args): + pdp = args[0] + datacallState = args[1] + if datacallState == 0: + print('modem network {} disconnected.'.format(pdp)) + elif datacallState == 1: + print('modem network {} connected.'.format(pdp)) + if nic != None: + lte=dataCall.getInfo(1, 0) + print(lte) + nic.set_default_NIC(lte[2][2]) + +def eth_init(): + lte=dataCall.getInfo(1, 0) + print('modem net config: {}'.format(lte)) + workMode=1 + global nic + print('eth init start') + nic = ethernet.DM9051(b'\x12\x34\x56\x78\x9a\xbc','192.168.1.1','','',-1,-1,-1,-1, workMode) + if lte != -1 and lte[2][0] == 1: + print('eth set default nic {}'.format(lte[2][2])) + nic.set_default_NIC(lte[2][2]) + nic.set_dns('8.8.8.8', '114.114.114.114') + print('eth net config: {}'.format(nic.ipconfig())) + nic.set_up() + print('eth startup success') + +dataCall.setCallback(netStatusCallback) +eth_init() + + + + + + + diff --git a/network-comm/nic/ethernet/DM9051/example_network_eth_wan_dm9051.py b/network-comm/nic/ethernet/DM9051/example_network_eth_wan_dm9051.py new file mode 100644 index 0000000..5e44d29 --- /dev/null +++ b/network-comm/nic/ethernet/DM9051/example_network_eth_wan_dm9051.py @@ -0,0 +1,45 @@ +# Copyright (c) Quectel Wireless Solution, Co., Ltd.All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import ethernet + +nic = None + +def eth_init(): + print('eth init start') + nic = ethernet.DM9051(b'\x12\x34\x56\x78\x9a\xbc','','','',-1,-1,-1,-1) + nic_info = nic.ipconfig() + print('nic net config before: {}'.format(nic_info)) + # dhcp ip config + nic.dhcp() + # static ip config + nic.set_addr('192.168.1.99', '255.255.255.0','192.168.1.1') + nic.set_dns('8.8.8.8', '114.114.114.114') + nic_info = nic.ipconfig() + print('nic net config after: {}'.format(nic_info)) + nic.set_default_NIC(nic_info[1][1]) + nic.set_up() + print('eth startup success') + +eth_init() + +# now, you can connect server by ethernet interface + + + + + + + + diff --git a/network-comm/nic/ethernet/example_network_eth_lan.py b/network-comm/nic/ethernet/W5500/example_network_eth_lan_w5500.py similarity index 100% rename from network-comm/nic/ethernet/example_network_eth_lan.py rename to network-comm/nic/ethernet/W5500/example_network_eth_lan_w5500.py diff --git a/network-comm/nic/ethernet/example_network_eth_wan.py b/network-comm/nic/ethernet/W5500/example_network_eth_wan_w5500.py similarity index 100% rename from network-comm/nic/ethernet/example_network_eth_wan.py rename to network-comm/nic/ethernet/W5500/example_network_eth_wan_w5500.py diff --git a/network-comm/nic/ethernet/YT8512/example_network_eth_lan_yt8512h.py b/network-comm/nic/ethernet/YT8512/example_network_eth_lan_yt8512h.py new file mode 100644 index 0000000..aba6a9b --- /dev/null +++ b/network-comm/nic/ethernet/YT8512/example_network_eth_lan_yt8512h.py @@ -0,0 +1,54 @@ +# Copyright (c) Quectel Wireless Solution, Co., Ltd.All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import dataCall +import ethernet + +nic = None + +def netStatusCallback(args): + pdp = args[0] + datacallState = args[1] + if datacallState == 0: + print('modem network {} disconnected.'.format(pdp)) + elif datacallState == 1: + print('modem network {} connected.'.format(pdp)) + if nic != None: + lte=dataCall.getInfo(1, 0) + print(lte) + nic.set_default_NIC(lte[2][2]) + +def eth_init(): + lte=dataCall.getInfo(1, 0) + print('modem net config: {}'.format(lte)) + global nic + print('eth init start') + nic = ethernet.YT8512H(b'\x12\x34\x56\x78\x9a\xbc','192.168.1.1','','') + if lte != -1 and lte[2][0] == 1: + print('eth set default nic {}'.format(lte[2][2])) + nic.set_default_NIC(lte[2][2]) + nic.set_dns('8.8.8.8', '114.114.114.114') + print('eth net config: {}'.format(nic.ipconfig())) + nic.set_up() + print('eth startup success') + +dataCall.setCallback(netStatusCallback) +eth_init() + + + + + + + diff --git a/network-comm/nic/ethernet/YT8512/example_network_eth_wan_yt8512h.py b/network-comm/nic/ethernet/YT8512/example_network_eth_wan_yt8512h.py new file mode 100644 index 0000000..8a70b7a --- /dev/null +++ b/network-comm/nic/ethernet/YT8512/example_network_eth_wan_yt8512h.py @@ -0,0 +1,45 @@ +# Copyright (c) Quectel Wireless Solution, Co., Ltd.All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import ethernet + +nic = None + +def eth_init(): + print('eth init start') + nic = ethernet.YT8512H(b'\x12\x34\x56\x78\x9a\xbc','','','') + nic_info = nic.ipconfig() + print('nic net config before: {}'.format(nic_info)) + # dhcp ip config + nic.dhcp() + # static ip config + nic.set_addr('192.168.1.99', '255.255.255.0','192.168.1.1') + nic.set_dns('8.8.8.8', '114.114.114.114') + nic_info = nic.ipconfig() + print('nic net config after: {}'.format(nic_info)) + nic.set_default_NIC(nic_info[1][1]) + nic.set_up() + print('eth startup success') + +eth_init() + +# now, you can connect server by ethernet interface + + + + + + + + diff --git a/network-comm/nic/usbnet/example_network_usbnet_android.py b/network-comm/nic/usbnet/example_network_usbnet_android.py new file mode 100644 index 0000000..b6b2e51 --- /dev/null +++ b/network-comm/nic/usbnet/example_network_usbnet_android.py @@ -0,0 +1,18 @@ +from misc import USBNET,Power +import utime +import dataCall + + +if USBNET.get_worktype() != USBNET.Type_ECM: + USBNET.set_worktype(USBNET.Type_ECM) + Power.powerRestart() +while True: + info = dataCall.getInfo(1, 0) + if info[2][2] != '0.0.0.0': + print('data:',info) + break + print('Wait for data calling') + utime.sleep(2) + +USBNET.open() +print('USBNET open successed.') diff --git a/network-comm/nic/usbnet/example_network_usbnet_ios.py b/network-comm/nic/usbnet/example_network_usbnet_ios.py new file mode 100644 index 0000000..b6b2e51 --- /dev/null +++ b/network-comm/nic/usbnet/example_network_usbnet_ios.py @@ -0,0 +1,18 @@ +from misc import USBNET,Power +import utime +import dataCall + + +if USBNET.get_worktype() != USBNET.Type_ECM: + USBNET.set_worktype(USBNET.Type_ECM) + Power.powerRestart() +while True: + info = dataCall.getInfo(1, 0) + if info[2][2] != '0.0.0.0': + print('data:',info) + break + print('Wait for data calling') + utime.sleep(2) + +USBNET.open() +print('USBNET open successed.') diff --git a/network-comm/nic/usbnet/example_network_usbnet_linux.py b/network-comm/nic/usbnet/example_network_usbnet_linux.py new file mode 100644 index 0000000..b6b2e51 --- /dev/null +++ b/network-comm/nic/usbnet/example_network_usbnet_linux.py @@ -0,0 +1,18 @@ +from misc import USBNET,Power +import utime +import dataCall + + +if USBNET.get_worktype() != USBNET.Type_ECM: + USBNET.set_worktype(USBNET.Type_ECM) + Power.powerRestart() +while True: + info = dataCall.getInfo(1, 0) + if info[2][2] != '0.0.0.0': + print('data:',info) + break + print('Wait for data calling') + utime.sleep(2) + +USBNET.open() +print('USBNET open successed.') diff --git a/network-comm/nic/usbnet/example_network_usbnet_pc.py b/network-comm/nic/usbnet/example_network_usbnet_pc.py new file mode 100644 index 0000000..b8373af --- /dev/null +++ b/network-comm/nic/usbnet/example_network_usbnet_pc.py @@ -0,0 +1,18 @@ +from misc import USBNET,Power +import utime +import dataCall + + +if USBNET.get_worktype() != USBNET.Type_RNDIS: + USBNET.set_worktype(USBNET.Type_RNDIS) + Power.powerRestart() +while True: + info = dataCall.getInfo(1, 0) + if info[2][2] != '0.0.0.0': + print('data:',info) + break + print('Wait for data calling') + utime.sleep(2) + +USBNET.open() +print('USBNET open successed.')