feat: add rust demo
This commit is contained in:
11
examples/tos_meets_rust/app/src/bridge.rs
Normal file
11
examples/tos_meets_rust/app/src/bridge.rs
Normal file
@@ -0,0 +1,11 @@
|
||||
use cty::*;
|
||||
|
||||
/// These glue functions are from tosglue.c
|
||||
extern {
|
||||
pub fn rust_print(msg: *const u8);
|
||||
pub fn rust_oled_print(msg: *const u8);
|
||||
pub fn rust_wifi_init() -> i32;
|
||||
pub fn rust_wifi_connect(ssid: *const u8, passwd: *const u8);
|
||||
pub fn rust_sleep(ms: u32);
|
||||
pub fn rust_mqtt_daemon() -> c_void;
|
||||
}
|
23
examples/tos_meets_rust/app/src/lib.rs
Normal file
23
examples/tos_meets_rust/app/src/lib.rs
Normal file
@@ -0,0 +1,23 @@
|
||||
#![no_std]
|
||||
|
||||
extern crate cortex_m;
|
||||
|
||||
mod bridge;
|
||||
|
||||
use crate::bridge::*;
|
||||
use cty::*;
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn application_entry_rust() -> c_void {
|
||||
unsafe {
|
||||
rust_print(b"[+] Welcome to the RUST-WORLD in TencentOS :)".as_ptr());
|
||||
rust_mqtt_daemon();
|
||||
}
|
||||
|
||||
loop {
|
||||
unsafe {
|
||||
rust_print(b"[+] This is a mqtt demo!".as_ptr());
|
||||
rust_sleep(5000u32);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user