The BLE WiFi Introducer app shows an example interfacing the BLE and WiFi components on a combo chip. It demonstrates GATT database initialization, DCT configuration, processing read/write requests from a BLE client, and sending data to the client. The BLE WiFi Introducer has two components, an app running on a WICED devices, and an app running on an iOS device.
WICED App Functionality:
- Reads WiFi network configuration from DCT and attempts to connect to the network
- Upon failure to join the network, BLE GATT server is started to advertise network connection characteristic values
- When the iOS app triggers the BLE GATT characteristic write event, the network credential values are received. The WICED device will attempt to connect to the network and send the result via a notification message to the iOS device
- Pressing the user button on the WICED board wipes the WiFi network credentials from the DCT and the system is rebooted
iOS App Functionality:
- Scans for a WICED based device and reads advertising data
- Connects to the WICED device and allows user to enter network credentials for the currently connected network
- Writes the network credentials to the corresponding BLE GATT characteristic values
- Indicates the success or failure state of the WICED device network connection and allows for re-entering credentials upon connection failure
Step by step usage guide:
- Use an OS X system to install the iOS Demo App (WiFIIntroducer) onto an iOS device. The files are located at <WICED_SDK>/apps/demo/ble_wifi_introducer/peerapps/iOS
- Compile and download the ble_wifi_introducer app onto a WICED device using the target "demo.ble_wifi_introducer-<platform> download run"
- Open a terminal to view the output. Since WiFi network credentials were not edited in the wifi_config_dct, the connection will fail and the BLE GATT server will start advertising. You should see output similar to the following,
- On the iOS device, connect to the WiFi AP that you want the WICED device to connect to. Open the WiFiIntroducer application and you should be greeted with the following splash screen,
- The app will scan until a nearby WICED device is detected. Bring the WICED device close to the iOS device and the following screen will be brought up
Note: If the iOS app does not detect the WICED device, kill and reopen the iOS application
- Enter the WiFi AP passphrase and press connect. You will be prompted to pair the device. Select "Pair" and a secure LE connection will be made between the iOS device and the WICED device using the ECDH algorithm to generate and exchange the secure keys.
Note: If the device has been previously paired, it may be necessary to remove the pairing before the app will run correctly. Do this by going to Settings > Bluetooth. Under My Devices, click the "i" icon next to WiFiInt and select "Forget This Device"
- The WiFi network credentials will be sent to the WICED device and the connection result will be pushed back to the iOS device. If the connection fails, press "Try Again" to re-input the passphrase. Upon successful connection, the network credentials will be saved to the DCT.
- When rebooting the WICED device, since the DCT has configured Network credentials, the BLE GATT server will not be started. You can press the user button on the WICED board to reset the DCT. The device will reboot and the BLE GATT server will start advertising.