Full implemented in cc3000_test3.py
Try it out.
Code: Select all
#cc3000_test1.py
SSID='';password=''
import network
#
pyb.LED(1).on()
nic = network.CC3K(pyb.SPI(2), pyb.Pin.board.Y5, pyb.Pin.board.Y4, pyb.Pin.board.Y3)
pyb.LED(1).off()
print(nic.isconnected())
pyb.LED(2).on()
nic.connect(SSID, password)
pyb.LED(2).off()
print(nic.ifconfig())
print(nic.isconnected())
while (not nic.isconnected()):
print('...Waiting...')
pyb.delay(250)
print(nic.isconnected())
print(nic.ifconfig())
#####################################
# after a hard-reset
===
False
('0.0.0.0', '0.0.0.0', '0.0.0.0', '0.0.0.0', '0.0.0.0', '00:00:00:00:00:00', '\\')
False
...Waiting...
...Waiting...
...Waiting...
True
('10.0.0.2', '255.255.255.0', '10.0.0.1', '10.0.0.1', '10.0.0.1', '08:00:28:57:93:ff', 'Hipokrit')
>>>
#####################################
# after a soft-reset (ctrl-d)
===
Traceback (most recent call last):
File "<stdin>", line 6, in <module>
OSError: failed to init CC3000 module
>>>
#####################################
#####################################
Code: Select all
#cc3000_test2.py
SSID='';password=''
import network
# 1
pyb.Pin('Y4').low()#vben, if I don't set this low and
pyb.udelay(250)#150 #no delay it saye's (OSError: failed to init CC3000 module)
# 1
pyb.LED(1).on()
nic = network.CC3K(pyb.SPI(2), pyb.Pin.board.Y5, pyb.Pin.board.Y4, pyb.Pin.board.Y3)
pyb.LED(1).off()
print(nic.isconnected())
pyb.LED(2).on()
nic.connect(SSID, password)
pyb.LED(2).off()
print(nic.ifconfig())
print(nic.isconnected())
while (not nic.isconnected()):
print('...Waiting...')
pyb.delay(250)
print(nic.isconnected())
print(nic.ifconfig())
#####################################
# after a hard-reset
===
False
('0.0.0.0', '0.0.0.0', '0.0.0.0', '0.0.0.0', '0.0.0.0', '00:00:00:00:00:00', '\\')
False
...Waiting...
...Waiting...
...Waiting...
True
('10.0.0.2', '255.255.255.0', '10.0.0.1', '10.0.0.1', '10.0.0.1', '08:00:28:57:93:ff', 'Hipokrit')
>>>
#####################################
# after a soft-reset (ctrl-d)
===
True
('0.0.0.0', '0.0.0.0', '0.0.0.0', '0.0.0.0', '0.0.0.0', '00:00:00:00:00:00', '\\')
True
True
('0.0.0.0', '0.0.0.0', '0.0.0.0', '0.0.0.0', '0.0.0.0', '00:00:00:00:00:00', '\\')
>>>
#####################################
#####################################
Code: Select all
#cc3000_test3.py
SSID='';password=''
import network
# 1
pyb.Pin('Y4').low()#vben, if I don't set this low and
pyb.udelay(250)#150 #no delay it saye's (OSError: failed to init CC3000 module)
# 1
# 2
a=[('0.0.0.0')]
b=tuple(a)
# 2
pyb.LED(1).on()
nic = network.CC3K(pyb.SPI(2), pyb.Pin.board.Y5, pyb.Pin.board.Y4, pyb.Pin.board.Y3)
pyb.LED(1).off()
print(nic.isconnected())
pyb.LED(2).on()
nic.connect(SSID, password)
pyb.LED(2).off()
print(nic.ifconfig())
print(nic.isconnected())
#while (not nic.isconnected()):
# print('...Waiting...')
# pyb.delay(250)
# 2
while (b == nic.ifconfig()[0:1]):
print('...waiting...')
pyb.delay(200)#50
# 2
print(nic.isconnected())
print(nic.ifconfig())
#####################################
# after a hard-reset
===
False
('0.0.0.0', '0.0.0.0', '0.0.0.0', '0.0.0.0', '0.0.0.0', '00:00:00:00:00:00', '\\')
False
...waiting...
...waiting...
...waiting...
...waiting...
True
('10.0.0.2', '255.255.255.0', '10.0.0.1', '10.0.0.1', '10.0.0.1', '08:00:28:57:93:ff', 'Hipokrit')
>>>
#####################################
# after a soft-reset (ctrl-d)
===
True
('0.0.0.0', '0.0.0.0', '0.0.0.0', '0.0.0.0', '0.0.0.0', '00:00:00:00:00:00', '\\')
True
...waiting...
...waiting...
...waiting...
...waiting...
True
('10.0.0.2', '255.255.255.0', '10.0.0.1', '10.0.0.1', '10.0.0.1', '08:00:28:57:93:ff', 'Hipokrit')
>>>
#####################################
#####################################