# -lorenzovecchi-react-native-esptouch-2-forked 中文文档

规范地址：https://npmcn.com/package/-lorenzovecchi-react-native-esptouch-2-forked/

版本：0\.2\.0
npm 元数据更新时间：2023-09-15T11:59:09.453Z
中文译文更新时间：2026-10-31T09:49:23.415Z
软件包许可：MIT

本文由上游 README 机器翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/-lorenzovecchi-react-native-esptouch-2-forked
原文对照：https://npmcn.com/package/-lorenzovecchi-react-native-esptouch-2-forked/?lang=original
项目主页：https://github.com/lorenzovecchi/react-native-esptouch-2#readme
源码仓库：https://github.com/lorenzovecchi/react-native-esptouch-2

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：1.2 MB，129 个文件
- 模块格式：ESM + CJS
- TypeScript 类型：包内自带
- 运行依赖：0 个
- peer 依赖：react \*，react-native \*
- 首次发布：2023-07-28T11:36:12.553Z
- 最新版本发布：2023-09-15T11:59:09.270Z
- 已发布版本数：35（近 12 个月 0 个）

## 中文简介

用于配置ESP设备连接到目标AP分叉版本

## 安装

```sh
npm install -- -lorenzovecchi-react-native-esptouch-2-forked
```

也可以使用：`pnpm add -- -lorenzovecchi-react-native-esptouch-2-forked`、`yarn add -- -lorenzovecchi-react-native-esptouch-2-forked`、`bun add -- -lorenzovecchi-react-native-esptouch-2-forked`

## README

# react-native-esptouch-2

# 我fork了这个repo来编辑由https://www.npmjs.com/package/@lorenzovecchi/react-native-esptouch-2/v/0.1.4创建的react-native-esptouch-2包

用于配置ESP设备连接到目标AP。

-   同时支持安卓和iOS
-   iOS代码未经测试

这是一个非官方项目。官方演示如下:

[EsptouchForAndroid](https://github.com/EspressifApp/EsptouchForAndroid)

[EsptouchForIOS](https://github.com/EspressifApp/EsptouchForIOS)

## 安装

从npm安装该模块

```sh
npm install @lorenzovecchi/react-native-esptouch-2
```

### 安卓

在AndroidManifest.xml中添加权限

```xml
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_MULTICAST_STATE" />
```

### iOS

```sh
cd ios && pod install
```

## 使用

```js
import * as ESPTouch2 from "react-native-esptouch-2";

/**
* Start the configuration broadcasting the informations to the device
* @param {string} ssid
*   AP SSID
* @param {string} bssid
*   AP BSSID
* @param {string} password
*   AP Password (null if open network)
* @param {string} customData
*   Additional data to send (nullable)
* @param {string} aesKey
*   Encrypt the data to send (if not null, it must be 16 byte) (nullable)
*
* @resolve {object} res
*   Object containing the successfully configured device address and bssid
* @reject {Exception} err
*   Error exception
*/
ESPTouch2.start(ssid, bssid, password, customData, aesKey).then(res => {
    //On success
    console.log(res.address, res.bssid);
}).catch(err => {
    //On error
    console.log(err);
});

/**
* Stop the configuration broadcasting
*/
ESPTouch2.stop();

/**
* Function called on broadcasting start
*/
ESPTouch2.onStart(() => {console.log('Starting broadcast')};

/**
* Function called on broadcasting stop
*/
ESPTouch2.onStop(() => {console.log('Stopping broadcast')};
```

## 贡献

看到 [贡献指南](https://npmcn.com/package/-lorenzovecchi-react-native-esptouch-2-forked/CONTRIBUTING.md) 了解如何对存储库和开发工作流做出贡献。

## 许可证

麻省理工学院

## 常见问题

### -lorenzovecchi-react-native-esptouch-2-forked 是什么？

用于配置ESP设备连接到目标AP分叉版本

### 如何安装 -lorenzovecchi-react-native-esptouch-2-forked？

在项目目录运行 npm install -- -lorenzovecchi-react-native-esptouch-2-forked，或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖：react（\*）、react-native（\*）。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖，Yarn 需要手动安装。

### -lorenzovecchi-react-native-esptouch-2-forked 支持 TypeScript 吗？

支持。包内自带 TypeScript 类型声明（package\.json 声明了 types 入口），安装后即可获得类型提示，无需再安装 @types 包。

### -lorenzovecchi-react-native-esptouch-2-forked 支持 ESM 还是 CommonJS？

同时提供 ES Module 与 CommonJS 入口，import 和 require\(\) 都可以使用，打包工具会自动选择合适的版本。

### -lorenzovecchi-react-native-esptouch-2-forked 可以商用吗？

-lorenzovecchi-react-native-esptouch-2-forked 使用 MIT 许可。宽松许可：允许商业使用、修改和再分发，通常只需在分发时保留原版权与许可声明。以上为概括，不构成法律意见，请以许可原文为准。

### -lorenzovecchi-react-native-esptouch-2-forked 还在维护吗？

最新版本 0\.2\.0 发布于 2023/09/15（3 年前）；至今共发布 35 个版本，其中过去 12 个月发布了 0 个；首次发布于 2023/07/28。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

