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

Function log_uplink_for_device

chirpstack/src/stream/frame.rs:131–179  ·  view source on GitHub ↗
(ufl: &stream::UplinkFrameLog)

Source from the content-addressed store, hash-verified

129}
130
131pub async fn log_uplink_for_device(ufl: &stream::UplinkFrameLog) -> Result<()> {
132 if ufl.dev_eui.is_empty() {
133 return Err(anyhow!("dev_eui must be set"));
134 }
135
136 let conf = config::get();
137
138 let b = ufl.encode_to_vec();
139
140 // per device stream
141 if conf.monitoring.per_device_frame_log_max_history > 0 {
142 let key = redis_key(format!("device:{{{}}}:stream:frame", ufl.dev_eui));
143
144 () = redis::pipe()
145 .atomic()
146 .cmd("XADD")
147 .arg(&key)
148 .arg("MAXLEN")
149 .arg("~")
150 .arg(conf.monitoring.per_device_frame_log_max_history)
151 .arg("*")
152 .arg("up")
153 .arg(&b)
154 .ignore()
155 .cmd("PEXPIRE")
156 .arg(&key)
157 .arg(conf.monitoring.per_device_frame_log_ttl.as_millis() as usize)
158 .ignore()
159 .query_async(&mut get_async_redis_conn().await?)
160 .await?;
161 }
162
163 // global device stream
164 if conf.monitoring.device_frame_log_max_history > 0 {
165 let key = redis_key("device:stream:frame".to_string());
166 () = redis::cmd("XADD")
167 .arg(&key)
168 .arg("MAXLEN")
169 .arg("~")
170 .arg(conf.monitoring.device_frame_log_max_history)
171 .arg("*")
172 .arg("up")
173 .arg(&b)
174 .query_async(&mut get_async_redis_conn().await?)
175 .await?;
176 }
177
178 Ok(())
179}
180
181pub async fn log_downlink_for_device(dfl: &stream::DownlinkFrameLog) -> Result<()> {
182 if dfl.dev_eui.is_empty() {

Callers 3

log_uplink_frame_setMethod · 0.85
log_uplink_frame_setMethod · 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