first commit
This commit is contained in:
commit
e25eff61e1
|
@ -0,0 +1 @@
|
||||||
|
xbnet
|
|
@ -0,0 +1,17 @@
|
||||||
|
## This repo is currently a work in progress
|
||||||
|
- The README.md will be fully updated once the repo is in a stable state
|
||||||
|
|
||||||
|
|
||||||
|
# TODO:
|
||||||
|
- Need to automate rust project (xbnet)
|
||||||
|
- Configure (looks good)
|
||||||
|
- Build
|
||||||
|
- Deploy
|
||||||
|
- On ubuntu for testing
|
||||||
|
- On Linux for Tegra for TX2
|
||||||
|
- On Jetson Orin
|
||||||
|
- Working on setup_host_device.sh
|
||||||
|
- Issues with bridging interfaces
|
||||||
|
- Need to add setup_end_device.sh
|
||||||
|
- Need dokcerize service
|
||||||
|
- Possibly may need to bridge docker xbnet network will local wifi interface as well
|
|
@ -0,0 +1,28 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
get_connected_wifi_device() {
|
||||||
|
# Get the active Wi-Fi connections
|
||||||
|
connections=$(nmcli -t -f DEVICE,TYPE,STATE device | grep -E '^.*:wifi:connected$' | cut -d: -f1)
|
||||||
|
|
||||||
|
# Return the device name of the first connected Wi-Fi device, or an empty string if none are found
|
||||||
|
if [ -z "$connections" ]; then
|
||||||
|
echo ""
|
||||||
|
else
|
||||||
|
# Return the device name
|
||||||
|
echo "$connections" | head -n 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
get_connected_wifi_name() {
|
||||||
|
# Get the device name of the first connected Wi-Fi device
|
||||||
|
device=$(get_connected_wifi_device)
|
||||||
|
|
||||||
|
# Return the SSID of the Wi-Fi device, or an empty string if none is found
|
||||||
|
if [ -z "$device" ]; then
|
||||||
|
echo ""
|
||||||
|
else
|
||||||
|
# Get the SSID (Wi-Fi name) for the connected device
|
||||||
|
name=$(nmcli -t -f NAME,DEVICE connection show --active | grep -E "^.*:$device$" | cut -d: -f1)
|
||||||
|
echo "$name"
|
||||||
|
fi
|
||||||
|
}
|
|
@ -0,0 +1,45 @@
|
||||||
|
# Enable IP forwarding
|
||||||
|
sudo sysctl \
|
||||||
|
-w # Write (or set) the value of a kernel parameter
|
||||||
|
net.ipv4.ip_forward=1 # Temporarily enable IP forwarding to forward network packets from one network interface to another
|
||||||
|
|
||||||
|
# Configure NAT for the bridge
|
||||||
|
sudo iptables \
|
||||||
|
-t nat # Specify the nat table used for Network Address Translation
|
||||||
|
-A POSTROUTING # Append this rule to the POSTROUTING chain, which alters packets as they are about to leave the network interface
|
||||||
|
-o wlp0s20f3 # Apply this rule to packets leaving the wlp0s20f3 interface (Wi-Fi interface)
|
||||||
|
-j MASQUERADE # Use the MASQUERADE target to change the source IP address to the IP address of the outgoing interface, enabling multiple devices on a private network to share a single public IP address
|
||||||
|
|
||||||
|
# Configure xbnet and bridge interfaces
|
||||||
|
sudo xbnet \
|
||||||
|
/dev/ttyUSB0 \ # Port where the XBee device is connected
|
||||||
|
tun # Create a TUN (network tunnel) interface for routing IP packets
|
||||||
|
|
||||||
|
sudo ip addr \
|
||||||
|
add 192.168.100.1/24 \ # Assign the IP address 192.168.100.1 with a subnet mask of 255.255.255.0
|
||||||
|
dev xbnet0 # to the xbnet0 interface
|
||||||
|
|
||||||
|
sudo ip link \
|
||||||
|
set dev xbnet0 up # Activate the xbnet0 interface
|
||||||
|
|
||||||
|
sudo brctl \
|
||||||
|
addbr br0 # Create a new bridge interface named br0
|
||||||
|
|
||||||
|
sudo brctl \
|
||||||
|
addif br0 wlp0s20f3 # Add the Wi-Fi interface wlp0s20f3 to the bridge br0
|
||||||
|
|
||||||
|
sudo brctl \
|
||||||
|
addif br0 xbnet0 # Add the xbnet0 interface to the bridge br0
|
||||||
|
|
||||||
|
sudo ip link \
|
||||||
|
set dev br0 up # Activate the bridge interface br0
|
||||||
|
|
||||||
|
sudo ip addr \
|
||||||
|
flush dev wlp0s20f3 # Remove any IP addresses assigned to the wlp0s20f3 interface
|
||||||
|
|
||||||
|
sudo ip addr \
|
||||||
|
add 192.168.7.122/24 \ # Assign the IP address 192.168.7.122 with a subnet mask of 255.255.255.0
|
||||||
|
dev br0 # to the bridge interface br0
|
||||||
|
|
||||||
|
sudo ip link \
|
||||||
|
set dev wlp0s20f3 up # Reactivate the wlp0s20f3 interface
|
|
@ -0,0 +1,37 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Source and call get_connected_wifi_name
|
||||||
|
call_get_connected_wifi_name() {
|
||||||
|
# Source the get_connected_wifi_name.sh script
|
||||||
|
source ./scripts/get_connected_wifi_name.sh
|
||||||
|
|
||||||
|
# Call the function to get the Wi-Fi name and capture the returned Wi-Fi name
|
||||||
|
wifi_name=$(get_connected_wifi_name)
|
||||||
|
|
||||||
|
# Print the captured Wi-Fi name if it is not empty
|
||||||
|
if [ -n "$wifi_name" ]; then
|
||||||
|
echo "Connected Wi-Fi SSID: $wifi_name"
|
||||||
|
else
|
||||||
|
echo "No connected Wi-Fi devices found."
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Source and call get_connected_wifi_device
|
||||||
|
call_get_connected_wifi_device() {
|
||||||
|
# Source the get_connected_wifi_name.sh script
|
||||||
|
source ./scripts/get_connected_wifi_name.sh
|
||||||
|
|
||||||
|
# Call the function to get the Wi-Fi device and capture the returned Wi-Fi device
|
||||||
|
wifi_device=$(get_connected_wifi_device)
|
||||||
|
|
||||||
|
# Print the captured Wi-Fi device if it is not empty
|
||||||
|
if [ -n "$wifi_device" ]; then
|
||||||
|
echo "Connected Wi-Fi Device: $wifi_device"
|
||||||
|
else
|
||||||
|
echo "No connected Wi-Fi devices found."
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Call the functions
|
||||||
|
call_get_connected_wifi_name
|
||||||
|
call_get_connected_wifi_device
|
|
@ -0,0 +1,16 @@
|
||||||
|
# Configure xbnet on remote device
|
||||||
|
sudo xbnet \
|
||||||
|
/dev/ttyUSB0 \ # Port where the XBee device is connected \
|
||||||
|
tun # Create a TUN (network tunnel) interface for routing IP packets
|
||||||
|
|
||||||
|
sudo ip addr \
|
||||||
|
add 192.168.100.2/24 \ # Assign the IP address 192.168.100.2 with a subnet mask of 255.255.255.0 \
|
||||||
|
dev xbnet1 # to the xbnet1 interface
|
||||||
|
|
||||||
|
sudo ip link \
|
||||||
|
set dev xbnet1 up # Activate the xbnet1 interface
|
||||||
|
|
||||||
|
# Add default route to use host machine as gateway
|
||||||
|
sudo ip route \
|
||||||
|
add default \ # Add a default route for all outgoing traffic \
|
||||||
|
via 192.168.100.1 # Use 192.168.100.1 (the host machine) as the gateway
|
Loading…
Reference in New Issue