pub struct EmbeddedNode { /* private fields */ }Implementations§
Source§impl EmbeddedNode
impl EmbeddedNode
Sourcepub fn new() -> Self
pub fn new() -> Self
Examples found in repository?
examples/std_managed_node.rs (line 10)
9fn main() {
10 let node = EmbeddedNode::new();
11 let subscription = node.subscribe_events().expect("subscribe");
12
13 let config = NodeConfig {
14 runtime: RuntimeConfig {
15 store_identity: [0x11; 32],
16 lxmf_address: [0x22; 16],
17 node_mode: NodeTransportMode::BleOnly,
18 announce_interval_ms: 1_000,
19 max_outbound_queue: 8,
20 max_events: 16,
21 capture_defaults: Default::default(),
22 },
23 backend: NodeBackendConfig::Ble(BleNodeBackendConfig::default()),
24 };
25
26 node.start(config).expect("start");
27 node.set_link_state(LinkState::Up).expect("link up");
28 node.send([0x42; 16], b"hello from managed std", SendOptions).expect("send");
29
30 thread::sleep(Duration::from_millis(75));
31
32 loop {
33 match subscription.next(0).expect("poll") {
34 PollResult::Event(event) => {
35 if let NodeEventKind::PacketSent { sequence, .. } = event.kind {
36 println!("packet sent with sequence {sequence}");
37 break;
38 }
39 }
40 PollResult::Timeout => break,
41 other => println!("poll result: {other:?}"),
42 }
43 }
44
45 node.stop().expect("stop");
46}More examples
examples/tcp_receive_once.rs (line 22)
14fn main() {
15 let Some(port) = env::args().nth(1).and_then(|value| value.parse::<u16>().ok()) else {
16 eprintln!("usage: cargo run -p rns-embedded-runtime --example tcp_receive_once -- <port>");
17 process::exit(2);
18 };
19
20 println!("LISTENING port={port} destination={}", encode_hex(&SERVER_LXMF_ADDRESS));
21
22 let node = EmbeddedNode::new();
23 let subscription = node.subscribe_events().expect("subscribe");
24 node.start(NodeConfig {
25 runtime: RuntimeConfig {
26 store_identity: SERVER_STORE_IDENTITY,
27 lxmf_address: SERVER_LXMF_ADDRESS,
28 node_mode: NodeTransportMode::TcpServer,
29 announce_interval_ms: 1_000,
30 max_outbound_queue: 8,
31 max_events: 32,
32 capture_defaults: Default::default(),
33 },
34 backend: NodeBackendConfig::TcpServer(TcpServerConfig { listen_port: port }),
35 })
36 .expect("start tcp server");
37 node.set_network_provisioned(true).expect("set network provisioned");
38
39 let deadline = Instant::now() + Duration::from_secs(10);
40 loop {
41 match subscription.next(500).expect("poll") {
42 PollResult::Event(event) => match event.kind {
43 NodeEventKind::Extension {
44 extension_id: NODE_EXTENSION_ID_RECEIVED_SUMMARY,
45 value0,
46 value1,
47 } => {
48 println!("RECEIVED sequence={value0} bytes={value1}");
49 break;
50 }
51 NodeEventKind::Error { error, .. } => {
52 eprintln!("ERROR {error:?}");
53 process::exit(1);
54 }
55 _ => {}
56 },
57 PollResult::NodeRestarted { .. } | PollResult::NodeStopped => continue,
58 PollResult::Timeout if Instant::now() < deadline => continue,
59 PollResult::Timeout => {
60 eprintln!("timeout waiting for inbound message");
61 process::exit(1);
62 }
63 other => {
64 eprintln!("unexpected poll result: {other:?}");
65 }
66 }
67 }
68
69 node.stop().expect("stop");
70}Sourcepub fn start(&self, config: NodeConfig) -> Result<(), NodeError>
pub fn start(&self, config: NodeConfig) -> Result<(), NodeError>
Examples found in repository?
examples/std_managed_node.rs (line 26)
9fn main() {
10 let node = EmbeddedNode::new();
11 let subscription = node.subscribe_events().expect("subscribe");
12
13 let config = NodeConfig {
14 runtime: RuntimeConfig {
15 store_identity: [0x11; 32],
16 lxmf_address: [0x22; 16],
17 node_mode: NodeTransportMode::BleOnly,
18 announce_interval_ms: 1_000,
19 max_outbound_queue: 8,
20 max_events: 16,
21 capture_defaults: Default::default(),
22 },
23 backend: NodeBackendConfig::Ble(BleNodeBackendConfig::default()),
24 };
25
26 node.start(config).expect("start");
27 node.set_link_state(LinkState::Up).expect("link up");
28 node.send([0x42; 16], b"hello from managed std", SendOptions).expect("send");
29
30 thread::sleep(Duration::from_millis(75));
31
32 loop {
33 match subscription.next(0).expect("poll") {
34 PollResult::Event(event) => {
35 if let NodeEventKind::PacketSent { sequence, .. } = event.kind {
36 println!("packet sent with sequence {sequence}");
37 break;
38 }
39 }
40 PollResult::Timeout => break,
41 other => println!("poll result: {other:?}"),
42 }
43 }
44
45 node.stop().expect("stop");
46}More examples
examples/tcp_receive_once.rs (lines 24-35)
14fn main() {
15 let Some(port) = env::args().nth(1).and_then(|value| value.parse::<u16>().ok()) else {
16 eprintln!("usage: cargo run -p rns-embedded-runtime --example tcp_receive_once -- <port>");
17 process::exit(2);
18 };
19
20 println!("LISTENING port={port} destination={}", encode_hex(&SERVER_LXMF_ADDRESS));
21
22 let node = EmbeddedNode::new();
23 let subscription = node.subscribe_events().expect("subscribe");
24 node.start(NodeConfig {
25 runtime: RuntimeConfig {
26 store_identity: SERVER_STORE_IDENTITY,
27 lxmf_address: SERVER_LXMF_ADDRESS,
28 node_mode: NodeTransportMode::TcpServer,
29 announce_interval_ms: 1_000,
30 max_outbound_queue: 8,
31 max_events: 32,
32 capture_defaults: Default::default(),
33 },
34 backend: NodeBackendConfig::TcpServer(TcpServerConfig { listen_port: port }),
35 })
36 .expect("start tcp server");
37 node.set_network_provisioned(true).expect("set network provisioned");
38
39 let deadline = Instant::now() + Duration::from_secs(10);
40 loop {
41 match subscription.next(500).expect("poll") {
42 PollResult::Event(event) => match event.kind {
43 NodeEventKind::Extension {
44 extension_id: NODE_EXTENSION_ID_RECEIVED_SUMMARY,
45 value0,
46 value1,
47 } => {
48 println!("RECEIVED sequence={value0} bytes={value1}");
49 break;
50 }
51 NodeEventKind::Error { error, .. } => {
52 eprintln!("ERROR {error:?}");
53 process::exit(1);
54 }
55 _ => {}
56 },
57 PollResult::NodeRestarted { .. } | PollResult::NodeStopped => continue,
58 PollResult::Timeout if Instant::now() < deadline => continue,
59 PollResult::Timeout => {
60 eprintln!("timeout waiting for inbound message");
61 process::exit(1);
62 }
63 other => {
64 eprintln!("unexpected poll result: {other:?}");
65 }
66 }
67 }
68
69 node.stop().expect("stop");
70}Sourcepub fn stop(&self) -> Result<(), NodeError>
pub fn stop(&self) -> Result<(), NodeError>
Examples found in repository?
examples/std_managed_node.rs (line 45)
9fn main() {
10 let node = EmbeddedNode::new();
11 let subscription = node.subscribe_events().expect("subscribe");
12
13 let config = NodeConfig {
14 runtime: RuntimeConfig {
15 store_identity: [0x11; 32],
16 lxmf_address: [0x22; 16],
17 node_mode: NodeTransportMode::BleOnly,
18 announce_interval_ms: 1_000,
19 max_outbound_queue: 8,
20 max_events: 16,
21 capture_defaults: Default::default(),
22 },
23 backend: NodeBackendConfig::Ble(BleNodeBackendConfig::default()),
24 };
25
26 node.start(config).expect("start");
27 node.set_link_state(LinkState::Up).expect("link up");
28 node.send([0x42; 16], b"hello from managed std", SendOptions).expect("send");
29
30 thread::sleep(Duration::from_millis(75));
31
32 loop {
33 match subscription.next(0).expect("poll") {
34 PollResult::Event(event) => {
35 if let NodeEventKind::PacketSent { sequence, .. } = event.kind {
36 println!("packet sent with sequence {sequence}");
37 break;
38 }
39 }
40 PollResult::Timeout => break,
41 other => println!("poll result: {other:?}"),
42 }
43 }
44
45 node.stop().expect("stop");
46}More examples
examples/tcp_receive_once.rs (line 69)
14fn main() {
15 let Some(port) = env::args().nth(1).and_then(|value| value.parse::<u16>().ok()) else {
16 eprintln!("usage: cargo run -p rns-embedded-runtime --example tcp_receive_once -- <port>");
17 process::exit(2);
18 };
19
20 println!("LISTENING port={port} destination={}", encode_hex(&SERVER_LXMF_ADDRESS));
21
22 let node = EmbeddedNode::new();
23 let subscription = node.subscribe_events().expect("subscribe");
24 node.start(NodeConfig {
25 runtime: RuntimeConfig {
26 store_identity: SERVER_STORE_IDENTITY,
27 lxmf_address: SERVER_LXMF_ADDRESS,
28 node_mode: NodeTransportMode::TcpServer,
29 announce_interval_ms: 1_000,
30 max_outbound_queue: 8,
31 max_events: 32,
32 capture_defaults: Default::default(),
33 },
34 backend: NodeBackendConfig::TcpServer(TcpServerConfig { listen_port: port }),
35 })
36 .expect("start tcp server");
37 node.set_network_provisioned(true).expect("set network provisioned");
38
39 let deadline = Instant::now() + Duration::from_secs(10);
40 loop {
41 match subscription.next(500).expect("poll") {
42 PollResult::Event(event) => match event.kind {
43 NodeEventKind::Extension {
44 extension_id: NODE_EXTENSION_ID_RECEIVED_SUMMARY,
45 value0,
46 value1,
47 } => {
48 println!("RECEIVED sequence={value0} bytes={value1}");
49 break;
50 }
51 NodeEventKind::Error { error, .. } => {
52 eprintln!("ERROR {error:?}");
53 process::exit(1);
54 }
55 _ => {}
56 },
57 PollResult::NodeRestarted { .. } | PollResult::NodeStopped => continue,
58 PollResult::Timeout if Instant::now() < deadline => continue,
59 PollResult::Timeout => {
60 eprintln!("timeout waiting for inbound message");
61 process::exit(1);
62 }
63 other => {
64 eprintln!("unexpected poll result: {other:?}");
65 }
66 }
67 }
68
69 node.stop().expect("stop");
70}pub fn restart(&self, config: NodeConfig) -> Result<(), NodeError>
pub fn get_status(&self) -> NodeStatus
Sourcepub fn send(
&self,
destination: [u8; 16],
data: &[u8],
_options: SendOptions,
) -> Result<NodeOperationReceipt, NodeError>
pub fn send( &self, destination: [u8; 16], data: &[u8], _options: SendOptions, ) -> Result<NodeOperationReceipt, NodeError>
Examples found in repository?
examples/std_managed_node.rs (line 28)
9fn main() {
10 let node = EmbeddedNode::new();
11 let subscription = node.subscribe_events().expect("subscribe");
12
13 let config = NodeConfig {
14 runtime: RuntimeConfig {
15 store_identity: [0x11; 32],
16 lxmf_address: [0x22; 16],
17 node_mode: NodeTransportMode::BleOnly,
18 announce_interval_ms: 1_000,
19 max_outbound_queue: 8,
20 max_events: 16,
21 capture_defaults: Default::default(),
22 },
23 backend: NodeBackendConfig::Ble(BleNodeBackendConfig::default()),
24 };
25
26 node.start(config).expect("start");
27 node.set_link_state(LinkState::Up).expect("link up");
28 node.send([0x42; 16], b"hello from managed std", SendOptions).expect("send");
29
30 thread::sleep(Duration::from_millis(75));
31
32 loop {
33 match subscription.next(0).expect("poll") {
34 PollResult::Event(event) => {
35 if let NodeEventKind::PacketSent { sequence, .. } = event.kind {
36 println!("packet sent with sequence {sequence}");
37 break;
38 }
39 }
40 PollResult::Timeout => break,
41 other => println!("poll result: {other:?}"),
42 }
43 }
44
45 node.stop().expect("stop");
46}pub fn broadcast( &self, data: &[u8], options: BroadcastOptions, ) -> Result<NodeOperationReceipt, NodeError>
pub fn set_log_level(&self, level: NodeLogLevel) -> Result<(), NodeError>
Sourcepub fn subscribe_events(&self) -> Result<EventSubscription, NodeError>
pub fn subscribe_events(&self) -> Result<EventSubscription, NodeError>
Examples found in repository?
examples/std_managed_node.rs (line 11)
9fn main() {
10 let node = EmbeddedNode::new();
11 let subscription = node.subscribe_events().expect("subscribe");
12
13 let config = NodeConfig {
14 runtime: RuntimeConfig {
15 store_identity: [0x11; 32],
16 lxmf_address: [0x22; 16],
17 node_mode: NodeTransportMode::BleOnly,
18 announce_interval_ms: 1_000,
19 max_outbound_queue: 8,
20 max_events: 16,
21 capture_defaults: Default::default(),
22 },
23 backend: NodeBackendConfig::Ble(BleNodeBackendConfig::default()),
24 };
25
26 node.start(config).expect("start");
27 node.set_link_state(LinkState::Up).expect("link up");
28 node.send([0x42; 16], b"hello from managed std", SendOptions).expect("send");
29
30 thread::sleep(Duration::from_millis(75));
31
32 loop {
33 match subscription.next(0).expect("poll") {
34 PollResult::Event(event) => {
35 if let NodeEventKind::PacketSent { sequence, .. } = event.kind {
36 println!("packet sent with sequence {sequence}");
37 break;
38 }
39 }
40 PollResult::Timeout => break,
41 other => println!("poll result: {other:?}"),
42 }
43 }
44
45 node.stop().expect("stop");
46}More examples
examples/tcp_receive_once.rs (line 23)
14fn main() {
15 let Some(port) = env::args().nth(1).and_then(|value| value.parse::<u16>().ok()) else {
16 eprintln!("usage: cargo run -p rns-embedded-runtime --example tcp_receive_once -- <port>");
17 process::exit(2);
18 };
19
20 println!("LISTENING port={port} destination={}", encode_hex(&SERVER_LXMF_ADDRESS));
21
22 let node = EmbeddedNode::new();
23 let subscription = node.subscribe_events().expect("subscribe");
24 node.start(NodeConfig {
25 runtime: RuntimeConfig {
26 store_identity: SERVER_STORE_IDENTITY,
27 lxmf_address: SERVER_LXMF_ADDRESS,
28 node_mode: NodeTransportMode::TcpServer,
29 announce_interval_ms: 1_000,
30 max_outbound_queue: 8,
31 max_events: 32,
32 capture_defaults: Default::default(),
33 },
34 backend: NodeBackendConfig::TcpServer(TcpServerConfig { listen_port: port }),
35 })
36 .expect("start tcp server");
37 node.set_network_provisioned(true).expect("set network provisioned");
38
39 let deadline = Instant::now() + Duration::from_secs(10);
40 loop {
41 match subscription.next(500).expect("poll") {
42 PollResult::Event(event) => match event.kind {
43 NodeEventKind::Extension {
44 extension_id: NODE_EXTENSION_ID_RECEIVED_SUMMARY,
45 value0,
46 value1,
47 } => {
48 println!("RECEIVED sequence={value0} bytes={value1}");
49 break;
50 }
51 NodeEventKind::Error { error, .. } => {
52 eprintln!("ERROR {error:?}");
53 process::exit(1);
54 }
55 _ => {}
56 },
57 PollResult::NodeRestarted { .. } | PollResult::NodeStopped => continue,
58 PollResult::Timeout if Instant::now() < deadline => continue,
59 PollResult::Timeout => {
60 eprintln!("timeout waiting for inbound message");
61 process::exit(1);
62 }
63 other => {
64 eprintln!("unexpected poll result: {other:?}");
65 }
66 }
67 }
68
69 node.stop().expect("stop");
70}pub fn tick(&self, now_ms: u64) -> Result<(), NodeError>
Sourcepub fn set_link_state(&self, state_value: LinkState) -> Result<(), NodeError>
pub fn set_link_state(&self, state_value: LinkState) -> Result<(), NodeError>
Examples found in repository?
examples/std_managed_node.rs (line 27)
9fn main() {
10 let node = EmbeddedNode::new();
11 let subscription = node.subscribe_events().expect("subscribe");
12
13 let config = NodeConfig {
14 runtime: RuntimeConfig {
15 store_identity: [0x11; 32],
16 lxmf_address: [0x22; 16],
17 node_mode: NodeTransportMode::BleOnly,
18 announce_interval_ms: 1_000,
19 max_outbound_queue: 8,
20 max_events: 16,
21 capture_defaults: Default::default(),
22 },
23 backend: NodeBackendConfig::Ble(BleNodeBackendConfig::default()),
24 };
25
26 node.start(config).expect("start");
27 node.set_link_state(LinkState::Up).expect("link up");
28 node.send([0x42; 16], b"hello from managed std", SendOptions).expect("send");
29
30 thread::sleep(Duration::from_millis(75));
31
32 loop {
33 match subscription.next(0).expect("poll") {
34 PollResult::Event(event) => {
35 if let NodeEventKind::PacketSent { sequence, .. } = event.kind {
36 println!("packet sent with sequence {sequence}");
37 break;
38 }
39 }
40 PollResult::Timeout => break,
41 other => println!("poll result: {other:?}"),
42 }
43 }
44
45 node.stop().expect("stop");
46}Sourcepub fn set_network_provisioned(
&self,
provisioned: bool,
) -> Result<(), NodeError>
pub fn set_network_provisioned( &self, provisioned: bool, ) -> Result<(), NodeError>
Examples found in repository?
examples/tcp_receive_once.rs (line 37)
14fn main() {
15 let Some(port) = env::args().nth(1).and_then(|value| value.parse::<u16>().ok()) else {
16 eprintln!("usage: cargo run -p rns-embedded-runtime --example tcp_receive_once -- <port>");
17 process::exit(2);
18 };
19
20 println!("LISTENING port={port} destination={}", encode_hex(&SERVER_LXMF_ADDRESS));
21
22 let node = EmbeddedNode::new();
23 let subscription = node.subscribe_events().expect("subscribe");
24 node.start(NodeConfig {
25 runtime: RuntimeConfig {
26 store_identity: SERVER_STORE_IDENTITY,
27 lxmf_address: SERVER_LXMF_ADDRESS,
28 node_mode: NodeTransportMode::TcpServer,
29 announce_interval_ms: 1_000,
30 max_outbound_queue: 8,
31 max_events: 32,
32 capture_defaults: Default::default(),
33 },
34 backend: NodeBackendConfig::TcpServer(TcpServerConfig { listen_port: port }),
35 })
36 .expect("start tcp server");
37 node.set_network_provisioned(true).expect("set network provisioned");
38
39 let deadline = Instant::now() + Duration::from_secs(10);
40 loop {
41 match subscription.next(500).expect("poll") {
42 PollResult::Event(event) => match event.kind {
43 NodeEventKind::Extension {
44 extension_id: NODE_EXTENSION_ID_RECEIVED_SUMMARY,
45 value0,
46 value1,
47 } => {
48 println!("RECEIVED sequence={value0} bytes={value1}");
49 break;
50 }
51 NodeEventKind::Error { error, .. } => {
52 eprintln!("ERROR {error:?}");
53 process::exit(1);
54 }
55 _ => {}
56 },
57 PollResult::NodeRestarted { .. } | PollResult::NodeStopped => continue,
58 PollResult::Timeout if Instant::now() < deadline => continue,
59 PollResult::Timeout => {
60 eprintln!("timeout waiting for inbound message");
61 process::exit(1);
62 }
63 other => {
64 eprintln!("unexpected poll result: {other:?}");
65 }
66 }
67 }
68
69 node.stop().expect("stop");
70}pub fn set_ble_recovery_active(&self, active: bool) -> Result<(), NodeError>
pub fn push_inbound_wire(&self, bytes: &[u8]) -> Result<(), NodeError>
pub fn take_outbound_wire(&self) -> Result<Option<Vec<u8>>, NodeError>
pub fn link_state(&self) -> Result<LinkState, NodeError>
pub fn capability_supports_blocking_next(&self) -> bool
pub fn capability_supports_managed_runtime(&self) -> bool
pub fn capability_supports_event_gap_signaling(&self) -> bool
Trait Implementations§
Source§impl Clone for EmbeddedNode
impl Clone for EmbeddedNode
Auto Trait Implementations§
impl Freeze for EmbeddedNode
impl RefUnwindSafe for EmbeddedNode
impl Send for EmbeddedNode
impl Sync for EmbeddedNode
impl Unpin for EmbeddedNode
impl UnsafeUnpin for EmbeddedNode
impl UnwindSafe for EmbeddedNode
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more