Skip to content

Instantly share code, notes, and snippets.

@dcoles
Created September 7, 2019 07:07
Show Gist options
  • Save dcoles/47f32f0baa150782312bc06fdece018f to your computer and use it in GitHub Desktop.
Save dcoles/47f32f0baa150782312bc06fdece018f to your computer and use it in GitHub Desktop.
Example of NFC using Windows Proximity APIs in Rust
// 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