Skip to content

Commit

Permalink
Merge pull request #16 from lgbrownjr/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
lgbrownjr authored Sep 16, 2021
2 parents df56a6a + 886c99e commit 12be014
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 29 deletions.
17 changes: 6 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ You will need:
- insert the SD card into a different computer to perform the first few steps:
- Download link is [here](https://www.raspberrypi.org/downloads/raspberry-pi-os/).
- Follow Raspbian’s directions [here](https://www.raspberrypi.org/documentation/installation/installing-images/README.md).
- Eject and re-insert the SD card, and use your PC's file explorer to open the SD card - should be called *boot*.
- Eject and re-insert the SD card, and use your PC's file explorer to open the SD card which should be called *boot*.
- Add the following to the end of the first line in the `/boot/cmdline.txt` file:
- modules-load=dwc2,g_serial
- Save and close *cmdline.txt*
Expand Down Expand Up @@ -119,7 +119,7 @@ Reboot your Pi when the upgrade is complete.
---
**NOTE**

Do Not forget the fact that you changed the password and hostname of your *bridge*!
Do Not forget that you just changed the password and hostname of your *bridge*!

---

Expand Down Expand Up @@ -154,14 +154,9 @@ cd ser2bt-bridge/
sudo ./upgrade basic
```
###### We're Done!
If everything went as planned, your *raspberry pi zero w* should be acting like a bluetooth to serial bridge, allowing you to connect to a switches console port via bluetooth from your computer.
- Now, reboot your *bridge*.
- After the raspberry pi has rebooted, use your PC/laptop to pair with it.
- Look for a device advertising your pi's *hostname*
- The Pi should advertise that it supports serial communications, so you'll be able to pair it with your PC's serial ports.
- Keep in mind, that no pin will be requested. Your PC should just pair with the pi.
- Under Widows 10, after pairing, select *More Bluetooth Settings*, under *Related settings*, on the right side of the settings window.
- Once that's done, go ahead and open your favorite terminal program, and point it to the com/ttyUSBx/tty/ACMx port, and set it up to connect at 115200 bps, n/8/1, xterm.
If everything went as planned, your *raspberry pi zero w* should be acting like a bluetooth to serial bridge, allowing you to connect to a switche's console port via bluetooth from your computer.
- Now, reboot your *bridge* and skip down to How to use:

### Full setup:
#### Installation of the *UPS* & *e-ink screen*:
The addition of am e-paper screen and ups backup will allow you to continue providing power to the Pi while not being plugged into a power source, and to easily tell the status of the bridge (Pi) without having to login to check.
Expand All @@ -178,7 +173,7 @@ Coming soon!
![Raspberry Pi Zero usb port location and definition:](/readme_md_images/rpi0_diagram_port.png)
### Power on the *bridge*:
1. Different ways, depending on your setup:
1. For the basic *bridge* option, Plug the power into the *bridges* power port. See
1. For the basic *bridge* option, Plug the power into it's power port. See the diagram here:
2. If your version of the *bridge* has a UPS, then slide the switch to the on position.
3. To charge the UPS, insert the power cord into the UPS's power input plug, do not power the pi using the pi's power port.
4. It will take up to 30 seconds to boot to a point where a *master* can connect to it via bluetooth.
Expand Down
5 changes: 3 additions & 2 deletions screen_get_baud
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#! /bin/bash
# I saved this as 'screen_backtick_battery'
# I saved this as 'screen_get_baud'
# 2021-06-02: get the rfcomm0 serial interface baud rate for a backtick command in the ser2bt_bridge screen config.
# 2021-07-27: change name of file referenced above.
stty < /dev/rfcomm0 | grep speed | cut -d ";" -f 1 | grep -o "[0-9]\+"
exit 0
exit 0
16 changes: 4 additions & 12 deletions ser2bt_status
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ try:
draw = ImageDraw.Draw(image)

epd.init(epd.FULL_UPDATE)

#Draw the non variablers to the to the screen
draw.text((0, 0), host_name, font = f_top_line_font16, fill = 0)
draw.text((50, 0), 'Bat:', font = f_top_line_font16, fill = 0)
Expand All @@ -259,14 +260,10 @@ try:
draw.text((50, 80), 'BT', font = f_var_font18, fill = 0)
draw.text((153, 80), 'ser2net', font = f_var_font18, fill = 0)
draw.text((0, 100), 'TTY:', font = f_title_font18, fill = 0)

epd.displayPartBaseImage(epd.getbuffer(image)) #This is the command to actually place the above to the e-ink display.
epd.init(epd.PART_UPDATE) #Initialize the partial screen

#This following coommandis just enough to get to the first iteration of the loop without dumping out and powering down.
while True:
# Grab initial information
#This part grabs the active network interface.
epd.init(epd.PART_UPDATE) #Initialize the partial screen
try:
draw.rectangle((82, 0, 120, 16), fill=255)
draw.text((82, 0), bat_lvl(), font=f_top_line_font16, fill=0)
Expand Down Expand Up @@ -302,33 +299,28 @@ try:
bt_serial_port, bt_serial_status_pos, bt_serial_connect, bt_serial_status = cap_bt_serial_port()
total_serial_lines = int(usb_serial_status) + int(acm_serial_status)
# first, if nothing is connected, then just say that:
#IF there are no tty connections, then display full_tty_status variable (saying nothing is attached).
#If there are no tty connections, then display full_tty_status variable (saying nothing is attached).
if bt_serial_connect is False and usb_serial_connect is False and acm_serial_connect is False:
full_tty_status = "No tty Connections"
if old_full_tty_status != full_tty_status:
old_full_tty_status = full_tty_status
draw.rectangle((50, 99, 245, 122), fill=255)
draw.text((50, 100), full_tty_status, font=f_var_font18, fill=0)
old_total_serial_lines = 'XX'
# old_bt_serial_port = 'XX'
else: #Otherwise, display the inidividual state of the ttys.
full_tty_status = ""
old_full_tty_status = full_tty_status
# if old_bt_serial_port != bt_serial_port:
draw.rectangle((50, 99, 152, 122), fill=255)
draw.text((50, 100), bt_ser_short_label + ' In:', font=f_var_font18, fill=0)
draw.text((bt_serial_status_pos, 100), bt_serial_status, font=f_var_font18, fill=0)
# old_bt_serial_port = bt_serial_port
if old_total_serial_lines != total_serial_lines:
draw.rectangle((153, 99, 245, 122), fill=255)
draw.text((153, 100), 'Serial Out:', font=f_var_font18, fill=0)
draw.text((usb_serial_status_pos, 100),str(total_serial_lines), font=f_var_font18, fill=0)
old_total_serial_lines = total_serial_lines

#This block draws the rectangles, then places the refreshable text/variables into them.

epd.displayPartial(epd.getbuffer(image)) #update the screeen to actually print the above to the e-ink display.
epd.sleep()
# epd.sleep()

except IOError as e:
syslog.syslog(syslog.LOG_INFO, 'traceback.format_exc():\n%s',traceback.format_exc())
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion ser2bt-e-paper.service → services/ser2bt-e-paper.service
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ RestartSec=10
KillMode=mixed

[Install]
WantedBy=ser2bt-e-paper-init.service
WantedBy=ser2bt-e-paper-init.service
7 changes: 4 additions & 3 deletions upgrade
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ dev_folder="/dev/"
boot="/boot/"
bt_folder="bluetooth/"
project_folder="${home}Projects/ser2bt-bridge/"
project_service_folder="${project_folder}services/"
support_folder="${home}Projects/support/"
logging_folder="${home}console_logs/"
bin_folder="/usr/local/bin/"
Expand Down Expand Up @@ -507,14 +508,14 @@ fi
fi
done
printf "\nCopy service files to the ${cyn}${etc_service_folder} ${nor}directory, then disable and enable copied services:\n" | fmt --goal=91 --width=${last_col}
printf "\nCoping service files to the ${cyn}${etc_service_folder} ${nor}directory, then disable and enable copied services:\n" | fmt --goal=91 --width=${last_col}
svc_count=0
for svc_file in ${service_files[@]} ; do
if cmp --silent "${etc_service_folder}${svc_file}" "${project_folder}${svc_file}" ; then
if cmp --silent "${etc_service_folder}${svc_file}" "${project_service_folder}${svc_file}" ; then
printf " ${nor}Both versions of ${yel}${svc_file} ${nor}are the same, Skipping...\n"
let svc_count++
else
cp ${project_folder}${svc_file} ${etc_service_folder} && printf " ${yel}${svc_file} ${nor}copied.\n" || break
cp ${project_service_folder}${svc_file} ${etc_service_folder} && printf " ${yel}${svc_file} ${nor}copied.\n" || break
systemctl disable ${svc_file} > /dev/null 2>&1 && printf " ${nor}${svc_file} ${drk_grn}successfully ${nor}disabeled.\n" || break
systemctl enable ${svc_file} > /dev/null 2>&1 && printf " ${nor}${svc_file} ${drk_grn}successfully ${nor}enabeled.\n" || break
fi
Expand Down

0 comments on commit 12be014

Please sign in to comment.