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

Function create_device

chirpstack/src/storage/device.rs:1124–1154  ·  view source on GitHub ↗
(
        dev_eui: EUI64,
        device_profile_id: Uuid,
        application_id: Option<Uuid>,
    )

Source from the content-addressed store, hash-verified

1122 }
1123
1124 pub async fn create_device(
1125 dev_eui: EUI64,
1126 device_profile_id: Uuid,
1127 application_id: Option<Uuid>,
1128 ) -> Device {
1129 let tenant_id = {
1130 let dp = storage::device_profile::get(&device_profile_id)
1131 .await
1132 .unwrap();
1133 dp.tenant_id.unwrap()
1134 };
1135
1136 let application_id = match application_id {
1137 Some(v) => v.into(),
1138 None => {
1139 let a =
1140 storage::application::test::create_application(Some(tenant_id.into())).await;
1141 a.id
1142 }
1143 };
1144
1145 let d = Device {
1146 name: "test-dev".into(),
1147 dev_eui,
1148 application_id,
1149 device_profile_id: device_profile_id.into(),
1150 ..Default::default()
1151 };
1152
1153 create(d).await.unwrap()
1154 }
1155
1156 #[tokio::test]
1157 async fn test_device() {

Callers 10

test_queue_itemFunction · 0.85
test_flush_queueFunction · 0.85
test_get_max_f_cnt_downFunction · 0.85
test_deviceFunction · 0.85
test_device_listFunction · 0.85
test_relayFunction · 0.85
deviceFunction · 0.85
device_queueFunction · 0.85

Calls 5

create_applicationFunction · 0.85
unwrapMethod · 0.80
getFunction · 0.70
createFunction · 0.70
intoMethod · 0.45

Tested by 8

test_queue_itemFunction · 0.68
test_flush_queueFunction · 0.68
test_get_max_f_cnt_downFunction · 0.68
test_deviceFunction · 0.68
test_device_listFunction · 0.68
test_relayFunction · 0.68