Hi Toshko,
To use Wifi pairing, you only need to replace the function demoEncodeBluetoothRecord() with your own, encoding a Wifi record, as shown in this example:
ReturnCode demoEncodeWifiRecord(uint8_t *buffer, uint32_t length)
{
ndefRecord record;
ndefType ndefWifi;
ReturnCode err;
if (buffer == NULL)
{
return ERR_PARAM;
}
uint8_t ssid[] = { 0x01, 0x02, 0x03, 0x04 };
ndefConstBuffer bufNetworkSSID = { ssid, sizeof(ssid) };
uint8_t key[] = { 0x05, 0x06, 0x07, 0x08 };
ndefConstBuffer bufNetworkKey = { key, sizeof(key) };
ndefTypeWifi wifiConfig = {
.bufNetworkSSID = bufNetworkSSID,
.bufNetworkKey = bufNetworkKey,
.authentication = NDEF_WIFI_AUTHENTICATION_WPAPSK,
.encryption = NDEF_WIFI_ENCRYPTION_TKIP
};
err = ndefWifiInit(&ndefWifi, &wifiConfig);
if (err != ERR_NONE)
{
return err;
}
err = ndefTypeToRecord(&ndefWifi, &record);
if (err != ERR_NONE)
{
return err;
}
err = ndefRecordDump(&record, true);
if (err != ERR_NONE)
{
return err;
}
/* Encode the record starting after the first two bytes that are saved
to store the NDEF file length */
ndefBuffer bufRecord = { &buffer[2], length - 2 };
err = ndefRecordEncode(&record, &bufRecord);
if (err != ERR_NONE)
{
return err;
}
/* Store the NDEF file length on the two first bytes */
buffer[0] = bufRecord.length >> 8;
buffer[1] = bufRecord.length & 0xFF;
return err;
}
Let me know if you face any issue.
Best regards,
Jasper