Created
September 7, 2019 07:07
-
-
Save dcoles/47f32f0baa150782312bc06fdece018f to your computer and use it in GitHub Desktop.
Example of NFC using Windows Proximity APIs in Rust
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
// Example of NFC using Windows Proximity APIs | |
// Tested using Sony RC-S380 (make sure you enable NFP in the driver). | |
use winrt::*; // import various helper types | |
use winrt::windows::foundation; | |
use winrt::windows::networking::proximity; | |
use std::{thread, time}; | |
const URL: &str = "https://dcoles.net"; | |
fn main() { | |
let device = proximity::ProximityDevice::get_default().unwrap() | |
.expect("No default proximity device found"); | |
let url = foundation::Uri::create_uri(&FastHString::new(URL)).unwrap(); | |
device.publish_uri_message(&url).unwrap(); | |
loop { | |
thread::sleep(time::Duration::from_secs(3600)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment