Skip to content

Commit

Permalink
enhance(ble): mac address convertion
Browse files Browse the repository at this point in the history
  • Loading branch information
andelf committed Nov 2, 2023
1 parent f97b5c0 commit ba85a19
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ This should be the reference hal implementation for CH57x, CH58x, CH59x.
- ADC, with Temperature sensor, VBAT sensor
- SPI
- libISP ROM functions
- BLE library support
- Basic BLE library support

## Usage

Expand Down
5 changes: 2 additions & 3 deletions examples/embassy-ble-scan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ use hal::ble::ffi::*;
use hal::ble::{get_raw_temperature, MacAddress};
use hal::gpio::{AnyPin, Input, Level, Output, OutputDrive, Pin, Pull};
use hal::interrupt::Interrupt;
use hal::prelude::*;
use hal::rtc::Rtc;
use hal::uart::UartTx;
use hal::{ble, peripherals, println};
Expand Down Expand Up @@ -132,9 +131,9 @@ async fn main(spawner: Spawner) -> ! {
println!("RTC datetime: {}", rtc.now());

let r = ble::init(ble::Config {
mac_addr: [0x22, 0x33, 0x44, 0x55, 0x66, 0x77],
mac_addr: [0x22, 0x33, 0x44, 0x55, 0x66, 0x77].into(),
});
println!("ble init: {:?}", r);
println!("BLE init: {:?}", r);
println!("MemFree: {}K", hal::stack_free() / 1024);

// start ble reg calibrate loop
Expand Down
6 changes: 6 additions & 0 deletions src/ble/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ impl core::fmt::Display for MacAddress {
}
}

impl From<[u8; 6]> for MacAddress {
fn from(addr: [u8; 6]) -> Self {
MacAddress::from_msb(addr)
}
}

#[derive(Debug)]
pub struct Config {
pub mac_addr: MacAddress,
Expand Down

0 comments on commit ba85a19

Please sign in to comment.