Skip to content

Commit b4668ae

Browse files
committed
refactor: use BeaconScanner in receiver
1 parent c940f74 commit b4668ae

File tree

21 files changed

+745
-2882
lines changed

21 files changed

+745
-2882
lines changed

Cargo.lock

Lines changed: 13 additions & 51 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

controller/Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,10 @@ bench = false
1111

1212
[dependencies]
1313
cortex-m = "0.5.8"
14-
cortex-m-semihosting = "0.3.2"
1514
cortex-m-rtfm = "0.4.2"
1615
cortex-m-rt = "0.6.8"
1716
embedded-hal = "0.2.2"
18-
nrf52810-hal = { git = "https://github.com/nrf-rs/nrf52-hal", rev = "8459b7e", features = ["rt"] }
17+
nrf52810-hal = { git = "https://github.com/chocol4te/nrf52-hal", rev = "5befd35", features = ["rt"] }
1918
nb = "0.1.1"
2019
fpa = "0.1.0"
2120
byteorder = { version = "1.3.1", default-features = false }

controller/src/main.rs

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,14 @@ use {
1010
crate::logger::{BbqLogger, StampedLogger},
1111
bbqueue::{bbq, BBQueue, Consumer},
1212
core::fmt::Write,
13-
cortex_m_semihosting::hprintln,
1413
embedded_hal::adc::OneShot,
1514
log::{info, LevelFilter},
1615
nrf52810_hal::{
1716
self as hal,
1817
gpio::Level,
1918
nrf52810_pac::{self as pac, UARTE0},
2019
prelude::*,
21-
saadc::Saadc,
20+
saadc::{Gain, Oversample, Reference, Resistor, Resolution, Saadc, SaadcConfig, Time},
2221
uarte::{Baudrate, Parity, Uarte},
2322
},
2423
rtfm::app,
@@ -68,7 +67,7 @@ const APP: () = {
6867

6968
#[init(resources = [BLE_TX_BUF, BLE_RX_BUF])]
7069
fn init() {
71-
hprintln!("\n<< INIT >>\n").ok();
70+
//hprintln!("\n<< INIT >>\n").ok();
7271

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

151+
let adc = {
152+
let config = SaadcConfig {
153+
resolution: Resolution::_14BIT,
154+
oversample: Oversample::OVER256X,
155+
reference: Reference::VDD1_4,
156+
gain: Gain::GAIN1_4,
157+
resistor: Resistor::BYPASS,
158+
time: Time::_40US,
159+
};
160+
161+
Saadc::new(device.SAADC, config)
162+
};
163+
152164
RADIO = radio;
153165
BLE_LL = ll;
154166
BLE_R = resp;
155167
BEACON_TIMER = device.TIMER1;
156168
SERIAL = serial;
157169
LOG_SINK = log_sink;
158170

159-
ADC = device.SAADC.constrain();
171+
ADC = adc;
160172
ADC_PIN = p0.p0_02.into_floating_input();
161173
}
162174

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

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

193+
info!("read val: {}", val);
194+
181195
let beacon = Beacon::new(
182196
device_address,
183197
&[AdStructure::Unknown {
184198
ty: 0xFF,
185-
data: &[((val / 13) - 250) as u8],
199+
data: &[(val / 64) as u8],
186200
}],
187201
)
188202
.unwrap();

receiver/Cargo.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ test = false
1010
bench = false
1111

1212
[dependencies]
13-
cortex-m = "0.6.0"
14-
cortex-m-semihosting = "0.3.2"
13+
cortex-m = "0.5.8"
1514
cortex-m-rtfm = "0.4.2"
1615
cortex-m-rt = "0.6.8"
1716
embedded-hal = "0.2.2"
@@ -22,3 +21,6 @@ byteorder = { version = "1.3.1", default-features = false }
2221
panic-semihosting = "0.5.1"
2322
bitflags = "1.0.4"
2423
uuid = { version = "0.7.4", default-features = false }
24+
rubble = { git = "https://github.com/jonas-schievink/rubble.git", rev = "0e49250" }
25+
log = "0.4.6"
26+
bbqueue = "0.3.2"

receiver/src/ble/beacon.rs

Lines changed: 0 additions & 53 deletions
This file was deleted.

0 commit comments

Comments
 (0)