Skip to content

Commit

Permalink
FIBER: Reposition FIBER and refactor code
Browse files Browse the repository at this point in the history
  • Loading branch information
nikitach507 committed Jan 6, 2025
1 parent 3c2c2f0 commit 083d3ba
Show file tree
Hide file tree
Showing 7 changed files with 181 additions and 100 deletions.
32 changes: 16 additions & 16 deletions docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,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: 'https://github.com/hardwario/docs/edit/main',
}),
],
[
'@docusaurus/plugin-content-docs',
({
Expand All @@ -68,16 +78,6 @@ 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: 'https://github.com/hardwario/docs/edit/main',
}),
],
[
'@docusaurus/plugin-ideal-image',
{
Expand Down Expand Up @@ -113,6 +113,12 @@ const config = {
position: 'left',
activeBaseRegex: `/ember/`,
},
{
to: '/fiber/',
label: 'FIBER',
position: 'left',
activeBaseRegex: `/fiber/`,
},
{
to: '/tower/',
label: 'TOWER',
Expand All @@ -125,12 +131,6 @@ const config = {
position: 'left',
activeBaseRegex: `/cloud/`,
},
{
to: '/fiber/',
label: 'FIBER',
position: 'left',
activeBaseRegex: `/fiber/`,
},
{
href: 'https://github.com/hardwario/docs',
label: 'GitHub',
Expand Down
69 changes: 45 additions & 24 deletions fiber/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,44 +6,65 @@ 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

```yaml
version: Specifies the version of the configuration file.
version: 'Specifies the version of the configuration file'

system:
interface: Defines the network interfaces used by the system. By default, it includes both "end0" and "eth0" interfaces.
static_ip: Specifies whether the client is using a static IP address.
- True: For static IP address, provide 'address', 'netmask', 'gateway', 'dns'.
- False: For automatic connection.
address: Specifies the IP address of the device.
netmask: Specifies the subnet mask.
gateway: Specifies the gateway address.
dns: Specifies the DNS server address.
interface: 'Defines the network interfaces used by the system. By default, it includes both "end0" and "eth0" interfaces'
static_ip: 'Specifies whether the client is using a static IP address'
- True: 'For static IP address, provide "address", "netmask", "gateway", "dns"'
- False: 'For automatic connection'
address: 'Specifies the IP address of the device'
netmask: 'Specifies the subnet mask'
gateway: 'Specifies the gateway address'
dns: 'Specifies the DNS server address'

sensor:
enabled: Indicates whether sensor data collection is enabled (True) or disabled (False).
report_interval_seconds: Specifies the interval (in seconds) at which sensor data is reported.
sampling_interval_seconds: Specifies the interval (in seconds) at which sensor data is sampled.
enabled: 'Indicates whether sensor data collection is enabled (True) or disabled (False)'
report_interval_seconds: 'Specifies the interval (in seconds) at which sensor data is reported'
sampling_interval_seconds: 'Specifies the interval (in seconds) at which sensor data is sampled'

measurement:
report_minimum: Show the minimum sensor value in the data analysis.
report_maximum: Show the maximum sensor value in the data analysis.
report_average: Show the average sensor value in the data analysis.
report_median: Show the median sensor value in the data analysis.
report_last: Show the last recorded sensor value in the data analysis.
report_minimum: 'Show the minimum sensor value in the data analysis'
report_maximum: 'Show the maximum sensor value in the data analysis'
report_average: 'Show the average sensor value in the data analysis'
report_median: 'Show the median sensor value in the data analysis'
report_last: 'Show the last recorded sensor value in the data analysis'

mqtt:
enabled: Indicates whether MQTT communication is enabled (True) or disabled (False).
host: Specifies the MQTT broker host address.
port: Specifies the MQTT broker port number.
enabled: 'Indicates whether MQTT communication is enabled (True) or disabled (False)'
host: 'Specifies the MQTT broker host address'
port: 'Specifies the MQTT broker port number'

storage:
enabled: Indicates whether data storage is enabled (True) or disabled (False).
name: Specifies the name of the database file for storing records.
enabled: 'Indicates whether data storage is enabled (True) or disabled (False)'
name: 'Specifies the name of the database file for storing records'
```
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.
## How to Modify the Configuration File
To modify the **`config.yaml`** file on the **FIBER** device, follow these steps:

1. Navigate to the configuration directory:

```bash
cd /config
```

2. Open the file with a text editor like **nano** or **vim**:

```bash
nano config.yaml
```

3. Modify and Save the file

4. Restart the **FIBER** service to apply the new configuration:

```bash
systemctl restart fiber-core.service
```
48 changes: 42 additions & 6 deletions fiber/installation-setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ This article uses the term host - a Linux-based PC which configures the target (

5. Set up network connection


## Network Connection Setup

To start **FIBER**, follow the instructions below depending on your preferred connection method:
Expand All @@ -60,7 +59,6 @@ If you are connecting **FIBER** to your network via **Wi-Fi**, follow these step

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


1. Connect one Ethernet cable from the PoE adapter's LAN port to your router or switch.
2. Connect another Ethernet cable from the PoE adapter's port to the **FIBER** device.
Expand All @@ -75,14 +73,52 @@ If you are connecting **FIBER** to your network via **Ethernet**, follow these s

5. Wait for approximately a minute for **FIBER** to establish a connection with your network.


### Static IP Address Connection

If you utilize a **static IP** address for **FIBER** connections, follow these steps:

1. 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`.
- Set **static_ip** to **True**.
- Replace the following placeholders with your network details: **address** (your static IP address), **netmask**, **gateway**, **dns**.

2. Depending on the type of [**Ethernet**](#ethernet-connection) or [**Wi-Fi**](#wi-fi-connection) connection, use the instructions for them above.

## Additional information

1. Verifying Network Connectivity:

Test the connection to the **FIBER** device from the host:

```bash
ping [ip address]
```
2. Checking device logs:

If the **FIBER** device does not function as expected, you can view logs for troubleshooting:

```bash
journalctl -u fiber-core.service
```
3. Managing the service:

Use the following commands to control the **FIBER** service:

```bash
systemctl start fiber-core.service
systemctl restart fiber-core.service
systemctl stop fiber-core.service
```
4. Restarting the device:

To restart the **FIBER** device after making changes or for troubleshooting:

- Using **SSH**:

```bash
reboot
```

2. Depending on the type of Ethernet or Wi-fi connection, use the instructions for them above.
- Press the physical reset button on the back of the device.
66 changes: 43 additions & 23 deletions fiber/mqtt-broker.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,57 +45,77 @@ You can read [**more about the MQTT topics and how to use them**](https://www.hi

| Explanation | MQTT Topic | Response |
| :---------------------- | :----------------------------: | :----------------------------------------------------: |
| Get Device IP Address | `fiber/{id}/system/ip/get` | `"10.0.0.111"` `"ok"` |
| Get Device MAC Address | `fiber/{id}/system/mac/get` | `"d1:1a:dd:11:1d:11"` `"ok"` |
| Get Device Uptime | `fiber/{id}/system/uptime/get` | `11111.11` `"ok"` |
| Request Device Reboot (payload-delay) | `fiber/{id}/system/reboot` | `{payload}` ` -> rebooting ` |
| Get Device IP Address | fiber/{id}/system/ip/get | "10.0.0.111" "ok" |
| Get Device MAC Address | fiber/{id}/system/mac/get | "d1:1a:dd:11:1d:11" "ok" |
| Get Device Uptime | fiber/{id}/system/uptime/get | 11111.11 "ok" |
| Request Device Reboot (payload-delay) | fiber/{id}/system/reboot | {payload} -> rebooting |

### Voltage

| Explanation | MQTT Topic | Response |
| :------------- | :---------------------: | :-------: |
| Voltage | `fiber/{id}/voltage/get`| `{"battery_voltage": 0.0, "poe_voltage": 0.0}`|
| Voltage | fiber/{id}/voltage/get| {"battery_voltage": 0.0, "poe_voltage": 0.0}|

### Config

| Explanation | MQTT Topic | Response |
| :----------------------- | :----------------------------: | :----------------------------------------------------------: |
| Get Current Configuration| `fiber/{id}/config/get` | `{"version": 1, "system": {"interface": "end0,eth0", ... }}` `"ok"` |
| Get Current Configuration| fiber/{id}/config/get | {"version": 1, "system": {"interface": "end0,eth0", ... }} "ok" |

| Explanation | MQTT Topic | Payload | Response |
| :----------- | :------------: | :-----------: | :-----------: |
|Set Configuration|`fiber/{id}/config/get`|`{"version": 2, "system": {"interface": "end0,eth0", ... }}`| `{"version": 2, "system": {"interface": "end0,eth0", ... }}` `"ok"`|
|Set Configuration|fiber/{id}/config/get|{"version": 2, "system": {"interface": "end0,eth0", ... }}| {"version": 2, "system": {"interface": "end0,eth0", ... }} "ok"|

# Mosquitto MQTT Broker Integration
## Mosquitto MQTT Broker Integration

#### Overview
### Overview

The integration of the Mosquitto MQTT broker into our product enhances its capabilities by providing a robust messaging infrastructure. Mosquitto facilitates the communication between different components of the system, enabling seamless data exchange and further system expansion.

#### Usage
### Pre-use

When connected to **FIBER**, you can use the mosquitto-cli package to subscribe to MQTT topics and monitor incoming messages. Perform the following steps:
When connected to **FIBER**, you can use the mosquitto-cli package to subscribe to MQTT topics and monitor incoming messages. Before using MQTT with **FIBER**, ensure that the **Mosquitto MQTT broker** is installed and running on your system.

Ensure that the Mosquitto MQTT broker is installed and running on your system.
- Check Mosquitto Service Status:

Use the following command to subscribe to all topics (#) and display incoming messages:
```bash
sudo systemctl status mosquitto
```
- Enable and Start Mosquitto: If the broker is not running, enable and start the service:

```bash
sudo systemctl enable mosquitto
sudo systemctl start mosquitto
```

```bash
mosquitto_sub -t "#" -v
```
### Subscribing to Topics

```bash
fiber/2158512345/beacon {"uptime": 11111.11, "ip_address": "10.0.0.111", "mac_address": "d1:1a:dd:11:1d:11"}
To **monitor all incoming messages** from the **FIBER** system, use the following command:

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}]}}
```
```bash
mosquitto_sub -t "#" -v
```

This command subscribes to all topics (`#`) and displays incoming messages in real-time.

**Example output**:

To retrieve information from the system via MQTT, you can use the following command:
```bash
fiber/{id}/beacon {"uptime": 11111.11, "ip_address": "10.0.0.111", "mac_address": "d1:1a:dd:11:1d:11"}
fiber/{id}/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}]}}
```

### Publishing Messages

To send commands to the **FIBER** system, use the mosquitto_pub command. To retrieve the IP address of the device:

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

**Expected response**:

```bash
fiber/2158512345/system/ip "10.0.0.111"
fiber/{id}/system/ip "10.0.0.111"
```
Loading

0 comments on commit 083d3ba

Please sign in to comment.