FreeRTOS: BLE
BLE
Return to main page ↑
iot_ble_wifi_provisioning.h File Reference

WiFi provisioning Gatt service. More...

#include "iot_ble.h"
#include "iot_wifi.h"

Go to the source code of this file.

Data Structures

struct  IotBleWifiProvListNetworksRequest_t
 Defines the list wifi networks request message structure sent from the provisioining app to the device. The request is used to list already provisioned networks as well as to scan nearby access points. More...
 
struct  IotBleWifiProvAddNetworkRequest_t
 Defines add wifi network request message structure sent from the provisioining app to the device. The request is used to provision a new access point with the credentials or to connect to an already provisioned access point. Inorder to connect to an already provisioned access point, a valid accessPointStoredIndex needs to be provided. Setting flag connectToAccessPoint to true results in the device first connecting to access point successfully before provisioning it in the flash. More...
 
struct  IotBleWifiProvEditNetworkRequest_t
 Defines edit wifi network request message structure sent from provisioning app to the device. The request is used to change the priority index for a provisioned access point. Priority index ranges from 0 (Max priority) to wificonfigMAX_NETWORK_PROFILES - 1 (Minimum priority). More...
 
struct  IotBleWifiProvDeleteNetworkRequest_t
 Defines delete access point request message structure sent from provisioning app to the device. The request is used to delete a provisioned access point at an index. Index ranges from 0 (Max priority) to wificonfigMAX_NETWORK_PROFILES - 1 (Minimum priority) More...
 
struct  IotBleWifiProvNetworkInfo_t
 Defines the structure used to hold a scanned or saved network information. More...
 
struct  IotBleWifiProvResponse_t
 Defines the structure used to hold the wifi provisioning response. More...
 
struct  IotBleWifiProvSerializer_t
 

Enumerations

enum  IotBleWiFiProvRequest_t {
  IotBleWiFiProvRequestInvalid = 0, IotBleWiFiProvRequestListNetwork = 1, IotBleWiFiProvRequestAddNetwork = 2, IotBleWiFiProvRequestEditNetwork = 3,
  IotBleWiFiProvRequestDeleteNetwork = 4, IotBleWiFiProvRequestStop = 5
}
 This enumeration defines the different types of request processed by the WiFi provisioning library. More...
 
enum  IotBleWifiProvEvent_t { IOT_BLE_WIFI_PROV_CONNECT = 0x01, IOT_BLE_WIFI_PROV_CONNECTED = 0x02, IOT_BLE_WIFI_PROV_DELETED = 0x4, IOT_BLE_WIFI_PROV_FAILED = 0x8 }
 Events Used by the WIFI provisioning service. More...
 

Functions

bool IotBleWifiProv_Init (void)
 Initialize wifi provisioning over BLE service. More...
 
bool IotBleWifiProv_RunProcessLoop (void)
 Function which runs the process loop for Wifi provisioning. Process loop can be run within a task, it waits for the incoming requests from the transport interface as well as commands from the user application. Process loop terminates when a stop command is sent from the application. More...
 
uint32_t IotBleWifiProv_GetNumNetworks (void)
 Gets the total number of provisioned networks. More...
 
bool IotBleWifiProv_Connect (uint32_t networkIndex)
 Connects to one of the saved networks in priority order. More...
 
bool IotBleWifiProv_Stop (void)
 Stop the WiFi provisionig process loop function. This enqueues a command to stop the WiFi provisioning process loop function. More...
 
bool IotBleWifiProv_EraseAllNetworks (void)
 Erase all wifi networks. More...
 
void IotBleWifiProv_Deinit (void)
 Tear down WIFI provisioning service.
 
IotBleWifiProvSerializer_tIotBleWifiProv_GetSerializer (void)
 Gets the serializer interface used to serialize/deserialize packets over BLE. By default it uses the cbor based serialization compatible with FreeRTOS wiFi provisioning mobile App. User can provide a serializer for their custom message format as well. More...
 

Detailed Description

WiFi provisioning Gatt service.

Enumeration Type Documentation

◆ IotBleWiFiProvRequest_t

This enumeration defines the different types of request processed by the WiFi provisioning library.

Enumerator
IotBleWiFiProvRequestInvalid 

Type used to denote an invalid request.

IotBleWiFiProvRequestListNetwork 

Request sent from a WiFi provisioning app to the device to list the access points.

IotBleWiFiProvRequestAddNetwork 

Request sent from a WiFi provisioning app to the device to provision an acess point.

IotBleWiFiProvRequestEditNetwork 

Request sent from a WiFi provisioning app to the device to change access point priority.

IotBleWiFiProvRequestDeleteNetwork 

Request sent from a WiFi provisioning app to the device to delete an access point.

IotBleWiFiProvRequestStop 

Request sent from an application task to stop WiFi provisioning loop.

Function Documentation

◆ IotBleWifiProv_Init()

bool IotBleWifiProv_Init ( void  )

Initialize wifi provisioning over BLE service.

Creates necessary data structures for the service. Opens ble data transfer channel and listens for incoming messages from the channel.

Returns
true if the initialization succeeded. false if the initialization failed.

◆ IotBleWifiProv_RunProcessLoop()

bool IotBleWifiProv_RunProcessLoop ( void  )

Function which runs the process loop for Wifi provisioning. Process loop can be run within a task, it waits for the incoming requests from the transport interface as well as commands from the user application. Process loop terminates when a stop command is sent from the application.

Returns
true if the process loop function ran successfully. false if process loop terminated due to an error.

◆ IotBleWifiProv_GetNumNetworks()

uint32_t IotBleWifiProv_GetNumNetworks ( void  )

Gets the total number of provisioned networks.

Returns
Number of provisioned networks

◆ IotBleWifiProv_Connect()

bool IotBleWifiProv_Connect ( uint32_t  networkIndex)

Connects to one of the saved networks in priority order.

Example usage of this API to connect to provisioned networks in priority order:

uint32_t numNetworks =  IotBleWifiProv_GetNumNetworks(); //Gets the number of provisioned networks
uint16_t priority;
TickType_t  xNetworkConnectionDelay = pdMS_TO_TICKS( 1000 ); //1 Second delay
for( priority = 0; priority < numNetworks; priority++ ) //Priority is always in descending order/0 being highest priority.
{
     bool ret = IotBleWifiProv_Connect( priority );
     if( ret == true )
     {
         break;
     }
     vTaskDelay( xNetworkConnectionDelay );
}
Returns
Returns the connected network index in the flash.

◆ IotBleWifiProv_Stop()

bool IotBleWifiProv_Stop ( void  )

Stop the WiFi provisionig process loop function. This enqueues a command to stop the WiFi provisioning process loop function.

Returns
true if succesfully enqueued command to stop WiFi provisioning loop.

◆ IotBleWifiProv_EraseAllNetworks()

bool IotBleWifiProv_EraseAllNetworks ( void  )

Erase all wifi networks.

Returns
true if success, false otherwise.

◆ IotBleWifiProv_GetSerializer()

IotBleWifiProvSerializer_t* IotBleWifiProv_GetSerializer ( void  )

Gets the serializer interface used to serialize/deserialize packets over BLE. By default it uses the cbor based serialization compatible with FreeRTOS wiFi provisioning mobile App. User can provide a serializer for their custom message format as well.

Returns
Serializer interface used