Skip to content

Commit

Permalink
Disable WiFi/BT for qemu_esp32
Browse files Browse the repository at this point in the history
  • Loading branch information
kghost committed Nov 3, 2021
1 parent 38fe11e commit b8a60f0
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 65 deletions.
23 changes: 23 additions & 0 deletions config/esp32/components/chip/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -431,9 +431,16 @@ menu "CHIP Device Layer"

menu "WiFi Station Options"

config ENABLE_WIFI_STATION
bool "Enable CHIP WIFI STATION"
default y
help
Enables WiFi station for CHIP.

config DEFAULT_WIFI_SSID
string "Default WiFi SSID"
default ""
depends on ENABLE_WIFI_STATION
help
The SSID of network to connect to if no WiFi station configuration exists in NV storage
at the time the device boots.
Expand All @@ -443,6 +450,7 @@ menu "CHIP Device Layer"
config DEFAULT_WIFI_PASSWORD
string "Default WiFi Password"
default ""
depends on ENABLE_WIFI_STATION
help
The password for the default WiFi network.

Expand All @@ -452,20 +460,23 @@ menu "CHIP Device Layer"
int "WiFi Station Interface Reconnect Interval (ms)"
range 0 65535
default 5000
depends on ENABLE_WIFI_STATION
help
The interval at which the CHIP platform will attempt to reconnect to the configured WiFi network (in milliseconds).

config MAX_SCAN_NETWORKS_RESULTS
int "Max ScanNetworks Results"
range 0 65535
default 10
depends on ENABLE_WIFI_STATION
help
The maximum number of networks to return as a result of a CHIP NetworkProvisioning:ScanNetworks request.

config WIFI_SCAN_COMPLETION_TIMEOUT
int "WiFi Scan Completion Timeout (ms)"
range 0 65535
default 10000
depends on ENABLE_WIFI_STATION
help
The amount of time (in milliseconds) after which the CHIP platform will timeout a WiFi scan
operation that hasn't completed. A value of 0 will disable the timeout logic.
Expand All @@ -474,6 +485,7 @@ menu "CHIP Device Layer"
int "WiFi Connectivity Timeout (ms)"
range 0 65535
default 30000
depends on ENABLE_WIFI_STATION
help
The amount of time (in milliseconds) to wait for Internet connectivity to be established on
the device's WiFi station interface during a Network Provisioning TestConnectivity operation.
Expand All @@ -482,9 +494,16 @@ menu "CHIP Device Layer"

menu "WiFi AP Options"

config ENABLE_WIFI_AP
bool "Enable CHIP WIFI AP"
default y
help
Enables WiFi AP for CHIP.

config WIFI_AP_SSID_PREFIX
string "WiFi AP SSID Prefix"
default "MATTER-"
depends on ENABLE_WIFI_AP
help
A prefix string used in forming the WiFi soft-AP SSID. The remainder of the SSID
consists of the final two bytes of the device's primary WiFi MAC address in hex.
Expand All @@ -493,27 +512,31 @@ menu "CHIP Device Layer"
int "WiFi AP Channel"
range 1 14
default 1
depends on ENABLE_WIFI_AP
help
The WiFi channel number to be used by the soft-AP.

config WIFI_AP_MAX_STATIONS
int "WiFi AP Max Allowed Stations"
range 1 10
default 4
depends on ENABLE_WIFI_AP
help
The maximum number of stations allowed to connect to the soft-AP.

config WIFI_AP_BEACON_INTERVAL
int "WiFi AP Beacon Interval (ms)"
range 100 60000
default 100
depends on ENABLE_WIFI_AP
help
The beacon interval (in milliseconds) for the WiFi soft-AP.

config WIFI_AP_IDLE_TIMEOUT
int "WiFi AP Idle Timeout (ms)"
range 0 600000
default 120000
depends on ENABLE_WIFI_AP
help
The amount of time (in milliseconds) after which the CHIP platform will deactivate the soft-AP
if it has been idle.
Expand Down
12 changes: 12 additions & 0 deletions src/platform/ESP32/CHIPPlatformConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,15 @@
#define CHIP_CONFIG_ENABLE_CASE_INITIATOR CONFIG_ENABLE_CASE_INITIATOR
#define CHIP_CONFIG_ENABLE_CASE_RESPONDER CONFIG_ENABLE_CASE_RESPONDER
#define CHIP_CONFIG_DEFAULT_INCOMING_CONNECTION_IDLE_TIMEOUT CONFIG_DEFAULT_INCOMING_CONNECTION_IDLE_TIMEOUT

#ifdef CONFIG_ENABLE_WIFI_STATION
#define CHIP_DEVICE_CONFIG_ENABLE_WIFI_STATION 1
#else
#define CHIP_DEVICE_CONFIG_ENABLE_WIFI_STATION 0
#endif

