Skip to content

Commit 0b29d7b

Browse files
author
Jonathan Pallant
authored
Merge pull request #18 from Wassasin/nrfxlib-v1.4.2
Update to nrfxlib-sys v1.4.2
2 parents a93bddc + 96f85f1 commit 0b29d7b

File tree

6 files changed

+35
-22
lines changed

6 files changed

+35
-22
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,12 @@ jobs:
1111
strategy:
1212
matrix:
1313
target:
14-
- thumbv8m.main-none-eabihf
1514
- thumbv8m.main-none-eabi
1615
steps:
1716
- uses: actions/checkout@v1
1817
- uses: actions-rs/toolchain@v1
1918
with:
20-
toolchain: stable
19+
toolchain: nightly
2120
target: ${{ matrix.target }}
2221
override: true
2322
- uses: actions-rs/cargo@v1

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@ license = "MIT OR Apache-2.0"
77
readme = "README.md"
88
repository = "https://github.com/42-technology-ltd/nrfxlib"
99
description = "Rust driver for the LTE stack on the Nordic nRF9160"
10+
resolver = "2"
1011

1112
[dependencies]
12-
nrfxlib-sys = "1.2.0"
1313
nrf9160-pac = "0.2.1"
1414
cortex-m = "0.6"
1515
heapless = "0.5"
1616
log = "0.4"
17+
nrfxlib-sys = "1.4.2"

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ See [nrf9160-demo](https://github.com/42-technology-ltd/nrf9160-demo) for a demo
7676

7777
### Unreleased Changes ([Source](https://github.com/42-technology-ltd/nrfxlib/tree/master) | [Changes](https://github.com/42-technology-ltd/nrfxlib/compare/v0.5.0...master))
7878

79-
* None
79+
* Updated to nrfxlib version 1.4.2. This requires Rust v1.51 as we use the new resolver to allow bindgen as a build-dep.
8080

8181
### v0.5.0 ([Source](https://github.com/42-technology-ltd/nrfxlib/tree/v0.5.0) | [Changes](https://github.com/42-technology-ltd/nrfxlib/compare/v0.4.0...v0.5.0))
8282

src/at.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ pub struct AtSocket(Socket);
5353
impl AtSocket {
5454
/// Create a new AT socket.
5555
pub fn new() -> Result<AtSocket, Error> {
56-
let skt = Socket::new(SocketDomain::Lte, SocketType::None, SocketProtocol::At)?;
56+
let skt = Socket::new(SocketDomain::Lte, SocketType::Datagram, SocketProtocol::At)?;
5757
Ok(AtSocket(skt))
5858
}
5959

src/lib.rs

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ pub use ffi::get_last_error;
5353
pub use raw::{poll, PollEntry, PollFlags, PollResult, Pollable};
5454

5555
use log::{debug, trace};
56-
use nrfxlib_sys as sys;
5756
use nrf9160_pac as cpu;
57+
use nrfxlib_sys as sys;
5858

5959
//******************************************************************************
6060
// Types
@@ -132,12 +132,28 @@ pub enum Error {
132132
//******************************************************************************
133133

134134
/// Start the BSD library
135-
pub fn init() {
135+
pub fn init(trace_on: bool) -> Result<(), Error> {
136136
debug!("nrfxlib init");
137-
unsafe {
138-
sys::bsd_init();
137+
let bsd_memory_size = if trace_on {
138+
sys::BSD_RESERVED_MEMORY_SIZE
139+
} else {
140+
sys::BSD_RESERVED_MEMORY_SIZE_TRACE_DISABLED
141+
};
142+
143+
let result = unsafe {
144+
sys::bsd_init(&sys::bsd_init_params_t {
145+
trace_on,
146+
bsd_memory_address: sys::BSD_RESERVED_MEMORY_ADDRESS,
147+
bsd_memory_size,
148+
})
149+
};
150+
151+
if result < 0 {
152+
Err(Error::Nordic("init", result, ffi::get_last_error()))
153+
} else {
154+
trace!("nrfxlib init complete");
155+
Ok(())
139156
}
140-
trace!("nrfxlib init complete");
141157
}
142158

143159
/// Stop the BSD library
@@ -161,10 +177,10 @@ impl core::fmt::Display for NrfSockAddrIn {
161177
write!(
162178
f,
163179
"{}.{}.{}.{}:{}",
164-
octets[0],
165-
octets[1],
166-
octets[2],
167180
octets[3],
181+
octets[2],
182+
octets[1],
183+
octets[0],
168184
u16::from_be(self.sin_port)
169185
)
170186
}

src/raw.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,6 @@ pub(crate) enum SocketDomain {
7171
/// The type of socket (Stream, Datagram, or neither)
7272
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
7373
pub(crate) enum SocketType {
74-
/// Used with `SocketDomain::Lte`
75-
None,
7674
/// Used with `SocketDomain::Inet` for TCP and TLS streams
7775
Stream,
7876
/// Used with UDP sockets, and for GPS
@@ -323,7 +321,6 @@ impl Into<i32> for SocketType {
323321
fn into(self) -> i32 {
324322
use SocketType::*;
325323
match self {
326-
None => 0,
327324
Stream => sys::NRF_SOCK_STREAM as i32,
328325
Datagram => sys::NRF_SOCK_DGRAM as i32,
329326
}
@@ -434,14 +431,14 @@ pub fn poll(poll_list: &mut [PollEntry], timeout_ms: u16) -> Result<i32, Error>
434431
}
435432

436433
let mut poll_fds: [sys::nrf_pollfd; MAX_SOCKETS_POLL] = [sys::nrf_pollfd {
437-
handle: 0,
438-
requested: 0,
439-
returned: 0,
434+
fd: 0,
435+
events: 0,
436+
revents: 0,
440437
}; MAX_SOCKETS_POLL];
441438

442439
for (poll_entry, pollfd) in poll_list.iter_mut().zip(poll_fds.iter_mut()) {
443-
pollfd.handle = poll_entry.socket.get_fd();
444-
pollfd.requested = poll_entry.flags as i16;
440+
pollfd.fd = poll_entry.socket.get_fd();
441+
pollfd.events = poll_entry.flags as i16;
445442
count += 1;
446443
}
447444

@@ -452,7 +449,7 @@ pub fn poll(poll_list: &mut [PollEntry], timeout_ms: u16) -> Result<i32, Error>
452449
0 => Ok(0),
453450
n => {
454451
for (poll_entry, pollfd) in poll_list.iter_mut().zip(poll_fds.iter()) {
455-
poll_entry.result = PollResult(pollfd.returned as u32);
452+
poll_entry.result = PollResult(pollfd.revents as u32);
456453
}
457454
Ok(n)
458455
}

0 commit comments

Comments
 (0)