0
0
Fork 0

feat wifi scan using http/json

This commit is contained in:
kerms 2024-02-14 16:06:31 +08:00
parent b00f2b2dd4
commit f8b7592f13
27 changed files with 637 additions and 16583 deletions

5
.gitignore vendored
View File

@ -4,4 +4,7 @@ tmp/
.history/
sdkconfig.old
.idea/
dependencies.lock
dependencies.lock
**/priv_note.md
_priv_tools/
project_components/wifi_manager/wifi_configuration.h

214
LICENSE
View File

@ -1,21 +1,201 @@
MIT License
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
Copyright (c) 2020 windowsair
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
1. Definitions.
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

107
README.md
View File

@ -2,12 +2,6 @@
![image](https://user-images.githubusercontent.com/17078589/107857220-05ecef00-6e68-11eb-9fa0-506b32052dba.png)
[![Build Status](https://github.com/windowsair/wireless-esp8266-dap/workflows/build/badge.svg?branch=master)](https://github.com/windowsair/wireless-esp8266-dap/actions?query=branch%3Amaster) master 
[![Build Status](https://github.com/windowsair/wireless-esp8266-dap/workflows/build/badge.svg?branch=develop)](https://github.com/windowsair/wireless-esp8266-dap/actions?query=branch%3Adevelop) develop
[![](https://img.shields.io/badge/license-MIT-green.svg?style=flat-square)](https://github.com/windowsair/wireless-esp8266-dap/LICENSE) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-blue.svg?style=flat-square)](https://github.com/windowsair/wireless-esp8266-dap/pulls) [![%e2%9d%a4](https://img.shields.io/badge/made%20with-%e2%9d%a4-ff69b4.svg?style=flat-square)](https://github.com/windowsair/wireless-esp8266-dap)
[中文](README_CN.md)
## Introduce
@ -27,7 +21,6 @@ For Keil users, we now also support [elaphureLink](https://github.com/windowsair
## Feature
1. SoC Compatibility
- [x] ESP8266/8285
- [x] ESP32
- [x] ESP32C3
@ -55,62 +48,19 @@ For Keil users, we now also support [elaphureLink](https://github.com/windowsair
The default connected WIFI SSID is `DAP` or `OTA` , password `12345678`
Support for specifying multiple possible WAP. It can be added here: [wifi_configuration.h](main/wifi_configuration.h)
Support for specifying multiple possible WAP. It can be added here: [wifi_configuration.h](project_components/wifi_manager/wifi_configuration.h)
You can also specify your IP in the above file (We recommend using the static address binding feature of the router).
![WIFI](https://user-images.githubusercontent.com/17078589/118365659-517e7880-b5d0-11eb-9a5b-afe43348c2ba.png)
There is built-in ipv4 only mDNS server. You can access the device using `dap.local`.
> The mDNS in ESP8266 only supports ipv4.
![mDNS](https://user-images.githubusercontent.com/17078589/149659052-7b29533f-9660-4811-8125-f8f50490d762.png)
### Debugger
<details>
<summary>ESP8266</summary>
| SWD | |
|----------------|--------|
| SWCLK | GPIO14 |
| SWDIO | GPIO13 |
| TVCC | 3V3 |
| GND | GND |
--------------
| JTAG | |
|--------------------|---------|
| TCK | GPIO14 |
| TMS | GPIO13 |
| TDI | GPIO4 |
| TDO | GPIO16 |
| nTRST \(optional\) | GPIO0\* |
| nRESET | GPIO5 |
| TVCC | 3V3 |
| GND | GND |
--------------
| Other | |
|--------------------|---------------|
| LED\_WIFI\_STATUS | GPIO15 |
| Tx | GPIO2 |
| Rx | GPIO3 (U0RXD) |
> Rx and Tx is used for uart bridge, not enabled by default.
</details>
<details>
<summary>ESP32</summary>
@ -185,31 +135,11 @@ There is built-in ipv4 only mDNS server. You can access the device using `dap.lo
| Rx | GPIO18 |
> Rx and Tx is used for uart bridge, not enabled by default.
</details>
----
## Hardware Reference
Only a hardware reference for the ESP8266 is currently available.
Here we provide a simple example for reference:
![sch](https://user-images.githubusercontent.com/17078589/150284806-e6dff0fa-4fe1-4d86-ac45-3b657fbea6b7.png)
***Alternatively, you can connect directly with wires as we gave at the beginning, without additional circuits.***
In addition, a complete hardware reference design is available from contributors, see [circuit](circuit)
------
## Build And Flash
@ -222,30 +152,6 @@ See: [Build with Github Action](https://github.com/windowsair/wireless-esp8266-d
### General build and Flash
<details>
<summary>ESP8266</summary>
1. Get ESP8266 RTOS Software Development Kit
The SDK is already included in the project. Please don't use other versions of the SDK.
2. Build & Flash
Build with ESP-IDF build system.
More information can be found at the following link: [Build System](https://docs.espressif.com/projects/esp-idf/en/latest/api-guides/build-system.html "Build System")
The following example shows a possible way to build on Windows:
```bash
# Build
python ./idf.py build
# Flash
python ./idf.py -p /dev/ttyS5 flash
```
</details>
<details>
<summary>ESP32/ESP32C3</summary>
@ -269,14 +175,8 @@ idf.py build
idf.py -p /dev/ttyS5 flash
```
> The `idf.py` in the project root directory is only applicable to the old ESP8266 target. Don't use it in ESP32.
</details>
> We also provided sample firmware for quick evaluation. See [Releases](https://github.com/windowsair/wireless-esp8266-dap/releases)
## Usage
1. Get USBIP project
@ -330,7 +230,6 @@ Some LAN broadcast packets can cause serious impact, including:
- Logitech Arx Control
- ...
For ESP8266, this is not far from UDP FLOOD...😰
It is also affected by the surrounding radio environment, your AP situation (some NICs have terrible AP performance), distance, etc.
@ -481,7 +380,7 @@ Credits to the following project, people and organizations:
> - https://github.com/ARM-software/CMSIS_5 for CMSIS
> - https://github.com/cezanne/usbip-win for usbip windows
- [@windowsair](https://www.github.com/windowsair/wireless-esp8266-dap)
- [@HeavenSpree](https://www.github.com/HeavenSpree)
- [@Zy19930907](https://www.github.com/Zy19930907)
- [@caiguang1997](https://www.github.com/caiguang1997)
@ -490,5 +389,5 @@ Credits to the following project, people and organizations:
## License
[MIT LICENSE](LICENSE)
[Apache2.0 LICENSE](LICENSE)

View File

@ -4,10 +4,6 @@
![image](https://user-images.githubusercontent.com/17078589/107857220-05ecef00-6e68-11eb-9fa0-506b32052dba.png)
[![Build Status](https://github.com/windowsair/wireless-esp8266-dap/workflows/build/badge.svg?branch=master)](https://github.com/windowsair/wireless-esp8266-dap/actions?query=branch%3Amaster) master 
[![Build Status](https://github.com/windowsair/wireless-esp8266-dap/workflows/build/badge.svg?branch=develop)](https://github.com/windowsair/wireless-esp8266-dap/actions?query=branch%3Adevelop) develop
[![](https://img.shields.io/badge/license-MIT-green.svg?style=flat-square)](https://github.com/windowsair/wireless-esp8266-dap/LICENSE) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-blue.svg?style=flat-square)](https://github.com/windowsair/wireless-esp8266-dap/pulls) [![%e2%9d%a4](https://img.shields.io/badge/made%20with-%e2%9d%a4-ff69b4.svg?style=flat-square)](https://github.com/windowsair/wireless-esp8266-dap)
## 简介
@ -24,7 +20,6 @@
## 特性
1. 支持的ESP芯片
- [x] ESP8266/8285
- [x] ESP32
- [x] ESP32C3
@ -57,50 +52,12 @@
固件中已经内置了一个mDNS服务。你可以通过`dap.local`的地址访问到设备。
> ESP8266的mDNS只支持ipv4。
![mDNS](https://user-images.githubusercontent.com/17078589/149659052-7b29533f-9660-4811-8125-f8f50490d762.png)
### 调试接口连接
<details>
<summary>ESP8266</summary>
| SWD | |
|----------------|--------|
| SWCLK | GPIO14 |
| SWDIO | GPIO13 |
| TVCC | 3V3 |
| GND | GND |
--------------
| JTAG | |
|--------------------|---------|
| TCK | GPIO14 |
| TMS | GPIO13 |
| TDI | GPIO4 |
| TDO | GPIO16 |
| nTRST \(optional\) | GPIO0\* |
| nRESET | GPIO5 |
| TVCC | 3V3 |
| GND | GND |
--------------
| Other | |
|--------------------|---------------|
| LED\_WIFI\_STATUS | GPIO15 |
| Tx | GPIO2 |
| Rx | GPIO3 (U0RXD) |
> Rx和Tx用于TCP转发的串口默认不开启该功能。
</details>
<details>
<summary>ESP32</summary>
@ -184,21 +141,6 @@
----
## 硬件参考电路
目前这里仅有ESP8266的参考电路。
我们为你提供了一个简单的硬件电路例子作为参考:
![sch](https://user-images.githubusercontent.com/17078589/120953707-2a0a6e00-c780-11eb-9ad8-7221cf847974.png)
***除此之外,你也可以像我们一开始给出的那张图片直接用杜邦线连接开发板,这就不需要额外的电路。***
此外,你还可以从贡献者那里获得一个完整的硬件参考电路,详见 [circuit](circuit)文件夹。
------
## 编译固件并烧写
你可以在本地构建或使用Github Action在线构建固件然后下载固件进行烧写。
@ -423,7 +365,7 @@ esptool.py -p (PORT) flash_id
> - https://github.com/ARM-software/CMSIS_5 for CMSIS
> - https://github.com/cezanne/usbip-win for usbip windows
- [@windowsair](https://github.com/windowsair/wireless-esp8266-dap)
- [@HeavenSpree](https://www.github.com/HeavenSpree)
- [@Zy19930907](https://www.github.com/Zy19930907)
- [@caiguang1997](https://www.github.com/caiguang1997)
@ -431,4 +373,4 @@ esptool.py -p (PORT) flash_id
## 许可证
[MIT 许可证](LICENSE)
[Apache 2.0 许可证](LICENSE)

30
circuit/.gitignore vendored
View File

@ -1,30 +0,0 @@
# For PCBs designed using KiCad: http://www.kicad-pcb.org/
# Format documentation: http://kicad-pcb.org/help/file-formats/
# Temporary files
*.000
*.bak
*.bck
*.kicad_pcb-bak
*.kicad_sch-bak
*.kicad_prl
*.sch-bak
*~
_autosave-*
*.tmp
*-save.pro
*-save.kicad_pcb
fp-info-cache
# Netlist files (exported from Eeschema)
*.net
# Autorouter files (exported from Pcbnew)
*.dsn
*.ses
# Exported BOM files
*.xml
*.csv
*-backups

File diff suppressed because it is too large Load Diff

View File

@ -1,440 +0,0 @@
{
"board": {
"design_settings": {
"defaults": {
"board_outline_line_width": 0.09999999999999999,
"copper_line_width": 0.19999999999999998,
"copper_text_italic": false,
"copper_text_size_h": 1.5,
"copper_text_size_v": 1.5,
"copper_text_thickness": 0.3,
"copper_text_upright": false,
"courtyard_line_width": 0.049999999999999996,
"dimension_precision": 4,
"dimension_units": 3,
"dimensions": {
"arrow_length": 1270000,
"extension_offset": 500000,
"keep_text_aligned": true,
"suppress_zeroes": false,
"text_position": 0,
"units_format": 1
},
"fab_line_width": 0.09999999999999999,
"fab_text_italic": false,
"fab_text_size_h": 1.0,
"fab_text_size_v": 1.0,
"fab_text_thickness": 0.15,
"fab_text_upright": false,
"other_line_width": 0.15,
"other_text_italic": false,
"other_text_size_h": 1.0,
"other_text_size_v": 1.0,
"other_text_thickness": 0.15,
"other_text_upright": false,
"pads": {
"drill": 0.762,
"height": 1.524,
"width": 1.524
},
"silk_line_width": 0.15,
"silk_text_italic": false,
"silk_text_size_h": 1.0,
"silk_text_size_v": 1.0,
"silk_text_thickness": 0.15,
"silk_text_upright": false,
"zones": {
"45_degree_only": false,
"min_clearance": 0.19999999999999998
}
},
"diff_pair_dimensions": [
{
"gap": 0.0,
"via_gap": 0.0,
"width": 0.0
}
],
"drc_exclusions": [],
"meta": {
"version": 2
},
"rule_severities": {
"annular_width": "error",
"clearance": "error",
"copper_edge_clearance": "error",
"courtyards_overlap": "error",
"diff_pair_gap_out_of_range": "error",
"diff_pair_uncoupled_length_too_long": "error",
"drill_out_of_range": "error",
"duplicate_footprints": "warning",
"extra_footprint": "warning",
"footprint_type_mismatch": "error",
"hole_clearance": "error",
"hole_near_hole": "error",
"invalid_outline": "error",
"item_on_disabled_layer": "error",
"items_not_allowed": "error",
"length_out_of_range": "error",
"malformed_courtyard": "error",
"microvia_drill_out_of_range": "error",
"missing_courtyard": "ignore",
"missing_footprint": "warning",
"net_conflict": "warning",
"npth_inside_courtyard": "ignore",
"padstack": "error",
"pth_inside_courtyard": "ignore",
"shorting_items": "error",
"silk_over_copper": "warning",
"silk_overlap": "warning",
"skew_out_of_range": "error",
"through_hole_pad_without_hole": "error",
"too_many_vias": "error",
"track_dangling": "warning",
"track_width": "error",
"tracks_crossing": "error",
"unconnected_items": "error",
"unresolved_variable": "error",
"via_dangling": "warning",
"zone_has_empty_net": "error",
"zones_intersect": "error"
},
"rules": {
"allow_blind_buried_vias": false,
"allow_microvias": false,
"max_error": 0.005,
"min_clearance": 0.19999999999999998,
"min_copper_edge_clearance": 0.0,
"min_hole_clearance": 0.25,
"min_hole_to_hole": 0.25,
"min_microvia_diameter": 0.19999999999999998,
"min_microvia_drill": 0.09999999999999999,
"min_silk_clearance": 0.0,
"min_through_hole_diameter": 0.3,
"min_track_width": 0.19999999999999998,
"min_via_annular_width": 0.15,
"min_via_diameter": 0.6,
"solder_mask_clearance": 0.0,
"solder_mask_min_width": 0.0,
"use_height_for_length_calcs": true
},
"track_widths": [
0.0,
0.254,
0.3,
0.5
],
"via_dimensions": [
{
"diameter": 0.0,
"drill": 0.0
},
{
"diameter": 0.6,
"drill": 0.3
}
],
"zones_allow_external_fillets": false,
"zones_use_no_outline": true
},
"layer_presets": []
},
"boards": [],
"cvpcb": {
"equivalence_files": []
},
"erc": {
"erc_exclusions": [],
"meta": {
"version": 0
},
"pin_map": [
[
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
2
],
[
0,
2,
0,
1,
0,
0,
1,
0,
2,
2,
2,
2
],
[
0,
0,
0,
0,
0,
0,
1,
0,
1,
0,
1,
2
],
[
0,
1,
0,
0,
0,
0,
1,
1,
2,
1,
1,
2
],
[
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
2
],
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
2
],
[
1,
1,
1,
1,
1,
0,
1,
1,
1,
1,
1,
2
],
[
0,
0,
0,
1,
0,
0,
1,
0,
0,
0,
0,
2
],
[
0,
2,
1,
2,
0,
0,
1,
0,
2,
2,
2,
2
],
[
0,
2,
0,
1,
0,
0,
1,
0,
2,
0,
0,
2
],
[
0,
2,
1,
1,
0,
0,
1,
0,
2,
0,
0,
2
],
[
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2
]
],
"rule_severities": {
"bus_definition_conflict": "error",
"bus_entry_needed": "error",
"bus_label_syntax": "error",
"bus_to_bus_conflict": "error",
"bus_to_net_conflict": "error",
"different_unit_footprint": "error",
"different_unit_net": "error",
"duplicate_reference": "error",
"duplicate_sheet_names": "error",
"extra_units": "error",
"global_label_dangling": "warning",
"hier_label_mismatch": "error",
"label_dangling": "error",
"lib_symbol_issues": "warning",
"multiple_net_names": "warning",
"net_not_bus_member": "warning",
"no_connect_connected": "warning",
"no_connect_dangling": "warning",
"pin_not_connected": "error",
"pin_not_driven": "error",
"pin_to_pin": "warning",
"power_pin_not_driven": "error",
"similar_labels": "warning",
"unannotated": "error",
"unit_value_mismatch": "error",
"unresolved_variable": "error",
"wire_dangling": "error"
}
},
"libraries": {
"pinned_footprint_libs": [],
"pinned_symbol_libs": []
},
"meta": {
"filename": "ESP8266.kicad_pro",
"version": 1
},
"net_settings": {
"classes": [
{
"bus_width": 12.0,
"clearance": 0.2,
"diff_pair_gap": 0.25,
"diff_pair_via_gap": 0.25,
"diff_pair_width": 0.2,
"line_style": 0,
"microvia_diameter": 0.3,
"microvia_drill": 0.1,
"name": "Default",
"pcb_color": "rgba(0, 0, 0, 0.000)",
"schematic_color": "rgba(0, 0, 0, 0.000)",
"track_width": 0.25,
"via_diameter": 0.8,
"via_drill": 0.4,
"wire_width": 6.0
}
],
"meta": {
"version": 2
},
"net_colors": null
},
"pcbnew": {
"last_paths": {
"gencad": "",
"idf": "",
"netlist": "",
"specctra_dsn": "",
"step": "",
"vrml": ""
},
"page_layout_descr_file": "default.kicad_wks"
},
"schematic": {
"annotate_start_num": 0,
"drawing": {
"default_line_thickness": 6.0,
"default_text_size": 50.0,
"field_names": [],
"intersheets_ref_own_page": false,
"intersheets_ref_prefix": "",
"intersheets_ref_short": false,
"intersheets_ref_show": false,
"intersheets_ref_suffix": "",
"junction_size_choice": 3,
"label_size_ratio": 0.375,
"pin_symbol_size": 25.0,
"text_offset_ratio": 0.15
},
"legacy_lib_dir": "",
"legacy_lib_list": [],
"meta": {
"version": 1
},
"net_format_name": "",
"ngspice": {
"fix_include_paths": true,
"fix_passive_vals": false,
"meta": {
"version": 0
},
"model_mode": 0,
"workbook_filename": ""
},
"page_layout_descr_file": "default.kicad_wks",
"plot_directory": "",
"spice_adjust_passive_values": false,
"spice_external_command": "spice \"%I\"",
"subpart_first_id": 65,
"subpart_id_separator": 0
},
"sheets": [
[
"0b185c93-b318-48f7-bf58-1936caccc44d",
""
]
],
"text_variables": {}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,252 +0,0 @@
(kicad_symbol_lib (version 20211014) (generator kicad_symbol_editor)
(symbol "ESP8266EX" (in_bom yes) (on_board yes)
(property "Reference" "U" (id 0) (at 31.75 39.37 0)
(effects (font (size 1.27 1.27)))
)
(property "Value" "ESP8266EX" (id 1) (at 35.56 -1.27 0)
(effects (font (size 1.27 1.27)))
)
(property "Footprint" "" (id 2) (at 15.24 -12.7 0)
(effects (font (size 1.27 1.27)) hide)
)
(property "Datasheet" "" (id 3) (at 15.24 -12.7 0)
(effects (font (size 1.27 1.27)) hide)
)
(symbol "ESP8266EX_0_1"
(rectangle (start 0 38.1) (end 38.1 0)
(stroke (width 0) (type default) (color 0 0 0 0))
(fill (type none))
)
)
(symbol "ESP8266EX_1_1"
(pin power_in line (at -2.54 27.94 0) (length 2.54)
(name "VDDA" (effects (font (size 1.27 1.27))))
(number "1" (effects (font (size 1.27 1.27))))
)
(pin bidirectional line (at 12.7 -2.54 90) (length 2.54)
(name "MTDI" (effects (font (size 1.27 1.27))))
(number "10" (effects (font (size 1.27 1.27))))
)
(pin power_in line (at 15.24 -2.54 90) (length 2.54)
(name "VDDPST" (effects (font (size 1.27 1.27))))
(number "11" (effects (font (size 1.27 1.27))))
)
(pin bidirectional line (at 17.78 -2.54 90) (length 2.54)
(name "MTCK" (effects (font (size 1.27 1.27))))
(number "12" (effects (font (size 1.27 1.27))))
)
(pin bidirectional line (at 20.32 -2.54 90) (length 2.54)
(name "MTDO" (effects (font (size 1.27 1.27))))
(number "13" (effects (font (size 1.27 1.27))))
)
(pin bidirectional line (at 22.86 -2.54 90) (length 2.54)
(name "GPIO2" (effects (font (size 1.27 1.27))))
(number "14" (effects (font (size 1.27 1.27))))
)
(pin bidirectional line (at 25.4 -2.54 90) (length 2.54)
(name "GPIO0" (effects (font (size 1.27 1.27))))
(number "15" (effects (font (size 1.27 1.27))))
)
(pin bidirectional line (at 27.94 -2.54 90) (length 2.54)
(name "GPIO4" (effects (font (size 1.27 1.27))))
(number "16" (effects (font (size 1.27 1.27))))
)
(pin power_in line (at 40.64 10.16 180) (length 2.54)
(name "VDDPST" (effects (font (size 1.27 1.27))))
(number "17" (effects (font (size 1.27 1.27))))
)
(pin bidirectional line (at 40.64 12.7 180) (length 2.54)
(name "SD_DATA2" (effects (font (size 1.27 1.27))))
(number "18" (effects (font (size 1.27 1.27))))
)
(pin bidirectional line (at 40.64 15.24 180) (length 2.54)
(name "SD_DATA3" (effects (font (size 1.27 1.27))))
(number "19" (effects (font (size 1.27 1.27))))
)
(pin input line (at -2.54 25.4 0) (length 2.54)
(name "LNA" (effects (font (size 1.27 1.27))))
(number "2" (effects (font (size 1.27 1.27))))
)
(pin bidirectional line (at 40.64 17.78 180) (length 2.54)
(name "SD_CMD" (effects (font (size 1.27 1.27))))
(number "20" (effects (font (size 1.27 1.27))))
)
(pin bidirectional line (at 40.64 20.32 180) (length 2.54)
(name "SD_CLK" (effects (font (size 1.27 1.27))))
(number "21" (effects (font (size 1.27 1.27))))
)
(pin bidirectional line (at 40.64 22.86 180) (length 2.54)
(name "SD_DATA0" (effects (font (size 1.27 1.27))))
(number "22" (effects (font (size 1.27 1.27))))
)
(pin bidirectional line (at 40.64 25.4 180) (length 2.54)
(name "SD_DATA1" (effects (font (size 1.27 1.27))))
(number "23" (effects (font (size 1.27 1.27))))
)
(pin bidirectional line (at 40.64 27.94 180) (length 2.54)
(name "GPIO5" (effects (font (size 1.27 1.27))))
(number "24" (effects (font (size 1.27 1.27))))
)
(pin bidirectional line (at 27.94 40.64 270) (length 2.54)
(name "U0RXD" (effects (font (size 1.27 1.27))))
(number "25" (effects (font (size 1.27 1.27))))
)
(pin bidirectional line (at 25.4 40.64 270) (length 2.54)
(name "U0TXD" (effects (font (size 1.27 1.27))))
(number "26" (effects (font (size 1.27 1.27))))
)
(pin input line (at 22.86 40.64 270) (length 2.54)
(name "XTAL_OUT" (effects (font (size 1.27 1.27))))
(number "27" (effects (font (size 1.27 1.27))))
)
(pin input line (at 20.32 40.64 270) (length 2.54)
(name "XTAL_IN" (effects (font (size 1.27 1.27))))
(number "28" (effects (font (size 1.27 1.27))))
)
(pin power_in line (at 17.78 40.64 270) (length 2.54)
(name "VDDD" (effects (font (size 1.27 1.27))))
(number "29" (effects (font (size 1.27 1.27))))
)
(pin power_in line (at -2.54 22.86 0) (length 2.54)
(name "VDD3P3" (effects (font (size 1.27 1.27))))
(number "3" (effects (font (size 1.27 1.27))))
)
(pin power_in line (at 15.24 40.64 270) (length 2.54)
(name "VDDA" (effects (font (size 1.27 1.27))))
(number "30" (effects (font (size 1.27 1.27))))
)
(pin output line (at 12.7 40.64 270) (length 2.54)
(name "RES12K" (effects (font (size 1.27 1.27))))
(number "31" (effects (font (size 1.27 1.27))))
)
(pin input line (at 10.16 40.64 270) (length 2.54)
(name "EXT_RSTB" (effects (font (size 1.27 1.27))))
(number "32" (effects (font (size 1.27 1.27))))
)
(pin power_in line (at 7.62 40.64 270) (length 2.54)
(name "GND" (effects (font (size 1.27 1.27))))
(number "33" (effects (font (size 1.27 1.27))))
)
(pin power_in line (at -2.54 20.32 0) (length 2.54)
(name "VDD3P3" (effects (font (size 1.27 1.27))))
(number "4" (effects (font (size 1.27 1.27))))
)
(pin passive line (at -2.54 17.78 0) (length 2.54)
(name "VDD_RTC" (effects (font (size 1.27 1.27))))
(number "5" (effects (font (size 1.27 1.27))))
)
(pin passive line (at -2.54 15.24 0) (length 2.54)
(name "TOUT" (effects (font (size 1.27 1.27))))
(number "6" (effects (font (size 1.27 1.27))))
)
(pin input line (at -2.54 12.7 0) (length 2.54)
(name "CHIP_EN" (effects (font (size 1.27 1.27))))
(number "7" (effects (font (size 1.27 1.27))))
)
(pin passive line (at -2.54 10.16 0) (length 2.54)
(name "XPD_DCDC" (effects (font (size 1.27 1.27))))
(number "8" (effects (font (size 1.27 1.27))))
)
(pin bidirectional line (at 10.16 -2.54 90) (length 2.54)
(name "MTMS" (effects (font (size 1.27 1.27))))
(number "9" (effects (font (size 1.27 1.27))))
)
)
)
(symbol "HX9193" (in_bom yes) (on_board yes)
(property "Reference" "U" (id 0) (at 1.27 11.43 0)
(effects (font (size 1.27 1.27)))
)
(property "Value" "HX9193" (id 1) (at 10.16 -1.27 0)
(effects (font (size 1.27 1.27)))
)
(property "Footprint" "Package_TO_SOT_SMD:SOT-23-5" (id 2) (at 6.35 -3.81 0)
(effects (font (size 1.27 1.27)) hide)
)
(property "Datasheet" "" (id 3) (at 0 0 0)
(effects (font (size 1.27 1.27)) hide)
)
(symbol "HX9193_0_1"
(rectangle (start 0 10.16) (end 13.97 0)
(stroke (width 0) (type default) (color 0 0 0 0))
(fill (type none))
)
)
(symbol "HX9193_1_1"
(pin power_in line (at -2.54 7.62 0) (length 2.54)
(name "VIN" (effects (font (size 1.4986 1.4986))))
(number "1" (effects (font (size 1.4986 1.4986))))
)
(pin power_in line (at -2.54 5.08 0) (length 2.54)
(name "GND" (effects (font (size 1.4986 1.4986))))
(number "2" (effects (font (size 1.4986 1.4986))))
)
(pin input line (at -2.54 2.54 0) (length 2.54)
(name "EN" (effects (font (size 1.4986 1.4986))))
(number "3" (effects (font (size 1.4986 1.4986))))
)
(pin no_connect line (at 16.51 2.54 180) (length 2.54)
(name "NC" (effects (font (size 1.4986 1.4986))))
(number "4" (effects (font (size 1.4986 1.4986))))
)
(pin power_out line (at 16.51 7.62 180) (length 2.54)
(name "VOUT" (effects (font (size 1.4986 1.4986))))
(number "5" (effects (font (size 1.4986 1.4986))))
)
)
)
(symbol "W25Q64" (in_bom yes) (on_board yes)
(property "Reference" "U" (id 0) (at 1.27 13.97 0)
(effects (font (size 1.27 1.27)))
)
(property "Value" "W25Q64" (id 1) (at 12.7 -1.27 0)
(effects (font (size 1.27 1.27)))
)
(property "Footprint" "Package_SO:SOIC-8_5.23x5.23mm_P1.27mm" (id 2) (at 12.7 -3.81 0)
(effects (font (size 1.27 1.27)) hide)
)
(property "Datasheet" "" (id 3) (at 33.02 -7.62 0)
(effects (font (size 1.27 1.27)) hide)
)
(symbol "W25Q64_0_1"
(rectangle (start 0 12.7) (end 16.51 0)
(stroke (width 0.254) (type default) (color 0 0 0 0))
(fill (type none))
)
)
(symbol "W25Q64_1_1"
(pin input line (at -2.54 10.16 0) (length 2.54)
(name "~{CS}" (effects (font (size 1.27 1.27))))
(number "1" (effects (font (size 1.27 1.27))))
)
(pin bidirectional line (at -2.54 2.54 0) (length 2.54)
(name "DO(IO1)" (effects (font (size 1.27 1.27))))
(number "2" (effects (font (size 1.27 1.27))))
)
(pin bidirectional line (at 19.05 5.08 180) (length 2.54)
(name "IO2" (effects (font (size 1.27 1.27))))
(number "3" (effects (font (size 1.27 1.27))))
)
(pin power_in line (at 19.05 2.54 180) (length 2.54)
(name "GND" (effects (font (size 1.27 1.27))))
(number "4" (effects (font (size 1.27 1.27))))
)
(pin bidirectional line (at -2.54 5.08 0) (length 2.54)
(name "DI(IO0)" (effects (font (size 1.27 1.27))))
(number "5" (effects (font (size 1.27 1.27))))
)
(pin input line (at -2.54 7.62 0) (length 2.54)
(name "CLK" (effects (font (size 1.27 1.27))))
(number "6" (effects (font (size 1.27 1.27))))
)
(pin bidirectional line (at 19.05 7.62 180) (length 2.54)
(name "IO3" (effects (font (size 1.27 1.27))))
(number "7" (effects (font (size 1.27 1.27))))
)
(pin power_in line (at 19.05 10.16 180) (length 2.54)
(name "VCC" (effects (font (size 1.27 1.27))))
(number "8" (effects (font (size 1.27 1.27))))
)
)
)
)

View File

@ -1,67 +0,0 @@
(footprint "ESP8266" (version 20211014) (generator pcbnew)
(layer "F.Cu")
(tedit 61FA80D7)
(descr "ESP8285")
(tags "Integrated Circuit")
(attr smd)
(fp_text reference "U**" (at 0.3556 -4.1656) (layer "F.SilkS")
(effects (font (size 1.27 1.27) (thickness 0.254)))
(tstamp a15a7506-eae4-4933-84da-9ad754258706)
)
(fp_text value "QFN50P500X500X90-33N-D" (at 0 0) (layer "F.SilkS") hide
(effects (font (size 1.27 1.27) (thickness 0.254)))
(tstamp d3c11c8f-a73d-4211-934b-a6da255728ad)
)
(fp_text user "${REFERENCE}" (at 0 0) (layer "F.Fab")
(effects (font (size 1.27 1.27) (thickness 0.254)))
(tstamp 7d928d56-093a-4ca8-aed1-414b7e703b45)
)
(fp_circle (center -2.9 -2.5) (end -2.9 -2.375) (layer "F.SilkS") (width 0.25) (fill none) (tstamp 770ad51a-7219-4633-b24a-bd20feb0a6c5))
(fp_line (start -3.125 3.125) (end -3.125 -3.125) (layer "F.CrtYd") (width 0.05) (tstamp 0c3dceba-7c95-4b3d-b590-0eb581444beb))
(fp_line (start 3.125 -3.125) (end 3.125 3.125) (layer "F.CrtYd") (width 0.05) (tstamp 730b670c-9bcf-4dcd-9a8d-fcaa61fb0955))
(fp_line (start -3.125 -3.125) (end 3.125 -3.125) (layer "F.CrtYd") (width 0.05) (tstamp 8a650ebf-3f78-4ca4-a26b-a5028693e36d))
(fp_line (start 3.125 3.125) (end -3.125 3.125) (layer "F.CrtYd") (width 0.05) (tstamp abe07c9a-17c3-43b5-b7a6-ae867ac27ea7))
(fp_line (start -2.5 2.5) (end -2.5 -2.5) (layer "F.Fab") (width 0.1) (tstamp 6595b9c7-02ee-4647-bde5-6b566e35163e))
(fp_line (start -2.5 -2.5) (end 2.5 -2.5) (layer "F.Fab") (width 0.1) (tstamp 965308c8-e014-459a-b9db-b8493a601c62))
(fp_line (start 2.5 -2.5) (end 2.5 2.5) (layer "F.Fab") (width 0.1) (tstamp b1c649b1-f44d-46c7-9dea-818e75a1b87e))
(fp_line (start -2.5 -2) (end -2 -2.5) (layer "F.Fab") (width 0.1) (tstamp b7199d9b-bebb-4100-9ad3-c2bd31e21d65))
(fp_line (start 2.5 2.5) (end -2.5 2.5) (layer "F.Fab") (width 0.1) (tstamp f3628265-0155-43e2-a467-c40ff783e265))
(pad "1" smd rect (at -2.5 -1.75 90) (size 0.3 0.8) (layers "F.Cu" "F.Paste" "F.Mask") (tstamp 639c0e59-e95c-4114-bccd-2e7277505454))
(pad "2" smd rect (at -2.5 -1.25 90) (size 0.3 0.8) (layers "F.Cu" "F.Paste" "F.Mask") (tstamp 8ca3e20d-bcc7-4c5e-9deb-562dfed9fecb))
(pad "3" smd rect (at -2.5 -0.75 90) (size 0.3 0.8) (layers "F.Cu" "F.Paste" "F.Mask") (tstamp 03caada9-9e22-4e2d-9035-b15433dfbb17))
(pad "4" smd rect (at -2.5 -0.25 90) (size 0.3 0.8) (layers "F.Cu" "F.Paste" "F.Mask") (tstamp 1f3003e6-dce5-420f-906b-3f1e92b67249))
(pad "5" smd rect (at -2.5 0.25 90) (size 0.3 0.8) (layers "F.Cu" "F.Paste" "F.Mask") (tstamp 0ff508fd-18da-4ab7-9844-3c8a28c2587e))
(pad "6" smd rect (at -2.5 0.75 90) (size 0.3 0.8) (layers "F.Cu" "F.Paste" "F.Mask") (tstamp 378af8b4-af3d-46e7-89ae-deff12ca9067))
(pad "7" smd rect (at -2.5 1.25 90) (size 0.3 0.8) (layers "F.Cu" "F.Paste" "F.Mask") (tstamp a27eb049-c992-4f11-a026-1e6a8d9d0160))
(pad "8" smd rect (at -2.5 1.75 90) (size 0.3 0.8) (layers "F.Cu" "F.Paste" "F.Mask") (tstamp 13c0ff76-ed71-4cd9-abb0-92c376825d5d))
(pad "9" smd rect (at -1.75 2.5) (size 0.3 0.8) (layers "F.Cu" "F.Paste" "F.Mask") (tstamp ffd175d1-912a-4224-be1e-a8198680f46b))
(pad "10" smd rect (at -1.25 2.5) (size 0.3 0.8) (layers "F.Cu" "F.Paste" "F.Mask") (tstamp 8412992d-8754-44de-9e08-115cec1a3eff))
(pad "11" smd rect (at -0.75 2.5) (size 0.3 0.8) (layers "F.Cu" "F.Paste" "F.Mask") (tstamp df32840e-2912-4088-b54c-9a85f64c0265))
(pad "12" smd rect (at -0.25 2.5) (size 0.3 0.8) (layers "F.Cu" "F.Paste" "F.Mask") (tstamp c332fa55-4168-4f55-88a5-f82c7c21040b))
(pad "13" smd rect (at 0.25 2.5) (size 0.3 0.8) (layers "F.Cu" "F.Paste" "F.Mask") (tstamp 68877d35-b796-44db-9124-b8e744e7412e))
(pad "14" smd rect (at 0.75 2.5) (size 0.3 0.8) (layers "F.Cu" "F.Paste" "F.Mask") (tstamp b96fe6ac-3535-4455-ab88-ed77f5e46d6e))
(pad "15" smd rect (at 1.25 2.5) (size 0.3 0.8) (layers "F.Cu" "F.Paste" "F.Mask") (tstamp 9f8381e9-3077-4453-a480-a01ad9c1a940))
(pad "16" smd rect (at 1.75 2.5) (size 0.3 0.8) (layers "F.Cu" "F.Paste" "F.Mask") (tstamp 911bdcbe-493f-4e21-a506-7cbc636e2c17))
(pad "17" smd rect (at 2.5 1.75 90) (size 0.3 0.8) (layers "F.Cu" "F.Paste" "F.Mask") (tstamp 6d26d68f-1ca7-4ff3-b058-272f1c399047))
(pad "18" smd rect (at 2.5 1.25 90) (size 0.3 0.8) (layers "F.Cu" "F.Paste" "F.Mask") (tstamp d3d7e298-1d39-4294-a3ab-c84cc0dc5e5a))
(pad "19" smd rect (at 2.5 0.75 90) (size 0.3 0.8) (layers "F.Cu" "F.Paste" "F.Mask") (tstamp 70e15522-1572-4451-9c0d-6d36ac70d8c6))
(pad "20" smd rect (at 2.5 0.25 90) (size 0.3 0.8) (layers "F.Cu" "F.Paste" "F.Mask") (tstamp dde51ae5-b215-445e-92bb-4a12ec410531))
(pad "21" smd rect (at 2.5 -0.25 90) (size 0.3 0.8) (layers "F.Cu" "F.Paste" "F.Mask") (tstamp 7599133e-c681-4202-85d9-c20dac196c64))
(pad "22" smd rect (at 2.5 -0.75 90) (size 0.3 0.8) (layers "F.Cu" "F.Paste" "F.Mask") (tstamp 4fb21471-41be-4be8-9687-66030f97befc))
(pad "23" smd rect (at 2.5 -1.25 90) (size 0.3 0.8) (layers "F.Cu" "F.Paste" "F.Mask") (tstamp 0755aee5-bc01-4cb5-b830-583289df50a3))
(pad "24" smd rect (at 2.5 -1.75 90) (size 0.3 0.8) (layers "F.Cu" "F.Paste" "F.Mask") (tstamp 4a21e717-d46d-4d9e-8b98-af4ecb02d3ec))
(pad "25" smd rect (at 1.75 -2.5) (size 0.3 0.8) (layers "F.Cu" "F.Paste" "F.Mask") (tstamp ec31c074-17b2-48e1-ab01-071acad3fa04))
(pad "26" smd rect (at 1.25 -2.5) (size 0.3 0.8) (layers "F.Cu" "F.Paste" "F.Mask") (tstamp 60dcd1fe-7079-4cb8-b509-04558ccf5097))
(pad "27" smd rect (at 0.75 -2.5) (size 0.3 0.8) (layers "F.Cu" "F.Paste" "F.Mask") (tstamp c5eb1e4c-ce83-470e-8f32-e20ff1f886a3))
(pad "28" smd rect (at 0.25 -2.5) (size 0.3 0.8) (layers "F.Cu" "F.Paste" "F.Mask") (tstamp 85b7594c-358f-454b-b2ad-dd0b1d67ed76))
(pad "29" smd rect (at -0.25 -2.5) (size 0.3 0.8) (layers "F.Cu" "F.Paste" "F.Mask") (tstamp 16bd6381-8ac0-4bf2-9dce-ecc20c724b8d))
(pad "30" smd rect (at -0.75 -2.5) (size 0.3 0.8) (layers "F.Cu" "F.Paste" "F.Mask") (tstamp a5cd8da1-8f7f-4f80-bb23-0317de562222))
(pad "31" smd rect (at -1.25 -2.5) (size 0.3 0.8) (layers "F.Cu" "F.Paste" "F.Mask") (tstamp 4f66b314-0f62-4fb6-8c3c-f9c6a75cd3ec))
(pad "32" smd rect (at -1.75 -2.5) (size 0.3 0.8) (layers "F.Cu" "F.Paste" "F.Mask") (tstamp 01e9b6e7-adf9-4ee7-9447-a588630ee4a2))
(pad "33" smd rect (at 0 0) (size 3.75 3.75) (layers "F.Cu" "F.Paste" "F.Mask") (tstamp ca87f11b-5f48-4b57-8535-68d3ec2fe5a9))
(model "ESP8285.stp"
(offset (xyz 0 0 0))
(scale (xyz 1 1 1))
(rotate (xyz 0 0 0))
)
)

View File

@ -1,30 +0,0 @@
(kicad_wks (version 20210606) (generator pl_editor)
(setup (textsize 1.5 1.5)(linewidth 0.15)(textlinewidth 0.15)
(left_margin 10)(right_margin 10)(top_margin 10)(bottom_margin 10))
(rect (name "rect1:Rect") (start 0 0 ltcorner) (end 0 0) (repeat 2) (incrx 2) (incry 2))
(line (name "segm1:Line") (start 50 2 ltcorner) (end 50 0 ltcorner) (repeat 30) (incrx 50))
(tbtext "1" (name "text1:Text") (pos 25 1 ltcorner) (font (size 1.3 1.3)) (repeat 100) (incrx 50))
(line (name "segm2:Line") (start 50 2 lbcorner) (end 50 0 lbcorner) (repeat 30) (incrx 50))
(tbtext "1" (name "text2:Text") (pos 25 1 lbcorner) (font (size 1.3 1.3)) (repeat 100) (incrx 50))
(line (name "segm3:Line") (start 0 50 ltcorner) (end 2 50 ltcorner) (repeat 30) (incry 50))
(tbtext "A" (name "text3:Text") (pos 1 25 ltcorner) (font (size 1.3 1.3)) (justify center) (repeat 100) (incry 50))
(line (name "segm4:Line") (start 0 50 rtcorner) (end 2 50 rtcorner) (repeat 30) (incry 50))
(tbtext "A" (name "text4:Text") (pos 1 25 rtcorner) (font (size 1.3 1.3)) (justify center) (repeat 100) (incry 50))
(tbtext "Date: ${ISSUE_DATE}" (name "text5:Text") (pos 87 6.9))
(line (name "segm5:Line") (start 110 5.5) (end 2 5.5))
(tbtext "${KICAD_VERSION}" (name "text6:Text") (pos 109 4.1))
(line (name "segm6:Line") (start 110 8.5) (end 2 8.5))
(tbtext "Rev: ${REVISION}" (name "text7:Text") (pos 24 6.9) (font bold))
(line (name "segm7:Line") (start 110.002 2.007) (end 110.002 18.5))
(tbtext "Size: ${PAPER}" (name "text8:Text") (pos 109 6.9))
(tbtext "Id: ${#}/${##}" (name "text9:Text") (pos 24 4.1))
(line (name "segm8:Line") (start 110 12.5) (end 2 12.5))
(tbtext "Title: ${TITLE}" (name "text10:Text") (pos 109 10.7) (font (size 2 2) bold italic))
(tbtext "File: ${FILENAME}" (name "text11:Text") (pos 109 14.3))
(line (name "segm9:Line") (start 110 18.5) (end 2 18.5))
(tbtext "Sheet: ${SHEETNAME}" (name "text12:Text") (pos 109 17))
(tbtext "${COMPANY}" (name "text13:Text") (pos 109 20) (font bold))
(line (name "segm10:Line") (start 90 8.5) (end 90 5.5))
(line (name "segm11:Line") (start 26 8.5) (end 26 2))
(rect (name "rect2:Rect") (start 0 0) (end 0 0))
)

21
components/DAP/LICENSE Normal file
View File

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2020 windowsair
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

21
components/USBIP/LICENSE Normal file
View File

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2020 windowsair
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2020 windowsair
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2020 windowsair
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

1315
idf.py

File diff suppressed because it is too large Load Diff

View File

@ -27,6 +27,7 @@ static esp_err_t api_post_handler(httpd_req_t *req)
ESP_LOGI(TAG, "=========== RECEIVED DATA ==========");
ESP_LOGI(TAG, "%.*s", data_len, buf);
ESP_LOGI(TAG, "====================================");
ESP_LOGI(TAG, "heap min: %lu, cur: %lu", esp_get_minimum_free_heap_size(), esp_get_free_heap_size());
/* Decode */
json_in.json = cJSON_ParseWithLength(buf, data_len);
@ -36,10 +37,6 @@ static esp_err_t api_post_handler(httpd_req_t *req)
return ESP_OK;
}
/* DEBUG print the actual decoded string */
cJSON_PrintPreallocated(json_in.json, buf, sizeof(buf), 0);
printf("json: %s\n", buf);
err = api_json_route(&json_in, &json_out);
if (err) {
httpd_resp_set_status(req, HTTPD_400);
@ -63,7 +60,11 @@ static esp_err_t api_post_handler(httpd_req_t *req)
return httpd_resp_send(req, NULL, 0);
}
return httpd_resp_send(req, buf, strlen(buf));
err = httpd_resp_send(req, buf, strlen(buf));
if (err) {
ESP_LOGE(TAG, "resp_send err: %s", esp_err_to_name(err));
}
return err;
}
/**

View File

@ -9,9 +9,8 @@
#include <sys/unistd.h>
#define TAG "web server"
#define EXAMPLE_HTTP_QUERY_KEY_MAX_LEN (64)
#define MAKE_U32(b0, b1, b2, b3) ((b0) | (b1) << 8 | (b2) << 16 | (b3) << 24)
#define MAKE_U32(b0, b1, b2, b3) ((b0) | (b1) << 8 | (b2) << 16 | (b3) << 24)
#define URI_WS_STR MAKE_U32('/', 'w', 's', '\0')
#define URI_API_STR MAKE_U32('/', 'a', 'p', 'i')
@ -101,29 +100,20 @@ void start_webserver(void)
httpd_config_t config = HTTPD_DEFAULT_CONFIG();
int err;
config.enable_so_linger = true;
config.linger_timeout = 0;
config.lru_purge_enable = true;
config.uri_match_fn = uri_match;
config.open_fn = web_server_on_open;
config.close_fn = web_server_on_close;
// Start the httpd server
ESP_LOGI(TAG, "Starting server on port: '%d'", config.server_port);
if ((err = httpd_start(&server, &config) != ESP_OK)) {
ESP_LOGE(TAG, "Error starting server!");
ESP_ERROR_CHECK(err);
}
// Set URI handlers
ESP_LOGI(TAG, "Registering URI handlers");
/*
* load http service
* TODO: make ws a module
* make http api POST a module
* make update a module
* */
uri_module_init(server);
http_server = server;
}

View File

@ -6,8 +6,8 @@ void wifi_api_get_ap_info(wifi_api_ap_info_t *ap_info)
{
wifi_ap_record_t ap_record;
esp_wifi_sta_get_ap_info(&ap_record);
strncpy(ap_info->ssid, (const char *)ap_record.ssid, sizeof(ap_info->ssid));
strncpy(ap_info->mac, (const char *)ap_record.bssid, sizeof(ap_info->mac));
strncpy(ap_info->ssid, (char *)ap_record.ssid, sizeof(ap_info->ssid));
strncpy(ap_info->mac, (char *)ap_record.bssid, sizeof(ap_info->mac));
ap_info->rssi = ap_record.rssi;
esp_netif_t *sta_netif = wifi_manager_get_sta_netif();
@ -17,3 +17,69 @@ void wifi_api_get_ap_info(wifi_api_ap_info_t *ap_info)
ip4_addr_set(&ap_info->gateway, &ip_info.gw);
ip4_addr_set(&ap_info->netmask, &ip_info.netmask);
}
static int rssi_comp(const void *a, const void *b)
{
const wifi_ap_record_t *r1 = a;
const wifi_ap_record_t *r2 = b;
return r2->rssi - r1->rssi;
}
/**
* @brief blocking function
* @param number
* @param ap_info
* @return
*/
int wifi_api_get_scan_list(uint16_t *number, wifi_api_ap_info_t *ap_info)
{
wifi_ap_record_t *records;
int err;
records = malloc(*number * sizeof(wifi_ap_record_t));
if (records == NULL) {
return ESP_ERR_NO_MEM;
}
err = wifi_manager_get_scan_list(number, records);
if (err) {
printf("get scan list err\n");
free(records);
return err;
}
for (int i = 0; i < *number; ++i) {
printf("%d %d %s\n", i, records[i].rssi, records[i].ssid);
strncpy(ap_info[i].ssid, (char *) records[i].ssid, sizeof(ap_info[i].ssid));
strncpy(ap_info[i].mac, (char *) records[i].bssid, sizeof(ap_info[i].mac));
ap_info[i].rssi = records[i].rssi;
}
free(records);
qsort(ap_info, *number, sizeof(wifi_api_ap_info_t), rssi_comp);
return 0;
}
static wifi_api_scan_done_cb scan_done_cb;
static void wifi_manager_scan_done(uint16_t ap_found, wifi_ap_record_t *records, void *arg)
{
wifi_api_ap_info_t *ap_info;
ap_info = malloc(ap_found * sizeof(wifi_api_ap_info_t));
for (int i = 0; i < ap_found; ++i) {
strncpy(ap_info[i].ssid, (char *) records[i].ssid, sizeof(ap_info[i].ssid));
strncpy(ap_info[i].mac, (char *) records[i].bssid, sizeof(ap_info[i].mac));
ap_info[i].rssi = records[i].rssi;
}
printf("wifi api scan done\n");
scan_done_cb(ap_found, ap_info, arg);
}
int wifi_api_trigger_scan(uint16_t *max_ap_count, wifi_api_scan_done_cb cb, void *cb_arg)
{
wifi_manager_trigger_scan(wifi_manager_scan_done, cb_arg);
scan_done_cb = cb;
return 0;
}

View File

@ -14,5 +14,11 @@ typedef struct wifi_api_ap_info_t {
void wifi_api_get_ap_info(wifi_api_ap_info_t *ap_info);
typedef void (*wifi_api_scan_done_cb)(uint16_t found, wifi_api_ap_info_t *aps, void *arg);
int wifi_api_trigger_scan(uint16_t *max_ap_count, wifi_api_scan_done_cb cb, void *cb_arg);
int wifi_api_get_scan_list(uint16_t *number, wifi_api_ap_info_t *ap_info);
#endif //WIFI_API_H_GUARD

View File

@ -21,7 +21,6 @@ static int on_json_req(uint16_t cmd, api_json_req_t *req, api_json_resp_t *rsp)
break;
case WIFI_API_JSON_GET_SCAN:
return wifi_api_json_get_scan(req, rsp);
break;
case UNKNOWN:
default:
break;
@ -42,7 +41,17 @@ static int wifi_api_json_get_ap_info(api_json_req_t *req, api_json_resp_t *resp)
static int wifi_api_json_get_scan(api_json_req_t *req, api_json_resp_t *resp)
{
wifi_api_ap_info_t ap_info[20];
uint16_t max_count = 20;
int err;
err = wifi_api_get_scan_list(&max_count, ap_info);
if (err == ESP_ERR_NOT_FINISHED) {
resp->json = wifi_api_json_create_err_rsp(req->json, "Wi-Fi scan busy");
return 1;
}
resp->json = wifi_api_json_serialize_scan_list(ap_info, max_count);
return 0;
}

View File

@ -3,11 +3,16 @@
#include <esp_netif.h>
#include <lwip/ip4_addr.h>
#include <esp_wifi.h>
#include <esp_log.h>
#include <freertos/FreeRTOS.h>
#include <freertos/semphr.h>
#define TAG __FILE_NAME__
void ip_event_handler(void *handler_arg __attribute__((unused)),
esp_event_base_t event_base __attribute__((unused)),
int32_t event_id,
void *event_data)
esp_event_base_t event_base __attribute__((unused)),
int32_t event_id,
void *event_data)
{
switch (event_id) {
case IP_EVENT_STA_GOT_IP: {
@ -39,6 +44,76 @@ void ip_event_handler(void *handler_arg __attribute__((unused)),
}
}
typedef struct wifi_scan_ctx_t {
wifi_ap_record_t *ap;
wifi_event_scan_done_cb cb;
uint16_t number;
} wifi_scan_ctx_t;
static wifi_scan_ctx_t scan_ctx = {
.ap = NULL,
};
static void wifi_on_scan_done(wifi_event_sta_scan_done_t *event)
{
int err;
if (!scan_ctx.cb || !scan_ctx.ap) {
scan_ctx.number = 0;
} else if (event->status == 1) {
/* error */
scan_ctx.number = 0;
} else if (event->number == 0) {
/* no ap found on current channel */
scan_ctx.number = 0;
}
err = esp_wifi_scan_get_ap_records(&scan_ctx.number, scan_ctx.ap);
if (err) {
esp_wifi_clear_ap_list();
}
int i;
for (i = 0; i < scan_ctx.number; ++i) {
if (scan_ctx.ap[i].rssi < -80)
break;
}
scan_ctx.number = i;
return scan_ctx.cb(scan_ctx.number, scan_ctx.ap);
}
int wifi_event_trigger_scan(uint8_t channel, wifi_event_scan_done_cb cb, uint16_t number, wifi_ap_record_t *aps)
{
int err;
if (aps == NULL) {
return 1;
}
wifi_scan_config_t config = {
.bssid = NULL,
.ssid = NULL,
.show_hidden = 0,
.scan_type = WIFI_SCAN_TYPE_ACTIVE,
.scan_time.active.min = 10,
.scan_time.active.max = 50,
.channel = channel,
.home_chan_dwell_time = 0,
};
err = esp_wifi_scan_start(&config, 0);
if (err) {
ESP_LOGE(TAG, "%s", esp_err_to_name(err));
return err;
}
scan_ctx.cb = cb;
scan_ctx.number = number;
scan_ctx.ap = aps;
return 0;
}
void wifi_event_handler(void *handler_arg __attribute__((unused)),
esp_event_base_t event_base __attribute__((unused)),
int32_t event_id,
@ -48,8 +123,15 @@ void wifi_event_handler(void *handler_arg __attribute__((unused)),
case WIFI_EVENT_WIFI_READY:
printf("event: WIFI_EVENT_WIFI_READY\n");
break;
case WIFI_EVENT_SCAN_DONE:
case WIFI_EVENT_SCAN_DONE: {
wifi_event_sta_scan_done_t *event = event_data;
// printf("event: WIFI_EVENT_SCAN_DONE: ok: %lu, nr: %u, seq: %u\n",
// event->status, event->number, event->scan_id);
wifi_on_scan_done(event);
scan_ctx.ap = NULL;
scan_ctx.cb = NULL;
break;
}
case WIFI_EVENT_STA_START:
printf("event: WIFI_EVENT_STA_START\n");
esp_wifi_connect();
@ -58,7 +140,8 @@ void wifi_event_handler(void *handler_arg __attribute__((unused)),
wifi_event_sta_connected_t *event = event_data;
uint8_t *m = event->bssid;
printf("event: WIFI_EVENT_STA_CONNECTED\n");
printf("connected to %2X:%2X:%2X:%2X:%2X:%2X\n", m[0], m[1], m[2], m[3], m[4], m[5]);
printf("connected to %02X:%02X:%02X:%02X:%02X:%02X\n",
m[0], m[1], m[2], m[3], m[4], m[5]);
#ifdef CONFIG_EXAMPLE_IPV6
tcpip_adapter_create_ip6_linklocal(TCPIP_ADAPTER_IF_STA);
#endif
@ -67,8 +150,8 @@ void wifi_event_handler(void *handler_arg __attribute__((unused)),
case WIFI_EVENT_STA_DISCONNECTED: {
wifi_event_sta_disconnected_t *event = event_data;
uint8_t *m = event->bssid;
printf("event: WIFI_EVENT_STA_DISCONNECTED\n");
printf("sta %2X:%2X:%2X:%2X:%2X:%2X disconnect reason %d\n",
printf("event: WIFI_EVENT_STA_DISCONNECTED ");
printf("sta %02X:%02X:%02X:%02X:%02X:%02X disconnect reason %d\n",
m[0], m[1], m[2], m[3], m[4], m[5], event->reason);
/* auto reconnect after disconnection */
esp_wifi_connect();
@ -81,7 +164,7 @@ void wifi_event_handler(void *handler_arg __attribute__((unused)),
wifi_event_ap_staconnected_t *event = event_data;
uint8_t *m = event->mac;
printf("event: WIFI_EVENT_AP_STACONNECTED\n");
printf("%2X:%2X:%2X:%2X:%2X:%2X is connected\n",
printf("%02X:%02X:%02X:%02X:%02X:%02X is connected\n",
m[0], m[1], m[2], m[3], m[4], m[5]);
break;
}
@ -89,11 +172,12 @@ void wifi_event_handler(void *handler_arg __attribute__((unused)),
wifi_event_ap_staconnected_t *event = event_data;
uint8_t *m = event->mac;
printf("event: WIFI_EVENT_AP_STADISCONNECTED\n");
printf("%2X:%2X:%2X:%2X:%2X:%2X is connected\n",
printf("%02X:%02X:%02X:%02X:%02X:%02X is connected\n",
m[0], m[1], m[2], m[3], m[4], m[5]);
break;
}
default:
break;
}
}
}

View File

@ -3,10 +3,16 @@
#include <stdint.h>
#include <esp_event_base.h>
#include <esp_wifi_types.h>
void ip_event_handler(void *handler_arg, esp_event_base_t event_base, int32_t event_id, void *event_data);
void wifi_event_handler(void *handler_arg, esp_event_base_t event_base, int32_t event_id, void *event_data);
typedef void (*wifi_event_scan_done_cb)(uint16_t ap_count, wifi_ap_record_t *aps_info);
int wifi_event_trigger_scan(uint8_t channel, wifi_event_scan_done_cb cb, uint16_t number, wifi_ap_record_t *aps);
#endif //WIFI_EVENT_HANDLER_H_GUARD

View File

@ -23,3 +23,35 @@ cJSON *wifi_api_json_serialize_ap_info(wifi_api_ap_info_t *ap_info)
return root;
}
cJSON *wifi_api_json_serialize_scan_list(wifi_api_ap_info_t *aps_info, uint16_t count)
{
cJSON *root;
char mac_str[18];
root = cJSON_CreateObject();
cJSON *scan_list = cJSON_AddArrayToObject(root, "scan_list");
for (int i = 0; i < count; ++i) {
cJSON *ap = cJSON_CreateObject();
cJSON_AddNumberToObject(ap, "rssi", aps_info[i].rssi);
cJSON_AddStringToObject(ap, "ssid", aps_info[i].ssid);
char *m = aps_info[i].mac;
snprintf(mac_str, sizeof(mac_str), "%02X:%02X:%02X:%02X:%02X:%02X",
m[0], m[1], m[2], m[3], m[4], m[5]);
cJSON_AddStringToObject(ap, "mac", mac_str);
cJSON_AddItemToArray(scan_list, ap);
}
return root;
}
cJSON *wifi_api_json_create_err_rsp(cJSON *req, const char *msg)
{
cJSON *root;
root = cJSON_Duplicate(req, 1);
cJSON_AddStringToObject(root, "msg", msg);
return root;
}

View File

@ -4,5 +4,9 @@
#include "wifi_api.h"
cJSON *wifi_api_json_serialize_ap_info(wifi_api_ap_info_t *ap_info);
cJSON *wifi_api_json_serialize_scan_list(wifi_api_ap_info_t *aps_info, uint16_t count);
cJSON *wifi_api_json_create_err_rsp(cJSON *req, const char *msg);
#endif //WIFI_JSON_UTILS_H_GUARD

View File

@ -7,15 +7,31 @@
#include <esp_wifi.h>
#include <esp_event.h>
#include <esp_log.h>
#include <freertos/FreeRTOS.h>
#include <freertos/semphr.h>
#include <lwip/ip4_addr.h>
#include <string.h>
#define TAG __FILENAME__
typedef struct wifi_scan_ctx_t {
wifi_ap_record_t *ap;
wifi_manager_scan_done_cb cb;
void *arg;
SemaphoreHandle_t lock;
TaskHandle_t task;
uint16_t total_aps;
uint16_t nr_aps_in_channel;
uint8_t status;
uint8_t max_ap;
} wifi_scan_ctx_t;
static esp_netif_t *ap_netif;
static esp_netif_t *sta_netif;
static wifi_scan_ctx_t scan_ctx;
void wifi_manager_init(void)
{
esp_err_t err;
@ -38,12 +54,9 @@ void wifi_manager_init(void)
ESP_ERROR_CHECK(esp_wifi_set_ps(WIFI_PS_NONE));
wifi_config_t ap_config = {0};
size_t len;
len = 32;
strncpy((char *) ap_config.ap.ssid, WIFI_DEFAULT_AP_SSID, len);
len = 64;
strncpy((char *) ap_config.ap.password, WIFI_DEFAULT_AP_PASS, len);
strncpy((char *) ap_config.ap.ssid, WIFI_DEFAULT_AP_SSID, 32);
strncpy((char *) ap_config.ap.password, WIFI_DEFAULT_AP_PASS, 64);
ap_config.ap.authmode = WIFI_AUTH_WPA2_WPA3_PSK;
ap_config.ap.max_connection = 4;
ap_config.ap.channel = 6;
@ -82,6 +95,97 @@ void wifi_manager_init(void)
ESP_ERROR_CHECK(esp_wifi_start());
ESP_LOGI(TAG, "wifi started");
scan_ctx.lock = xSemaphoreCreateBinary();
scan_ctx.status = 0;
xSemaphoreGive(scan_ctx.lock);
}
static void wifi_event_scan_channel_done(uint16_t number, wifi_ap_record_t *aps)
{
scan_ctx.nr_aps_in_channel = number;
scan_ctx.total_aps += number;
if (scan_ctx.task) {
xTaskNotifyGive(scan_ctx.task);
}
}
static void scan_loop()
{
uint32_t ret;
uint16_t number;
scan_ctx.total_aps = 0;
for (int scan_channel = 1; scan_channel <= 13; ++scan_channel) {
number = scan_ctx.max_ap - scan_ctx.total_aps;
if (wifi_event_trigger_scan(scan_channel,
wifi_event_scan_channel_done, number,
&scan_ctx.ap[scan_ctx.total_aps])) {
ESP_LOGE(TAG, "trigger scan %d error", scan_channel);
goto end;
}
/* shadow wifi_event_scan_channel_done() called */
vTaskDelay(100);
ret = ulTaskNotifyTake(pdTRUE, pdMS_TO_TICKS(1000));
if (ret == 0) {
/* timeout */
ESP_LOGE(TAG, "scan channel %d timeout", scan_channel);
goto end;
}
}
end:
if (scan_ctx.cb) {
// scan_ctx.cb(scan_ctx.total_aps, scan_ctx.ap);
}
}
static void wifi_manager_scan_task(void *arg)
{
scan_loop();
free(scan_ctx.ap);
xSemaphoreGive(scan_ctx.lock);
vTaskDelete(NULL);
}
int wifi_manager_trigger_scan(wifi_manager_scan_done_cb cb, void *arg)
{
if (xSemaphoreTake(scan_ctx.lock, pdMS_TO_TICKS(0)) != pdTRUE) {
return 1;
}
/* TODO: let API allocate ? */
scan_ctx.ap = malloc(sizeof(wifi_scan_ctx_t) * 32);
if (scan_ctx.ap == NULL) {
return 1;
}
scan_ctx.cb = cb;
scan_ctx.arg = arg;
scan_ctx.max_ap = 32;
ulTaskNotifyTake(pdTRUE, 0);
xTaskCreatePinnedToCore(wifi_manager_scan_task, "scan task", 4 * 1024,
NULL, 7, &scan_ctx.task, 0);
return 0;
}
int wifi_manager_get_scan_list(uint16_t *number, wifi_ap_record_t *aps)
{
if (xSemaphoreTake(scan_ctx.lock, pdMS_TO_TICKS(0)) != pdTRUE) {
return 1;
}
scan_ctx.ap = aps;
scan_ctx.max_ap = *number;
scan_ctx.cb = NULL;
scan_ctx.task = xTaskGetCurrentTaskHandle();
scan_loop();
xSemaphoreGive(scan_ctx.lock);
*number = scan_ctx.total_aps;
return 0;
}
void *wifi_manager_get_ap_netif()
@ -93,17 +197,3 @@ void *wifi_manager_get_sta_netif()
{
return sta_netif;
}
void test()
{
// esp_netif_get_ip_info()
wifi_sta_list_t list;
wifi_ap_config_t ap_conf;
wifi_ap_record_t ap_info;
/* ESP_ERR_WIFI_NOT_CONNECT / ESP_ERR_WIFI_CONN */
esp_wifi_sta_get_ap_info(&ap_info);
// esp_wifi_ap_get_sta_list()
}

View File

@ -1,6 +1,8 @@
#ifndef WIFI_MANAGER_H_GUARD
#define WIFI_MANAGER_H_GUARD
#include <esp_wifi_types.h>
void wifi_manager_init();
int wifi_set_ap_cred(const char *ssid, const char *password);
@ -10,4 +12,11 @@ int wifi_set_sta_cred(const char *ssid, const char *password);
void *wifi_manager_get_ap_netif();
void *wifi_manager_get_sta_netif();
typedef void (*wifi_manager_scan_done_cb)(uint16_t ap_found, wifi_ap_record_t *record, void *arg);
int wifi_manager_scan(uint16_t *number, wifi_ap_record_t *records, uint8_t is_async);
int wifi_manager_trigger_scan(wifi_manager_scan_done_cb cb, void *arg);
int wifi_manager_get_scan_list(uint16_t *number, wifi_ap_record_t *aps);
#endif //WIFI_MANAGER_H_GUARD