Compare commits
3 Commits
3a76aa6ef6
...
6c485c9ead
| Author | SHA1 | Date | |
|---|---|---|---|
| 6c485c9ead | |||
| 3020f98684 | |||
| 58f2f56c35 |
@ -1,11 +1,11 @@
|
|||||||
[target.'cfg(all(target_arch = "arm", target_os = "none"))']
|
[target.'cfg(all(target_arch = "arm", target_os = "none"))']
|
||||||
# replace nRF82810_xxAA with your chip as listed in `probe-rs chip list`
|
# replace nRF82810_xxAA with your chip as listed in `probe-rs chip list`
|
||||||
runner = "probe-rs run --chip nRF52810_xxAA"
|
runner = "probe-rs run --chip nRF52832_xxAA"
|
||||||
|
|
||||||
[alias]
|
[alias]
|
||||||
rr = "run --release"
|
rr = "run --release"
|
||||||
f = "flash --chip nRF52810_xxAA --reset-halt"
|
f = "flash --chip nRF52832_xxAA --reset-halt"
|
||||||
fr = "flash --chip nRF52810_xxAA --release --reset-halt"
|
fr = "flash --chip nRF52832_xxAA --release --reset-halt"
|
||||||
|
|
||||||
[build]
|
[build]
|
||||||
target = "thumbv7em-none-eabi"
|
target = "thumbv7em-none-eabi"
|
||||||
|
|||||||
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -734,7 +734,7 @@ dependencies = [
|
|||||||
"heapless",
|
"heapless",
|
||||||
"nrf-softdevice-macro",
|
"nrf-softdevice-macro",
|
||||||
"nrf-softdevice-s112",
|
"nrf-softdevice-s112",
|
||||||
"nrf52810-pac",
|
"nrf52832-pac",
|
||||||
"num_enum",
|
"num_enum",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|||||||
@ -11,7 +11,7 @@ defmt = "0.3.8"
|
|||||||
defmt-rtt = "0.4.1"
|
defmt-rtt = "0.4.1"
|
||||||
embassy-executor = { version = "0.6.1", features = ["task-arena-size-8192", "arch-cortex-m", "executor-thread", "executor-interrupt", "defmt", "integrated-timers"] }
|
embassy-executor = { version = "0.6.1", features = ["task-arena-size-8192", "arch-cortex-m", "executor-thread", "executor-interrupt", "defmt", "integrated-timers"] }
|
||||||
embassy-futures = "0.1.1"
|
embassy-futures = "0.1.1"
|
||||||
embassy-nrf = { version = "0.2.0", features = ["defmt", "nrf52810", "time-driver-rtc1", "gpiote", "unstable-pac", "time"] }
|
embassy-nrf = { version = "0.2.0", features = ["defmt", "nrf52832", "time-driver-rtc1", "gpiote", "unstable-pac", "time"] }
|
||||||
embassy-sync = { version = "0.6.0", features = ["defmt"] }
|
embassy-sync = { version = "0.6.0", features = ["defmt"] }
|
||||||
embassy-time = { version = "0.3.2", features = ["defmt", "defmt-timestamp-uptime"] }
|
embassy-time = { version = "0.3.2", features = ["defmt", "defmt-timestamp-uptime"] }
|
||||||
embedded-storage = "0.3.1"
|
embedded-storage = "0.3.1"
|
||||||
@ -19,7 +19,7 @@ embedded-storage-async = "0.4.1"
|
|||||||
fixed = "1.28.0"
|
fixed = "1.28.0"
|
||||||
futures = { version = "0.3.31", default-features = false }
|
futures = { version = "0.3.31", default-features = false }
|
||||||
heapless = "0.8.0"
|
heapless = "0.8.0"
|
||||||
nrf-softdevice = { version = "0.1.0", features = ["defmt", "ble-peripheral", "ble-gatt-server", "critical-section-impl", "nrf52810", "s112"] }
|
nrf-softdevice = { version = "0.1.0", features = ["defmt", "ble-peripheral", "ble-gatt-server", "critical-section-impl", "nrf52832", "s112"] }
|
||||||
nrf-softdevice-s112 = "0.1.2"
|
nrf-softdevice-s112 = "0.1.2"
|
||||||
panic-probe = { version = "0.3.2", features = ["print-defmt"] }
|
panic-probe = { version = "0.3.2", features = ["print-defmt"] }
|
||||||
static_cell = "2.1.0"
|
static_cell = "2.1.0"
|
||||||
|
|||||||
7
memory.x
7
memory.x
@ -1,8 +1,7 @@
|
|||||||
MEMORY
|
MEMORY
|
||||||
{
|
{
|
||||||
/* NOTE 1 K = 1 KiB = 1024 bytes */
|
/* NOTE 1 K = 1 KiB = 1024 bytes */
|
||||||
/* These values correspond to the NRF52810 with SoftDevice S112 v7.x */
|
/* These values correspond to the NRF52832 with SoftDevice S112 v7.x */
|
||||||
FLASH : ORIGIN = 0x00000000 + 100K, LENGTH = 192K - 100K
|
FLASH : ORIGIN = 0x00000000 + 100K, LENGTH = 512K - 100K
|
||||||
RAM : ORIGIN = 0x20000000 + 0x24b8, LENGTH = 24K - 0x24b8
|
RAM : ORIGIN = 0x20000000 + 30K, LENGTH = 64K - 30K
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -61,102 +61,100 @@ async fn main(spawner: Spawner) {
|
|||||||
let mut led = Output::new(p.P0_18, Level::Low, OutputDrive::Standard);
|
let mut led = Output::new(p.P0_18, Level::Low, OutputDrive::Standard);
|
||||||
led.set_high();
|
led.set_high();
|
||||||
|
|
||||||
info!("Hello World!");
|
let config = nrf_softdevice::Config {
|
||||||
|
clock: Some(raw::nrf_clock_lf_cfg_t {
|
||||||
|
source: raw::NRF_CLOCK_LF_SRC_RC as u8,
|
||||||
|
rc_ctiv: 16,
|
||||||
|
rc_temp_ctiv: 2,
|
||||||
|
accuracy: raw::NRF_CLOCK_LF_ACCURACY_500_PPM as u8,
|
||||||
|
}),
|
||||||
|
conn_gap: Some(raw::ble_gap_conn_cfg_t {
|
||||||
|
conn_count: 1,
|
||||||
|
event_length: 24,
|
||||||
|
}),
|
||||||
|
conn_gatt: Some(raw::ble_gatt_conn_cfg_t { att_mtu: 256 }),
|
||||||
|
gatts_attr_tab_size: Some(raw::ble_gatts_cfg_attr_tab_size_t {
|
||||||
|
attr_tab_size: raw::BLE_GATTS_ATTR_TAB_SIZE_DEFAULT,
|
||||||
|
}),
|
||||||
|
gap_role_count: Some(raw::ble_gap_cfg_role_count_t {
|
||||||
|
adv_set_count: 1,
|
||||||
|
periph_role_count: 1,
|
||||||
|
// central_role_count: 3,
|
||||||
|
// central_sec_count: 0,
|
||||||
|
// _bitfield_1: raw::ble_gap_cfg_role_count_t::new_bitfield_1(0),
|
||||||
|
}),
|
||||||
|
gap_device_name: Some(raw::ble_gap_cfg_device_name_t {
|
||||||
|
p_value: b"HelloRust" as *const u8 as _,
|
||||||
|
current_len: 9,
|
||||||
|
max_len: 9,
|
||||||
|
write_perm: unsafe { mem::zeroed() },
|
||||||
|
_bitfield_1: raw::ble_gap_cfg_device_name_t::new_bitfield_1(
|
||||||
|
raw::BLE_GATTS_VLOC_STACK as u8,
|
||||||
|
),
|
||||||
|
}),
|
||||||
|
..Default::default()
|
||||||
|
};
|
||||||
|
|
||||||
// let config = nrf_softdevice::Config {
|
let sd = Softdevice::enable(&config);
|
||||||
// clock: Some(raw::nrf_clock_lf_cfg_t {
|
let server = unwrap!(Server::new(sd));
|
||||||
// source: raw::NRF_CLOCK_LF_SRC_RC as u8,
|
unwrap!(spawner.spawn(softdevice_task(sd)));
|
||||||
// rc_ctiv: 16,
|
|
||||||
// rc_temp_ctiv: 2,
|
static ADV_DATA: LegacyAdvertisementPayload = LegacyAdvertisementBuilder::new()
|
||||||
// accuracy: raw::NRF_CLOCK_LF_ACCURACY_500_PPM as u8,
|
.flags(&[Flag::GeneralDiscovery, Flag::LE_Only])
|
||||||
// }),
|
.services_16(ServiceList::Complete, &[ServiceUuid16::BATTERY])
|
||||||
// conn_gap: Some(raw::ble_gap_conn_cfg_t {
|
.full_name("HelloRust")
|
||||||
// conn_count: 1,
|
.build();
|
||||||
// event_length: 24,
|
|
||||||
// }),
|
static SCAN_DATA: LegacyAdvertisementPayload = LegacyAdvertisementBuilder::new()
|
||||||
// conn_gatt: Some(raw::ble_gatt_conn_cfg_t { att_mtu: 256 }),
|
.services_128(
|
||||||
// gatts_attr_tab_size: Some(raw::ble_gatts_cfg_attr_tab_size_t {
|
ServiceList::Complete,
|
||||||
// attr_tab_size: raw::BLE_GATTS_ATTR_TAB_SIZE_DEFAULT,
|
&[0x9e7312e0_2354_11eb_9f10_fbc30a62cf38_u128.to_le_bytes()],
|
||||||
// }),
|
)
|
||||||
// gap_role_count: Some(raw::ble_gap_cfg_role_count_t {
|
.build();
|
||||||
// adv_set_count: 1,
|
|
||||||
// periph_role_count: 1,
|
loop {
|
||||||
// // central_role_count: 3,
|
info!("Creating config");
|
||||||
// // central_sec_count: 0,
|
let config = peripheral::Config::default();
|
||||||
// // _bitfield_1: raw::ble_gap_cfg_role_count_t::new_bitfield_1(0),
|
info!("Creating adv object");
|
||||||
// }),
|
let adv = peripheral::ConnectableAdvertisement::ScannableUndirected {
|
||||||
// gap_device_name: Some(raw::ble_gap_cfg_device_name_t {
|
adv_data: &ADV_DATA,
|
||||||
// p_value: b"HelloRust" as *const u8 as _,
|
scan_data: &SCAN_DATA,
|
||||||
// current_len: 9,
|
};
|
||||||
// max_len: 9,
|
info!("Starting advertising");
|
||||||
// write_perm: unsafe { mem::zeroed() },
|
let conn = unwrap!(peripheral::advertise_connectable(sd, adv, &config).await);
|
||||||
// _bitfield_1: raw::ble_gap_cfg_device_name_t::new_bitfield_1(
|
|
||||||
// raw::BLE_GATTS_VLOC_STACK as u8,
|
info!("advertising done!");
|
||||||
// ),
|
|
||||||
// }),
|
// Run the GATT server on the connection. This returns when the connection gets disconnected.
|
||||||
// ..Default::default()
|
//
|
||||||
// };
|
// Event enums (ServerEvent's) are generated by nrf_softdevice::gatt_server
|
||||||
//
|
// proc macro when applied to the Server struct above
|
||||||
// let sd = Softdevice::enable(&config);
|
let e = gatt_server::run(&conn, &server, |e| match e {
|
||||||
// let server = unwrap!(Server::new(sd));
|
ServerEvent::Bas(e) => match e {
|
||||||
// unwrap!(spawner.spawn(softdevice_task(sd)));
|
BatteryServiceEvent::BatteryLevelCccdWrite { notifications } => {
|
||||||
//
|
info!("battery notifications: {}", notifications)
|
||||||
// static ADV_DATA: LegacyAdvertisementPayload = LegacyAdvertisementBuilder::new()
|
}
|
||||||
// .flags(&[Flag::GeneralDiscovery, Flag::LE_Only])
|
},
|
||||||
// .services_16(ServiceList::Complete, &[ServiceUuid16::BATTERY])
|
ServerEvent::Foo(e) => match e {
|
||||||
// .full_name("HelloRust")
|
FooServiceEvent::FooWrite(val) => {
|
||||||
// .build();
|
info!("wrote foo: {}", val);
|
||||||
//
|
if let Err(e) = server.foo.foo_notify(&conn, &(val + 1)) {
|
||||||
// static SCAN_DATA: LegacyAdvertisementPayload = LegacyAdvertisementBuilder::new()
|
info!("send notification error: {:?}", e);
|
||||||
// .services_128(
|
}
|
||||||
// ServiceList::Complete,
|
}
|
||||||
// &[0x9e7312e0_2354_11eb_9f10_fbc30a62cf38_u128.to_le_bytes()],
|
FooServiceEvent::FooCccdWrite {
|
||||||
// )
|
indications,
|
||||||
// .build();
|
notifications,
|
||||||
//
|
} => {
|
||||||
// loop {
|
info!(
|
||||||
// info!("Creating config");
|
"foo indications: {}, notifications: {}",
|
||||||
// let config = peripheral::Config::default();
|
indications, notifications
|
||||||
// info!("Creating adv object");
|
)
|
||||||
// let adv = peripheral::ConnectableAdvertisement::ScannableUndirected {
|
}
|
||||||
// adv_data: &ADV_DATA,
|
},
|
||||||
// scan_data: &SCAN_DATA,
|
})
|
||||||
// };
|
.await;
|
||||||
// info!("Starting advertising");
|
|
||||||
// let conn = unwrap!(peripheral::advertise_connectable(sd, adv, &config).await);
|
info!("gatt_server run exited with error: {:?}", e);
|
||||||
//
|
}
|
||||||
// info!("advertising done!");
|
|
||||||
//
|
|
||||||
// // Run the GATT server on the connection. This returns when the connection gets disconnected.
|
|
||||||
// //
|
|
||||||
// // Event enums (ServerEvent's) are generated by nrf_softdevice::gatt_server
|
|
||||||
// // proc macro when applied to the Server struct above
|
|
||||||
// let e = gatt_server::run(&conn, &server, |e| match e {
|
|
||||||
// ServerEvent::Bas(e) => match e {
|
|
||||||
// BatteryServiceEvent::BatteryLevelCccdWrite { notifications } => {
|
|
||||||
// info!("battery notifications: {}", notifications)
|
|
||||||
// }
|
|
||||||
// },
|
|
||||||
// ServerEvent::Foo(e) => match e {
|
|
||||||
// FooServiceEvent::FooWrite(val) => {
|
|
||||||
// info!("wrote foo: {}", val);
|
|
||||||
// if let Err(e) = server.foo.foo_notify(&conn, &(val + 1)) {
|
|
||||||
// info!("send notification error: {:?}", e);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// FooServiceEvent::FooCccdWrite {
|
|
||||||
// indications,
|
|
||||||
// notifications,
|
|
||||||
// } => {
|
|
||||||
// info!(
|
|
||||||
// "foo indications: {}, notifications: {}",
|
|
||||||
// indications, notifications
|
|
||||||
// )
|
|
||||||
// }
|
|
||||||
// },
|
|
||||||
// })
|
|
||||||
// .await;
|
|
||||||
//
|
|
||||||
// info!("gatt_server run exited with error: {:?}", e);
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user