wasefire_board_api/radio.rs
1// Copyright 2023 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// http://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//! Radio interface.
16
17#[cfg(feature = "api-radio-ble")]
18pub mod ble;
19
20/// Radio event.
21#[cfg_attr(feature = "defmt", derive(defmt::Format))]
22#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq, PartialOrd, Ord)]
23pub enum Event {
24 /// BLE event.
25 #[cfg(feature = "api-radio-ble")]
26 Ble(ble::Event),
27}
28
29impl<B: crate::Api> From<Event> for crate::Event<B> {
30 fn from(event: Event) -> Self {
31 crate::Event::Radio(event)
32 }
33}
34
35/// Radio interface.
36pub trait Api: Send {
37 /// Bluetooth Low Energy (BLE) interface.
38 #[cfg(feature = "api-radio-ble")]
39 type Ble: ble::Api;
40}
41
42/// Bluetooth Low Energy (BLE) interface.
43#[cfg(feature = "api-radio-ble")]
44pub type Ble<B> = <super::Radio<B> as Api>::Ble;