Today I'm working on the QR Code Generator.
UPDATE #1: I got it mostly done.
UPDATE #2: I re-inverted the QR code (so it's not inverted now). This results in a clearer, more readable, faster-scanning QR code. Also, some QR Code scanner apps simply just don't work with color-inverted QR codes.
UPDATE #3: I added a button to give you more time to view the QR code and a button to Go Back (see bottom of page)
I also added a white bar at the bottom of the screen to display the URL behind the code.
To top it off, the white bar at the top of the screen connects to the QR code and URL in one piece.
But before I got it looking like it did in the pic above, here's a pic after I got the screen elements arranged:
The Initial Plan
Here's what I set out to do:
- Rotate screen 180 degrees
- Print the following in the unused part of the screen:
- URL for:
- (SSH / NoVNC / Spiderfoot / Phoneinfoga / P4wnP1 WebGUI / script-server)
- Exit button
- Help button (decided not to go with this - instead went with "Previous / Next Service" buttons - see below)
What I Actually Did
After wrestling with this code for hours, I finally got it to a decent spot:
- QR Code in left half of screen (64x64 px)
- Heading bar in top right part of screen (shows name of service for current QR Code, for example: "SSH")
- Immediately below the heading bar is the name of the Previous service (ex: P4wnP1 WebGUI)
- After that, we have the name of the Next service (ex: VNC)
- Then we have an "X" to indicate that KEY3 takes you BACK and out of the QR Code screen
- Finally, p4wnsolo prints the text contained within the QR Code (for manual entry and viewing)
The heart of the QR Code Generator feature in p4wnsolo is a simple Python library on Github called python-qrcode.
At some point I used this StackOverflow post to call a subprocess and get its output.
I split a string or two in Python.
In Python, I also used a method to rotate an image 180 degrees.
For the circles to indicate what happens when a button is pressed, I made ellipses in Python.
And I'm still stoked on this one-liner Linux command to get your IP address.
To Do for QR Code Generation
I didn't get around to adding the "Generating QR Code - Please wait" display screen.
- Copy this from wifi-askreconnect.py (the screen that says "Reconnecting.. Connected").
- After that, just add a countdown timer to autokill the script after 10 seconds or so - and/or add an Exit button (currently slated for KEY3).
Currently Working with These Filenames:
Finished (with the Display part):
I finally got the QR Code to show up un-inverted along with the other text on the screen.
This took awhile.
But it's done:
Run this command to view on OLED SH1106:
python3 filename.py -i spi --display sh1106
Update #3: Exit Button, Countdown, Loading Screen
I added an "Exit" button (KEY3) to exit the script when the button is pressed.
Then I added a countdown timer which also exits the script when the timer reaches 0.
Finally, I added a "Generating (Service Name) QR Code. Please Wait" screen
Currently working with these filenames:
Added "+" Button for More Time
- Pressing the + button (KEY2) adds 20 seconds to the countdown timer, toggles the background color of the ellipse for KEY2, and adds a + in front of the current # of seconds on the screen.
- I also changed the text in the middle of the screen to tell you how to use that particular QR code. For example, "ssh" will say "Use with: SSH App", while "web SSH" will say "Use with: Browser".
- Add the QR Code script to Crontab (place it just before the Dashboard is launched)
- Make the QR Code accept a new parameter (servicename) to tell the script what PORT and URL PREFIX to output. Ex: ssh / vnc / spiderfoot / phoneinfoga / wifiap / hostname
- Adapt the key_demo.py script to display different QR codes with different button presses (using parameter-ized QR Code script)
To simplify this and tie it all together, can we make the QR Generate / display code into a function w/parameter?
This way we could just call the function from within key_demo.py. Ex: showqr('spiderfoot')
List of QR Codes to Make for Raspberry Pi (P4wnP1)
- P4wnP1 Web GUI
- SSH (Done)
- Web SSH
- Spiderfoot (Done)
- WiFi AP