示例#1
0
 /// <summary>
 /// Create a new record with the specified type name format and type.
 /// Doesn't set the payload and ID.
 /// </summary>
 /// <param name="tnf">Type name format to use, based on the tnf's standardized
 /// by the Nfc Forum.</param>
 /// <param name="type">Type string.</param>
 public NdefRecord(TypeNameFormatType tnf, byte[] type)
 {
     TypeNameFormat = tnf;
     if (type != null)
     {
         // Can't call Type property set method from constructor, as it's virtual
         _type = new byte[type.Length];
         Array.Copy(type, _type, type.Length);
     }
 }
示例#2
0
 /** @brief Creates and returns the TNF and Flags byte.
  *
  *  @param msgBegin is the flag indicating if the NDEF Record is the first
  *  @param msgEnd is the flag indicating if the NDEF Record is the last
  *  @param chunkFlag is the flag indicating if it is a chunked message part
  *  @param shortRecord is the flag indicating if the message is shorter than 2^8-1
  *  @param idLength indicates the length of the id
  *  @param type indicats the name format type
  *
  * @return the TNF and Flag byte
  */
 public byte getNdefTNFandFlagsByte(bool msgBegin, bool msgEnd, bool chunkFlag, bool
                                    shortRecord, byte idLength, TypeNameFormatType type)
 {
     return(NDEF.getTNFandFlagsByte(msgBegin, msgEnd,
                                    chunkFlag, shortRecord, idLength, type));
 }
示例#3
0
        /** @brief Creates and returns the TNF and Flags byte.
         *
         *  @param msgBegin is the flag indicating if the NDEF Record is the first
         *  @param msgEnd is the flag indicating if the NDEF Record is the last
         *  @param chunkFlag is the flag indicating if it is a chunked message part
         *  @param shortRecord is the flag indicating if the message is shorter than 2^8-1
         *  @param idLength indicates the length of the id
         *  @param type indicats the name format type
         *
         * @return the TNF and Flag byte
         */
        public static byte getTNFandFlagsByte(bool msgBegin, bool msgEnd, bool chunkFlag, bool shortRecord, byte idLength, TypeNameFormatType type)
        {
            byte tnfAndFlags = 0x00;

            tnfAndFlags |= (byte)(Convert.ToByte(msgBegin) << 7);
            tnfAndFlags |= (byte)(Convert.ToByte(msgEnd) << 6);
            tnfAndFlags |= (byte)(Convert.ToByte(chunkFlag) << 5);
            tnfAndFlags |= (byte)(Convert.ToByte(shortRecord) << 4);
            tnfAndFlags |= (byte)(idLength << 3);
            tnfAndFlags |= (byte)type;
            return(tnfAndFlags);
        }
示例#4
0
 /// <summary>
 /// Create a new record with the specified type name format and type.
 /// Doesn't set the payload and ID.
 /// </summary>
 /// <param name="tnf">Type name format to use, based on the tnf's standardized
 /// by the Nfc Forum.</param>
 /// <param name="type">Type string.</param>
 public NdefRecord(TypeNameFormatType tnf, byte[] type)
 {
     TypeNameFormat = tnf;
     if (type != null)
     {
         // Can't call Type property set method from constructor, as it's virtual
         _type = new byte[type.Length];
         Array.Copy(type, _type, type.Length);
     }
 }