MCPcopy Create free account
hub / github.com/chirpstack/chirpstack / send_telemetry

Method send_telemetry

chirpstack/src/integration/thingsboard.rs:67–90  ·  view source on GitHub ↗
(
        &self,
        vars: &HashMap<String, String>,
        telemetry: &Payload,
    )

Source from the content-addressed store, hash-verified

65 }
66
67 async fn send_telemetry(
68 &self,
69 vars: &HashMap<String, String>,
70 telemetry: &Payload,
71 ) -> Result<()> {
72 let access_token = vars.get("ThingsBoardAccessToken").cloned().ok_or_else(|| {
73 anyhow!("Device does not have ThingsBoardAccessToken variable configured")
74 })?;
75
76 let endpoint = format!("{}/api/v1/{}/telemetry", self.server, access_token);
77 let b = serde_json::to_string(&telemetry)?;
78
79 let mut headers = HeaderMap::new();
80 headers.insert(CONTENT_TYPE, "application/json".parse().unwrap());
81
82 let res = get_client()
83 .post(endpoint)
84 .body(b)
85 .headers(headers)
86 .send()
87 .await?;
88 let _ = res.error_for_status()?;
89 Ok(())
90 }
91}
92
93#[async_trait]

Callers 3

uplink_eventMethod · 0.80
status_eventMethod · 0.80
location_eventMethod · 0.80

Calls 5

insertMethod · 0.80
unwrapMethod · 0.80
postMethod · 0.80
get_clientFunction · 0.70
getMethod · 0.45

Tested by

no test coverage detected