Emulates an Edge hardware-based room sensor client purely as a CLI application

Overview

ambi_mock_client

Usage

You must have Rust installed to build ambi_mock_client. You can find documentation on installing Rust here.

Using cargo run

cargo run {"tempurature":"33.5","humidity":"39.6","pressure":"1100","dust_concentration":"8","air_purity":"FRESH_AIR"}">
> cargo build
> cargo run
{"tempurature":"23.7","humidity":"63.8","pressure":"945","dust_concentration":"999","air_purity":"DANGEROUS"}

# Or just

> cargo run
{"tempurature":"33.5","humidity":"39.6","pressure":"1100","dust_concentration":"8","air_purity":"FRESH_AIR"}

As an executable binary

> cargo build
> ./target/debug/ambi_mock_client
{"tempurature":"25.9","humidity":"43.4","pressure":"1076","dust_concentration":"322","air_purity":"DANGEROUS"}
You might also like...
A binary that bootstraps a Leptos application with client side rendering, tailwind, and vercel

create-leptos-csr-tw This CLI provides a quick setup to start building web applications using the Leptos web framework integrated with TailwindCSS. It

cli application to visualize crate download metrics.

cli application to visualize crate download metrics.

CLI application to run clang-format on a set of files specified using globs in a JSON configuration file.
CLI application to run clang-format on a set of files specified using globs in a JSON configuration file.

run_clang_format CLI application for running clang-format for an existing .clang-format file on a set of files, specified using globs in a .json confi

laydown is a simple CLI application to help you prepare for your next Daily Standup

laydown is a simple CLI application to help you prepare for your next Daily Standup. No longer shall your name be called on only for you to stare into the abyss while you struggle to remember what you did yesterday.

gfold is a CLI-driven application that helps you keep track of multiple Git repositories.

gfold is a CLI-driven application that helps you keep track of multiple Git repositories.

CLI application to run clang-tidy on a set of files specified using globs in a JSON configuration file.
CLI application to run clang-tidy on a set of files specified using globs in a JSON configuration file.

run-clang-tidy CLI application for running clang-tidy for an existing .clang-tidy file on a set of files, specified using globs in a .json configurati

Yet Another Texture Packer - a small and simple CLI application to pack multiple textures/sprites into a texture atlas/sprite sheet

YATP (Yet Another Texture Packer) A small and simple CLI application to pack multiple textures/sprites into a texture atlas/sprite sheet. Installation

FileSorterX is an automatic file sorting application that sorts your files into folders based on their file extension
FileSorterX is an automatic file sorting application that sorts your files into folders based on their file extension

FileSorterX is an automatic file sorting application that sorts your files into folders based on their file extension. With FileSorterX, you can easily keep your files organized and find what you need quickly.

CLI Web client for moedict.tw

meowdict CLI Web client for moedict.tw Usage Console Mode

