class CC3K – control CC3000 WiFi modules

This class provides a driver for CC3000 WiFi modules. Example usage:: 这个类为CC3000 WiFi模块提供了一个驱动程序。用法:例子:

import network 进口网络 nic = network.CC3K(pyb.SPI(2), pyb.Pin.board.Y5, pyb.Pin.board.Y4, pyb.Pin.board.Y3) nic.connect(‘your-ssid’, ‘your-password’) while not nic.isconnected():

pyb.delay(50)

print(nic.ifconfig())

# now use socket as usual # 现在像往常一样使用套接字 …

For this example to work the CC3000 module must have the following connections: 在这个例子中,CC3000模块必须有以下连接:

  • MOSI connected to Y8

  • MISO connected to Y7

  • CLK connected to Y6

  • CS connected to Y5

  • VBEN connected to Y4

  • IRQ connected to Y3

It is possible to use other SPI busses and other pins for CS, VBEN and IRQ. 它是可能使用其他SPI总线和其他针的CS, VBEN和IRQ。

Constructors 构造函数 ————

class network.CC3K(spi, pin_cs, pin_en, pin_irq)

Create a CC3K driver object, initialise the CC3000 module using the given SPI bus and pins, and return the CC3K object. 创建一个CC3K驱动程序对象,使用给定的SPI总线初始化CC3000模块 并返回CC3K对象。

Arguments are: 参数:

  • spi is an SPI object which is the SPI bus that the CC3000 is connected to (the MOSI, MISO and CLK pins).

  • spi is an SPI object CC3000是哪一种SPI总线 连接到(MOSI,味噌和CLK引脚)。

  • pin_cs is a Pin object which is connected to the CC3000 CS pin.

  • pin_cs is a Pin object 连接到CC3000 CS引脚。

  • pin_en is a Pin object which is connected to the CC3000 VBEN pin.

  • pin_en is a Pin object 连接到CC3000 VBEN引脚。

  • pin_irq is a Pin object which is connected to the CC3000 IRQ pin.

  • pin_irq is a Pin object 它连接到CC3000 IRQ引脚。

All of these objects will be initialised by the driver, so there is no need to initialise them yourself. For example, you can use:: 所有这些对象都将被驱动程序初始化,所以没有必要这样做 初始化自己。例如,你可以用:

nic = network.CC3K(pyb.SPI(2), pyb.Pin.board.Y5, pyb.Pin.board.Y4, pyb.Pin.board.Y3)

Methods 方法 ——-

CC3K.connect(ssid, key=None, \*, security=WPA2, bssid=None)

Connect to a WiFi access point using the given SSID, and other security parameters. 使用给定的SSID和其他安全措施连接到WiFi接入点参数。

CC3K.disconnect()

Disconnect from the WiFi access point. 断开WiFi接入点。

CC3K.isconnected()

Returns True if connected to a WiFi access point and has a valid IP address, False otherwise. 如果连接到WiFi接入点并且有一个有效的IP地址,返回True,否则错误。

CC3K.ifconfig()

Returns a 7-tuple with (ip, subnet mask, gateway, DNS server, DHCP server, MAC address, SSID). 返回一个7元组(ip,子网掩码,网关,DNS服务器,DHCP服务器,MAC地址,SSID)。

CC3K.patch_version()

Return the version of the patch program (firmware) on the CC3000. 返回CC3000上补丁程序(固件)的版本。

CC3K.patch_program('pgm')

Upload the current firmware to the CC3000. You must pass ‘pgm’ as the first argument in order for the upload to proceed. 上传当前固件到CC3000。你必须以第一名通过’pgm’参数,以便继续上载。

Constants 常量 ———

CC3K.WEP
CC3K.WPA
CC3K.WPA2

security type to use 要使用的安全类型