Skip to content

Commit

Permalink
refactor: use BeaconScanner in receiver
Browse files Browse the repository at this point in the history
  • Loading branch information
fmckeogh committed Apr 19, 2019
1 parent c940f74 commit b4668ae
Show file tree
Hide file tree
Showing 21 changed files with 745 additions and 2,882 deletions.
64 changes: 13 additions & 51 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions controller/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,10 @@ bench = false

[dependencies]
cortex-m = "0.5.8"
cortex-m-semihosting = "0.3.2"
cortex-m-rtfm = "0.4.2"
cortex-m-rt = "0.6.8"
embedded-hal = "0.2.2"
nrf52810-hal = { git = "https://github.com/nrf-rs/nrf52-hal", rev = "8459b7e", features = ["rt"] }
nrf52810-hal = { git = "https://github.com/chocol4te/nrf52-hal", rev = "5befd35", features = ["rt"] }
nb = "0.1.1"
fpa = "0.1.0"
byteorder = { version = "1.3.1", default-features = false }
Expand Down
24 changes: 19 additions & 5 deletions controller/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,14 @@ use {
crate::logger::{BbqLogger, StampedLogger},
bbqueue::{bbq, BBQueue, Consumer},
core::fmt::Write,
cortex_m_semihosting::hprintln,
embedded_hal::adc::OneShot,
log::{info, LevelFilter},
nrf52810_hal::{
self as hal,
gpio::Level,
nrf52810_pac::{self as pac, UARTE0},
prelude::*,
saadc::Saadc,
saadc::{Gain, Oversample, Reference, Resistor, Resolution, Saadc, SaadcConfig, Time},
uarte::{Baudrate, Parity, Uarte},
},
rtfm::app,
Expand Down Expand Up @@ -68,7 +67,7 @@ const APP: () = {

#[init(resources = [BLE_TX_BUF, BLE_RX_BUF])]
fn init() {
hprintln!("\n<< INIT >>\n").ok();
//hprintln!("\n<< INIT >>\n").ok();

{
// On reset the internal high frequency clock is used, but starting the HFCLK task
Expand Down Expand Up @@ -149,14 +148,27 @@ const APP: () = {
L2CAPState::new(BleChannelMap::with_attributes(GattServer::new())),
);

let adc = {
let config = SaadcConfig {
resolution: Resolution::_14BIT,
oversample: Oversample::OVER256X,
reference: Reference::VDD1_4,
gain: Gain::GAIN1_4,
resistor: Resistor::BYPASS,
time: Time::_40US,
};

Saadc::new(device.SAADC, config)
};

RADIO = radio;
BLE_LL = ll;
BLE_R = resp;
BEACON_TIMER = device.TIMER1;
SERIAL = serial;
LOG_SINK = log_sink;

ADC = device.SAADC.constrain();
ADC = adc;
ADC_PIN = p0.p0_02.into_floating_input();
}

Expand All @@ -178,11 +190,13 @@ const APP: () = {

let val: u16 = resources.ADC.read(resources.ADC_PIN).unwrap();

info!("read val: {}", val);

let beacon = Beacon::new(
device_address,
&[AdStructure::Unknown {
ty: 0xFF,
data: &[((val / 13) - 250) as u8],
data: &[(val / 64) as u8],
}],
)
.unwrap();
Expand Down
6 changes: 4 additions & 2 deletions receiver/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ test = false
bench = false

[dependencies]
cortex-m = "0.6.0"
cortex-m-semihosting = "0.3.2"
cortex-m = "0.5.8"
cortex-m-rtfm = "0.4.2"
cortex-m-rt = "0.6.8"
embedded-hal = "0.2.2"
Expand All @@ -22,3 +21,6 @@ byteorder = { version = "1.3.1", default-features = false }
panic-semihosting = "0.5.1"
bitflags = "1.0.4"
uuid = { version = "0.7.4", default-features = false }
rubble = { git = "https://github.com/jonas-schievink/rubble.git", rev = "0e49250" }
log = "0.4.6"
bbqueue = "0.3.2"
53 changes: 0 additions & 53 deletions receiver/src/ble/beacon.rs

This file was deleted.

Loading

0 comments on commit b4668ae

Please sign in to comment.