(&self)
| 1112 | } |
| 1113 | |
| 1114 | async fn handle_uplink_ack(&self) -> Result<()> { |
| 1115 | let mac = if let lrwn::Payload::MACPayload(pl) = &self.phy_payload.payload { |
| 1116 | pl |
| 1117 | } else { |
| 1118 | return Err(anyhow!("Expected MacPayload")); |
| 1119 | }; |
| 1120 | if !mac.fhdr.f_ctrl.ack { |
| 1121 | return Ok(()); |
| 1122 | } |
| 1123 | |
| 1124 | info!("Handling uplink ack"); |
| 1125 | |
| 1126 | let tenant = self.tenant.as_ref().unwrap(); |
| 1127 | let app = self.application.as_ref().unwrap(); |
| 1128 | let dp = self.device_profile.as_ref().unwrap(); |
| 1129 | let dev = self.device.as_ref().unwrap(); |
| 1130 | let ts: DateTime<Utc> = |
| 1131 | helpers::get_rx_timestamp(&self.uplink_frame_set.rx_info_set).into(); |
| 1132 | |
| 1133 | let qi = match device_queue::get_pending_for_dev_eui(&dev.dev_eui).await { |
| 1134 | Ok(v) => v, |
| 1135 | Err(e) => { |
| 1136 | warn!(dev_eui = %dev.dev_eui, error = %e.full(), "Get pending queue-item error"); |
| 1137 | return Ok(()); |
| 1138 | } |
| 1139 | }; |
| 1140 | |
| 1141 | device_queue::delete_item(&qi.id).await?; |
| 1142 | |
| 1143 | let mut tags = (*app.tags).clone(); |
| 1144 | tags.extend((*dp.tags).clone()); |
| 1145 | tags.extend((*dev.tags).clone()); |
| 1146 | |
| 1147 | integration::ack_event( |
| 1148 | app.id.into(), |
| 1149 | &dev.variables, |
| 1150 | &integration_pb::AckEvent { |
| 1151 | deduplication_id: self.uplink_frame_set.uplink_set_id.to_string(), |
| 1152 | time: Some(ts.into()), |
| 1153 | device_info: Some(integration_pb::DeviceInfo { |
| 1154 | tenant_id: tenant.id.to_string(), |
| 1155 | tenant_name: tenant.name.clone(), |
| 1156 | application_id: app.id.to_string(), |
| 1157 | application_name: app.name.to_string(), |
| 1158 | device_profile_id: dp.id.to_string(), |
| 1159 | device_profile_name: dp.name.clone(), |
| 1160 | device_name: dev.name.clone(), |
| 1161 | device_class_enabled: dev.enabled_class.to_proto().into(), |
| 1162 | dev_eui: dev.dev_eui.to_string(), |
| 1163 | tags, |
| 1164 | }), |
| 1165 | queue_item_id: qi.id.to_string(), |
| 1166 | acknowledged: true, |
| 1167 | f_cnt_down: qi.f_cnt_down.unwrap_or(0) as u32, |
| 1168 | }, |
| 1169 | ) |
| 1170 | .await; |
| 1171 |
no test coverage detected