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

Function handle_vendor

chirpstack/src/cmd/import_device_profiles.rs:140–167  ·  view source on GitHub ↗
(dir: &Path)

Source from the content-addressed store, hash-verified

138}
139
140async fn handle_vendor(dir: &Path) -> Result<()> {
141 let vendor_conf = dir.join("vendor.toml");
142 info!(path = ?vendor_conf, "Reading vendor configuration");
143 let vendor_conf: VendorConfig = toml::from_str(&fs::read_to_string(vendor_conf)?)?;
144 info!(vendor_name = %vendor_conf.vendor.name, "Vendor loaded");
145
146 info!(id = %vendor_conf.vendor.id, "Upserting vendor");
147 let _ = device_profile::upsert_vendor(device_profile::Vendor {
148 id: vendor_conf.vendor.id.into(),
149 name: vendor_conf.vendor.name.clone(),
150 vendor_id: vendor_conf.vendor.vendor_id,
151 ouis: fields::StringVec::new(
152 vendor_conf
153 .vendor
154 .ouis
155 .iter()
156 .map(|v| Some(v.clone()))
157 .collect(),
158 ),
159 metadata: fields::KeyValue::new(vendor_conf.vendor.metadata.clone()),
160 ..Default::default()
161 })
162 .await?;
163
164 handle_devices(dir, &vendor_conf.vendor).await?;
165
166 Ok(())
167}
168
169async fn handle_devices(dir: &Path, vendor: &Vendor) -> Result<()> {
170 info!(id = %vendor.id, "Upserting vendor devices");

Callers 1

runFunction · 0.85

Calls 4

upsert_vendorFunction · 0.85
handle_devicesFunction · 0.85
iterMethod · 0.80
intoMethod · 0.45

Tested by

no test coverage detected