UPDATE: "Huge" hardware upgrades!
Finished On-Boot WiFi Connect Debugging
Today I took a quick stab at running through the code of the wifi-pw.py script.
Within a minute or two I noticed that the font file references were relative file references.
So I changed the relative file reference to an absolute file reference by adding "prefix +" before it, where "prefix" = "/root/BeBoXGui/".
font = './font/Font.ttf' ### The "./" is a relative file path reference
was swithed to..
font = prefix + 'font/Font.ttf' ### I set the "prefix" as '/root/BeBoXGui' (absolute reference)
This fixed the entire script!
Since the WiFi script is (in this case) launching via "crontab -e", the script wasn't launching because of the relative file reference.
Here's a shot of my device running after successfully fixing the scripts:
Note: The actual folder name I used is arbitrary - and "/root/BeBoXGui" is the name of the folder I'm currently working in.
This is the folder name I'm working in because I've unsuccessfully been trying to build my scripts on top of BeBoXGui Kali image - until lately. Lately I took a few steps back and re-built my OLED P4wnP1 WiFi script package on top of P4wnP1 ALOA.
This is just the BeBoXGui image file without the BeBoXGui scripts.
My intent by attempting to build from BeBoXGui was to add my scripts to launch before BeBoXGui's gui.py Python script.
So the device would get connected to WiFi on boot - then display BeBoX GUI for P4wnP1 Kali Linux.
But my scripts had too many bugs and errors to simply just switch or add to BeBoXGui.
So, taking a few steps back solved everything:
I figured out how to get crontab to automatically run my scripts on boot.
Then I figured out the proper syntax which crontab requires
- absolute path to python3 binary file
- absolute path to your custom Python scripts
- your scripts can't produce any errors
After putting all of these together, my device now automatically runs all of my WiFi-connect scripts in order.
Here's the flow of the WiFi connect scripts:
If the device finds the previously-saved network in its WiFi network scan, you're prompted to Reconnect.
If the device does NOT find the previously-saved network OR the user says "No - don't reconnect", then the device displays the Select-WiFi-Network screen.
After that, the Enter Password screen appears.
Finally, the script sends the command to connect us to WiFi.
Once connected to WiFi, our device runs a "ping google.com" command to check if we have a solid Internet connection.
Finally, the script asks if we want to Save the WiFi network.
Testing with Previously-Seen & Unseen WiFi Networks
I tested the on-boot WiFi Connect script package by connecting to a previously-unseen WiFi network (with my "saved" WiFi network turned off) - all scripts ran as intended by successfully connecting to my WiFi networks.
One of these tests I performed using a standard WiFi modem/router combo (like you get from your ISP).
The other test was done using my phone's built-in WiFi hotspot.
(I tested the script package's feature to re-connect to a previously saved network by using my phone's WiFi hotspot - and it connected properly.)
TIP: This seems to be the easiest way to use the WiFi connect script package:
- Set up a WiFi hotspot using your phone
- When setting up the hotspot, make an easy-to-input password. This can be a time saver due to the limits of the buttons on the OLED screen. They're small buttons, so we don't want to spend a ton of time entering really-long WiFi passwords.
Current Contents of OLED-WiFi-P4wnP1 Script Package
Here's a recap / latest rendition of the scripts included in the OLED WiFi Connect package.
- (wifi-splash.py -
coming soon) *** UPDATE: DONE - Shows splash screen
- wifi-scan.py scans for WiFi networks
- wifi-askreconnect.py checks if the "saved" WiFi network was found in the WiFi scan. If yes, the script asks to auto-reconnect. If reconnecting, the script connects now and skips the next 2 scripts (wifi-disp.py and wifi-pw.py)
- wifi-disp.py displays the found networks for the user to select
- wifi-pw.py displays the "Enter WiFi Password" screen, then connects to the WiFi network selected in the previous script (wifi-disp.py)
- wifi-chek.py checks the WiFi connection and pings google.com to see if the device can reach the Internet
- wifi-asksave.py asks if the user wants to save the WiFi network and password in a (currently unsafe) txt file (similar to wpa_supplicant.conf)
- (wifi-dash.py - coming soon)
- Create a splash screen (DONE) wifi-splash-launch.py
- Add splash screen into crontab -e / wifi-wrap.py (DONE)
- Extra: Made OLED "animation" out of P4WNSOLO splash screen
- Add an exit screen
- Make a super simple dashboard
- (NEXT) Add a "Reconnecting" screen
- (NEXT) Modify wifi-disp.py to scroll
- Get it running on Raspberry Pi Zero 2 W with Raspberry Pi OS 64 / Ubuntu 64 / Kali 64 ?
- Make a "raspi-config-OLED-wrapper"?
- Pipes raspi-config menu choices to OLED
- Sends up/down/Enter keystroke for menu choices
- Sends text input using wifi-pw.py (the "Enter Password" screen in the WiFi script)
- Clone the entire script package and adapt it to connect Raspberry Pi via Bluetooth
- Clone and adapt to setup WiFi AP (Access Point)?
- Encrypt "saved" WiFi info using these steps by the official RPi site.
- Make wifi-scan.py auto-rescan every X seconds. Also add a re-scan button and a cancel button
- Add a pawn animation (rotating clockwise? shrinking / growing? use fa-chess-pawn?)
- Add feature to fetch RSS feed
- Display P4wnP1 Web Admin URL on-screen (ex: http://172.16.0.1:8000)
- Add noVNC, button to enable/disable and address (ex: 192.168.68.100:2)
- Add font options? Must be monospace. Make a fontname.txt file?
10 Ways to Make Code Better
- Add more comments
- Remove old / extra comments
- Consistent file names / variable names (ex: cfg-wifi-wpa.txt, cfg-wifi-ssid.txt, cfg-wifi-ssids.txt)
- Remove old files from folder
- Explain what the script does at the top of each script
- Give a summary of the sections in the script
- Add debug / logging lines
- Output debug to txt file
BIG (Little) Hardware Upgrades!
I finally received my 180 degree USB adapter! Sweet!
I was excited to receive this because I wanted to plug my OLED P4wnP1 into a power bank without using a cable. The only way to get this done was to use a "hard" adapter straight out from the power bank. The right-angle adapters I tried were too big - and left the P4wnP1 dangling about a half inch above the front of the power bank.
That's why I checked out USB 180 degree adapters. They're perfect for this case - almost:
The clearance on these adapters is not enough to clear most power banks.
BUT - it is enough to clear "ultra thin" power banks. This means (if the power bank has an equal amount of space between one edge of the USB port and the other edge) that the power bank must be 0.5 inches wide or less. This is because the USB 180 adapter has roughly 0.25 inches of clearance.
The USB 180 adapter actually has about 0.2 inches of clearance, so feel free to use a small chisel to shave off just a hair of the outer rubber casing on the USB adapter to make that extra 0.05 inches of spaces. This is officially not recommended since it could technically create a safety concern. But I'd definitely do it so there's enough clearance - and your OLED P4wnP1 rests flat on the face of your power bank.
My Current OLED P4wnP1 Hardware Setup:
- Raspberry Pi Zero W (with GPIO header pins snipped down to slimagotchi height)
- iUniker USB dongle adapter for Raspberry Pi Zero (W / 2)
- Ultra Thin Power Bank (look for 5000mAh) with 0.25in of clearance or less (see above)
- USB 180 Adapter
- 1.3" Waveshare OLED display hat
Future additions & improvements:
Unu Case from Daddy makes stuff (on Tindie)
2mm x 1mm neodymium magnets - search Amazon for B07RTQW58Z
Icon / Logo Concept:
Icon: Font awesome pawn (fa-chess-pawn)
Device: Thumb drive icon to resemble an OLED P4wnP1 device / weapon / tool