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

Method validate_dev_nonce_and_get_device_keys

chirpstack/src/uplink/join.rs:453–515  ·  view source on GitHub ↗
(&mut self)

Source from the content-addressed store, hash-verified

451 }
452
453 async fn validate_dev_nonce_and_get_device_keys(&mut self) -> Result<()> {
454 trace!("Validate dev-nonce and get device-keys");
455 let dev = self.device.as_ref().unwrap();
456 let app = self.application.as_ref().unwrap();
457 let join_request = self.join_request.as_ref().unwrap();
458
459 self.device_keys = Some(
460 match device_keys::validate_incr_join_and_store_dev_nonce(
461 join_request.join_eui,
462 dev.dev_eui,
463 join_request.dev_nonce,
464 )
465 .await
466 {
467 Ok(v) => v,
468 Err(v) => match v {
469 StorageError::InvalidDevNonce => {
470 integration::log_event(
471 app.id.into(),
472 &dev.variables,
473 &integration_pb::LogEvent {
474 time: Some(Utc::now().into()),
475 device_info: self.device_info.clone(),
476 level: integration_pb::LogLevel::Error.into(),
477 code: integration_pb::LogCode::Otaa.into(),
478 description: "DevNonce has already been used".into(),
479 context: [
480 (
481 "deduplication_id".to_string(),
482 self.uplink_frame_set.uplink_set_id.to_string(),
483 ),
484 ("join_eui".to_string(), join_request.join_eui.to_string()),
485 ("dev_nonce".to_string(), join_request.dev_nonce.to_string()),
486 ]
487 .iter()
488 .cloned()
489 .collect(),
490 },
491 )
492 .await;
493
494 metrics::save(
495 &format!("device:{}", dev.dev_eui),
496 &metrics::Record {
497 time: Local::now(),
498 kind: metrics::Kind::ABSOLUTE,
499 metrics: [("error_OTAA".into(), 1f64)].iter().cloned().collect(),
500 },
501 &metrics::Aggregation::default_aggregations(),
502 )
503 .await?;
504
505 return Err(v.into());
506 }
507 _ => {
508 return Err(v.into());
509 }
510 },

Callers 2

_handleMethod · 0.45
_handle_relayedMethod · 0.45

Calls 8

unwrapMethod · 0.80
as_refMethod · 0.80
iterMethod · 0.80
to_stringMethod · 0.80
log_eventFunction · 0.50
saveFunction · 0.50
intoMethod · 0.45

Tested by

no test coverage detected