Skip to content

Commit 7c2beee

Browse files
Merge pull request #17 from Jim-Hodapp-Coaching/updateReadme
Update README
2 parents 168c4d7 + 563d990 commit 7c2beee

File tree

1 file changed

+39
-76
lines changed

1 file changed

+39
-76
lines changed

README.md

Lines changed: 39 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -18,82 +18,45 @@ The ambi_mock_client repository makes use of several Git hooks to ensure that co
1818

1919
This will create symlinks to the Git hooks, preserving any hooks that you may have already configured.
2020

21-
### Using cargo run
22-
```BASH
23-
> cargo build
24-
> cargo run
25-
26-
Sending POST request to http://localhost:4000/api/readings/add as JSON: {"tempurature":"19.2","humidity":"87.7","pressure":"1074","dust_concentration":"415","air_purity":"DANGEROUS"}
27-
Response: Ok(
28-
Response {
29-
url: Url {
30-
scheme: "http",
31-
cannot_be_a_base: false,
32-
username: "",
33-
password: None,
34-
host: Some(
35-
Domain(
36-
"localhost",
37-
),
38-
),
39-
port: Some(
40-
4000,
41-
),
42-
path: "/api/readings/add",
43-
query: None,
44-
fragment: None,
45-
},
46-
status: 200,
47-
headers: {
48-
"cache-control": "max-age=0, private, must-revalidate",
49-
"content-length": "60",
50-
"content-type": "application/json; charset=utf-8",
51-
"date": "Sat, 22 Jan 2022 19:25:14 GMT",
52-
"server": "Cowboy",
53-
"x-request-id": "FsyuNssWKjhYHbUAAAAj",
54-
},
55-
},
56-
)
57-
58-
# Or just
59-
60-
> cargo run
21+
## Usage
22+
23+
You can either install this as a CLI tool by running `cargo install --path .` (which is the
24+
recommended way of using this) or you can run it directly from this repository.
25+
26+
```
27+
# Installed
28+
$ ambi_mock_client -h
29+
30+
# Or not Installed
31+
$ cargo run -- -h
32+
33+
# Output
34+
Provides a mock Ambi client that emulates real sensor hardware such as an Edge client.
35+
36+
Usage: ambi_mock_client [OPTIONS]
37+
38+
Options:
39+
-d, --debug
40+
Turns verbose console debug output on
41+
-n, --post-amount <POST_AMOUNT>
42+
The number of sensor readings to post. [DEFAULT: 1]
43+
-t, --time-per-post <TIME_PER_POST_S>
44+
The time between each sensor reading post (in seconds). [DEFAULT: 10]
45+
-T, --total-time <TOTAL_TIME_S>
46+
The total time over which all the sensor reading posts must be sent (in seconds, alternative to -t)
47+
-p, --num-threads <NUM_THREADS>
48+
The number of threads to spawn. The workload will be cloned to each thread, not divided. [DEFAULT: 1]
49+
-h, --help
50+
Print help (see more with '--help')
51+
-V, --version
52+
Print version
6153
```
6254

63-
### As an executable binary
64-
```BASH
65-
> cargo build
66-
> ./target/debug/ambi_mock_client
67-
68-
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"}
69-
Response: Ok(
70-
Response {
71-
url: Url {
72-
scheme: "http",
73-
cannot_be_a_base: false,
74-
username: "",
75-
password: None,
76-
host: Some(
77-
Domain(
78-
"localhost",
79-
),
80-
),
81-
port: Some(
82-
4000,
83-
),
84-
path: "/api/readings/add",
85-
query: None,
86-
fragment: None,
87-
},
88-
status: 200,
89-
headers: {
90-
"cache-control": "max-age=0, private, must-revalidate",
91-
"content-length": "60",
92-
"content-type": "application/json; charset=utf-8",
93-
"date": "Sat, 22 Jan 2022 19:28:08 GMT",
94-
"server": "Cowboy",
95-
"x-request-id": "FsyuX1U1NOj9m7IAAABB",
96-
},
97-
},
98-
)
55+
Example output:
56+
57+
```log
58+
$ ambi_mock_client -n 1
59+
60+
[2023-03-08T17:39:54Z INFO ambi_mock_client::sensor_posts] [Thread 0]: Sending POST request to http://localhost:8000/api/readings/add
61+
[2023-03-08T17:39:54Z INFO ambi_mock_client::sensor_posts] [Thread 0]: Response from Ambi backend: 201
9962
```

0 commit comments

Comments
 (0)