Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a function for reading the device address to rubble-nrf52 #89

Open
jonas-schievink opened this issue Nov 3, 2019 · 0 comments

Comments

@jonas-schievink
Copy link
Owner

@jonas-schievink jonas-schievink commented Nov 3, 2019

Currently the demo has to manually piece the device address together by reading FICR:

let mut devaddr = [0u8; 6];
let devaddr_lo = device.FICR.deviceaddr[0].read().bits();
let devaddr_hi = device.FICR.deviceaddr[1].read().bits() as u16;
LittleEndian::write_u32(&mut devaddr, devaddr_lo);
LittleEndian::write_u16(&mut devaddr[4..], devaddr_hi);
let devaddr_type = if device
.FICR
.deviceaddrtype
.read()
.deviceaddrtype()
.is_public()
{
AddressKind::Public
} else {
AddressKind::Random
};
let device_address = DeviceAddress::new(devaddr, devaddr_type);

This code should be moved into a little helper function in rubble-nrf52.

AFAIK FICR is completely read-only, so we can use unsafe { *FICR::ptr() } to access it.

@jonas-schievink jonas-schievink changed the title rubble-nrf52 should provide a helper for reading the device address Add a function for reading the device address to rubble-nrf52 Nov 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.