Microchip® Advanced Software Framework

wifi_provisioning.h File Reference

WiFi Provisioning Profile declarations.

Copyright (c) 2017-2019 Microchip Technology Inc. and its subsidiaries.

#include "ble_manager.h"
#include "driver/include/m2m_wifi.h"
#include "wifi_con.h"

Data Structures

struct  _scanitem
 Store the scan list and then later populate when creating the database. More...
 
struct  credentials
 
struct  credentials_mschapv2
 
struct  credentials_tls
 
struct  wifi_provision_scanlist
 

Macros

#define BLE_IS_CONNECTED   (1)
 
#define BLE_IS_NOT_CONNECTED   (0)
 BLE connected or otherwise. More...
 
#define CREDENTIALS_NOT_VALID   (0)
 credentials provisioning status More...
 
#define CREDENTIALS_VALID   (1)
 
#define WIFI_PROVISION_ADV_DATA_NAME_DATA   ("3400-DEMO")
 
#define WIFI_PROVISION_ADV_DATA_NAME_LEN   (11)
 WIFI_PROVISION_ADV_DATA_NAME_LEN the length of the device name. More...
 
#define WIFI_PROVISION_ADV_DATA_NAME_TYPE   (0x09)
 WIFI_PROVISION_ADV_DATA_NAME_TYPE the gap ad data type. More...
 
#define WIFI_PROVISION_ADV_SCAN_RESP_LEN   (31)
 advertisement or scan response length. More...
 
#define WIFI_PROVISION_ADV_TIMEOUT   (1000)
 
#define WIFI_PROVISION_FAST_ADV   (100)
 WIFI_PROVISION_FAST_ADV between 0x0020 and 0x4000 in 0.625 ms units (20ms to 10.24s). More...
 
#define WIFI_PROVISION_MAX_AP_NUM   (15)
 maximum number of APs in scan list given to remote device More...
 
#define WIFI_PROVISION_MAX_PASS_LENGTH   (64)
 maximum pass phrase length More...
 
#define WIFI_PROVISION_MAX_SSID_LENGTH   (32)
 maximum ssid length More...
 
#define WIFI_PROVISION_MAX_USERNAME_LENGTH   (34)
 maximum username length More...
 
#define WIFI_PROVISION_SCP_TYPE_MORE_128_BIT_UUID   (0x06)
 Scan response type Incomplete List of 128-bit Service Class UUIDs. More...
 
#define WIFI_PROVISION_STATE_FAILED   (0x10)
 
#define WIFI_PROVISION_STATE_HAVE_CREDENTIAL   (0x08)
 
#define WIFI_PROVISION_STATE_IDLE   (0x00)
 provisioning state that the app can query More...
 
#define WIFI_PROVISION_STATE_IN_PROGRESS   (0x04)
 
#define WIFI_PROVISION_STATE_REQUESTING_SCAN   (0x01)
 
#define WIFI_PROVISION_STATE_WIFI_SCANNING   (0x02)
 
#define WIFI_PROVISION_TLS_CERT_LENGTH   ((1024*2)-32)
 maximum TLS CERT length More...
 
#define WIFI_PROVISION_TLS_KEY_LENGTH   (1024*2)
 maximum TLS key length More...
 

Typedefs

typedef struct _scanitem scanitem
 
typedef at_ble_status_t(* wifi_provision_cred_callback_t )(credentials *)
 
typedef at_ble_status_t(* wifi_provision_scanning_callback_t )(void)
 
typedef void(* wifi_provision_u8_callback_t )(uint8_t)
 

Enumerations

enum  {
  WIFI_PROVISION_SCANMODE_SCANNING = 1,
  WIFI_PROVISION_SCANMODE_DONE
}
 scanning status: can be scanning or scan done when the AP list is refreshed More...
 
enum  {
  WIFI_CONNECTION_STATE_NOTSTARTED,
  WIFI_CONNECTION_STATE_PROVISIONFAILED,
  WIFI_CONNECTION_STATE_CONNECTING,
  WIFI_CONNECTION_STATE_PROVISIONED
}
 WiFi status;application can inform on this. More...
 

Functions

void ble_connected (void)
 application updates ble has connected More...
 
void ble_disconnected (void)
 application updates ble has disconnected More...
 
uint8_t ble_is_connected (void)
 function for querying ble connect status More...
 
void disconnect_ble (void)
 application requests ble be disconnected More...
 
void inform_wifi_connection_state (uint8_t s)
 application updates wifi provisioning on wifi connect state More...
 
at_ble_status_t provision_start (void)
 start or restart provision and advertise and get scan list More...
 
void register_wifi_provision_credentials_handler (wifi_provision_cred_callback_t credentials_fn)
 application to register the credential update function callback More...
 
void register_wifi_provision_scanning_handler (wifi_provision_scanning_callback_t scanning_fn)
 application to register the scanning function callback More...
 
