1 // Copyright 2025 Google LLC
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // https://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 use crate::{
16 devices::chip::ChipIdentifier,
17 wireless::WirelessChipImpl,
18 wireless::{ble_beacon, mocked},
19 };
20
21 #[cfg(not(test))]
22 use crate::wireless::{bluetooth, uwb, wifi_chip, wifi_manager};
23
24 /// Parameter for each constructor of Emulated Chips
25 #[allow(clippy::large_enum_variant, dead_code)]
26 pub enum CreateParam {
27 BleBeacon(ble_beacon::CreateParams),
28 #[cfg(not(test))]
29 Bluetooth(bluetooth::CreateParams),
30 #[cfg(not(test))]
31 Wifi(wifi_chip::CreateParams),
32 #[cfg(not(test))]
33 Uwb(uwb::CreateParams),
34 Mock(mocked::CreateParams),
35 }
36
37 /// This is called when the transport module receives a new packet stream
38 /// connection from a virtual device.
add_chip(create_param: &CreateParam, chip_id: ChipIdentifier) -> WirelessChipImpl39 pub fn add_chip(create_param: &CreateParam, chip_id: ChipIdentifier) -> WirelessChipImpl {
40 // Based on create_param, construct WirelessChip.
41 match create_param {
42 CreateParam::BleBeacon(params) => ble_beacon::add_chip(params, chip_id),
43 #[cfg(not(test))]
44 CreateParam::Bluetooth(params) => bluetooth::add_chip(params, chip_id),
45 #[cfg(not(test))]
46 CreateParam::Wifi(params) => wifi_manager::add_chip(params, chip_id),
47 #[cfg(not(test))]
48 CreateParam::Uwb(params) => uwb::add_chip(params, chip_id),
49 CreateParam::Mock(params) => mocked::add_chip(params, chip_id),
50 }
51 }
52