diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/wipy/reset/reset.py | 12 | ||||
-rw-r--r-- | tests/wipy/reset/reset.py.exp | 1 | ||||
-rw-r--r-- | tests/wipy/wlan/wlan.py | 166 | ||||
-rw-r--r-- | tests/wipy/wlan/wlan.py.exp | 47 |
4 files changed, 226 insertions, 0 deletions
diff --git a/tests/wipy/reset/reset.py b/tests/wipy/reset/reset.py new file mode 100644 index 0000000000..c1990a4af3 --- /dev/null +++ b/tests/wipy/reset/reset.py @@ -0,0 +1,12 @@ +''' +Reset script for the cc3200 boards +This is needed to force the board to reboot +with the default WLAN AP settings +''' + +from pyb import WDT +import time + +wdt = WDT(timeout=1000) +print(wdt) +time.sleep_ms(900) diff --git a/tests/wipy/reset/reset.py.exp b/tests/wipy/reset/reset.py.exp new file mode 100644 index 0000000000..4b6cc11e0d --- /dev/null +++ b/tests/wipy/reset/reset.py.exp @@ -0,0 +1 @@ +<WDT> diff --git a/tests/wipy/wlan/wlan.py b/tests/wipy/wlan/wlan.py new file mode 100644 index 0000000000..d4f9b9fa94 --- /dev/null +++ b/tests/wipy/wlan/wlan.py @@ -0,0 +1,166 @@ +''' +WLAN test for the CC3200 based boards. +''' + +from network import WLAN +import os +import time +import testconfig +import pyb + +machine = os.uname().machine +if not 'LaunchPad' in machine and not 'WiPy' in machine: + raise Exception('Board not supported!') + + +def wait_for_connection(wifi, timeout=10): + while not wifi.isconnected() and timeout > 0: + time.sleep(1) + timeout -= 1 + if wifi.isconnected(): + print('Connected') + else: + print('Connection failed!') + + +wifi = WLAN() +print(wifi.mode() == WLAN.STA) +print(wifi.antenna() == WLAN.INT_ANT) + +wifi = WLAN(mode=WLAN.AP) +print(wifi.mode() == WLAN.AP) +print(wifi.channel() == 1) +print(wifi.auth() == None) +print(wifi.antenna() == WLAN.INT_ANT) +wifi = WLAN(0, mode=WLAN.AP, ssid='test-wlan', auth=(WLAN.WPA, '123456abc'), channel=7) +print(wifi.mode() == WLAN.AP) +print(wifi.channel() == 7) +print(wifi.ssid() == 'test-wlan') +print(wifi.auth() == (WLAN.WPA, '123456abc')) +print(wifi.antenna() == WLAN.INT_ANT) + +wifi = WLAN(mode=WLAN.STA) +print(wifi.mode() == WLAN.STA) +scan_r = wifi.scan() +print(len(scan_r) > 3) +for net in scan_r: + if net.ssid == testconfig.wlan_ssid: + print('Network found') + break + +wifi.mode(WLAN.STA) +print(wifi.mode() == WLAN.STA) +wifi.channel(7) +print(wifi.channel() == 7) +wifi.ssid('t-wlan') +print(wifi.ssid() == 't-wlan') +wifi.auth(None) +print(wifi.auth() == None) +wifi.auth((WLAN.WEP, '11223344556677889900')) +print(wifi.auth() == (WLAN.WEP, '11223344556677889900')) +wifi.antenna(WLAN.INT_ANT) +print(wifi.antenna() == WLAN.INT_ANT) + +wifi.antenna(WLAN.EXT_ANT) +print(wifi.antenna() == WLAN.EXT_ANT) +scan_r = wifi.scan() +print(len(scan_r) > 3) +for net in scan_r: + if net.ssid == testconfig.wlan_ssid: + print('Network found') + break + +wifi.antenna(WLAN.INT_ANT) +wifi.mode(WLAN.STA) +print(wifi.mode() == WLAN.STA) +wifi.connect(testconfig.wlan_ssid, auth=testconfig.wlan_auth, timeout=10000) +wait_for_connection(wifi) + +wifi.ifconfig(config='dhcp') +wait_for_connection(wifi) +print('0.0.0.0' not in wifi.ifconfig()) +wifi.ifconfig(0, ('192.168.178.109', '255.255.255.0', '192.168.178.1', '8.8.8.8')) +wait_for_connection(wifi) +print(wifi.ifconfig(0) == ('192.168.178.109', '255.255.255.0', '192.168.178.1', '8.8.8.8')) +wait_for_connection(wifi) + +print(wifi.isconnected() == True) +wifi.disconnect() +print(wifi.isconnected() == False) + +t0 = time.ticks_ms() +wifi.connect(testconfig.wlan_ssid, auth=testconfig.wlan_auth, timeout=0) +print(time.ticks_ms() - t0 < 500) + +wifi.disconnect() +print(wifi.isconnected() == False) + +# test init again +wifi.init(WLAN.AP, ssid='www.wipy.io', auth=None, channel=5, antenna=WLAN.INT_ANT) + +# next ones MUST raise +try: + wifi.init(mode=12345) +except: + print('Exception') + +try: + wifi.init(1, mode=WLAN.AP) +except: + print('Exception') + +try: + wifi.init(mode=WLAN.AP, ssid=None) +except: + print('Exception') + +try: + wifi = WLAN(mode=WLAN.AP, channel=12) +except: + print('Exception') + +try: + wifi.antenna(2) +except: + print('Exception') + +try: + wifi.mode(10) +except: + print('Exception') + +try: + wifi.ssid('11111sdfasdfasdfasdf564sdf654asdfasdf123451245ssdgfsdf1111111111111111111111111234123412341234asdfasdf') +except: + print('Exception') + +try: + wifi.auth((0)) +except: + print('Exception') + +try: + wifi.auth((0, None)) +except: + print('Exception') + +try: + wifi.auth((10, 10)) +except: + print('Exception') + +try: + wifi.channel(0) +except: + print('Exception') + +try: + wifi.ifconfig(1, 'dhcp') +except: + print('Exception') + +try: + wifi.ifconfig(config=()) +except: + print('Exception') + diff --git a/tests/wipy/wlan/wlan.py.exp b/tests/wipy/wlan/wlan.py.exp new file mode 100644 index 0000000000..407c31db98 --- /dev/null +++ b/tests/wipy/wlan/wlan.py.exp @@ -0,0 +1,47 @@ +True +True +True +True +True +True +True +True +True +True +True +True +True +Network found +True +True +True +True +True +True +True +True +Network found +True +Connected +Connected +True +Connected +True +Connected +True +True +True +True +Exception +Exception +Exception +Exception +Exception +Exception +Exception +Exception +Exception +Exception +Exception +Exception +Exception |