void request_scan (void)
 application requests wif scanning More...
 
uint8_t wifi_provision_char_changed_handler (at_ble_characteristic_changed_t *char_handle)
 character changed handler More...
 
at_ble_status_t wifi_provision_define (void)
 profile services definition to the attribute data base More...
 
void wifi_provision_init (void *param)
 Initialize the profile, includes all initializations and start up routines of the profiles. More...
 
uint8_t wifi_provision_processing (void)
 application periodically kicks wifi provision processing More...
 
uint8_t wifi_provision_scanlist_receive (wifi_provision_scanlist *param)
 application updates the wifi scan list More...
 
uint8_t wifi_provision_svc_changed_handler (uint8_t *data)
 ble stack indicate service client configuration change More...
 

#define BLE_IS_CONNECTED   (1)

Referenced by ble_connected().

#define BLE_IS_NOT_CONNECTED   (0)

BLE connected or otherwise.

Referenced by ble_disconnected(), provision_start(), and wifi_provision_init().

#define CREDENTIALS_NOT_VALID   (0)

credentials provisioning status

#define CREDENTIALS_VALID   (1)
#define WIFI_PROVISION_ADV_DATA_NAME_DATA   ("3400-DEMO")
#define WIFI_PROVISION_ADV_DATA_NAME_LEN   (11)

WIFI_PROVISION_ADV_DATA_NAME_LEN the length of the device name.

Referenced by prepare_advertisement().

#define WIFI_PROVISION_ADV_DATA_NAME_TYPE   (0x09)

WIFI_PROVISION_ADV_DATA_NAME_TYPE the gap ad data type.

Referenced by prepare_advertisement().

#define WIFI_PROVISION_ADV_SCAN_RESP_LEN   (31)

advertisement or scan response length.

Referenced by prepare_advertisement().

#define WIFI_PROVISION_ADV_TIMEOUT   (1000)

Referenced by start_advertise().

#define WIFI_PROVISION_FAST_ADV   (100)

WIFI_PROVISION_FAST_ADV between 0x0020 and 0x4000 in 0.625 ms units (20ms to 10.24s).

Referenced by start_advertise().

#define WIFI_PROVISION_MAX_AP_NUM   (15)

maximum number of APs in scan list given to remote device

Referenced by send_scan_result().

#define WIFI_PROVISION_MAX_PASS_LENGTH   (64)
#define WIFI_PROVISION_MAX_SSID_LENGTH   (32)
#define WIFI_PROVISION_MAX_USERNAME_LENGTH   (34)

maximum username length

Referenced by wifi_provision_char_changed_handler().

#define WIFI_PROVISION_SCP_TYPE_MORE_128_BIT_UUID   (0x06)

Scan response type Incomplete List of 128-bit Service Class UUIDs.

Referenced by prepare_advertisement().

#define WIFI_PROVISION_STATE_HAVE_CREDENTIAL   (0x08)
#define WIFI_PROVISION_STATE_IDLE   (0x00)
#define WIFI_PROVISION_STATE_IN_PROGRESS   (0x04)
#define WIFI_PROVISION_STATE_WIFI_SCANNING   (0x02)
#define WIFI_PROVISION_TLS_CERT_LENGTH   ((1024*2)-32)

maximum TLS CERT length

Referenced by wifi_provision_char_changed_handler().

#define WIFI_PROVISION_TLS_KEY_LENGTH   (1024*2)

maximum TLS key length

Referenced by wifi_provision_char_changed_handler().

typedef struct _scanitem scanitem
typedef at_ble_status_t(* wifi_provision_cred_callback_t)(credentials *)
typedef at_ble_status_t(* wifi_provision_scanning_callback_t)(void)
typedef void(* wifi_provision_u8_callback_t)(uint8_t)

anonymous enum

scanning status: can be scanning or scan done when the AP list is refreshed

Enumerator
WIFI_PROVISION_SCANMODE_SCANNING 
WIFI_PROVISION_SCANMODE_DONE 
anonymous enum

WiFi status;application can inform on this.

Enumerator
WIFI_CONNECTION_STATE_NOTSTARTED 
WIFI_CONNECTION_STATE_PROVISIONFAILED 
WIFI_CONNECTION_STATE_CONNECTING 
WIFI_CONNECTION_STATE_PROVISIONED 

void ble_connected ( void  )

application updates ble has connected

application updates ble has connected

References BLE_IS_CONNECTED, is_BLE_Connected, and PROVISION_PRINTF.

Referenced by ble_app_connected_update().

uint8_t ble_is_connected ( void  )

function for querying ble connect status

Returns
ble connected true or false

References is_BLE_Connected.

Referenced by provision_start(), and start_provisioning_app().

void disconnect_ble ( void  )

application requests ble be disconnected

application requests ble be disconnected

References at_ble_adv_stop(), at_ble_disconnect(), and AT_BLE_TERMINATED_BY_USER.

