diff --git a/examples/network/simple_sniffer/README.md b/examples/network/simple_sniffer/README.md index 2af07bb0965..0b57e6e64a4 100644 --- a/examples/network/simple_sniffer/README.md +++ b/examples/network/simple_sniffer/README.md @@ -17,7 +17,10 @@ This example is based on console component. For more information about console, ### Hardware Required -To run this example with WiFi interface, you should have one ESP32 dev board integrated with a SD card slot (e.g. [ESP-WROVER-KIT](https://docs.espressif.com/projects/esp-idf/en/latest/hw-reference/modules-and-boards.html#esp-wrover-kit-v4-1)) or just connect [ESP32-DevKitC](https://docs.espressif.com/projects/esp-idf/en/latest/hw-reference/modules-and-boards.html#esp32-devkitc-v4) to a SD card breakout board. To run this example with Ethernet interface option, you should have one ESP32 dev board with physical layer Ethernet support (e.g. [ESP32-Ethernet-Kit](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/hw-reference/esp32/get-started-ethernet-kit.html#)) or connect SPI-Ethernet module (e.g. DM9051) to your dev board. +To run this example with the WiFi interface, use an ESP32 development board with an integrated SD card slot (for example, [ESP-WROVER-KIT](https://docs.espressif.com/projects/esp-idf/en/v4.4/esp32/hw-reference/esp32/get-started-wrover-kit.html)), or connect an SD card breakout board to your dev kit. Verify that the default SD pins are available on your board; if not, update the pin assignments in the project configuration. + +To run this example with the Ethernet interface, use an ESP32 development board with a physical layer Ethernet (PHY) interface (for example, [ESP32-Ethernet-Kit](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/hw-reference/esp32/get-started-ethernet-kit.html#)), or connect an SPI-Ethernet module (for example, DM9051) to your board. + If you want to send packets to host, make sure to connect ESP32 to some kind of [JTAG adapter](https://docs.espressif.com/projects/esp-idf/en/latest/api-guides/jtag-debugging/index.html#jtag-debugging-selecting-jtag-adapter). #### Ethernet Pin Assignment diff --git a/examples/network/simple_sniffer/main/Kconfig.projbuild b/examples/network/simple_sniffer/main/Kconfig.projbuild index 627fcd17066..cb8f1abcc97 100644 --- a/examples/network/simple_sniffer/main/Kconfig.projbuild +++ b/examples/network/simple_sniffer/main/Kconfig.projbuild @@ -46,6 +46,37 @@ menu "Example Configuration" help Use SPI mode. endchoice + menu "SD card pin configuration (SPI)" + depends on SNIFFER_SD_SPI_MODE + + config SNIFFER_PIN_MOSI + int "MOSI GPIO number" + range ENV_GPIO_RANGE_MIN ENV_GPIO_OUT_RANGE_MAX + default 15 + help + GPIO pin number for SPI MOSI (Master Out Slave In). + + config SNIFFER_PIN_MISO + int "MISO GPIO number" + range ENV_GPIO_RANGE_MIN ENV_GPIO_IN_RANGE_MAX + default 2 + help + GPIO pin number for SPI MISO (Master In Slave Out). + + config SNIFFER_PIN_CLK + int "CLK GPIO number" + range ENV_GPIO_RANGE_MIN ENV_GPIO_OUT_RANGE_MAX + default 14 + help + GPIO pin number for SPI Clock. + + config SNIFFER_PIN_CS + int "CS GPIO number" + range ENV_GPIO_RANGE_MIN ENV_GPIO_OUT_RANGE_MAX + default 13 + help + GPIO pin number for SPI Chip Select. + endmenu config SNIFFER_MOUNT_POINT string "SD card mount point in the filesystem" default "/sdcard" diff --git a/examples/network/simple_sniffer/main/simple_sniffer_example_main.c b/examples/network/simple_sniffer/main/simple_sniffer_example_main.c index 1c74842479a..ef939af8bb1 100644 --- a/examples/network/simple_sniffer/main/simple_sniffer_example_main.c +++ b/examples/network/simple_sniffer/main/simple_sniffer_example_main.c @@ -35,20 +35,10 @@ #endif #if CONFIG_SNIFFER_SD_SPI_MODE - -#if CONFIG_IDF_TARGET_ESP32 || CONFIG_IDF_TARGET_ESP32S2 -#define PIN_NUM_MISO 2 -#define PIN_NUM_MOSI 15 -#define PIN_NUM_CLK 14 -#define PIN_NUM_CS 13 - -#elif CONFIG_IDF_TARGET_ESP32C3 -#define PIN_NUM_MISO 18 -#define PIN_NUM_MOSI 9 -#define PIN_NUM_CLK 8 -#define PIN_NUM_CS 19 -#endif //CONFIG_IDF_TARGET_ESP32 || CONFIG_IDF_TARGET_ESP32S2 - +#define PIN_NUM_MISO CONFIG_SNIFFER_PIN_MISO +#define PIN_NUM_MOSI CONFIG_SNIFFER_PIN_MOSI +#define PIN_NUM_CLK CONFIG_SNIFFER_PIN_CLK +#define PIN_NUM_CS CONFIG_SNIFFER_PIN_CS #endif // CONFIG_SNIFFER_SD_SPI_MODE static const char *TAG = "example"; diff --git a/examples/network/simple_sniffer/sdkconfig.ci.sdcard b/examples/network/simple_sniffer/sdkconfig.ci.sdcard new file mode 100644 index 00000000000..74d466bbca9 --- /dev/null +++ b/examples/network/simple_sniffer/sdkconfig.ci.sdcard @@ -0,0 +1,2 @@ +# Enable SD Card Interface. +CONFIG_SNIFFER_SD_SPI_MODE=y