Skip to content

Commit

Permalink
Merge branch 'feat/add_example_usb_dongle' into 'master'
Browse files Browse the repository at this point in the history
feat(usb_dongle): add usb dongle example

Closes AEG-1368

See merge request ae_group/esp-iot-solution!971
  • Loading branch information
leeebo committed May 23, 2024
2 parents 453f4d3 + a694ab1 commit 20b5ccd
Show file tree
Hide file tree
Showing 72 changed files with 7,043 additions and 3 deletions.
22 changes: 19 additions & 3 deletions .gitlab/ci/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
- pip install idf_build_apps
- python tools/build_apps.py ${EXAMPLE_DIR} --config ${EXAMPLE_CONFIG} -t all -vv

.build_idf_release_version:
.build_idf_active_release_version:
parallel:
matrix:
- IMAGE: espressif/idf:release-v4.4
Expand All @@ -48,6 +48,14 @@
- IMAGE: espressif/idf:release-v5.2
- IMAGE: espressif/idf:release-v5.3

.build_idf_version_larger_than_v5_0:
parallel:
matrix:
- IMAGE: espressif/idf:release-v5.0
- IMAGE: espressif/idf:release-v5.1
- IMAGE: espressif/idf:release-v5.2
- IMAGE: espressif/idf:release-v5.3

build_example_audio_wav_player:
extends:
- .build_examples_template
Expand Down Expand Up @@ -565,6 +573,14 @@ build_example_ulp_lp_cpu_lp_environment_sensor:
variables:
EXAMPLE_DIR: examples/ulp/lp_cpu/lp_environment_sensor

build_example_usb_device_usb_dongle:
extends:
- .build_examples_template
- .rules:build:example_usb_device_usb_dongle
- .build_idf_version_larger_than_v5_0
variables:
EXAMPLE_DIR: examples/usb/device/usb_dongle

build_example_usb_device_usb_uart_bridge:
extends:
- .build_examples_template
Expand All @@ -580,7 +596,7 @@ build_example_usb_device_usb_uac:
extends:
- .build_examples_template
- .rules:build:example_usb_device_usb_uac
- .build_idf_release_version
- .build_idf_active_release_version
variables:
EXAMPLE_DIR: examples/usb/device/usb_uac

Expand Down Expand Up @@ -1057,7 +1073,7 @@ build_components_led_lightbulb_driver_test_apps:
extends:
- .build_examples_template
- .rules:build:components_led_lightbulb_driver_test_apps
- .build_idf_release_version
- .build_idf_active_release_version
variables:
EXAMPLE_DIR: components/led/lightbulb_driver/test_apps

Expand Down
12 changes: 12 additions & 0 deletions .gitlab/ci/rules.yml
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,9 @@
.patterns-example_sensors_sensor_hub_monitor: &patterns-example_sensors_sensor_hub_monitor
- "examples/sensors/sensor_hub_monitor/**/*"

.patterns-example_usb_device_usb_dongle: &patterns-example_usb_device_usb_dongle
- "examples/usb/device/usb_dongle/**/*"

.patterns-example_ulp_lp_cpu_lp_environment_sensor: &patterns-example_ulp_lp_cpu_lp_environment_sensor
- "examples/ulp/lp_cpu/lp_environment_sensor/**/*"

Expand Down Expand Up @@ -1048,6 +1051,15 @@
- <<: *if-dev-push
changes: *patterns-example_usb_device_usb_hid_device

.rules:build:example_usb_device_usb_dongle:
rules:
- <<: *if-protected
- <<: *if-label-build
- <<: *if-dev-push
changes: *patterns-build_system
- <<: *if-dev-push
changes: *patterns-example_usb_device_usb_dongle

.rules:build:example_usb_device_usb_uart_bridge:
rules:
- <<: *if-protected
Expand Down
4 changes: 4 additions & 0 deletions examples/.build-rules.yml
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,10 @@ examples/sensors/sensor_hub_monitor:
enable:
- if: IDF_TARGET in ["esp32","esp32s2"] and (IDF_VERSION_MAJOR == 4 and IDF_VERSION_MINOR == 4)

examples/usb/device/usb_dongle:
enable:
- if: SOC_USB_OTG_SUPPORTED == 1

examples/ulp/lp_cpu/lp_environment_sensor:
enable:
- if: IDF_TARGET in ["esp32c6"]
Expand Down
7 changes: 7 additions & 0 deletions examples/usb/device/usb_dongle/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# The following lines of boilerplate have to be in your project's
# CMakeLists in this exact order for cmake to work correctly
cmake_minimum_required(VERSION 3.5)

