Skip to content

Commit

Permalink
adding networking
Browse files Browse the repository at this point in the history
  • Loading branch information
CamDavidsonPilon committed Jun 6, 2024
1 parent 6c9cac4 commit 3ee160b
Show file tree
Hide file tree
Showing 4 changed files with 119 additions and 5 deletions.
2 changes: 1 addition & 1 deletion developer-guide/20-User interface/01-introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ The web server we use is lighttpd, and hosted from `/var/www/pioreactorui`. This

The lighttpd conf file is located in `/etc/lighttpd/conf-enabled/50-pioreactorui.conf`. Error logs (though not helpful) are in `/var/log/lighttpd/error.log`.

The default protocol is `http` served on port `80`. To use `https` requires a certificate, and is out of scope for this project. If you'd change the protocol or the port, you'll need up tell the software too: look in the config.ini under `[ui]` section.
The default protocol is `http` served on port `80`. To use `https` requires a certificate, and is out of scope for this project. If you'd change the protocol or the port, you'll need up tell the software too: look in the config.ini under `[ui]` section. [How to change the web UI port](/user-guide/networking#changing-web-ui-port-from-80-to-something-else)


### Backend
Expand Down
105 changes: 105 additions & 0 deletions user-guide/30-Advanced/05-networking.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
---
title: Networking
slug: /networking
---

:::info
Previously, Raspberry Pis used a file called `wpa_supplicant.conf` to handle wifi network connections. **This is not longer the case**. Modern Raspberry Pi software, including the Pioreactor, doesn't use `wpa_supplicant.conf` at all. Instead, the tool `nmcli` replaces it. Don't follow tutorials that use `wpa_supplicant.conf`.
:::


## General networking tools

### Connecting to a wifi network using `nmcli`


You can first discover all the visible networks with:

```
sudo nmcli d wifi list
```

If you see your network on the list, then run:


```
sudo nmcli device wifi connect <ssid name> password <ssid password> ifname wlan0
```

(If you get a "Can't find" error, try running the above `list` command again.)

### Connecting to multiple networks

First, some terminology and understanding for us: a computer, like a Pi, has networking interfaces. For example, the onboard wifi on RPi’s is one such interface. The larger, model Bs, have an ethernet connector, which is another interface. Each interface can connect to 0 or 1 networks.

In order to connect to multiple networks, you need a Raspberry Pi with multiple interfaces. You can add interfaces with devices like a [USB wifi device](https://forum.pioreactor.com/t/connecting-more-workers-to-cluster/330/3).

To see what your current interfaces are doing, use:
```
nmcli device
```

The right hand side shows your connected interfaces. For example, if have a ethernet connection to a router, you'll see an `eth0` connection active. If you have an additional wifi hardware device attached to your Pi, you'll see `wlan1`.

----

To connect to another wifi network using `wlan1`, use:

```
sudo nmcli device wifi connect <ssid name> password <ssid password> ifname wlan1
```

----

If your leader is connected to multiple networks `A` and `B`, and you access the UI over network `A`, but your workers access over network `B`, the leader is in the position called a "gateway". You'll need to make some configuration changes to your cluster. Since the leader is attached to networks `A` and `B`, it has two IPs (use `hostname -I` to see all the ips), let's call them `ipA` and `ipB` respectively.

1. Access the configuration in the UI.
2. In the _shared_ config.ini, edit the `[mqtt]` `broker` field to be equal to `ipA`. Also edit the `leader_address` to be `ipB`.
3. In each of the workers (including the leader's config.ini, if it's a worker), add the following:
```
[mqtt]
broker=ipB
```

You may need to restart your cluster for these to take full effect.



### Starting the [Pioreactor local access](/user-guide/local-access-point) point using `nmcli`

Note that you can only have 1 network connection for each network interface. So if you have only 1 wifi device (by default, RPi's only have 1 wifi device on them -> only 1 wifi interface), the following will replace any existing wifi connection.

```
sudo nmcli con up PioreactorAP
```


#### Setting `leader_address` and MQTT `broker` in your config.ini


### Changing web UI port from `80` to something else

To change the web UI port from the default of `80`, following these instructions:

1. SSH into your leader Pioreactor.
2. We'll edit the lighttpd configuration first:
```
sudo nano /etc/lighttpd/lighttpd.conf
```

and find the line starting with `server.port`. Change this to something else (preferably not a value below 1024). Save and exit.

3. Restart lighttpd with:
```
sudo systemctl restart lighttpd.service
```
You should be able to access the web UI only on http://`leader name`:`new port`, for example: http://leader.local:8080

4. In your configuration, under the `[ui]` section, change the `port` option from `80` to your new port value. Save. You may need to restart your cluster for this new port to propagate to all machines correctly.


## Connecting to eduroam

This is a work-in-progress, but here's [one example](https://forum.pioreactor.com/t/connecting-more-workers-to-cluster/330/3#connecting-to-eduroam-2).


6 changes: 5 additions & 1 deletion user-guide/50-Troubleshooting/Networking troubleshooting.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,16 @@ slug: /troubleshooting-networks

It is possible that your mDNS is being blocked or restricted. If possible, log into your router and enable settings that allow "multicast", or "mDNS", or "IGMP proxing". If you are using a the builtin [local access point](/user-guide/local-access-point), this solution is not the correct one.

Also, if you are able to provide a permanent IPv4 address to your leader, you can get a significant performance boost by setting the configuration parameter `leader_address` in section `[cluster.topology]` to the IPv4 address.
Also, if you are able to provide a permanent IPv4 address to your leader, you can get a significant performance boost by setting the configuration some config parameters to the IPv4 address.

```
[cluster.topology]
# below is an example, your IPv4 may differ:
leader_address=192.168.0.3
[mqtt]
broker_address=192.168.0.3
```

### I'm having trouble with the local access point
Expand Down
11 changes: 8 additions & 3 deletions user-guide/99-common-questions.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -134,13 +134,14 @@ If the standard mixing and aeration with the stir bar is not enough for your app
Raspberry Pi Hardware
---------------------

#### What Raspberry Pi hardware can I use? I see Raspberry Pi 1, 2, 3, 4, A, B, +, Zero - it's confusing!
#### What Raspberry Pi hardware can I use? I see Raspberry Pi 1, 2, 3, 4, 5, A, B, +, Zero - it's confusing!

We've designed the hardware and software to be compatible with any Raspberry Pi that has onboard Wifi and a 40 pin header. That includes (at the time of writing):

* Raspberry Pi 3 Model B & B+
* Raspberry Pi 3 Model A+
* Raspberry Pi 4 Model B ³
* Raspberry Pi 5 Model B
* Raspberry Pi Zero W (with header) ¹
* Raspberry Pi Zero 2 W (with header)
* Raspberry Pi 400 ²
Expand Down Expand Up @@ -224,9 +225,13 @@ Unfortunately, the microSD card becoming corrupted or damaged is an infrequent b
Networking
---------------------------------

#### Can I use Ethernet cable connections instead of WIFI connections?
#### How do I change/edit the network the Pioreactor on?

Yes, so long as the Raspberry Pi's are connected to the same network and discoverable, this should work. Even mixing Ethernet and WIFI is fine.
With modern Raspberry Pis,

#### Can I use Ethernet cable connections instead of Wifi connections?

Yes, so long as the Raspberry Pi's are connected to the same network and discoverable, this should work. Even mixing Ethernet and Wifi is fine.

#### How can I determine the Pioreactor's IP address? Or the MAC address?

Expand Down

0 comments on commit 3ee160b

Please sign in to comment.