@espark-consultants/react-native-esp-idf-provisioning
v0.0.4
Published
Android and iOS wrapper for ESP IDF provisioning
Downloads
19
Readme
react-native-esp-idf-provisioning
Android and iOS bridge for ESP IDF provisioning. Provides a unified interface for BLE and SoftAP provisioning using the libraries provided by Espressif:
- https://github.com/espressif/esp-idf-provisioning-android
- https://github.com/espressif/esp-idf-provisioning-ios
SoftAP mode tested and working fine. Still working on enhancement.
QR code scanning is deliberately not supported. This can be done using other react-native libraries.
Installation
npm install @espark-consultants/react-native-esp-idf-provisioning
or
yarn add @espark-consultants/react-native-esp-idf-provisioning
Usage
import {
ESPProvisionManager,
ESPDevice,
ESPTransport,
ESPSecurity,
} from '@espark-consultants/react-native-esp-idf-provisioning';
// Method 1.
// Get devices...
const devices = ESPProvisionManager.searchESPDevices('prefix');
// ... and select device (using picklist, dropdown, w/e)
const device: ESPDevice = devices[0];
// Method 2.
// If you know device name and transport/security settings, create a device class instance
const device = new ESPDevice({
name: 'name',
transport: ESPTransport.ble,
security: ESPSecurity.secure2,
});
// Connect to device with proofOfPossession
const proofOfPossession = 'pop';
await device.connect(proofOfPosession);
// Connect to device with proofOfPossession + username
const proofOfPossession = 'pop';
const username = 'username';
await device.connect(proofOfPosession, null, username);
// Connect to device with softAP password
const softAPPassword = 'password';
await device.connect(null, softAPPassword, null);
// Get wifi list
const wifiList = await device.scanWifiList();
// Provision device
const ssid = 'ssid';
const passphrase = 'passphrase';
await device.provision(ssid, passphrase);
// Disconnect
device.disconnect();
Enums
enum ESPTransport {
ble = 'ble',
softap = 'softap',
}
enum ESPSecurity {
unsecure = 0,
secure = 1,
secure2 = 2,
}
enum ESPWifiAuthMode {
open = 0,
wep = 1,
wpa2Enterprise = 2,
wpa2Psk = 3,
wpaPsk = 4,
wpaWpa2Psk = 5,
}
Permissions
Android
See AndroidManifest.xml in the example project.
iOS
Since iOS 13, apps that want to access SSID (Wi-Fi network name) are required to have the location permission. Add key
NSLocationWhenInUseUsageDescription
in Info.plist with proper description. This permission is required to verify iOS device is currently connected with the SoftAP.Since iOS 14, apps that communicate over local network are required to have the local network permission. Add key
NSLocalNetworkUsageDescription
in Info.plist with proper description. This permission is required to send/receive provisioning data with the SoftAP devices.
Contributing
See the contributing guide to learn how to contribute to the repository and the development workflow.
License
MIT
Made with create-react-native-library