Fork for the GitHub
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:
Definition at line 80 of file lib_NDEF_Wifi.h.
- Enumerator:
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:
-
pPayload Pointer on the payload data of the NDEF message. PayloadSize number of data in the payload. pWifiTokenStruct pointer 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:
-
pRecordStruct Pointer on the record structure. pWifiTokenStruct Pointer 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:
-
pRecordStruct Pointer on the record structure. pWifiTokenStruct Pointer on a `sWifiTokenInfo` structure to fill with the WifiToken information.
- Return values:
-
NDEF_OK WifiToken information from NDEF have been retrieved. NDEF_ERROR Not 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:
-
pWifiTokenStruct Pointer on the structure containing the WifiToken information.
- Return values:
-
NDEF_OK The NDEF message has been successfully written. NDEF_ERROR Not 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.
Generated on Fri Jul 15 2022 10:08:35 by
1.7.2