Skip to content

enorms/esp-idf-provisioning-ios

 
 

Repository files navigation

ESPProvision

ESPProvision is a provisioning library written in Swift. It provides mechanism to provide network credentials and/or custom data to an ESP32, ESP32-S2 or ESP8266 devices.

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.
  • Provision device.
  • Scan for available Wi-Fi networks.
  • Console logs

Requirements

  • iOS 11.0+ / macOS 10.12+
  • Xcode 11+
  • Swift 5.1+
  • Enable Hotspot Configuration capability in Xcode.
  • Enable Access WiFI Information capability in Xcode.

Installation

CocoaPods

CocoaPods is a dependency manager for Cocoa projects. For usage and installation instructions, visit their website. To integrate ESPProvision into your Xcode project using CocoaPods, specify it in your Podfile:

pod 'ESPProvision'

Using ESPProvision

Introduction

ESPProvision provides a simpler mechanism to communicate with an ESP-32, ESP32-S2 and ESP8266 devices. It gives an efficient search and scan model to listen and return devices which are in provisioning mode. ESProvision 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/ESP8266 devices. It provides interface to interact with devices directly in a simpler manner. ESPProvisionManager is a singleton class that encompasses APIs for managing these objects. ESPDevice instances can be obtained from any of the following techniques :

Search

ESPProvision supports searching of BLE devices which are currently in provisioning mode. It returns list of devices that are discoverable and matches the parameter criteria.

ESPProvisionManager.shared.searchESPDevices(devicePrefix:"Prefix",    transport:.ble, security:.secure) { deviceList, _ in
}

Transport parameter is medium of data transmission, ESPProvision support .softAP and .ble transport. Security parameter describe if connection needed to be secure or unsecure. SoftAP search is not supported in iOS currently.

Scan

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

ESPProvisionManager.shared.scanQRCode(scanView: scannerView) { espDevice, _ in
}

Create

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

ESPProvisionManager.shared.createESPDevice(deviceName: deviceName, transport: transport, security: security){ espDevice, _ in
}

Provisioning

The main feature of ESPProvision 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. This can be achieved by calling connect as shown below :

espDevice.connect(delegate: self) { status in
}

Delegate is required to get Proof of Possession from user, if device has pop capability.

If status is connected then 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.scanWifiList { wifiList, _ in 
}

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

espDevice.provision(ssid: ssid, passPhrase: passphrase) { status in
}

License

ESPProvision is released under the Apache License Version 2.0.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Swift 96.5%
  • Objective-C 2.7%
  • Other 0.8%