esptest.esp_console.wifi_cmd module

class esptest.esp_console.wifi_cmd.ConnectedInfo(ssid: str, bssid: str = '', channel: int = 0, bandwidth: str = '', aid: int = -1, security: str = '', phy: str = '', rssi: int = -128, ip4: str = '', ip4_mask: str = '', ip4_gw: str = '', ip6: str = '', ip6_global: str = '', ip6_link_local: str = '', ip6_site_local: str = '')[source]

Bases: object

Parameters:
ssid: str
bssid: str = ''
channel: int = 0
bandwidth: str = ''
aid: int = -1
security: str = ''
phy: str = ''
rssi: int = -128
ip4: str = ''
ip4_mask: str = ''
ip4_gw: str = ''
ip6: str = ''
ip6_global: str = ''
ip6_site_local: str = ''
class esptest.esp_console.wifi_cmd.WifiCmd[source]

Bases: object

For esp-console based wifi-cmd: https://components.espressif.com/components/esp-qa/wifi-cmd

Supported wifi-cmd Versions: v0.1.x

Basic example:

from esptest import dut_wrapper
from esptest.esp_console import WifiCmd
...
with dut_wrapper(serial) as sta_dut:
    connected_info = WifiCmd.connect_wifi(sta_dut, ssid, password)
sta_ip = connected_info.ip
VERSION = 'v0.1'
IDF_WIFI_CONNECTED_PATTERN = re.compile('(connected with .+)\\n')
IDF_WIFI_CONNECTED_AP_INFO_PATTERN = re.compile('wifi:.*security:\\s*([^,]+), phy:\\s*([\\w-]+),\\s*rssi:\\s*([-\\d]+)[^\\d]')
IDF_GOT_IP4_PATTERN = re.compile('sta ip: ([\\.\\d]+), mask: ([\\.\\d]+), gw: ([\\.\\d]+)[^\\.\\d]')
WIFI_CONNECTED_PATTERN = re.compile('WIFI_EVENT_STA_CONNECTED')
GOT_IP4_PATTERN = re.compile('IPv4 address: ([\\.\\d]+)[^\\.\\d]')
classmethod detect_version(dut=None, help_text='')[source]

Detect and update wifi-cmd version from the help log.

Parameters:
  • dut (DutBase, optional) – dut object, used to get help text.

  • help_text (str, optional) – use given help text rather than getting from dut.

Returns:

wifi-cmd version, eg: 1.0

Return type:

str

classmethod gen_connect_cmd(ssid, password='', *, bssid='')[source]

generate correct connect command

Parameters:
  • sta_dut (DutBase) – which dut

  • ssid (str) – ssid of AP

  • password (str, optional) – password of AP. Defaults to ‘’.

  • bssid (str, optional) – specify bssid of AP. Defaults to None.

Returns:

connect command string

Return type:

str

classmethod connect_to_ap(sta_dut, conn_cmd, timeout=30, wait_ip=True)[source]

Connect to external AP and check connected

Parameters:
  • sta_dut (DutBase) – which dut

  • conn_cmd (str) – connect command

  • timeout (int, optional) – maximum waiting time before connected. Defaults to 30 seconds.

  • wait_ip (bool, optional) – Do not return until got ip. Defaults to True.

  • wait_ip6_num (int, optional) – TBD, please use other command to get ipv6 for now.

Returns:

an object contains connected information

Return type:

ConnectedInfo