Fork for the GitHub

Embed: (wiki syntax)

« Back to documentation index

Wifi OOB library (WPS)

Wifi OOB library (WPS)

This module is used to manage a Wifi Out-Of-Band NDEF message, to start a communication based on Wifi. More...

Data Structures

struct  sWifiTokenInfo
 WifiToken structure, to store Network SSID, Authentication Type, Encryption Type and Network Key. More...

Enumerations

enum  Ndef_Wifi_Encryption_t { NDEF_WIFI_ENCRYPTION_NONE = 0x0000, NDEF_WIFI_ENCRYPTION_WEP = 0x0002, NDEF_WIFI_ENCRYPTION_TKIP = 0x0003, NDEF_WIFI_ENCRYPTION_AES = 0x0004 }
enum  Ndef_Wifi_Authentication_t {
  NDEF_WIFI_AUTHENTICATION_NONE = 0x0000, NDEF_WIFI_AUTHENTICATION_WPAPSK = 0x0002, NDEF_WIFI_AUTHENTICATION_SHARED = 0x0003, NDEF_WIFI_AUTHENTICATION_WPA = 0x0004,
  NDEF_WIFI_AUTHENTICATION_WPA2 = 0x0005, NDEF_WIFI_AUTHENTICATION_WPA2PSK = 0x0006
}

Functions

static void NDEF_FillWifiTokenStruct (uint8_t *pPayload, uint32_t PayloadSize, sWifiTokenInfo *pWifiTokenStruct)
 This function fills a WifiToken structure with information from the NDEF message.
static void NDEF_Read_WifiToken (struct sRecordInfo *pRecordStruct, sWifiTokenInfo *pWifiTokenStruct)
 This fonction reads the WifiToken and store data in a structure.
uint16_t NDEF_ReadWifiToken (struct sRecordInfo *pRecordStruct, sWifiTokenInfo *pWifiTokenStruct)
 This fonction reads a NDEF record and retrieves a WifiToken information if any.
uint16_t NDEF_WriteWifiToken (sWifiTokenInfo *pWifiTokenStruct, I2C *mi2cChannel)
 This fonction writes a NDEF message built with the WifiToken data given in the structure.

Variables

uint8_t NDEF_Buffer [NDEF_MAX_SIZE]
 This buffer is used to store the data sent/received by the TAG.

Detailed Description

This module is used to manage a Wifi Out-Of-Band NDEF message, to start a communication based on Wifi.

The Wifi OOB format is described by the Wifi Protected Setup specification. It consists in a list of data elements formated as type-length-value. This module allows to build, write & read such data embedded in a NDEF message.

Wifi NDEF library usage

How to write a Wifi OOB

The Wifi OOB written in a NDEF record by this module has the following structure:

  • Version
  • Credential
    • Network index
    • SSID
    • Authentication Type
    • Encryption Type
    • Network Key
    • MAC Address
    • Vendor Extension
      • Network Key Shareable
    • Vendor Extension
      • Version2

To write a Wifi OOB, the user must: 1. Instanciate & initialize a `sWifiTokenInfo` structure, such as:

sWifiTokenInfo wps_oob = {.NetworkSSID = "MY_SSID", .AuthenticationType = NDEF_WIFI_AUTHENTICATION_NONE, .EncryptionType = NDEF_WIFI_ENCRYPTION_NONE, .NetworkKey = "01234567"};

Note:
1. `AuthenticationType` & `EncryptionType` fields must respectively be values from enums: `Ndef_Wifi_Authentication_t` & `Ndef_Wifi_Encryption_t`. 2. If the `Network key` is set to an empty string, the library sets it to `00000000`.
Even if 0-length Network Key is supposed to be supported, smartphones dont necessarily accept it.

2. Call the `NDEF_WriteWifiToken` function on a pointer on the previous struct instance:

NDEF_WriteWifiToken(&wps_oob);

How to read a Wifi OOB

1. Read the 1st record of the NDEF message:

