1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#![no_std]
use log::warn;
use spin::Once;
use unmp::protocol::Protocol;
pub use unmp::protocol::{Respose, WaitDataFuture};
use unmp::Connection;
pub const PROTOCOL_ID: u8 = 0;
static RAW: Once<Protocol> = Once::new();
pub fn init() {
if let Ok(protocol) = Protocol::new(PROTOCOL_ID) {
RAW.call_once(|| protocol);
} else {
warn!("can't crate raw.")
}
}
pub async fn send(buf: &[u8], conn: &Connection) -> Result<(), ()> {
let raw = RAW.get().unwrap();
return raw.send(&buf, conn).await;
}
pub fn recv() -> WaitDataFuture {
let raw = RAW.get().unwrap();
return raw.recv();
}