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

Function log_downlink_for_device

chirpstack/src/stream/frame.rs:181–229  ·  view source on GitHub ↗
(dfl: &stream::DownlinkFrameLog)

Source from the content-addressed store, hash-verified

179}
180
181pub async fn log_downlink_for_device(dfl: &stream::DownlinkFrameLog) -> Result<()> {
182 if dfl.dev_eui.is_empty() {
183 return Err(anyhow!("dev_eui must be set"));
184 }
185
186 let conf = config::get();
187
188 let b = dfl.encode_to_vec();
189
190 // per device stream
191 if conf.monitoring.per_device_frame_log_max_history > 0 {
192 let key = redis_key(format!("device:{{{}}}:stream:frame", dfl.dev_eui));
193
194 () = redis::pipe()
195 .atomic()
196 .cmd("XADD")
197 .arg(&key)
198 .arg("MAXLEN")
199 .arg("~")
200 .arg(conf.monitoring.per_device_frame_log_max_history)
201 .arg("*")
202 .arg("down")
203 .arg(&b)
204 .ignore()
205 .cmd("PEXPIRE")
206 .arg(&key)
207 .arg(conf.monitoring.per_device_frame_log_ttl.as_millis() as usize)
208 .ignore()
209 .query_async(&mut get_async_redis_conn().await?)
210 .await?;
211 }
212
213 // global device stream
214 if conf.monitoring.device_frame_log_max_history > 0 {
215 let key = redis_key("device:stream:frame".to_string());
216 () = redis::cmd("XADD")
217 .arg(&key)
218 .arg("MAXLEN")
219 .arg("~")
220 .arg(conf.monitoring.device_frame_log_max_history)
221 .arg("*")
222 .arg("down")
223 .arg(&b)
224 .query_async(&mut get_async_redis_conn().await?)
225 .await?;
226 }
227
228 Ok(())
229}
230
231pub async fn get_frame_logs(
232 key: String,

Callers 1

log_downlink_frameMethod · 0.85

Calls 4

redis_keyFunction · 0.85
get_async_redis_connFunction · 0.85
to_stringMethod · 0.80
getFunction · 0.50

Tested by

no test coverage detected