2024-08-08 12:19:09 -03:00
## This repo is currently a work in progress
- The README.md will be fully updated once the repo is in a stable state
2024-08-08 14:11:30 -03:00
## TODO
- Need to automate Rust project (xbnet)
2024-08-08 12:19:09 -03:00
- Configure (looks good)
- Build
- Deploy
2024-08-08 14:11:30 -03:00
- On Ubuntu for testing
2024-08-08 12:19:09 -03:00
- 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
2024-08-08 14:11:30 -03:00
- Need to dockerize service
- Possibly may need to bridge docker xbnet network with local wifi interface as well
2024-08-16 13:37:05 -03:00
- Make a submodule of xbnet, or copy over raw files, depending on future decisions
---
2024-08-21 10:48:40 -03:00
# SERVICES-XBEE_NET
2024-08-16 13:37:05 -03:00
This project contains a Dockerized setup to create and manage an XBee network using the `xbnet` utility. The network interface is bridged with a host Wi-Fi interface, enabling internet access for connected devices.
2024-08-16 18:07:17 -03:00
##### Note: This project uses the `tap` xbnet protocol, which is a layer 2 protocol. This supports full ethernet pipeline. For a simple IP level protocol support, the `tun` xbnet protocol can be used.
2024-08-16 13:37:05 -03:00
## File Structure
2024-08-21 10:48:40 -03:00
```bash
services-xbee_net/
2024-08-16 13:37:05 -03:00
├── scripts/
│ ├── entrypoint.sh # Entrypoint script for Docker container
│ ├── get_connected_wifi_info.sh # Script to fetch connected Wi-Fi device information
│ ├── health_check.sh # Script to perform health checks on the container
2024-08-29 12:25:32 -03:00
| ├── debug/ # Directory for testing-related scripts and files
│ | ├── create_tap_device.sh # Create a tap device directly on an OS
│ | ├── destroy_tap_device.sh # Destroy a tap device directly on an OS
│ | ├── enable_host_macvlan.sh # Destroy a tap device directly on an OS
│ | ├── host_setup.sh # Script to set up Masquerade bridge docker0 network with active wifi
│ | ├── test.sh # Script to run tests
2024-08-16 13:37:05 -03:00
├── tests/ # Directory for testing-related scripts and files
├── xbnet/ # The xbnet source code directory
├── .env # Environment variables for the Docker setup
├── .gitignore # Git ignore file
├── docker-compose-run-multiple.yml # Docker Compose file to run multiple instances
├── docker-compose.yml # Main Docker Compose file
├── Dockerfile # Dockerfile to build the Docker image
├── README.md # Project documentation
2024-08-29 12:25:32 -03:00
└── run-single.sh # Script to set up env vars and start a docker service with a single xbnet node
2024-08-16 13:37:05 -03:00
```
## Prerequisites
Ensure Docker and Docker Compose are installed on your machine.
## Getting Started
2024-08-21 10:48:40 -03:00
#### 1. Clone the Repository
2024-08-16 13:37:05 -03:00
```bash
2024-08-21 10:48:40 -03:00
git clone https://git.spirirobotics.com/Spiri/services-xbee_net
2024-08-16 18:10:04 -03:00
cd services-xbee_net
2024-08-16 13:37:05 -03:00
```
2024-09-04 14:26:59 -03:00
#### 2. To run the project in `PRODUCTION` mode, use the following cmd:
2024-08-16 13:37:05 -03:00
2024-09-04 14:26:59 -03:00
- `docker-compose -f docker-compose.yml up --build`
2024-08-16 13:37:05 -03:00
2024-09-04 14:26:59 -03:00
- Configure the project for user specs, modify the `docker-compose.yml` file for the following parameters:
```bash
environment:
- XBEE_INDEX=1
- XBEE_BAUDRATE=230400
- XBEE_PORT=/dev/ttyUSB0
- XBNET_BASE_SUBNET=2.2.2
- XBNET_INTERFACE_TYPE=router # ["router" | "gateway"]
- XBNET_PROTO=tap # ["tap" | "tun"]
```
2024-09-03 10:09:03 -03:00
2024-09-04 14:26:59 -03:00
#### 3. To run a single xbnet node in `DEVELOPEMENT` mode, use the following cmd:
2024-08-28 16:45:47 -03:00
2024-09-04 14:26:59 -03:00
- Router mode: `sh ./run-single.sh --subnet=7.7.7 --serial-speed=230400 --port=/dev/ttyUSB0 --interface-type=router`
- Gateway mode: `sh ./run-single.sh --subnet=7.7.7 --serial-speed=230400 --port=/dev/ttyUSB0 --interface-type=gateway`
2024-08-21 10:48:40 -03:00
2024-09-04 14:26:59 -03:00
#### OR Manually build and Start the Docker Container
NOTE: This will require the config `.env` to be manually modified, based on user needs.
2024-08-16 13:37:05 -03:00
2024-08-29 12:25:32 -03:00
- Configure a single xbnet net service using:
```bash
# Configuration for xbnet0
XBEE_PORT=/dev/ttyUSB0
XBEE_BAUDRATE=230400
XBEE_NET_SRC_IP=192.168.1.100 # Ensure this IP matches the network range
XBEE_NET_IFACE_NAME=xbnet0
# Default Gateway
DEFAULT_GATEWAY=192.168.1.1
```
2024-09-04 14:26:59 -03:00
#### 4. To run a multiple xbnet nodes in `DEVELOPEMENT` mode, use the following cmd:
- Router 1: `sh ./run-multiple.sh --index=1 --subnet=7.7.7 --serial-speed=230400 --port=/dev/ttyUSB0 --interface-type=router`
- Router 2: `sh ./run-multiple.sh --index=2 --subnet=7.7.7 --serial-speed=230400 --port=/dev/ttyUSB0 --interface-type=router`
- Gateway: `sh ./run-multiple.sh --subnet=7.7.7 --serial-speed=230400 --port=/dev/ttyUSB0 --interface-type=gateway`
NOTE: This will require the config `.env` to be manually modified, based on user needs.
2024-08-29 12:25:32 -03:00
- Configure multiple xbnet net services using:
```bash
# Configuration for xbnet0 (REQUIRED: minimum config to run a single xbnet node)
XBEE0_PORT=/dev/ttyUSB0 # The serial port for the XBee device
XBEE0_BAUDRATE=230400 # Baud rate for the XBee device
XBEE0_NET_SRC_IP=192.168.1.100 # Source IP for the XBee network
XBEE0_NET_IFACE_NAME=xbnet0 # Interface name for the XBee network
# Configuration for xbnet1 (OPTIONAL: only required for multi node xbnets)
XBEE1_PORT=/dev/ttyUSB1
XBEE1_BAUDRATE=230400
XBEE1_NET_SRC_IP=192.168.1.101
XBEE1_NET_IFACE_NAME=xbnet1
# Default Gateway (REQUIRED: part of minimum concifg to run a single xbnet node)
DEFAULT_GATEWAY=192.168.1.1
```
2024-08-16 13:37:05 -03:00
This will build the Docker image and start the container with the XBee network and the required setup.
2024-09-04 14:26:59 -03:00
#### 5. Health Check and Container Management
2024-08-16 13:37:05 -03:00
2024-08-21 10:48:40 -03:00
The container includes a health check that pings the XBee network interface to ensure it is functioning properly. \
The container is configured to restart automatically if the health check fails.
2024-08-16 13:37:05 -03:00
2024-09-04 14:26:59 -03:00
#### 6. Troubleshooting
2024-08-16 13:37:05 -03:00
2024-08-21 10:48:40 -03:00
Ensure the XBee devices are connected to the correct serial ports.\
Verify the network interfaces using ip a inside the container.\
2024-08-16 13:37:05 -03:00
The container logs can be viewed using:
```bash
docker logs xbee_node
```