Skip to content

Commit

Permalink
FIBER: Add important modules and code refactor
Browse files Browse the repository at this point in the history
* Add documentation for Fiber

* Add FIBER modules

* Update sidebars-fiber.js

* Refactor installation-setup.md

* Refactor introduction.md

* Refactor project-structure.md
  • Loading branch information
nikitach507 committed Dec 31, 2024
1 parent 97d6791 commit 5d522aa
Show file tree
Hide file tree
Showing 10 changed files with 177 additions and 186 deletions.
16 changes: 16 additions & 0 deletions docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,16 @@ const config = {
editUrl: 'https://github.com/hardwario/docs/edit/main',
}),
],
[
'@docusaurus/plugin-content-docs',
({
id: 'fiber',
path: 'fiber',
routeBasePath: 'fiber',
sidebarPath: require.resolve('./sidebars-fiber.js'),
editUrl: 'hhttps://github.com/hardwario/docs/edit/main',
}),
],
[
'@docusaurus/plugin-ideal-image',
{
Expand Down Expand Up @@ -115,6 +125,12 @@ const config = {
position: 'left',
activeBaseRegex: `/cloud/`,
},
{
to: 'fiber/',
label: 'FIBER',
position: 'left',
activeBaseRegex: `/fiber/`,
},
{
href: 'https://github.com/hardwario/docs',
label: 'GitHub',
Expand Down
4 changes: 2 additions & 2 deletions fiber/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@
slug: configuration
title: FIBER Configuration File
---

import Image from '@theme/IdealImage';

# Configuration File

The configuration file is located on the FIBER device within the config directory and is named config.yaml. This file contains parameters that govern various aspects of FIBER's operation, such as network interfaces, sensor data collection intervals, MQTT communication settings, and data storage preferences.
The configuration file is located on the **FIBER** device within the config directory and is named **config.yaml**. This file contains parameters that govern various aspects of **FIBER**'s operation, such as network interfaces, sensor data collection intervals, MQTT communication settings, and data storage preferences.

## Overview of Configuration Parameters

Expand Down Expand Up @@ -47,3 +46,4 @@ storage:
```
To modify the configuration file, you must access the FIBER device. Once you have access, navigate to the **config** directory and edit the **config.yaml** file using a text editor, command line tools, or through Docker.
181 changes: 39 additions & 142 deletions fiber/installation-setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,186 +6,83 @@ import Image from '@theme/IdealImage';

# FIBER Installation

This article provides instructions on bootstrap and configuring the Linux system on Compute Module 4. The instructions below assume the Linux host environment.
This article provides instructions on bootstrap and configuring the Linux system on **Compute Module 4**. The instructions below assume the Linux host environment.
This article uses the term host - a Linux-based PC which configures the target (FIBER version 2 hardware).

## Install Image

- Download image
- Uncompress the image
- Install image to FIBER
- Connect the PoE adapter to the target.
- Connect the Mini USB cable between the host and the target.
- Use a jumper to short the BOOT pins on the mainboard.
- Shortly press the RESET tact switch on the rear side of the mainboard.
- Now Compute Module 4 should start in the bootloader mode.
- Remove the jumper from the BOOT pins on the mainboard.
- Flash the image
- Set up network connection
1. Download image

2. Uncompress the image

## Network Connection Setup

To start FIBER, follow the instructions below depending on your preferred connection method:

### Wi-Fi Connection

If you are connecting FIBER to your network via Wi-Fi, follow these steps:

- Connect your FIBER device to the PoE port of the PoE adapter.
- Wait for the device to establish a Wi-Fi connection with your network.
- Determine the IP address.
- Log in to the target (password *`fiber`*):
```sh
ssh root@[ip address]
```
- Wait for approximately a minute for FIBER to establish a connection with your network.

### Ethernet Connection

If you are connecting FIBER to your network via Ethernet, follow these steps:

- Connect one Ethernet cable from the PoE adapter's LAN port to your router or switch.
- Connect another Ethernet cable from the PoE adapter's port to the FIBER device.
- Determine the IP address.
- Log in to the target (password *`fiber`*):
```sh
ssh root@[ip address]
```
- Wait for approximately a minute for FIBER to establish a connection with your network.

### Static IP Address Connection

If your company utilizes a static IP address for FIBER connections, follow these steps:

- Update Configuration File (system section)
- Set static_ip to True.
- Replace the following placeholders with your network details: address (Your static IP address), netmask, gateway, dns.
- Depending on the type of Ethernet or Wi-fi connection, use the instructions for them above.

## Development Environment Setup
3. Install image to **FIBER**

This section outlines the process of configuring the development environment to facilitate work on the FIBER project. Follow these steps to ensure a smooth and efficient development experience with FIBER.
- Connect the **PoE adapter** to the target.

- Connect the **Mini USB cable** between the host and the target.

### 1. Clone Project Repository Locally from GitLab
- Use a jumper to short the **BOOT pins** on the mainboard.

[https://gitlab.hardwario.com/Fiber-v2/application](https://gitlab.hardwario.com/Fiber-v2/application) clone to local/path/to/project
- Shortly press the **RESET tact switch** on the rear side of the mainboard.

### 2. Create Dockerfile and Build Docker Container
- Now **Compute Module 4** should start in the bootloader mode.

#### 2.1 Install Docker
- Remove the jumper from the **BOOT pins** on the mainboard.

**For Windows and macOS:**
4. Flash the image

- Download Docker Desktop from the official Docker website.
- Start Docker Desktop and wait for Docker Engine to fully start.
5. Set up network connection

**For Ubuntu:**

```terminal
sudo apt update
sudo apt install -y docker.io
```

#### 2.2 Create Dockerfile

```Dockerfile
# Specify the base image, in this case Python 3.10 slim
FROM python:3.10-slim

# Update the package list and install necessary dependencies
RUN apt-get update && apt-get install -y \
build-essential \
libffi-dev \
libgpiod-dev \
python3-dev \
gcc \
libc-dev \
libncurses5-dev \
libncursesw5-dev \
ansible \ # Install Ansible for automating configuration management
sshpass \ # Install sshpass for passing SSH password in scripts
sudo # Install sudo for executing commands with superuser privileges

# Install Poetry - a tool for managing Python dependencies
RUN pip install poetry

# Set the working directory to /app
WORKDIR /app
## Network Connection Setup

# Create a volume to persist data inside the container
VOLUME /app
To start **FIBER**, follow the instructions below depending on your preferred connection method:

# Disable virtual environment creation for Poetry, as we are using a container
RUN poetry config virtualenvs.create false
```
### Wi-Fi Connection

#### 2.3 Start Docker Container
If you are connecting **FIBER** to your network via **Wi-Fi**, follow these steps:

1. Navigate to the project directory:
1. Connect your **FIBER** device to the PoE port of the PoE adapter.

```sh
cd local/path/to/project
```
2. Wait for the device to establish a Wi-Fi connection with your network.

2. Build the Docker image:
3. Determine the IP address.

```sh
docker build -t image-name .
```
4. Log in to the target (password *`fiber`*):

3. Run the Docker container:
```bash
ssh root@[ip address]
```

```sh
docker run -it -v ${PWD}:/app --name container-name image-name bash
```
5. Wait for approximately a minute for **FIBER** to establish a connection with your network.

4. If the container is stopped, start it and open a bash session:
### Ethernet Connection

```sh
docker start container-name ; docker exec -it container-name bash
```
If you are connecting **FIBER** to your network via **Ethernet**, follow these steps:

_Please replace image-name and container-name with the desired names. Ensure that you execute docker build and docker run commands with administrator privileges if Docker Desktop is running without administrator rights (Windows and macOS)._ You'll be able to work with the project inside this container, and any changes you make will be reflected immediately in the local file system.

### 3. Put the project in the FIBER
1. Connect one Ethernet cable from the PoE adapter's LAN port to your router or switch.
1. You need to copy the local project to your target:
2. Connect another Ethernet cable from the PoE adapter's port to the **FIBER** device.

```sh
scp -r local/path/to/project/* root@[ip address]:/app/
```
3. Determine the IP address.

2. Log in to the target
4. Log in to the target (password *`fiber`*):

```sh
```bash
ssh root@[ip address]
```

3. Run the installation script using the following command:

```sh
/app/scripts/install.sh
```
5. Wait for approximately a minute for **FIBER** to establish a connection with your network.

The program must be running.

#### Additional information

1. View logs journal

```sh
journalctl -u fiber-core.service
```
### Static IP Address Connection

2. Restart the service
If you utilize a **static IP** address for **FIBER** connections, follow these steps:

```sh
systemctl restart fiber-core.service
```
1. Update Configuration File (system section)

3. Stop the service
- Set `static_ip` to `True`.
- Replace the following placeholders with your network details: `address` (Your static IP address), `netmask`, `gateway`, `dns`.

```sh
systemctl stop fiber-core.service
```
2. Depending on the type of Ethernet or Wi-fi connection, use the instructions for them above.
11 changes: 7 additions & 4 deletions fiber/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,18 @@ import Image from '@theme/IdealImage';

# Introduction

FIBER is an IoT device designed to provide precise temperature measurements in industrial settings. It connects to various sensors via cables and computes temperature data which is displayed to the user. The product supports connectivity through WiFi or Ethernet and enables extensive device networking. Data from connected sensors is aggregated and displayed, showing detailed metrics such as average, median, minimum, and maximum values at given timestamps.
**FIBER** is an IoT device designed to provide precise temperature measurements in industrial settings. It connects to various sensors via cables and computes temperature data which is displayed to the user. The product supports connectivity through WiFi or Ethernet and enables extensive device networking. Data from connected sensors is aggregated and displayed, showing detailed metrics such as average, median, minimum, and maximum values at given timestamps.

## Key Highlights

### Advanced Temperature Monitoring:
FIBER boasts the capability to interface with up to eight temperature sensors concurrently. Through meticulous data processing, users gain access to comprehensive metrics including averages, medians, and extrema, facilitating nuanced environmental analysis.

**FIBER** boasts the capability to interface with up to eight temperature sensors concurrently. Through meticulous data processing, users gain access to comprehensive metrics including averages, medians, and extrema, facilitating nuanced environmental analysis.

### Versatile Connectivity:
Seamlessly integrating into diverse network architectures, FIBER supports both WiFi and Ethernet connectivity options. This versatility ensures effortless deployment and integration within existing infrastructures, delivering a robust and adaptable solution.

Seamlessly integrating into diverse network architectures, **FIBER** supports both **WiFi** and **Ethernet** connectivity options. This versatility ensures effortless deployment and integration within existing infrastructures, delivering a robust and adaptable solution.

### Intuitive User Interface:
Driven by user-centric design principles, FIBER features an intuitive interface that grants users direct access to critical temperature data. Displayed on an screen adorned with LED indicators, information is presented in a clear and accessible manner, enabling swift decision-making.

Driven by user-centric design principles, **FIBER** features an intuitive interface that grants users direct access to critical temperature data. Displayed on an screen adorned with LED indicators, information is presented in a clear and accessible manner, enabling swift decision-making.
37 changes: 27 additions & 10 deletions fiber/mqtt-broker.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,40 @@ title: MQTT Broker Integration
---
import Image from '@theme/IdealImage';

# MQTT
# MQTT BROKER

MQTT is an open, simple and low overhead communication protocol for sending messages between many clients which are connected to the central MQTT broker. The FIBER system integrates an MQTT (Message Queuing Telemetry Transport) broker to facilitate seamless communication and interaction with the device or system. MQTT offers users a versatile platform for exchanging data, configuring system parameters, retrieving system information, and executing remote commands.

- Every **message** consists of two parts - **topic** and **payload**

- The **Topic** describes the content of the message and identifies it

- The **Topic** name has a **directory structure** - each level is divided with a symbol `/`

- Topic can be `bedroom/temperature`, `kitchen/light/set`, etc.

- MQTT server is called the **broker** and clients can **publish messages** and **subscribe to topics**

- The task of the MQTT broker is to **deliver messages** from **publishers** to **subscribers**

- You can use two so-called **wildcards** while subscribing to the MQTT topic

- `+` wildcard will subscribe to all topics in the specified topic

- e.g. `+/light/set` will subscribe to `bedroom/light/set`, `kitchen/light/set`, etc.

- `#` wildcard will subscribe to all sub-topics of a specified topic

- e.g. `kitchen/#` will subscribe to `kitchen/light/set`, `kitchen/light/get`, `kitchen/temperature/get`, etc.
caution

The wildcard **#** can be used only at the **end of the topic** name

> You can read [**more about the MQTT topics and how to use them**](https://www.hivemq.com/blog/mqtt-essentials-part-5-mqtt-topics-best-practices/).
> The wildcard **#** can be used only at the **end of the topic** name

:::tip

You can read [**more about the MQTT topics and how to use them**](https://www.hivemq.com/blog/mqtt-essentials-part-5-mqtt-topics-best-practices/).

:::

## FIBER Topics

Expand Down Expand Up @@ -65,20 +80,22 @@ Ensure that the Mosquitto MQTT broker is installed and running on your system.

Use the following command to subscribe to all topics (#) and display incoming messages:

```
```bash
mosquitto_sub -t "#" -v
```

```
```bash
fiber/2158512345/beacon {"uptime": 11111.11, "ip_address": "10.0.0.111", "mac_address": "d1:1a:dd:11:1d:11"}

fiber/2158512345/measurement {"5": {"28-00000dc9cd6b": [{"timestamp": 1717581574, "value": {"minimum": 22.5, "maximum": 25.19, "average": 23.4, "median": 22.5, "last": 25.11}, "sample_count": 3}]}}
```

To retrieve information from the system via MQTT, you can use the following command:

```
```bash
mosquitto_pub -h localhost -t fiber/2158512345/system/ip/get -m ""
```
```

```bash
fiber/2158512345/system/ip "10.0.0.111"
```
```
Loading

0 comments on commit 5d522aa

Please sign in to comment.