diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 00000000..3836f7bd --- /dev/null +++ b/.gitmodules @@ -0,0 +1,4 @@ +[submodule "CampusAppWP8/NfcLib"] + path = CampusAppWP8/NfcLib + url = git@141.43.76.143:repos/bare/nfclib.git + branch = develop diff --git a/CampusAppWP8/CampusAppW8.sln b/CampusAppWP8/CampusAppW8.sln index d29ea4e1..a9e66846 100644 --- a/CampusAppWP8/CampusAppW8.sln +++ b/CampusAppWP8/CampusAppW8.sln @@ -13,6 +13,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CampusAppDLL", "CampusAppDL EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CampusAppWP8ScheduledTaskAgent", "CampusAppWP8ScheduledTaskAgent\CampusAppWP8ScheduledTaskAgent.csproj", "{2A51FA6C-791B-4935-B869-FDBA9ED774D7}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ndefpclib", "NfcLib\src\ndefpclib\ndefpclib.csproj", "{01C6941E-AAF1-4324-BA54-B4A53BC66ADF}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -163,6 +165,22 @@ Global {2A51FA6C-791B-4935-B869-FDBA9ED774D7}.Release|x64.ActiveCfg = Release|Any CPU {2A51FA6C-791B-4935-B869-FDBA9ED774D7}.Release|x86.ActiveCfg = Release|x86 {2A51FA6C-791B-4935-B869-FDBA9ED774D7}.Release|x86.Build.0 = Release|x86 + {01C6941E-AAF1-4324-BA54-B4A53BC66ADF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {01C6941E-AAF1-4324-BA54-B4A53BC66ADF}.Debug|Any CPU.Build.0 = Debug|Any CPU + {01C6941E-AAF1-4324-BA54-B4A53BC66ADF}.Debug|ARM.ActiveCfg = Debug|Any CPU + {01C6941E-AAF1-4324-BA54-B4A53BC66ADF}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {01C6941E-AAF1-4324-BA54-B4A53BC66ADF}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {01C6941E-AAF1-4324-BA54-B4A53BC66ADF}.Debug|Win32.ActiveCfg = Debug|Any CPU + {01C6941E-AAF1-4324-BA54-B4A53BC66ADF}.Debug|x64.ActiveCfg = Debug|Any CPU + {01C6941E-AAF1-4324-BA54-B4A53BC66ADF}.Debug|x86.ActiveCfg = Debug|Any CPU + {01C6941E-AAF1-4324-BA54-B4A53BC66ADF}.Release|Any CPU.ActiveCfg = Release|Any CPU + {01C6941E-AAF1-4324-BA54-B4A53BC66ADF}.Release|Any CPU.Build.0 = Release|Any CPU + {01C6941E-AAF1-4324-BA54-B4A53BC66ADF}.Release|ARM.ActiveCfg = Release|Any CPU + {01C6941E-AAF1-4324-BA54-B4A53BC66ADF}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {01C6941E-AAF1-4324-BA54-B4A53BC66ADF}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {01C6941E-AAF1-4324-BA54-B4A53BC66ADF}.Release|Win32.ActiveCfg = Release|Any CPU + {01C6941E-AAF1-4324-BA54-B4A53BC66ADF}.Release|x64.ActiveCfg = Release|Any CPU + {01C6941E-AAF1-4324-BA54-B4A53BC66ADF}.Release|x86.ActiveCfg = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj b/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj index 33bfb91a..ed5b8434 100644 --- a/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj +++ b/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj @@ -251,9 +251,7 @@ WeekViewDay.xaml - - - + NFC.xaml @@ -693,6 +691,10 @@ {67D80BE2-0FB7-44C8-A495-7D44FC2AC262} CampusAppWPortalLib8 + + {01C6941E-AAF1-4324-BA54-B4A53BC66ADF} + ndefpclib + diff --git a/CampusAppWP8/CampusAppWP8/Pages/Campusmap/CampusMapPage.xaml.cs b/CampusAppWP8/CampusAppWP8/Pages/Campusmap/CampusMapPage.xaml.cs index 30343e78..3c1b10b3 100644 --- a/CampusAppWP8/CampusAppWP8/Pages/Campusmap/CampusMapPage.xaml.cs +++ b/CampusAppWP8/CampusAppWP8/Pages/Campusmap/CampusMapPage.xaml.cs @@ -493,7 +493,7 @@ namespace CampusAppWP8.Pages.Campusmap this.device.StopSubscribingForMessage(message.SubscriptionId); var ndefMessage = message.Data; byte[] data = ndefMessage.ToArray(); - NDEFMessage ndef = new NDEFMessage(data); + BTUTagMessage ndef = new BTUTagMessage(data); // search for placeId string nfcContent = ndef.GetContent(); diff --git a/CampusAppWP8/CampusAppWP8/Pages/Dev/NFC.xaml.cs b/CampusAppWP8/CampusAppWP8/Pages/Dev/NFC.xaml.cs index 4c187c35..58f81c57 100644 --- a/CampusAppWP8/CampusAppWP8/Pages/Dev/NFC.xaml.cs +++ b/CampusAppWP8/CampusAppWP8/Pages/Dev/NFC.xaml.cs @@ -34,7 +34,7 @@ namespace CampusAppWP8.Pages.Dev private int actNDEFIndex; /// List of ndefs. - private List ndefList; + private List ndefList; /// The file. private PlacesFile file; @@ -82,12 +82,12 @@ namespace CampusAppWP8.Pages.Dev /// Stubbfel, 15.10.2013. private void FileIsReady() { - this.ndefList = new List(); + this.ndefList = new List(); // MapModel map = new CBMainMapModel(this.file.Model.Places.ToList()); foreach (PlaceModel place in this.file.Model.Places.ToList()) { - this.ndefList.Add(new NDEFMessage(place.ToNfcString(), NDEFMessage.TYPEVAL.TEXT)); + this.ndefList.Add(new BTUTagMessage(place.ToNfcString())); } this.Writecontent.Text = this.ndefList[this.actNDEFIndex].GetContent(); @@ -113,7 +113,7 @@ namespace CampusAppWP8.Pages.Dev var ndefMessage = message.Data; byte[] testa = ndefMessage.ToArray(); - NDEFMessage ndef = new NDEFMessage(testa); + BTUTagMessage ndef = new BTUTagMessage(testa); this.Dispatcher.BeginInvoke(new Action(() => MessageBox.Show(ndef.GetContent()))); } diff --git a/CampusAppWP8/CampusAppWP8/Pages/PlaceNews/PlaceNews.xaml.cs b/CampusAppWP8/CampusAppWP8/Pages/PlaceNews/PlaceNews.xaml.cs index 416a96c7..96abd842 100644 --- a/CampusAppWP8/CampusAppWP8/Pages/PlaceNews/PlaceNews.xaml.cs +++ b/CampusAppWP8/CampusAppWP8/Pages/PlaceNews/PlaceNews.xaml.cs @@ -426,7 +426,7 @@ namespace CampusAppWP8.Pages.PlaceNews var ndefMessage = message.Data; byte[] data = ndefMessage.ToArray(); - NDEFMessage ndef = new NDEFMessage(data); + BTUTagMessage ndef = new BTUTagMessage(data); string nfcContent = ndef.GetContent(); string pid = Wp8StringManager.FilterPlaceIdinNFCResultString(nfcContent.Trim()); if (pid != null) diff --git a/CampusAppWP8/CampusAppWP8/Pages/StartPage.xaml.cs b/CampusAppWP8/CampusAppWP8/Pages/StartPage.xaml.cs index a3a32770..9f84551d 100644 --- a/CampusAppWP8/CampusAppWP8/Pages/StartPage.xaml.cs +++ b/CampusAppWP8/CampusAppWP8/Pages/StartPage.xaml.cs @@ -382,7 +382,7 @@ namespace CampusAppWP8.Pages this.device.StopSubscribingForMessage(message.SubscriptionId); var ndefMessage = message.Data; byte[] data = ndefMessage.ToArray(); - NDEFMessage ndef = new NDEFMessage(data); + BTUTagMessage ndef = new BTUTagMessage(data); string nfcContent = ndef.GetContent(); if (nfcContent == null) { diff --git a/CampusAppWP8/CampusAppWP8/Utility/NDEF/BTUTagMessage.cs b/CampusAppWP8/CampusAppWP8/Utility/NDEF/BTUTagMessage.cs new file mode 100644 index 00000000..a690dc63 --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Utility/NDEF/BTUTagMessage.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace CampusAppWP8.Utility.NDEF +{ + public class BTUTagMessage : ndefpclib.message.Text.TextMessageUTF8 + { + public BTUTagMessage(string content): base(content,ndefpclib.type.Const.Language.DE) + { + + } + + public BTUTagMessage(byte[] array) : base(array) + { + } + } +} diff --git a/CampusAppWP8/CampusAppWP8/Utility/NDEF/NDEFMessage.cs b/CampusAppWP8/CampusAppWP8/Utility/NDEF/NDEFMessage.cs deleted file mode 100644 index 09e10bb0..00000000 --- a/CampusAppWP8/CampusAppWP8/Utility/NDEF/NDEFMessage.cs +++ /dev/null @@ -1,155 +0,0 @@ -//----------------------------------------------------------------------- -// -// Company copyright tag. -// -// stubbfel -// 21.08.2013 -//---------------------------------------------------------------------- -namespace CampusAppWP8.Utility.NDEF -{ - using System.Collections.Generic; - using System.IO; - - /// Ndef message. - /// Stubbfel, 21.08.2013. - public class NDEFMessage - { - #region Members - - /// The records. - private List records; - - #endregion - - #region constructors - - /// Initializes a new instance of the NDEFMessage class. - /// Stubbfel, 21.08.2013. - /// The content. - /// The type. - /// (Optional) the tnf. - public NDEFMessage(string content, TYPEVAL type, NDEFRecord.TNFVAL tnf = NDEFRecord.TNFVAL.WKT) - { - this.records = new List(); - float recordsCount = (float)content.Length / NDEFRecord.MaxRecordPayLoad; - NDEFRecord tmpRecord = null; - string praefix = NDEFMessage.GetPraefix(type); - - for (int i = 0; recordsCount > 0; i++) - { - tmpRecord = new NDEFShortRecord(); - tmpRecord.Type = type; - tmpRecord.TNF = tnf; - tmpRecord.PayloadPraefix = praefix; - int recordsize = 255; - if (content.Length < (i + 1) * recordsize) - { - recordsize = content.Length - (i * recordsize); - } - - tmpRecord.Payload = content.Substring(i * 255, recordsize); - if (i == 0) - { - tmpRecord.MB = NDEFRecord.NDEFFlags.MBSET; - } - - this.records.Add(tmpRecord); - recordsCount--; - } - - this.records[this.records.IndexOf(tmpRecord)].ME = NDEFRecord.NDEFFlags.MESET; - } - - /// Initializes a new instance of the NDEFMessage class. - /// Stubbfel, 21.08.2013. - /// The array. - public NDEFMessage(byte[] array) - { - this.records = new List(); - - NDEFRecord tmpRecord = null; - for (int i = 0; i < array.Length; i += tmpRecord.RecordSize) - { - tmpRecord = new NDEFShortRecord(array, i); - - this.records.Add(tmpRecord); - } - } - - #endregion - - #region enum - - /// Values that represent TYPEVAL. - /// Stubbfel, 21.08.2013. - public enum TYPEVAL - { - /// An enum constant representing the empty option. - EMPTY = 0x00, - - /// An enum constant representing the URL option. - URL = 0x55, - - /// An enum constant representing the text option. - TEXT = 0x54, - } - - #endregion - - #region Methods - - /// Gets a praefix. - /// Stubbfel, 21.08.2013. - /// The type. - /// The praefix. - public static string GetPraefix(TYPEVAL type) - { - string praefix = string.Empty; - - switch (type) - { - case TYPEVAL.TEXT: - praefix = "\x02" + "de"; - break; - case TYPEVAL.URL: - praefix = "\x01"; - break; - default: - break; - } - - return praefix; - } - - /// Gets the content. - /// Stubbfel, 21.08.2013. - /// The content. - public string GetContent() - { - string result = string.Empty; - - foreach (NDEFRecord record in this.records) - { - result += record.Payload; - } - - return result; - } - - /// Converts this object to a byte array. - /// Stubbfel, 21.08.2013. - /// This object as a byte[]. - public byte[] ToByteArray() - { - MemoryStream ms = new MemoryStream(); - foreach (NDEFRecord record in this.records) - { - ms.Write(record.ToByteArray(), 0, record.RecordSize); - } - - return ms.ToArray(); - } - - #endregion - } -} diff --git a/CampusAppWP8/CampusAppWP8/Utility/NDEF/NDEFRecord.cs b/CampusAppWP8/CampusAppWP8/Utility/NDEF/NDEFRecord.cs deleted file mode 100644 index 4b26a89f..00000000 --- a/CampusAppWP8/CampusAppWP8/Utility/NDEF/NDEFRecord.cs +++ /dev/null @@ -1,191 +0,0 @@ -//----------------------------------------------------------------------- -// -// The MIT License (MIT). Copyright (c) 2013 BTU/IIT. -// -// Stubbfel -// 15.10.2013 -// Implements the ndef record class -//----------------------------------------------------------------------- -namespace CampusAppWP8.Utility.NDEF -{ - using System.IO; - using System.Text; - - /// Ndef record of a NDEFMessage. - /// Stubbfel, 21.08.2013. - public abstract class NDEFRecord - { - #region Members - - /// The maximum record pay load. - public const int MaxRecordPayLoad = 255; - - /// Size of the type. - protected const byte TypeSize = 0x01; - - #endregion - - #region Constructors - - /// Initializes a new instance of the NDEFRecord class. - /// Stubbfel, 21.08.2013. - public NDEFRecord() - { - } - - /// Initializes a new instance of the NDEFRecord class. - /// Stubbfel, 21.08.2013. - /// The array. - /// (Optional) zero-based index of the. - public NDEFRecord(byte[] array, int index = 0) - { - this.FormatFlags = array[index]; - } - - #endregion - - #region enum - - /// Values that represent NDEFFlags. - /// Stubbfel, 21.08.2013. - public enum NDEFFlags - { - /// An Enum constant representing the UNSET option. - UNSET = 0x00, - - /// An Enum constant representing the Message begin option. - MBSET = 0x80, - - /// An Enum constant representing the Message end option. - MESET = 0x40, - - /// An Enum constant representing the CHUNK FLAG option. - CFSET = 0x20, - - /// An Enum constant representing the Short Record set option. - SRSET = 0x10, - - /// An Enum constant representing the ID length option. - ILSET = 0x08, - - /// An enum constant representing the tnfset option. - TNFSET = 0x03 - } - - /// Values that represent TNFVAL. - /// Stubbfel, 21.08.2013. - public enum TNFVAL - { - /// An enum constant representing the empty option. - EMPTY = 0x00, - - /// An enum constant representing the Well-Know-Type option. - WKT = 0x01, - - /// An enum constant representing the MediaType option. - MEDIATYPE = 0x02, - - /// An enum constant representing the URI option. - URI = 0x03, - - /// An enum constant representing the NFCE option. - NFCE = 0x04, - - /// An enum constant representing the unknow option. - unknow = 0x05, - - /// An enum constant representing the unchanged option. - UNCHANGED = 0x06, - - /// An enum constant representing the reserved option. - RESERVED = 0x07 - } - - #endregion - - #region Properties - - /// Gets or sets the MBFlag. - /// The MBFlag. - public NDEFFlags MB { get; set; } - - /// Gets or sets MEFlag. - /// The MEFlag . - public NDEFFlags ME { get; set; } - - /// Gets or sets the CFFlag. - /// The CFFlag. - public NDEFFlags CF { get; set; } - - /// Gets or sets the SRFlag. - /// The SRFlag. - public NDEFFlags SR { get; set; } - - /// Gets or sets the ILFlag. - /// The ILFlag. - public NDEFFlags IL { get; set; } - - /// Gets or sets the TNFField. - /// The TNFField. - public TNFVAL TNF { get; set; } - - /// Gets or sets the type. - /// The type. - public NDEFMessage.TYPEVAL Type { get; set; } - - /// Gets the format flags. - /// The format flags. - public byte FormatFlags - { - get - { - return (byte)((byte)this.TNF | ((byte)this.MB) | ((byte)this.ME) | ((byte)this.CF) | ((byte)this.SR) | ((byte)this.IL)); - } - - protected set - { - this.TNF = (TNFVAL)(value & (byte)NDEFFlags.TNFSET); - this.MB = (NDEFFlags)(value & (byte)NDEFFlags.MBSET); - this.ME = (NDEFFlags)(value & (byte)NDEFFlags.MESET); - this.CF = (NDEFFlags)(value & (byte)NDEFFlags.CFSET); - this.SR = (NDEFFlags)(value & (byte)NDEFFlags.SRSET); - this.IL = (NDEFFlags)(value & (byte)NDEFFlags.ILSET); - } - } - - /// Gets or sets the payload. - /// The payload. - public string Payload { get; set; } - - /// Gets the size of the record. - /// The size of the record. - public int RecordSize - { - get - { - return this.HeaderSize + this.Payload.Length + this.PayloadPraefix.Length; - } - } - - /// Gets or sets the payload praefix. - /// The payload praefix. - public string PayloadPraefix { get; set; } - - /// Gets or sets the size of the header. - /// The size of the header. - protected int HeaderSize { get; set; } - - #endregion - - #region Methods - - /// Converts the record to a byte array. - /// Stubbfel, 21.08.2013. - /// This object as a byte[]. - public abstract byte[] ToByteArray(); - - #endregion - } -} - -// End of Utility\NDEF\NDEFRecord.cs diff --git a/CampusAppWP8/CampusAppWP8/Utility/NDEF/NDEFShortRecord.cs b/CampusAppWP8/CampusAppWP8/Utility/NDEF/NDEFShortRecord.cs deleted file mode 100644 index 29785ef1..00000000 --- a/CampusAppWP8/CampusAppWP8/Utility/NDEF/NDEFShortRecord.cs +++ /dev/null @@ -1,73 +0,0 @@ -//----------------------------------------------------------------------- -// -// The MIT License (MIT). Copyright (c) 2013 BTU/IIT. -// -// Stubbfel -// 15.10.2013 -// Implements the ndef short record class -//----------------------------------------------------------------------- -namespace CampusAppWP8.Utility.NDEF -{ - using System.Text; - - /// Ndef short record. - /// Stubbfel, 21.08.2013. - /// - public class NDEFShortRecord : NDEFRecord - { - #region Constructor - - /// Initializes a new instance of the NDEFShortRecord class. - /// Stubbfel, 21.08.2013. - public NDEFShortRecord() - { - this.HeaderSize = 4; - this.SR = NDEFFlags.SRSET; - this.IL = NDEFFlags.UNSET; - this.CF = NDEFFlags.UNSET; - } - - /// Initializes a new instance of the NDEFShortRecord class. - /// Stubbfel, 21.08.2013. - /// The array. - /// (Optional) zero-based index of the. - public NDEFShortRecord(byte[] array, int index = 0) - : base(array) - { - this.HeaderSize = 4; - this.Type = (NDEFMessage.TYPEVAL)array[index + 3]; - this.PayloadPraefix = NDEFMessage.GetPraefix(this.Type); - int payLoadSize = array[index + 2] - this.PayloadPraefix.Length; - this.Payload = Encoding.UTF8.GetString(array, index + this.HeaderSize + this.PayloadPraefix.Length, payLoadSize); - } - - #endregion - - #region Method - - /// Converts this NDEFShortRecord to a byte array. - /// Stubbfel, 21.08.2013. - /// - public override byte[] ToByteArray() - { - byte[] payloadAr = Encoding.UTF8.GetBytes(this.PayloadPraefix + this.Payload); - byte[] array = new byte[payloadAr.Length + this.HeaderSize]; - - array[0] = this.FormatFlags; - array[1] = NDEFRecord.TypeSize; - array[2] = (byte)(Payload.Length + this.PayloadPraefix.Length); - array[3] = (byte)this.Type; - - int i = this.HeaderSize; - foreach (byte b in payloadAr) - { - array[i] = b; - i++; - } - - return array; - } - - #endregion - } -} diff --git a/CampusAppWP8/CampusAppWPortalLib8/Model/Utility/GeoMapPoint.cs b/CampusAppWP8/CampusAppWPortalLib8/Model/Utility/GeoMapPoint.cs index ab300aed..27ee0a7f 100644 --- a/CampusAppWP8/CampusAppWPortalLib8/Model/Utility/GeoMapPoint.cs +++ b/CampusAppWP8/CampusAppWPortalLib8/Model/Utility/GeoMapPoint.cs @@ -1,18 +1,44 @@ -using System.Globalization; -using System.Runtime.Serialization; - +//----------------------------------------------------------------------- +// +// The MIT License (MIT). Copyright (c) 2013 BTU/IIT. +// +// Stubbfel +// 23.10.2013 +// Implements the geo map point class +//----------------------------------------------------------------------- namespace CampusAppWPortalLib8.Model.Utility { + using System.Globalization; + + /// A geo map point. + /// Stubbfel, 23.10.2013. + /// public class GeoMapPoint : MapPoint { #region Constructor + /// Initializes a new instance of the GeoMapPoint class. + /// Stubbfel, 23.10.2013. + public GeoMapPoint() + { + } + + /// Initializes a new instance of the GeoMapPoint class. + /// Stubbfel, 23.10.2013. + /// The latitude. + /// The longitude. + /// The timestamp. public GeoMapPoint(double latitude, double longitude, long timestamp) : base(longitude, latitude) { this.Timestamp = timestamp; } + /// Initializes a new instance of the GeoMapPoint class. + /// Stubbfel, 23.10.2013. + /// The latitude. + /// The longitude. + /// The timestamp. public GeoMapPoint(string latitude, string longitude, string timestamp) { double lat; @@ -34,7 +60,8 @@ namespace CampusAppWPortalLib8.Model.Utility #region Property - [DataMember] + /// Gets or sets the latitude. + /// The latitude. public double Latitude { get @@ -48,7 +75,8 @@ namespace CampusAppWPortalLib8.Model.Utility } } - [DataMember] + /// Gets or sets the longitude. + /// The longitude. public double Longitude { get @@ -62,7 +90,8 @@ namespace CampusAppWPortalLib8.Model.Utility } } - [DataMember] + /// Gets or sets the timestamp. + /// The timestamp. public long Timestamp { get; set; }