Skip to content

Commit

Permalink
generate a lot of missing types & fields
Browse files Browse the repository at this point in the history
  • Loading branch information
ewilken committed May 7, 2021
1 parent 7752c72 commit dc84c3b
Show file tree
Hide file tree
Showing 19 changed files with 945 additions and 289 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ env:

jobs:
style:
name: Check Style
name: Check style
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand Down
5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "starlink"
version = "0.1.1"
version = "0.2.0"
authors = ["Elias Wilken <[email protected]>"]
edition = "2018"
description = "Rust client implementation to the gRPC endpoint exposed by the SpaceX Starlink user terminal"
Expand All @@ -25,7 +25,8 @@ tonic = "0.4"
prost = "0.7"

[build-dependencies]
tonic-build = "0.4"
#tonic-build = "0.4"
tonic-build = { git = 'https://github.com/ewilken/tonic.git' } # waiting for https://github.com/danburkert/prost/pull/455 to be released into tonic

[dev-dependencies]
async-stream = "0.3"
Expand Down
262 changes: 116 additions & 146 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Working examples for request/response and streaming communication are in the [`/
### Request / Response

```rust
use starlink::proto::space_x::api::device::{device_client::DeviceClient, GetStatusRequest, Request};
use starlink::proto::space_x::api::device::{device_client::DeviceClient, request, GetStatusRequest, Request};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
Expand All @@ -39,27 +39,12 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
id: None,
epoch_id: None,
target_id: None,
signed_request: None,
get_next_id: None,
authenticate: None,
factory_reset: None,
get_history: None,
get_log: None,
get_ping: None,
get_device_info: None,
get_status: Some(GetStatusRequest {}),
reboot: None,
set_trusted_keys: None,
speed_test: None,
dish_stow: None,
wifi_get_clients: None,
wifi_set_config: None,
wifi_setup: None,
request: Some(request::Request::GetStatus(GetStatusRequest {})),
});

let response = client.handle(request).await?;

println!("RESPONSE={:#?}", response);
dbg!(response);

Ok(())
}
Expand All @@ -72,7 +57,7 @@ cargo run --example request_response
Prints something like:

```
RESPONSE=Response {
Response {
metadata: MetadataMap {
headers: {
"content-type": "application/grpc",
Expand All @@ -83,114 +68,107 @@ RESPONSE=Response {
message: Response {
id: None,
status: None,
get_next_id: None,
factory_reset: None,
get_log: None,
get_ping: None,
reboot: None,
speed_test: None,
get_device_info: None,
set_trusted_keys: None,
dish_authenticate: None,
dish_get_history: None,
dish_get_status: Some(
DishGetStatusResponse {
device_info: Some(
DeviceInfo {
id: Some(
"<my-ID>",
),
hardware_version: Some(
"rev1_pre_production",
),
software_version: Some(
"39d476b5-2101-44ec-bb7e-e526cc8f94f8.release",
),
country_code: None,
},
),
device_state: Some(
DeviceState {
uptime_s: Some(
34809,
),
},
),
state: Some(
Connected,
),
alerts: Some(
DishAlerts {
motors_stuck: None,
thermal_throttle: None,
thermal_shutdown: None,
},
),
snr: Some(
9.0,
),
seconds_to_first_nonempty_slot: None,
pop_ping_drop_rate: None,
downlink_throughput_bps: Some(
31826.379,
),
uplink_throughput_bps: Some(
13597.934,
),
pop_ping_latency_ms: Some(
19.17647,
),
obstruction_stats: Some(
DishObstructionStats {
currently_obstructed: None,
fraction_obstructed: Some(
0.00015074655,
),
last_24h_obstructed_s: Some(
16.0,
),
valid_s: Some(
26564.736,
),
wedge_fraction_obstructed: [
1.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
],
wedge_abs_fraction_obstructed: [
0.00015074655,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
],
},
),
},
response: Some(
DishGetStatus(
DishGetStatusResponse {
device_info: Some(
DeviceInfo {
id: Some(
"<my-ID>",
),
hardware_version: Some(
"rev1_pre_production",
),
software_version: Some(
"1f86ec34-34ea-4e7a-9758-3842e72422fb.release",
),
country_code: Some(
"DE",
),
utc_offset_s: Some(
1,
),
},
),
device_state: Some(
DeviceState {
uptime_s: Some(
26115,
),
},
),
state: Some(
Connected,
),
alerts: Some(
DishAlerts {
motors_stuck: None,
thermal_throttle: None,
thermal_shutdown: None,
mast_not_near_vertical: None,
unexpected_location: None,
slow_ethernet_speeds: None,
},
),
snr: Some(
6.0,
),
seconds_to_first_nonempty_slot: None,
pop_ping_drop_rate: None,
downlink_throughput_bps: Some(
8584784.0,
),
uplink_throughput_bps: Some(
311510.97,
),
pop_ping_latency_ms: Some(
38.857143,
),
obstruction_stats: Some(
DishObstructionStats {
currently_obstructed: None,
fraction_obstructed: Some(
0.0010516815,
),
last_24h_obstructed_s: Some(
72.0,
),
valid_s: Some(
21260.67,
),
wedge_fraction_obstructed: [
1.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
],
wedge_abs_fraction_obstructed: [
0.0010516815,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
],
},
),
},
),
),
dish_stow: None,
wifi_authenticate: None,
wifi_get_clients: None,
wifi_get_history: None,
wifi_get_status: None,
wifi_set_config: None,
wifi_setup: None,
},
}
```
Expand All @@ -202,7 +180,14 @@ use async_stream::stream;
use std::time::Duration;
use tokio::time::sleep;

use starlink::proto::space_x::api::device::{device_client::DeviceClient, GetStatusRequest, Request, ToDevice};
use starlink::proto::space_x::api::device::{
device_client::DeviceClient,
request,
to_device,
GetStatusRequest,
Request,
ToDevice,
};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
Expand All @@ -211,27 +196,12 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
let request_stream = stream! {
loop {
yield ToDevice {
request: Some(Request {
message: Some(to_device::Message::Request(Request {
id: None,
epoch_id: None,
target_id: None,
signed_request: None,
get_next_id: None,
authenticate: None,
factory_reset: None,
get_history: None,
get_log: None,
get_ping: None,
get_device_info: None,
get_status: Some(GetStatusRequest {}),
reboot: None,
set_trusted_keys: None,
speed_test: None,
dish_stow: None,
wifi_get_clients: None,
wifi_set_config: None,
wifi_setup: None,
}),
request: Some(request::Request::GetStatus(GetStatusRequest {})),
})),
};

sleep(Duration::from_secs(1)).await;
Expand All @@ -243,7 +213,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut response_stream = client.stream(request).await?.into_inner();

while let Some(message) = response_stream.message().await? {
println!("RESPONSE={:#?}", message);
dbg!(message);
}

Ok(())
Expand Down
1 change: 1 addition & 0 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
"proto/spacex/api/device/device.proto",
"proto/spacex/api/device/dish.proto",
"proto/spacex/api/device/service.proto",
"proto/spacex/api/device/transceiver.proto",
"proto/spacex/api/device/wifi_config.proto",
"proto/spacex/api/device/wifi.proto",
],
Expand Down
2 changes: 1 addition & 1 deletion codegen/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "starlink-codegen"
version = "0.1.0"
version = "0.2.0"
authors = ["Elias Wilken <[email protected]>"]
edition = "2018"

Expand Down
Loading

0 comments on commit dc84c3b

Please sign in to comment.