#ifdef CONFIG_ENABLE_WIFI_AP
#define CHIP_DEVICE_CONFIG_ENABLE_WIFI_AP 1
#else
#define CHIP_DEVICE_CONFIG_ENABLE_WIFI_AP 0
#endif
10 changes: 5 additions & 5 deletions src/platform/ESP32/ConnectivityManagerImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,6 @@ class ConnectivityManagerImpl final : public ConnectivityManager,
CHIP_ERROR _GetWiFiCurrentMaxRate(uint64_t & currentMaxRate);
CHIP_ERROR _GetWiFiOverrunCount(uint64_t & overrunCount);

// ===== Members for internal use by the following friends.

friend ConnectivityManager & ConnectivityMgr(void);
friend ConnectivityManagerImpl & ConnectivityMgrImpl(void);

// ===== Private members reserved for use by this class only.

System::Clock::Timestamp mLastStationConnectFailTime;
Expand Down Expand Up @@ -162,6 +157,11 @@ class ConnectivityManagerImpl final : public ConnectivityManager,

#endif // CHIP_DEVICE_CONFIG_ENABLE_WIFI

// ===== Members for internal use by the following friends.

friend ConnectivityManager & ConnectivityMgr(void);
friend ConnectivityManagerImpl & ConnectivityMgrImpl(void);

static ConnectivityManagerImpl sInstance;
};

Expand Down
60 changes: 1 addition & 59 deletions src/test_driver/esp32/main/main_app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,6 @@ using namespace ::chip::DeviceLayer;

const char * TAG = "CHIP-tests";

static int app_entropy_source(void * data, unsigned char * output, size_t len, size_t * olen)
{
esp_fill_random(output, len);
*olen = len;
return 0;
}

static void tester_task(void * pvParameters)
{
ESP_LOGI(TAG, "Starting CHIP tests!");
Expand Down Expand Up @@ -74,56 +67,5 @@ extern "C" void app_main()
exit(err);
}

// Initialize the LwIP core lock. This must be done before the ESP
// tcpip_adapter layer is initialized.
CHIP_ERROR error = PlatformMgrImpl().InitLwIPCoreLock();
if (error != CHIP_NO_ERROR)
{
ESP_LOGE(TAG, "PlatformMgr().InitLocks() failed: %s", ErrorStr(error));
exit(1);
}

err = esp_netif_init();
if (err != ESP_OK)
{
ESP_LOGE(TAG, "esp_netif_init() failed: %s", esp_err_to_name(err));
exit(err);
}

// Arrange for the ESP event loop to deliver events into the CHIP Device layer.
err = esp_event_loop_create_default();
if (err != ESP_OK)
{
ESP_LOGE(TAG, "esp_event_loop_create_default() failed: %s", esp_err_to_name(err));
exit(err);
}
esp_netif_create_default_wifi_ap();
esp_netif_create_default_wifi_sta();

err = esp_event_handler_register(WIFI_EVENT, ESP_EVENT_ANY_ID, PlatformManagerImpl::HandleESPSystemEvent, NULL);
if (err != ESP_OK)
{
ESP_LOGE(TAG, "esp_event_handler_register() failed for WIFI_EVENT: %s", esp_err_to_name(err));
exit(err);
}
err = esp_event_handler_register(IP_EVENT, ESP_EVENT_ANY_ID, PlatformManagerImpl::HandleESPSystemEvent, NULL);
if (err != ESP_OK)
{
ESP_LOGE(TAG, "esp_event_handler_register() failed for IP_EVENT: %s", esp_err_to_name(err));
exit(err);
}

error = Crypto::add_entropy_source(app_entropy_source, NULL, 16);
if (error != CHIP_NO_ERROR)
{
ESP_LOGE(TAG, "add_entropy_source() failed: %s", ErrorStr(error));
exit(error.AsInteger());
}

xTaskCreate(tester_task, "tester", 12288, (void *) NULL, tskIDLE_PRIORITY + 10, NULL);

while (1)
{
vTaskDelay(50 / portTICK_PERIOD_MS);
}
tester_task(nullptr);
}
6 changes: 5 additions & 1 deletion src/test_driver/esp32/sdkconfig_qemu.defaults
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@ CONFIG_ESP32_PANIC_PRINT_REBOOT=y
CONFIG_ESP32_PANIC_PRINT_HALT=n

# enable BT
CONFIG_BT_ENABLED=y
CONFIG_BT_ENABLED=n

# disable WiFi
CONFIG_ENABLE_WIFI_STATION=n
CONFIG_ENABLE_WIFI_AP=n

# Use a custom partition table
CONFIG_PARTITION_TABLE_CUSTOM=y
Expand Down

0 comments on commit b8a60f0

Please sign in to comment.