Referenced by provision_app_ble_disconnect().

void register_wifi_provision_credentials_handler ( wifi_provision_cred_callback_t  credentials_fn)

application to register the credential update function callback

Parameters
[in]application'scredential function

References credentials_cb.

Referenced by initialise_provisioning_app().

void register_wifi_provision_scanning_handler ( wifi_provision_scanning_callback_t  scanning_fn)

application to register the scanning function callback

Parameters
[in]application'sscanning function

References scanning_cb.

Referenced by initialise_provisioning_app().

void request_scan ( void  )

application requests wif scanning

application requests wif scanning

References wifi_provision_set_state(), and WIFI_PROVISION_STATE_REQUESTING_SCAN.

uint8_t wifi_provision_char_changed_handler ( at_ble_characteristic_changed_t char_handle)

character changed handler

Parameters
[in]at_ble_characteristic_changed_twhich includes handle,new value
Precondition
Must be called when character change event occurred
Returns
AT_BLE_SUCCESS operation completed successfully
AT_BLE_FAILURE Generic error.

character changed handler

References APPARAM_MULTIPART_LENGTH, APPARAM_MULTIPART_PASS_POS, APPARAM_MULTIPART_PASSLEN_POS, APPARAM_MULTIPART_SECTYPE_POS, APPARAM_MULTIPART_SSID_POS, APPARAM_MULTIPART_SSIDLEN_POS, APPARAM_MULTIPART_TLSCERT_POS, APPARAM_MULTIPART_TLSCERTLEN_POS, APPARAM_MULTIPART_TLSKEY_POS, APPARAM_MULTIPART_TLSKEYLEN_POS, APPARAM_MULTIPART_USERLEN_POS, APPARAM_MULTIPART_USERNAME_POS, AT_BLE_SUCCESS, credentials_tls::certificate, credentials_tls::certificate_length, at_ble_characteristic_changed_t::char_len, at_ble_characteristic_changed_t::char_new_value, at_ble_characteristic_changed_t::char_offset, credentials_cb, FAILED_WIFICON_CHANGE_PARAM, FAILED_WIFISCAN_CHANGE_PARAM, INVALID_WIFICON_CHANGE_PARAM, credentials_tls::keydata, credentials_tls::keydata_length, multi_part, credentials::passphrase, credentials_mschapv2::passphrase, credentials::passphrase_length, credentials_mschapv2::passphrase_length, PROVISION_PRINTF, PROVISION_PRINTF_CONT, credentials::sec_type, credentials_tls::sec_type, credentials_mschapv2::sec_type, credentials::ssid, credentials_tls::ssid, credentials_mschapv2::ssid, credentials::ssid_length, credentials_tls::ssid_length, credentials_mschapv2::ssid_length, credentials_mschapv2::username, credentials_mschapv2::username_length, VALID_WIFICON_CHANGE_PARAM, VALID_WIFISCAN_CHANGE_PARAM, WIFI_PROVISION_MAX_PASS_LENGTH, WIFI_PROVISION_MAX_SSID_LENGTH, WIFI_PROVISION_MAX_USERNAME_LENGTH, WIFI_PROVISION_SCANMODE_SCANNING, wifi_provision_set_state(), WIFI_PROVISION_STATE_FAILED, WIFI_PROVISION_STATE_HAVE_CREDENTIAL, WIFI_PROVISION_STATE_REQUESTING_SCAN, WIFI_PROVISION_TLS_CERT_LENGTH, WIFI_PROVISION_TLS_KEY_LENGTH, wificon_char_change_apparam(), wificon_char_change_state_client_cfg(), and wifiscan_char_change_scanmode().

at_ble_status_t wifi_provision_define ( void  )

profile services definition to the attribute data base

Parameters
[in]void
Precondition
Must be called after ref wifi_provision_init
Returns
AT_BLE_SUCCESS operation completed successfully
AT_BLE_FAILURE Generic error.

profile services definition to the attribute data base

References AT_BLE_SUCCESS, printf, wificon_primary_service_define(), and wifiscan_primary_service_define().

Referenced by wifi_provision_init().

void wifi_provision_init ( void *  param)

Initialize the profile, includes all initializations and start up routines of the profiles.

Parameters
[in]void
Precondition
Must be called after ble_init
Returns
void

Initialize the profile, includes all initializations and start up routines of the profiles.

References BLE_IS_NOT_CONNECTED, is_BLE_Connected, wifi_provision_define(), wifi_provision_service_init(), wifi_provision_set_state(), and WIFI_PROVISION_STATE_IDLE.

uint8_t wifi_provision_processing ( void  )
uint8_t wifi_provision_svc_changed_handler ( uint8_t *  data)

ble stack indicate service client configuration change

Parameters
[in]servicechange data

References at_ble_characteristic_value_set(), AT_BLE_SUCCESS, s, and wificon_gatt_service_handler::serv_handle.