diff --git a/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj b/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj
index b4446480..a2653e83 100644
--- a/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj
+++ b/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj
@@ -116,9 +116,13 @@
+
+
+ NFC.xaml
+
AppSettingPage.xaml
@@ -279,6 +283,10 @@
Designer
MSBuild:Compile
+
+ Designer
+ MSBuild:Compile
+
Designer
MSBuild:Compile
@@ -428,7 +436,9 @@
-
+
+ Designer
+
diff --git a/CampusAppWP8/CampusAppWP8/Model/Utility/NDEF/NDEFRecord.cs b/CampusAppWP8/CampusAppWP8/Model/Utility/NDEF/NDEFRecord.cs
new file mode 100644
index 00000000..a9bfbbff
--- /dev/null
+++ b/CampusAppWP8/CampusAppWP8/Model/Utility/NDEF/NDEFRecord.cs
@@ -0,0 +1,92 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace CampusAppWP8.Model.Utility.NDEF
+{
+ public class NDEFRecord
+ {
+ private const byte typeSize = 0x01;
+ public enum NDEFFlags
+ {
+ UNSET = 0x00,
+ MBSET = 0x80,
+ MESET = 0x40,
+ CFSET = 0x20,
+ SRSET = 0x10,
+ ILSET = 0x08
+ }
+
+ public enum TNFVAL
+ {
+ EMPTY = 0x00,
+ WKT = 0x01,
+ MEDIATYPE = 0x02,
+ URI = 0x03,
+ NFCE = 0x04,
+ UNKOWN = 0x05,
+ UNCHANGED = 0x06,
+ RESERVED = 0x07
+ }
+
+ public enum TYPEVAL
+ {
+ EMPTY = 0x00,
+ URL = 0x55,
+ TEXT = 0x54,
+ }
+
+ public NDEFRecord()
+ {
+
+ }
+ public NDEFRecord(byte[] array)
+ {
+ this.Payload = Encoding.UTF8.GetString(array, 4, array.Length - 4);
+ }
+ public NDEFFlags MB { get; set; }
+ public NDEFFlags ME { get; set; }
+ public NDEFFlags CF { get; set; }
+ public NDEFFlags SR { get; set; }
+ public NDEFFlags IL { get; set; }
+ public TNFVAL TNF { get; set; }
+ public TYPEVAL Type { get; set; }
+ public byte FormatFlags
+ {
+ get
+ {
+ return (byte)((byte)this.TNF | ((byte)this.MB) | ((byte)this.ME) | ((byte)this.CF) | ((byte)this.SR) | ((byte)this.IL));
+ }
+ }
+
+
+ public byte Record = 0xD1;
+
+ public string Payload = "nokia.com";
+
+ public byte[] toByteArray()
+ {
+ MemoryStream m = new MemoryStream();
+ byte[] payloadAr = Encoding.UTF8.GetBytes(Payload);
+ byte[] array = new byte[payloadAr.Length + 4];
+
+ array[0] = this.FormatFlags;
+ array[1] = NDEFRecord.typeSize;
+ array[2] = (byte)(Payload.Length);
+ array[3] = (byte)this.Type;
+
+ int i = 4;
+ foreach (byte b in payloadAr)
+ {
+ array[i] = b;
+ i++;
+ }
+ return array;
+ }
+
+
+ }
+}
diff --git a/CampusAppWP8/CampusAppWP8/Pages/Dev/NFC.xaml b/CampusAppWP8/CampusAppWP8/Pages/Dev/NFC.xaml
new file mode 100644
index 00000000..cac77add
--- /dev/null
+++ b/CampusAppWP8/CampusAppWP8/Pages/Dev/NFC.xaml
@@ -0,0 +1,35 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/CampusAppWP8/CampusAppWP8/Pages/Dev/NFC.xaml.cs b/CampusAppWP8/CampusAppWP8/Pages/Dev/NFC.xaml.cs
new file mode 100644
index 00000000..6549e8a8
--- /dev/null
+++ b/CampusAppWP8/CampusAppWP8/Pages/Dev/NFC.xaml.cs
@@ -0,0 +1,90 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Net;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Navigation;
+using Microsoft.Phone.Controls;
+using Microsoft.Phone.Shell;
+using Windows.Networking.Proximity;
+using System.Runtime.InteropServices.WindowsRuntime;
+using CampusAppWP8.Model.Utility.NDEF;
+
+
+namespace CampusAppWP8.Pages.Dev
+{
+ public partial class NFC : PhoneApplicationPage
+ {
+
+ private readonly ProximityDevice device = ProximityDevice.GetDefault();
+ private long lastMsgId;
+ public NFC()
+ {
+ InitializeComponent();
+ }
+
+ ///
+ /// Override the OnNavigatedTo method
+ ///
+ /// Arguments of navigation
+ protected override void OnNavigatedTo(NavigationEventArgs e)
+ {
+ base.OnNavigatedTo(e);
+
+ if (this.device != null)
+ {
+ MessageBox.Show("NFC present");
+ }
+ else
+ {
+ MessageBox.Show("Your phone has no NFC or NFC is disabled");
+ }
+ this.lastMsgId = this.device.SubscribeForMessage("WriteableTag", WriteableTagDetected);
+ }
+
+ protected override void OnNavigatedFrom(NavigationEventArgs e)
+ {
+ base.OnNavigatedTo(e);
+
+ this.device.StopSubscribingForMessage(this.lastMsgId);
+ }
+
+
+ private void WriteableTagDetected(ProximityDevice sender, ProximityMessage message)
+ {
+ Deployment.Current.Dispatcher.BeginInvoke(() =>
+ {
+ MessageBox.Show("message");
+ });
+
+ this.device.StopSubscribingForMessage(message.SubscriptionId);
+
+ NDEFRecord ndef = new NDEFRecord();
+ ndef.TNF = NDEFRecord.TNFVAL.URI;
+ ndef.MB = NDEFRecord.NDEFFlags.MBSET;
+ ndef.ME = NDEFRecord.NDEFFlags.MESET;
+ ndef.SR = NDEFRecord.NDEFFlags.SRSET;
+ ndef.Type = NDEFRecord.TYPEVAL.TEXT;
+ ndef.toByteArray();
+ ndef.Payload = "test";
+ device.PublishBinaryMessage("NDEF:WriteTag", ndef.toByteArray().AsBuffer(), publishHandler);
+ }
+
+ private void publishHandler(ProximityDevice sender, long messageId)
+ {
+ device.StopPublishingMessage(messageId);
+
+ device.SubscribeForMessage("NDEF", NDEFHandler);
+ }
+
+
+ private void NDEFHandler(ProximityDevice sender, ProximityMessage message)
+ {
+
+ var NDefMessage = message.Data;
+ byte[] testa = NDefMessage.ToArray();
+ NDEFRecord test = new NDEFRecord(testa);
+ }
+ }
+}
\ No newline at end of file
diff --git a/CampusAppWP8/CampusAppWP8/Pages/StartPage.xaml b/CampusAppWP8/CampusAppWP8/Pages/StartPage.xaml
index ca2c2d80..ab7c5c3c 100644
--- a/CampusAppWP8/CampusAppWP8/Pages/StartPage.xaml
+++ b/CampusAppWP8/CampusAppWP8/Pages/StartPage.xaml
@@ -142,6 +142,7 @@
+
diff --git a/CampusAppWP8/CampusAppWP8/Pages/StartPage.xaml.cs b/CampusAppWP8/CampusAppWP8/Pages/StartPage.xaml.cs
index 6c3d516d..5562226d 100644
--- a/CampusAppWP8/CampusAppWP8/Pages/StartPage.xaml.cs
+++ b/CampusAppWP8/CampusAppWP8/Pages/StartPage.xaml.cs
@@ -31,6 +31,7 @@ namespace CampusAppWP8.Pages
this.InitializeComponent();
ApplicationBarMenuItem menuItem1 = ApplicationBar.MenuItems[0] as ApplicationBarMenuItem;
ApplicationBarMenuItem menuItem2 = ApplicationBar.MenuItems[1] as ApplicationBarMenuItem;
+ ApplicationBarMenuItem menuItem3 = ApplicationBar.MenuItems[2] as ApplicationBarMenuItem;
if (menuItem1 != null)
{
menuItem1.Text = AppResources.Setting_UserProfilAppBarTitle;
@@ -41,6 +42,11 @@ namespace CampusAppWP8.Pages
menuItem2.Text = AppResources.Setting_ApplAppBarTitle;
}
+ if (menuItem3 != null)
+ {
+ menuItem3.Text = "Nfc";
+ }
+
if (!Settings.AppSetting.InitApp)
{
this.ShowOptIns();
@@ -126,6 +132,17 @@ namespace CampusAppWP8.Pages
NavigationService.Navigate(url);
}
+ ///
+ /// Method Navigate to
+ ///
+ /// Caller of the function
+ /// some EventArgs
+ private void ApplicationBarMenuItem3_Click(object sender, EventArgs e)
+ {
+ Uri url = new Uri("/Pages/Dev/NFC.xaml", UriKind.Relative);
+ NavigationService.Navigate(url);
+ }
+
///
/// Method change the Opacity of the ApplicationBar
///