Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implementatation of the stream functionality #12

Merged
merged 17 commits into from
Nov 29, 2024

Conversation

rgallor
Copy link
Collaborator

@rgallor rgallor commented Sep 3, 2024

This pull request introduces a Rust application that initiates an Astarte device, establishes an MQTT connection to a running Astarte instance, and sends data generated from a set of predefined mathematical functions.

Key Features:

  • Connection Configuration: The application requires a config.toml file, which contains the necessary information to connect the device to the Astarte instance.
  • Data Generation: Users can define mathematical functions and their parameters either through command-line interface (CLI) options or by setting the corresponding environment variables.

This work is inspired by and builds upon what has been done in the stream-qt5-test repository.

Closes #3

The interface allows generic sensors to stream samples data in double
format.
The interface is the same as the one defined in the
stream-qt5-test astarte-platform repository

Signed-off-by: Riccardo Gallo <[email protected]>
Introduce:
- `color_eyre` to have a structured report handler
- `tracing_subscriber` to collect scoped, structured and async-aware log data

Signed-off-by: Riccardo Gallo <[email protected]>
Copy link

codecov bot commented Sep 3, 2024

Welcome to Codecov 🎉

Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests.

Thanks for integrating Codecov - We've got you covered ☂️

@rgallor rgallor force-pushed the feat/implementatation branch 2 times, most recently from 0fcd3ec to a6f84a6 Compare September 9, 2024 13:31
src/main.rs Outdated Show resolved Hide resolved
@rgallor rgallor force-pushed the feat/implementatation branch 2 times, most recently from d775c12 to 7c6b1b5 Compare September 25, 2024 13:15
astarte-device-conf/.env Outdated Show resolved Hide resolved
astarte-device-conf/config.toml Outdated Show resolved Hide resolved
src/astarte.rs Outdated Show resolved Hide resolved
src/astarte.rs Outdated Show resolved Hide resolved
@rgallor rgallor requested a review from harlem88 October 1, 2024 15:57
@rgallor rgallor force-pushed the feat/implementatation branch 2 times, most recently from 835921f to 04d4e6a Compare October 4, 2024 15:18
.cargo/config.toml Outdated Show resolved Hide resolved
scripts/run.sh Outdated Show resolved Hide resolved
src/astarte.rs Show resolved Hide resolved
src/astarte.rs Outdated Show resolved Hide resolved
src/astarte.rs Outdated Show resolved Hide resolved
src/astarte.rs Outdated Show resolved Hide resolved
src/main.rs Outdated Show resolved Hide resolved
src/math.rs Outdated Show resolved Hide resolved
src/math.rs Outdated Show resolved Hide resolved
src/math.rs Outdated Show resolved Hide resolved
@joshuachp
Copy link
Contributor

I would check the other functions like sinc they don't seem to do the same thing as in the original code

@rgallor
Copy link
Collaborator Author

rgallor commented Nov 7, 2024

I would check the other functions like sinc they don't seem to do the same thing as in the original code

Yes, for this one I used the original definition of the normalized sinc function, which differs from the implementation in the stream-qt5-test

This required also the introduction of some environment variables and
structures to handle the generation of the samples to be sent to
Astarte.
For simplicity, the math functions are the same as the ones used in the
stream-qt5-test repository.

Signed-off-by: Riccardo Gallo <[email protected]>
Use clap to start the application, also taking into account possible
environment variables set by the user.

Signed-off-by: Riccardo Gallo <[email protected]>
Now the configuration information to connect a device to Astarte are
provided inside a `astarte-device-DEVICE_ID_HERE-conf` directory, in
a `config.toml` file. Instead, all the information necessary to generate
samples to be sent to Astarte are provided via CLI or environment
variables.
Also the README have been update to explain how to configure the
application and build/run it.

Signed-off-by: Riccardo Gallo <[email protected]>
Signed-off-by: Riccardo Gallo <[email protected]>
Provide the Atsarte configuration via environment variables or config.toml file, prioritizing env vars

Signed-off-by: Riccardo Gallo <[email protected]>
Give more flexibility to choose the mqtt or grpc Astarte connection
configuration by using the CLI, environment variables and a config.toml
file

Signed-off-by: Riccardo Gallo <[email protected]>
src/math.rs Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
src/math.rs Outdated Show resolved Hide resolved
src/math.rs Outdated Show resolved Hide resolved
Now it is only possible to specify the type of connection (mqtt or grpc)
through the ASTARTE_CONNECTION env variable. The application will first
try to retrieve the config from env; if an error occurs, it tries to
retrieve them from a config.toml (if a path has beem specified). The
merge operation for the 2 sources of config has been removed.

Signed-off-by: Riccardo Gallo <[email protected]>
@harlem88 harlem88 merged commit cc4695e into astarte-platform:master Nov 29, 2024
15 checks passed
@rgallor rgallor deleted the feat/implementatation branch November 29, 2024 15:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Stream configuration via command line
4 participants