Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions network-comm/nic/ethernet/CH395/example_network_eth_lan_ch395.py
Original file line number Diff line number Diff line change
@@ -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()







45 changes: 45 additions & 0 deletions network-comm/nic/ethernet/CH395/example_network_eth_wan_ch395.py
Original file line number Diff line number Diff line change
@@ -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








55 changes: 55 additions & 0 deletions network-comm/nic/ethernet/DM9051/example_network_eth_lan_dm9051.py
Original file line number Diff line number Diff line change
@@ -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()







45 changes: 45 additions & 0 deletions network-comm/nic/ethernet/DM9051/example_network_eth_wan_dm9051.py
Original file line number Diff line number Diff line change
@@ -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








Original file line number Diff line number Diff line change
@@ -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()







Original file line number Diff line number Diff line change
@@ -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








18 changes: 18 additions & 0 deletions network-comm/nic/usbnet/example_network_usbnet_android.py
Original file line number Diff line number Diff line change
@@ -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.')
18 changes: 18 additions & 0 deletions network-comm/nic/usbnet/example_network_usbnet_ios.py
Original file line number Diff line number Diff line change
@@ -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.')
18 changes: 18 additions & 0 deletions network-comm/nic/usbnet/example_network_usbnet_linux.py
Original file line number Diff line number Diff line change
@@ -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.')
18 changes: 18 additions & 0 deletions network-comm/nic/usbnet/example_network_usbnet_pc.py
Original file line number Diff line number Diff line change
@@ -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.')