Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bencevans/tonik
Rust library and command line interface for Teltonika routers
https://github.com/bencevans/tonik
teltonika
Last synced: 5 days ago
JSON representation
Rust library and command line interface for Teltonika routers
- Host: GitHub
- URL: https://github.com/bencevans/tonik
- Owner: bencevans
- Created: 2024-04-12T11:27:37.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2024-04-25T21:46:57.000Z (8 months ago)
- Last Synced: 2024-05-01T23:14:34.213Z (8 months ago)
- Topics: teltonika
- Language: Rust
- Homepage:
- Size: 23.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Tonik
A Rust library and command line interface for Teltonika routers.
## Library
The library provides a set of functions to interact with Teltonika routers using the REST API.
### Installation
Add the library to your `Cargo.toml` file.
```toml
[dependencies]
tonik = "0.1"
```### Usage
Futher information can be found in the [documentation](https://docs.rs/tonik).
```rust
use tonik::Client;#[tokio::main]
async fn main() {
let client = Client::new("ROUTER_IP");// Authenticate
client.authenticate("USERNAME", "PASSWORD").await.unwrap();// Get device information
let info = client.get_device_info().await.unwrap();
println!("{:?}", info);
}
```## Command Line Interface
The CLI is a command line tool for Teltonika routers. It provides a set of commands to interact with the router using the REST API.
### Installation
Install the CLI using `cargo` package manager included with Rust.
```bash
cargo install tonik-cli
```### Usage
```
Usage: tonik [OPTIONS] --passwordCommands:
dhcp DHCP related commands
firmware Firmware related commands
gps Global Positioning System related commands
help Print this message or the help of the given subcommand(s)Options:
--host Teltonika host [env: TELTONIKA_HOST=] [default: 192.168.7.1]
--username Teltonika username [env: TELTONIKA_USERNAME=] [default: admin]
--password Teltonika password [env: TELTONIKA_PASSWORD=]
--json Output in JSON format
-h, --help Print help
```### Examples
#### List Connected MAC Addresses
```
$ tonik --json dhcp ipv4 status | jq -r '.[].macaddr'
00:01:02:03:04:05
EA:EB:EC:ED:EE:EF
```#### Get GPS Information
```
$ tonik gps position
Accuracy: 0.8
Fix status: 1
Altitude: 6.2
Timestamp: 1714074213
Satellites: 7
Longitude: -0.054569
Latitude: 51.589495
Angle: 0
UTC timestamp: 1714074213
```