Git Product home page Git Product logo

esp-idf-provisioning-android's Introduction

Provisioning Library

Provisioning library provides mechanism to send network credentials and/or custom data to an ESP32 or ESP32-S2 devices.
This repository contains the source code for the companion Android app for this provisioning mechanism.

Features

  • Search for available BLE devices.
  • Scan device QR code to provide reference to ESP device.
  • Create reference of ESPDevice manually.
  • Data Encryption
  • Data transmission through BLE and SoftAP.
  • Scan for available Wi-Fi networks.
  • Provision device.
  • Scan for available Wi-Fi networks.
  • Support for exchanging custom data.

Requirements

  • Supports Android 7.0 (API level 24) and above.

How to include

Add it in your root build.gradle at the end of repositories:

allprojects {
	repositories {
		...
		maven { url 'https://jitpack.io' }
	}
}

And add a dependency code to your app module's build.gradle file.

implementation 'com.github.espressif:esp-idf-provisioning-android:lib-2.0'

Using Provisioning Library

Introduction

Provisioning library provides a simpler mechanism to communicate with an ESP-32 and ESP32-S2 devices. It gives an efficient search and scan model to listen and return devices which are in provisioning mode. It embeds security protocol and allow for safe transmission of data by doing end to end encryption. It supports BLE and SoftAP as mode of transmission which are configurable at runtime. Its primarily use is to provide home network credentials to a device and ensure device connectivity status is returned to the application.

Getting ESPDevice

ESPDevice object is virtual representation of ESP-32/ESP32-S2 devices. It provides interface to interact with devices directly in a simpler manner. ESPProvisionManager is a singleton class that encompasses APIs for searching ESP devices using BLE or SoftAP transport. ESPDevice instances can be obtained from two ways as described following :

Scan

Device information can be extracted from scanning valid QR code. User of this API decides the camera preview layer frame by providing SurfaceView as parameter. It return single ESPDevice instance on success. Supports both SoftAP and BLE.

  
ESPProvisionManager.getInstance(context).scanQRCode(Activity activityContext, SurfaceView surfaceView, QRCodeScanListener qrCodeScanListener)
  

Create

ESPDevice can be also created by passing necessary parameters as argument of below function.

  
ESPProvisionManager.getInstance(context).createESPDevice(TransportType transportType, SecurityType securityType);
  

This will return ESPDevice with given transport and security type.

  1. For BLE Transport

    For BLE transport type, library will need BluetoothDevice to connect with actual device. To get BluetoothDevice app can call search API or also app can use own BLE scanning. Library supports searching of BLE devices which are currently in provisioning mode. It returns list of devices that are discoverable and matches the parameter criteria. This API will return BluetoothDevice objects for the devices found in BLE scan with given prefix. After user select BLE device, app can call connect API.

  
ESPProvisionManager.getInstance(context).searchBleEspDevices(String prefix, BleScanListener bleScannerListener)  
  

After user select BLE device, app can call connect API.

  
espDevice.connectBLEDevice(BluetoothDevice bluetoothDevice, String primaryServiceUuid)
  
  1. For SoftAP Transport

For SoftAP transport type, app can call connect API to connect with the device.

  
espDevice.connectWiFiDevice()  
  

For both transport app can listen device connected / disconnected events by resigtering for events.

Provisioning

The main feature of Provisioning library is to provision ESP devices. Once we get instance of ESPDevice from above APIs we need to establish session with the device before we can transmit/receive data from it. After receiving device connected event, app can get device capabilities and also set Proof of possesion if device has pop capability.

After that application can proceed to scan list of available networks visible to device. This list can be used to give option to the user to choose network of their own choice.

  
espDevice.scanNetworks(final WiFiScanListener wifiScanListener); 
  

User can choose to apply Wi-Fi settings from the above list or choose other Wi-Fi network to provision the device.

  
espDevice.provision(final String ssid, final String passphrase, final ProvisionListener provisionListener);  
  

License

Copyright 2020 Espressif Systems (Shanghai) PTE LTD  
 
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.

esp-idf-provisioning-android's People

Contributors

khushbushah25 avatar ameyinamdar avatar shahpiyushv avatar jamie-pate avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.