3.1.7.4 Provisioning Service
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:
RNWF_RESULT_t RNWF_PROV_SrvCtrl(RNWF_PROV_SERVICE_t request, void *input)
The provisioning service provides the following options for the user:
The following list captures the provisioning service callback event
codes and their arguments
Options | Inputs | Remarks |
---|---|---|
RNWF_PROV_ENABLE | None | Enables the provisioning service |
RNWF_PROV_DISABLE | None | Disables the provisioning service |
RNWF_PROV_SET_CALLBACK | Callback handler | Registers the application callback function to report the provisioning status |
Event | Response Components | Remarks |
---|---|---|
RNWF_PROV_COMPLTE | Mode, SSID, Passphrase, Security, Autoenable | 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:
Following example code showcases the use of provisioning service
/* Provisioning application */ void APP_WIFI_Callback(RNWF_WIFI_EVENT_t event, uint8_t *p_str) { switch(event) { 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_DONE: printf("DHCP IP:%s\n", &p_str[2]); break; default: break; } } void APP_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; } } int main(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(); } }