https://github.com/astarte-platform/astarte-device-sdk-elixir
Astarte Elixir Device SDK
https://github.com/astarte-platform/astarte-device-sdk-elixir
elixir elixir-library iot-device iot-framework mqtt-client
Last synced: 3 months ago
JSON representation
Astarte Elixir Device SDK
- Host: GitHub
- URL: https://github.com/astarte-platform/astarte-device-sdk-elixir
- Owner: astarte-platform
- License: apache-2.0
- Created: 2019-06-04T10:39:29.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2024-04-22T13:38:19.000Z (about 2 years ago)
- Last Synced: 2025-11-12T14:11:39.956Z (7 months ago)
- Topics: elixir, elixir-library, iot-device, iot-framework, mqtt-client
- Language: Elixir
- Size: 221 KB
- Stars: 7
- Watchers: 2
- Forks: 7
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
- Security: SECURITY.md
Awesome Lists containing this project
README
# Astarte Device SDK Elixir
This project allows you to execute a device communication on your Astarte
cluster.
## Prerequisites
Before you begin, ensure you have a running Astarte cluster either on your local machine or accessible remotely.
To manually build an Astarte cluster, follow this [guide](https://docs.astarte-platform.org/astarte/latest/010-astarte_in_5_minutes.html).
Alternatively, you can set up an automated instance on Astarte Cloud [here](https://astarte.cloud/).
## Supported Versions
| Elixir SDK | Astarte |
| ---------- | --------|
| 1.0 | 1.0 |
| 1.1+ | 1.1+ |
## Getting Started
Follow these steps to get started with this project:
1. **Clone the Repository**
Begin by cloning this repository to your local machine.
```
git clone https://github.com/astarte-platform/astarte-device-sdk-elixir.git
```
2. **Install the Elixir and Erlang Version**
You can use ASDF to install these versions:
```
asdf install
```
3. **Fetch Dependencies**
Fetch the project dependencies using the `mix deps.get` command.
```
mix deps.get
```
4. **Compile the Project**
Compile the project using the `mix compile` command.
```
mix compile
```
5. **Run the Project**
Run the project using the `iex -S mix` command.
```
iex -S mix
```
You can explore the tools inside by entering the IEx shell and typing
`h Astarte.Device`.
## Basic Usage
Initialize a device instance
You can easily initialize a device by following the steps below:
##### Device Options
Create a device option variable as follows. Use your parameters taken when you
have created a device from Astarte Cloud or on astartectl:
```
device_options = [ pairing_url: "https://api.your-astarte-instance/pairing", realm: "realm_name", device_id: "device_id", credentials_secret: "device_secret" ignore_ssl_errors: false, interface_provider: "./path-to/interface.json" ]
```
##### Interacting with Your Realm
To interact with your realm, you can either save the Device PID when starting
the start_link function or retrieve it later using the get_pid function:
```
{:ok, pid} = Astarte.Device.start_link(device_options)
```
or
```
pid = Astarte.Device.get_pid("realm_name", "device_id")
```
To send data through your interface, use the set_property or send_datastream
functions. These functions require four parameters: the device process PID, the
interface name, the path, and the value you want to send. An optional fifth
parameter, opts, is also accepted:
```
Astarte.Device.set_property(pid, interface_name, path, value)
Astarte.Device.send_datastream(pid, interface_name, path, value, opts \\ [])
```
## Contributing
We welcome contributions! Please read our [contributing guide](#) for details on
how to submit pull requests to us.
## License
This project is licensed under the Apache-2.0 License - see the [LICENSE]
(https://github.com/astarte-platform/astarte-device-sdk-elixir/blob/master/LICENSE)
file for details.