Function
create_device
(
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() { |