codebude/QRCoder

WiFi Payload Won't Generate Correctly

Closed this issue · 2 comments

Type of issue

Bug

Expected Behavior

WiFi Payload should generate a valid QR Code for ANY kind of string.

Current Behavior

If you explicitly provide a string within the "" parameters, the QR Code will generate correctly. However, instead of typing a hard coded SSID and password, whenever I use another variable that has a string, for example "textBox1.Text", it returns an empty string rather than using whatever text is inside the TextBox. In other words, typing in: PayloadGenerator.WiFi wifiPayload = new PayloadGenerator.WiFi("MyWiFi-SSID", "MyWiFi-Pass", PayloadGenerator.WiFi.Authentication.WPA); works fine. but typing in: PayloadGenerator.WiFi wifiPayload = new PayloadGenerator.WiFi(ssidTextBox.Text, passwordTextBox.Text, PayloadGenerator.WiFi.Authentication.WPA); does NOT work! And also, I even tried using 'ssidTextBox.Text.ToString()' and still doesn't work. I'm not sure why. A string is a string regardless.

Possible Solution (optional)

Make the PayloadGenerator.WiFi class accept ANY kind of string, rather than a hard coded value

Steps to Reproduce (for bugs)

  1. Make a TextBox for a user provided SSID or password
  2. Use the value of that textbox in a PayloadGenerator.WiFi class
  3. QR Code results in generating an empty SSID and an empty password, rather than what the user inputted

Your Environment

  • Version used: 1.4.3 (latest as of 7/2/2023)
  • Compiled from source or NuGet package?: No
  • Payload/Encoded text: ssidTextBox.Text and passwordTextBox.Text
  • Used payload generator: WiFi
  • Used ECC-level: Tried with no ECC level and tried with Q. No difference
  • Used renderer class: idk what this means, sorry
  • Environment (.NET 3.5, .NET 4.X, .NETCore, ...): .NET 4.8

Please compare the result of wifiPayload.ToString() with the two different methods and see if there is a difference in the generated text.

Hi @futureflash01 ,

A string is a string regardless.

Yes, and that's also true for QRCoder. The only reason I can think of, why the QRCode generated with text from your textBox is empty, is that your textBox isn't filled/used properly. My guess is that the problem is not QRCoder but anywhere else in your code. To proof this, please change this line:

PayloadGenerator.WiFi wifiPayload = new PayloadGenerator.WiFi(ssidTextBox.Text, passwordTextBox.Text, PayloadGenerator.WiFi.Authentication.WPA);

to:

string input = ssidTextBox.Text;
PayloadGenerator.WiFi wifiPayload = new PayloadGenerator.WiFi(input, passwordTextBox.Text, PayloadGenerator.WiFi.Authentication.WPA);

If you set a breakpoint at the second line, you should see that also the input-variable is already empty.