Unicode C Requires Chilkat v11.7.0+
;S:;P:;; and offer to join the network. T is WPA (also used for WPA2 and WPA3), WEP, or nopass for an open network, and H:true can be added for a hidden network. In the name and the password, the characters backslash, semicolon, comma, colon and double quote must each be preceded by a backslash.
Unicode C
Create a Wi-Fi QR Code
See more QR Code Examples
Demonstrates a QR code that joins a phone to a Wi-Fi network when scanned. A QR code only holds text. Phones recognize text of the form WIFI:T:Chilkat Unicode C Downloads
#include <C_CkJsonObjectW.h>
#include <C_CkFormatsW.h>
void ChilkatSample(void)
{
BOOL success;
HCkJsonObjectW json;
HCkFormatsW fmt;
HCkJsonObjectW jsonOut;
success = FALSE;
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
json = CkJsonObjectW_Create();
CkJsonObjectW_UpdateString(json,L"payload.text",L"WIFI:T:WPA;S:Chilkat Guest;P:correct-horse-battery-staple;;");
// Level Q, so that the code still scans when it is printed small or gets worn.
CkJsonObjectW_UpdateString(json,L"encoding.qr.errorCorrection",L"Q");
CkJsonObjectW_UpdateInt(json,L"render.moduleSize",8);
// Say which network it is under the code.
CkJsonObjectW_UpdateBool(json,L"render.text.enabled",TRUE);
CkJsonObjectW_UpdateString(json,L"render.text.value",L"Wi-Fi: Chilkat Guest");
CkJsonObjectW_UpdateInt(json,L"render.text.scale",2);
CkJsonObjectW_UpdateString(json,L"output.path",L"qa_output/qr_wifi.png");
CkJsonObjectW_UpdateBool(json,L"output.overwrite",TRUE);
CkJsonObjectW_UpdateString(json,L"output.return",L"none");
fmt = CkFormatsW_Create();
jsonOut = CkJsonObjectW_Create();
success = CkFormatsW_QrCode(fmt,L"generate",json,jsonOut);
if (success == FALSE) {
wprintf(L"%s\n",CkFormatsW_lastErrorText(fmt));
CkJsonObjectW_Dispose(json);
CkFormatsW_Dispose(fmt);
CkJsonObjectW_Dispose(jsonOut);
return;
}
wprintf(L"file: %s\n",CkJsonObjectW_stringOf(jsonOut,L"outputs[0].path"));
wprintf(L"QR version: %d\n",CkJsonObjectW_IntOf(jsonOut,L"symbols[0].selectedEncoding.version"));
wprintf(L"image: %d x %d pixels\n",CkJsonObjectW_IntOf(jsonOut,L"outputs[0].width"),CkJsonObjectW_IntOf(jsonOut,L"outputs[0].height"));
// The image written to qa_output/qr_wifi.png:
//
// Sample output:
// file: qa_output/qr_wifi.png
// QR version: 5
// image: 360 x 374 pixels
CkJsonObjectW_Dispose(json);
CkFormatsW_Dispose(fmt);
CkJsonObjectW_Dispose(jsonOut);
}