add_compile_options(-fdiagnostics-color=always)
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(usb_dongle)
269 changes: 269 additions & 0 deletions examples/usb/device/usb_dongle/Commands.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,269 @@
### 命令介绍

#### 1.help

**Function:**

列出所有注册的命令

**Command:**

```
help
```

**Response:**

```
help:
Lists all the registered commands
ap <ssid> [<password>]: configure ssid and password
sta -s <ssid> [-p <password>]: join specified soft-AP
sta -d: disconnect specified soft-AP
mode <mode>: <sta> station mode; <ap> ap mode
smartconfig [op]: op:1, start smartconfig; op:0, stop smartconfig
scan [<ssid>]: <ssid> SSID of AP want to be scanned
ram: Get the current size of free heap memory and minimum size of free heap memory
restart: Software reset of the chip
version: Get version of chip and SDK
>
```

#### 2.ap

**Function:**

设置 AP 模式、查询 AP 设置

**Set Command:**

```
ap Soft_AP espressif
```

**Query Command:**

```
ap
```

**Response:**

```
AP mode:Soft_AP,espressif
>
```

Note:

>password 为可选项,若不配置默认不加密
#### 3.sta

**Function:**

启动 Station 模式、查询所连接 AP 信息

**Set Command:**

```
sta -s AP_Test -p espressif
```

**Query Command:**

```
sta
```

**Response:**

```
<ssid>,<channel>,<listen_interval>,<authmode>
>
```

| authmode_value | mode |
| :------------: | :------------------------ |
| 0 | WIFI_AUTH_OPEN |
| 1 | WIFI_AUTH_WEP |
| 2 | WIFI_AUTH_WPA_PSK |
| 3 | WIFI_AUTH_WPA2_PSK |
| 4 | WIFI_AUTH_WPA_WPA2_PSK |
| 5 | WIFI_AUTH_WPA2_ENTERPRISE |
| 6 | WIFI_AUTH_WPA3_PSK |
| 7 | WIFI_AUTH_WPA2_WPA3_PSK |
| 8 | WIFI_AUTH_WAPI_PSK |

Note:

>password 为可选项
**Function:**

断开与 AP 的连接

**Set Command:**

```
sta -d
```

**Response:**

```
OK
>
```

#### 4.mode

**Function:**

设置 WiFi 模式

**Command:**

* 设置 Station 模式

```
mode sta
```
* 设置 AP 模式
```
mode ap
```
#### 5.smartconfig
**Function:**
* 开启 SmartConfig 配网
**Command:**
```
smartconfig 1
```
**Response:**
```
>SSID:FAST_XLZ,PASSWORD:12345678
OK
>
```
* 关闭 SmartConfig 配网
**Command:**
```
smartconfig 0
```
**Response:**
```
OK
>
```
Note:
>使用 `smartconfig 1` 命令开启 SmartConfig 配网并成功连接后,不需要再使用 `smartconfig 0` 命令来关闭 SmartConfig 配网
>
>`smartconfig 0` 命令只需要在 SmartConfig 配网失败时进行调用
配网步骤:
>* 下载 ESPTOUCH APP :[Android source code](https://github.com/EspressifApp/EsptouchForAndroid) [iOS source code](https://github.com/EspressifApp/EsptouchForIOS)
>* 确保你的手机连接至目标 AP(2.4GHz)
>* 打开 ESPTOUCH APP 输入 password 并确认
>* PC 端通过 USB 端口发送 `smartconfig 1` 命令
#### 6.scan
**Function:**
扫描 AP 并列出对应 SSID 以及 RSSI
**Command:**
* 扫描特定 AP
```
scan <SSID>
```
* 扫描所有 AP
```
scan
```
**Response:**
```
>
[ssid][rssi=-22]
>
```
#### 7.ram
**Function:**
获取当前剩余内存大小以及系统运行期间最小时内存大小
**Command:**
```
ram
```
**Response:**
```
free heap size: 132612, min heap size: 116788
>
```
#### 8.restart
**Function:**
重启系统
**Command:**
```
restart
```
#### 9.version
**Function:**
获取当前 IDF 版本以及芯片信息
**Command:**
```
version
```
**Response:**
```
IDF Version:v4.4-dev-2571-gb1c3ee71c5
Chip info:
cores:1
feature:/802.11bgn/External-Flash:2 MB
revision number:0
>
```
Loading

0 comments on commit 20b5ccd

Please sign in to comment.