Comments
  • Add an HTTP client

    Add an HTTP client

    Description

    This PR adds a very basic HTTP client which allows us to make requests to an actual local Ambi server.

    The URL is hardcoded at the moment as http://localhost:4000/api/readings/add which is the default endpoint for adding readings when running Ambi locally.

    I also updated the usage notes in the README

    it works

    ambi_mock_client

    caleb@calebs-MacBook-Pro ambi_mock_client % ./target/debug/ambi_mock_client
    Sending POST request to http://localhost:4000/api/readings/add as JSON: {"tempurature":"28.8","humidity":"85.2","pressure":"964","dust_concentration":"930","air_purity":"DANGEROUS"}
    Response: Ok(
        Response {
            url: Url {
                scheme: "http",
                cannot_be_a_base: false,
                username: "",
                password: None,
                host: Some(
                    Domain(
                        "localhost",
                    ),
                ),
                port: Some(
                    4000,
                ),
                path: "/api/readings/add",
                query: None,
                fragment: None,
            },
            status: 200,
            headers: {
                "cache-control": "max-age=0, private, must-revalidate",
                "content-length": "60",
                "content-type": "application/json; charset=utf-8",
                "date": "Sat, 22 Jan 2022 19:28:08 GMT",
                "server": "Cowboy",
                "x-request-id": "FsyuX1U1NOj9m7IAAABB",
            },
        },
    )
    

    Ambi

    [info] POST /api/readings/add
    Verb: "POST"
    Host: "localhost"
    Headers: [{"accept", "*/*"}, {"content-length", "109"}, {"host", "localhost:4000"}]
    
    [debug] Processing with AmbiWeb.ApiController.add_reading/2
      Parameters: %{}
      Pipelines: [:api]
    [debug] Added new reading to the DB
    [info] Sent 200 in 1ms
    

    Testing

    I decided to not write tests for this step in the MVP

    Two options I considered were:

    • Finding library to provide some sort of mock that I could send requests to in tests.
      • This seemed like overkill a bit for a CLI at this stage
    • Use dependency injection and define a test Client
      • It would be really cool if reqwest provided a trait for Client that we could use to create a test client. For the moment this felt like overkill as well. Also, since we can assume the functions being used that are provided by reqwest are themselves tested within that crate maybe it does not make sense to re-test them here. We would essentially be writing a test for the main function.
    opened by calebbourg 2
Owner
Jim Hodapp
Software Engineering Coach (you can work with me!) and programmer for life.
Jim Hodapp
An feature packed Google Tasks CLI written purely in Rust

rChore A feature packed unofficial Google Tasks CLI to boost your producitvity, written purely in Rust. ?? What is rChore? rChore is an unofficial Goo

Hemanth Krishna 41 Dec 24, 2022
Humidity & Temperature CLI datalogger for DHT22 sensor on Raspberry Pi.

Datalogger Humidity & Temperature CLI datalogger for DHT22 sensor on Raspberry Pi. Index Install Git Cargo Master branch Latest release from crates.io

Marco Radocchia 2 Aug 2, 2022
Simple system monitoring app that runs on terminal. Made purely with Rust.

What is it? RCTOP is a simple WIP system monitoring app that runs purely on terminal and doesn't feature GUI. One can compare it to htop, but more str

Niko Huuskonen 7 Oct 14, 2022
Multiple precision floating point numbers implemented purely in Rust.

Multiple precision floating point numbers implemented purely in Rust. Rationale There are several notable implementations of numbers with increased pr

null 11 Nov 23, 2022
A very tiny terminal snake game, purely implemented in Rust.

tiny-snake.rs A very tiny terminal snake game, purely implemented in Rust. Features Optimized binary has only 2760 bytes. No dependencies. Not even li

Rodrigo Batista de Moraes 59 Aug 16, 2023
Code for working with edge-matching puzzles in the Eternity 2 family.

e2rs Code for working with edge-matching puzzles in the Eternity 2 family. This is a WIP sketch of some APIs and algs for representing and manipulatin

Matthew Pocock 3 Jan 18, 2023
Veryl: A Modern Hardware Description Language

Veryl Veryl is a modern hardware description language. This project is under the exploration phase of language design. If you have any idea, please op

null 26 Jan 3, 2023
High performance wlroots screen recording, featuring hardware encoding

wl-screenrec High performance wlroots based screen recorder. Uses dma-buf transfers to get surface, and uses the GPU to do both the pixel format conve

Russell Greene 32 Jan 21, 2023
Simple but convenient CLI-based Matrix client app for sending and receiving (in Rust)

matrix-commander-rs simple but convenient CLI-based Matrix client app for sending and receiving Help create this Rust program! This project is current

null 19 Dec 30, 2022
simple but convenient CLI-based Nostr client app for following users and sending DMs

nostr-commander-rs TLDR: simple but convenient CLI-based Nostr client app for publishing, sending DMs, as well as following users and channels nostr-c

null 18 Dec 30, 2022