A capacitor plugin that wraps the Espressif IDF Provisioning libraries for iOS and Android.
Using this library will allow you to use an Ionic app to provision Espressif devices running the WiFi provisioning stack.
I've regained access to our npm organization so this package is now published on npm instead of github packages. To consume future versions you should remove the github packages config for this repo.
This project will only work in Android apps using SDK Level 25 or higher. Android SDK Distribution Stats
npm install @general-galactic/capacitor-esp-idf-provisioning
npx cap sync
Apps will need to add the maven repo to their build.gradle
file so that the ESPProvision library from Espressif can be included:
allprojects {
repositories {
google()
jcenter()
maven { url 'https://jitpack.io' } // <-- Add This line
}
}
Android build won't run after adding the npm dependency
You need to add the https://jitpack.io
repository to your build.gradle
. See 'Initial Integration into an Android App' above.
ESPProvisioning is not implemented on [iOS|Android]
You need to run npx cap sync
checkPermissions()
requestPermissions()
checkStatus()
searchESPDevices(...)
connect(...)
scanWifiList(...)
provision(...)
sendCustomDataString(...)
disconnect(...)
openLocationSettings()
openBluetoothSettings()
openAppSettings()
enableLogging()
disableLogging()
- Interfaces
- Type Aliases
- Enums
checkPermissions() => Promise<PermissionStatus>
Check the status of system permissions:
- ble - Bluetooth access
- location - Location access, android only
Returns: Promise<PermissionStatus>
requestPermissions() => Promise<PermissionStatus>
Have the system prompt the user for access to the proper permissions - Android only.
Returns: Promise<PermissionStatus>
checkStatus() => Promise<EspProvisioningStatus>
See if the bluetooth adapter is up and running
Returns: Promise<EspProvisioningStatus>
searchESPDevices(options: { devicePrefix: string; transport: ESPTransport; security: ESPSecurity; }) => Promise<{ devices?: ESPDevice[]; }>
Perform a BLE scan to find devices that are connection with the given devicePrefix. The transport and security parameters map directly to ESPProvision's own values.
Param | Type |
---|---|
options |
{ devicePrefix: string; transport: ESPTransport; security: ESPSecurity; } |
Returns: Promise<{ devices?: ESPDevice[]; }>
connect(options: { deviceName: string; proofOfPossession: string; }) => Promise<{ connected: boolean; }>
Connect to the device with the given name using the given proofOfPossession.
Param | Type |
---|---|
options |
{ deviceName: string; proofOfPossession: string; } |
Returns: Promise<{ connected: boolean; }>
scanWifiList(options: { deviceName: string; }) => Promise<{ networks?: ESPNetwork[]; }>
Request a list of available WiFi networks from the device with the given name.
Param | Type |
---|---|
options |
{ deviceName: string; } |
Returns: Promise<{ networks?: ESPNetwork[]; }>
provision(options: { deviceName: string; ssid: string; passPhrase?: string; }) => Promise<{ success: boolean; }>
Provision the device onto WiFi using the given ssid and passPhrase.
Param | Type |
---|---|
options |
{ deviceName: string; ssid: string; passPhrase?: string; } |
Returns: Promise<{ success: boolean; }>
sendCustomDataString(options: { deviceName: string; path: string; dataString: string; }) => Promise<{ success: boolean; returnString?: string; }>
Send a custom string to the device with the given name. This is usefull if you need to share other data with your device during provisioning. NOTE: Android will truncate returned strings to around 512 bytes. If you need to send more than 512 bytes back on a read you'll need to implement a mechanism to do so.
Param | Type |
---|---|
options |
{ deviceName: string; path: string; dataString: string; } |
Returns: Promise<{ success: boolean; returnString?: string; }>
disconnect(options: { deviceName: string; }) => Promise<void>
Disconnect from the device.
Param | Type |
---|---|
options |
{ deviceName: string; } |
openLocationSettings() => Promise<{ value: boolean; }>
Open the user's location settings for your app. Android only.
Returns: Promise<{ value: boolean; }>
openBluetoothSettings() => Promise<{ value: boolean; }>
Open the user's bluetooth settings for your app. Android only.
Returns: Promise<{ value: boolean; }>
openAppSettings() => Promise<{ value: boolean; }>
Open the OS settings for your app.
Returns: Promise<{ value: boolean; }>
enableLogging() => Promise<void>
Enable extra logging - useful for troubleshooting. Best on iOS because the iOS ESPProvision library offers much more verbose logging when enabled.
disableLogging() => Promise<void>
Disable detailed logging.
Prop | Type |
---|---|
ble |
PermissionState |
location |
PermissionState |
Prop | Type |
---|---|
ble |
{ supported: boolean; allowed: boolean; poweredOn: boolean; } |
location |
{ allowed: boolean; } |
'prompt' | 'prompt-with-rationale' | 'granted' | 'denied'
{ name: string // Your devices must have a unique name advertisementData?: ESPDeviceAdvertisingData }
{ localName?: string isConnectable?: number manufacturerData?: any serviceUUIDs?: string[] }
{ ssid: string rssi: number auth: 'open' | 'wep' | 'wpapsk' | 'wpawpa2psk' | 'wpa2enterprise' | 'unknown' }
Members | Value |
---|---|
ble |
'ble' |
softap |
'softap' |
Members | Value |
---|---|
unsecure |
'unsecure' |
secure |
'secure' |