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

Method send_attributes

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

Source from the content-addressed store, hash-verified

40 }
41
42 async fn send_attributes(
43 &self,
44 vars: &HashMap<String, String>,
45 attributes: &Payload,
46 ) -> Result<()> {
47 let access_token = vars.get("ThingsBoardAccessToken").cloned().ok_or_else(|| {
48 anyhow!("Device does not have ThingsBoardAccessToken variable configured")
49 })?;
50
51 let endpoint = format!("{}/api/v1/{}/attributes", self.server, access_token);
52 let b = serde_json::to_string(&attributes)?;
53
54 let mut headers = HeaderMap::new();
55 headers.insert(CONTENT_TYPE, "application/json".parse().unwrap());
56
57 let res = get_client()
58 .post(endpoint)
59 .body(b)
60 .headers(headers)
61 .send()
62 .await?;
63 let _ = res.error_for_status()?;
64 Ok(())
65 }
66
67 async fn send_telemetry(
68 &self,

Callers 1

uplink_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