Created
November 14, 2019 16:28
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// main() will be called at Mynewt startup. It replaces the C version of the main() function. | |
#[no_mangle] // Don't mangle the name "main" | |
extern "C" fn main() -> ! { // Declare extern "C" because it will be called by Mynewt | |
// Initialise the Mynewt OS. | |
mynewt::sysinit(); | |
// TODO: Start the Server Transport for sending sensor data to the cloud. | |
// sensor_network::start_server_transport() | |
// .expect("NET fail"); | |
// Start a sensor listener that polls a simulated tmperature sensor. | |
// Will be changed to handle touch events instead. | |
app_sensor::start_sensor_listener() | |
.expect("TMP fail"); | |
// Start Bluetooth Beacon. TODO: Create a safe wrapper for starting Bluetooth LE. | |
extern { fn start_ble() -> i32; } | |
let rc = unsafe { start_ble() }; | |
assert!(rc == 0, "BLE fail"); | |
// Show the display. | |
display::show() | |
.expect("DSP fail"); | |
// Test the touch sensor. | |
touch_sensor::test() | |
.expect("TCH fail"); | |
// Mynewt event loop | |
loop { // Loop forever... | |
os::eventq_run( // Processing events... | |
os::eventq_dflt_get() // From default event queue. | |
.expect("GET fail") | |
).expect("RUN fail"); | |
} | |
// Never comes here | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment