mirror of
https://github.com/chirpstack/chirpstack.git
synced 2024-12-19 05:07:54 +00:00
Fix device activation not setting the device class for LoRaWAN 1.0 on ABP. (#344)
This commit is contained in:
parent
f248379259
commit
3b7ab175b4
@ -17,7 +17,8 @@ use super::error::ToStatus;
|
||||
use super::helpers::{self, FromProto, ToProto};
|
||||
use crate::storage::error::Error;
|
||||
use crate::storage::{
|
||||
device, device_keys, device_profile, device_queue, device_session, fields, metrics,
|
||||
device::{self, DeviceClass},
|
||||
device_keys, device_profile, device_queue, device_session, fields, metrics,
|
||||
};
|
||||
use crate::{codec, devaddr::get_random_dev_addr};
|
||||
|
||||
@ -538,6 +539,17 @@ impl DeviceService for Device {
|
||||
.map_err(|e| e.status())?;
|
||||
}
|
||||
|
||||
// LoRaWAN 1.1 devices send a mac-command when changing to Class-C. Change the class here for LoRaWAN 1.0 devices.
|
||||
if dp.supports_class_c && dp.mac_version.to_string().starts_with("1.0") {
|
||||
let _ = device::set_enabled_class(&dev_eui, DeviceClass::C)
|
||||
.await
|
||||
.map_err(|e| e.status())?;
|
||||
} else {
|
||||
let _ = device::set_enabled_class(&dev_eui, DeviceClass::A)
|
||||
.await
|
||||
.map_err(|e| e.status())?;
|
||||
}
|
||||
|
||||
let mut resp = Response::new(());
|
||||
resp.metadata_mut()
|
||||
.insert("x-log-dev_eui", req_da.dev_eui.parse().unwrap());
|
||||
|
Loading…
Reference in New Issue
Block a user