sRecordInfo_t rRecord; NDEF_ReadNDEF(NDEF_Buffer); NDEF_IdentifyBuffer(rRecord,NDEF_Buffer); 2. Decode the Wifi OOB:

sWifiTokenInfo wps; NDEF_ReadWifiToken(&record, &wps);

Note:
Only the `NetworkSSID` & `NetworkKey` are extracted from the Wifi OOB, other fields of the `sWifiTokenInfo` structure are left un-initialized.

Enumeration Type Documentation

Enumerator:
NDEF_WIFI_AUTHENTICATION_NONE 

WPS No Authentication (set to 0 for Android native support / should be 1)

NDEF_WIFI_AUTHENTICATION_WPAPSK 

WPS Authentication based on WPAPSK.

NDEF_WIFI_AUTHENTICATION_SHARED 

WPS Authentication based on ??

NDEF_WIFI_AUTHENTICATION_WPA 

WPS Authentication based on WPA.

NDEF_WIFI_AUTHENTICATION_WPA2 

WPS Authentication based on WPA2.

NDEF_WIFI_AUTHENTICATION_WPA2PSK 

WPS Authentication based on WPA2PSK.

Definition at line 80 of file lib_NDEF_Wifi.h.

Enumerator:
NDEF_WIFI_ENCRYPTION_NONE 

WPS No Encryption (set to 0 for Android native support / should be 1)

NDEF_WIFI_ENCRYPTION_WEP 

WPS Encryption based on WEP.

NDEF_WIFI_ENCRYPTION_TKIP 

WPS Encryption based on TKIP.

NDEF_WIFI_ENCRYPTION_AES 

WPS Encryption based on AES.

Definition at line 73 of file lib_NDEF_Wifi.h.


Function Documentation

static void NDEF_FillWifiTokenStruct ( uint8_t *  pPayload,
uint32_t  PayloadSize,
sWifiTokenInfo pWifiTokenStruct 
) [static]

This function fills a WifiToken structure with information from the NDEF message.

Parameters:
pPayloadPointer on the payload data of the NDEF message.
PayloadSizenumber of data in the payload.
pWifiTokenStructpointer on the structure to fill.
Return values:
NONE

Definition at line 107 of file lib_NDEF_Wifi.cpp.

static void NDEF_Read_WifiToken ( struct sRecordInfo *  pRecordStruct,
sWifiTokenInfo pWifiTokenStruct 
) [static]

This fonction reads the WifiToken and store data in a structure.

Parameters:
pRecordStructPointer on the record structure.
pWifiTokenStructPointer on the structure to fill.
Return values:
NONE

Definition at line 174 of file lib_NDEF_Wifi.cpp.

uint16_t NDEF_ReadWifiToken ( struct sRecordInfo *  pRecordStruct,
sWifiTokenInfo pWifiTokenStruct 
)

This fonction reads a NDEF record and retrieves a WifiToken information if any.

Parameters:
pRecordStructPointer on the record structure.
pWifiTokenStructPointer on a `sWifiTokenInfo` structure to fill with the WifiToken information.
Return values:
NDEF_OKWifiToken information from NDEF have been retrieved.
NDEF_ERRORNot able to retrieve the WifiToken information.

Definition at line 197 of file lib_NDEF_Wifi.cpp.

uint16_t NDEF_WriteWifiToken ( sWifiTokenInfo pWifiTokenStruct,
I2C *  mi2cChannel 
)

This fonction writes a NDEF message built with the WifiToken data given in the structure.

Parameters:
pWifiTokenStructPointer on the structure containing the WifiToken information.
Return values:
NDEF_OKThe NDEF message has been successfully written.
NDEF_ERRORNot able to store the NDEF message inside the tag.

Definition at line 217 of file lib_NDEF_Wifi.cpp.


Variable Documentation

uint8_t NDEF_Buffer[NDEF_MAX_SIZE]

This buffer is used to store the data sent/received by the TAG.

This buffer contains the data send/received by TAG.

Definition at line 65 of file lib_NDEF.cpp.