The provisioning service helps to configure the Wi-Fi interface credentials. It
supports TCP tunnel and Web server based provisioning services. It implements or handles
all the required AT commands to start the module in Access Point mode and open up a TCP
tunnel or serve a HTML web page to receive the Wi-Fi credentials. The provisioning
service call API syntax is provided below:
Provisioning complete and returns the
provisioned Access Point credentials. User
application can store it securely for auto
reconnection on every boot up
RNWF_PROV_FAILURE
None
Provisioning failure
The provisioning service sequence is provided below:Figure 3-40. Provisioning Service Sequence
Following example code showcases the use of provisioning service
/*
This is ONLY an example for Provisioning application
*///-------------------------------------#include<stdio.h>/* This section lists other files that are included in this file.*/#include"rnwf_app.h"#include"rnwf_wifi_service.h"#include"rnwf_provision_service.h"#include"rnwf_interface.h"voidAPP_WIFI_Callback(RNWF_WIFI_EVENT_t event, uint8_t *p_str)
{
switch(event)
{
case RNWF_SNTP_UP:
{
break;
}
case RNWF_CONNECTED:
{
printf("Wi-Fi Connected\n");
break;
}
case RNWF_DISCONNECTED:
{
printf("Wi-Fi Disconnected\nReconnecting... \n");
RNWF_WIFI_SrvCtrl(RNWF_STA_CONNECT, NULL);
break;
}
case RNWF_DHCP_IPV4_DONE:
{
printf("DHCP IPv4: %s\n", &p_str[2]);
break;
}
case RNWF_DHCP_LINK_LOCAL_IPV6_DONE:
{
printf("DHCP link-local IPv6:%s\n", &p_str[2]);
break;
}
case RNWF_DHCP_GLOBAL_IPV6_DONE:
{
printf("DHCP global IPv6:%s\n", &p_str[2]);
break;
}
case RNWF_SET_REGDOM:
{
RNWF_WIFI_SrvCtrl(RNWF_SET_WIFI_REGDOM, (void *)COUNTRY_CODE);
break;
}
case RNWF_SCAN_INDICATION:
{
break;
}
case RNWF_SCAN_DONE:
{
break;
}
case RNWF_CONNECT_FAILED:
{
break;
}
default:
{
break;
}
}
}
voidAPP_PROV_Callback(RNWF_PROV_EVENT_t event, uint8_t *p_str)
{
switch(event)
{
case RNWF_PROV_COMPLTE:
{
RNWF_PROV_SrvCtrl(RNWF_PROV_DISABLE, NULL);
RNWF_WIFI_SrvCtrl(RNWF_WIFI_SET_CALLBACK, APP_WIFI_Callback);
// Application can save the configuration in NVM
RNWF_WIFI_SrvCtrl(RNWF_SET_WIFI_PARAMS, (void *)p_str);
}
break;
case RNWF_PROV_FAILURE:
break;
default:
break;
}
}
intmain(void)
{
SYSTEM_Initialize();
RNWF_IF_Init();
// Enable Provisioning Mode
RNWF_PROV_SrvCtrl(RNWF_PROV_ENABLE, NULL);
RNWF_PROV_SrvCtrl(RNWF_PROV_SET_CALLBACK, (void *)APP_PROV_Callback);
while(1)
{
RNWF_EVENT_Handler();
}
}