Generate QR Code Image in WinCC OA …

Add a label object into your screen and add some lines of code to get a QR image. In this example a mobile phone app will scan the QR code and send username and password via a GraphQL server to WinCC OA and set it on datapoints (username and password should additionally be encrypted).

#uses "CtrlQRCode"

string g_code;

main()
{
  g_code = createUuid();
  strreplace(g_code,"{", "");
  strreplace(g_code,"}", "");
  DebugTN(g_code);

  string fpath = PROJ_PATH+"/pictures/";
  string fname = "login_qr_code_"+myUiNumber();
  int ret = createQRCodeFile(g_code, fpath+fname);
  this.image=fname+".png";

  dpConnect("work", false, "QRLogin.code", "QRLogin.usr", "QRLogin.pwd");
}

void work(string dp, string code, string dp1, string usr, string dp2, string pwd)
{
  if (code == g_code)
  {
    setInputFocus(myModuleName(), myPanelName(), txt_username.name());
    txt_username.text = usr;
    setInputFocus(myModuleName(), myPanelName(), txt_password.name());
    txt_password.text = pwd;
    m_loginFrameworkController.doContinue();
  }
}