Пример #1
0
 public static DateTimeResources Deserialise(TlvReader reader)
 {
     DateTimeResources result = null;
     if (reader.TlvRecord == null)
         reader.Read();
     if (reader.TlvRecord != null)
     {
         if (reader.TlvRecord.TypeIdentifier == TTlvTypeIdentifier.MultipleResources)
         {
             result = new DateTimeResources(reader.TlvRecord.Identifier.ToString());
             if (reader.TlvRecord.Value != null)
             {
                 using (TlvReader childReader = new TlvReader(reader.TlvRecord.Value))
                 {
                     while (childReader.Read())
                     {
                         if (childReader.TlvRecord.TypeIdentifier == TTlvTypeIdentifier.ResourceInstance)
                         {
                             DateTimeResource childResource = new DateTimeResource(childReader.TlvRecord.Identifier.ToString());
                             childResource.Value = childReader.TlvRecord.ValueAsDateTime();
                             result.Add(childResource);
                         }
                     }
                 }
             }
         }
     }
     return result;
 }
Пример #2
0
        private List <Model.Object> ParseObjects(ObjectDefinition objectDefinition, int requestContentType, Response response)
        {
            List <Model.Object> result = new List <Model.Object>();
            int contentType;

            if (response.ContentType == -1)
            {
                contentType = requestContentType;
            }
            else
            {
                contentType = response.ContentType;
            }
            if (contentType == TlvConstant.CONTENT_TYPE_TLV)
            {
                TlvReader reader = new TlvReader(response.Payload);
                while (reader.Read())
                {
                    if (reader.TlvRecord.TypeIdentifier == TTlvTypeIdentifier.ObjectInstance)
                    {
                        TlvReader    objectReader = new TlvReader(reader.TlvRecord.Value);
                        Model.Object item         = ObjectUtils.ParseObject(objectDefinition, objectReader);
                        if (item != null)
                        {
                            item.InstanceID = reader.TlvRecord.Identifier.ToString();
                            result.Add(item);
                        }
                    }
                }
            }
            return(result);
        }
Пример #3
0
 public static bool Deserialise(TlvReader reader, OpaqueResource item)
 {
     bool result = false;
     if (reader.TlvRecord == null)
         reader.Read();
     if (reader.TlvRecord.TypeIdentifier == TTlvTypeIdentifier.ResourceWithValue)
     {
         item.Value = reader.TlvRecord.Value;
         result = true;
     }
     return result;
 }
 public override bool Deserialise(TlvReader reader)
 {
     bool result = false;
     while (reader.Read())
     {
         if ((reader.TlvRecord.TypeIdentifier != TTlvTypeIdentifier.ObjectInstance) && (reader.TlvRecord.TypeIdentifier != TTlvTypeIdentifier.NotSet))
         {
             switch ((ResourceID)reader.TlvRecord.Identifier)
             {
                 case ResourceID.InterfaceName:
                     this.InterfaceName = reader.TlvRecord.ValueAsString();
                     result = true;
                     break;
                 case ResourceID.Enable:
                     this.Enable = reader.TlvRecord.ValueAsBoolean();
                     result = true;
                     break;
                 case ResourceID.RadioEnabled:
                     this.RadioEnabled = reader.TlvRecord.ValueAsInt64();
                     result = true;
                     break;
                 case ResourceID.Status:
                     this.Status = reader.TlvRecord.ValueAsInt64();
                     result = true;
                     break;
                 case ResourceID.BSSID:
                     this.BSSID = reader.TlvRecord.ValueAsString();
                     result = true;
                     break;
                 case ResourceID.SSID:
                     this.SSID = reader.TlvRecord.ValueAsString();
                     result = true;
                     break;
                 case ResourceID.BroadcastSSID:
                     this.BroadcastSSID = reader.TlvRecord.ValueAsBoolean();
                     result = true;
                     break;
                 case ResourceID.BeaconEnabled:
                     this.BeaconEnabled = reader.TlvRecord.ValueAsBoolean();
                     result = true;
                     break;
                 case ResourceID.Mode:
                     this.Mode = reader.TlvRecord.ValueAsInt64();
                     result = true;
                     break;
                 case ResourceID.Channel:
                     this.Channel = reader.TlvRecord.ValueAsInt64();
                     result = true;
                     break;
                 case ResourceID.SupportedChannels:
                     this.SupportedChannels = IntegerResources.Deserialise(reader);
                     result = true;
                     break;
                 case ResourceID.ChannelsInUse:
                     this.ChannelsInUse = IntegerResources.Deserialise(reader);
                     result = true;
                     break;
                 case ResourceID.RegulatoryDomain:
                     this.RegulatoryDomain = reader.TlvRecord.ValueAsString();
                     result = true;
                     break;
                 case ResourceID.Standard:
                     this.Standard = reader.TlvRecord.ValueAsInt64();
                     result = true;
                     break;
                 case ResourceID.AuthenticationMode:
                     this.AuthenticationMode = reader.TlvRecord.ValueAsInt64();
                     result = true;
                     break;
                 case ResourceID.EncryptionMode:
                     this.EncryptionMode = reader.TlvRecord.ValueAsInt64();
                     result = true;
                     break;
                 case ResourceID.WPAPreSharedKey:
                     this.WPAPreSharedKey = reader.TlvRecord.ValueAsString();
                     result = true;
                     break;
                 case ResourceID.WPAKeyPhrase:
                     this.WPAKeyPhrase = reader.TlvRecord.ValueAsString();
                     result = true;
                     break;
                 case ResourceID.WEPEncryptionType:
                     this.WEPEncryptionType = reader.TlvRecord.ValueAsInt64();
                     result = true;
                     break;
                 case ResourceID.WEPKeyIndex:
                     this.WEPKeyIndex = reader.TlvRecord.ValueAsInt64();
                     result = true;
                     break;
                 case ResourceID.WEPKeyPhrase:
                     this.WEPKeyPhrase = reader.TlvRecord.ValueAsString();
                     result = true;
                     break;
                 case ResourceID.WEPKey1:
                     this.WEPKey1 = reader.TlvRecord.ValueAsString();
                     result = true;
                     break;
                 case ResourceID.WEPKey2:
                     this.WEPKey2 = reader.TlvRecord.ValueAsString();
                     result = true;
                     break;
                 case ResourceID.WEPKey3:
                     this.WEPKey3 = reader.TlvRecord.ValueAsString();
                     result = true;
                     break;
                 case ResourceID.WEPKey4:
                     this.WEPKey4 = reader.TlvRecord.ValueAsString();
                     result = true;
                     break;
                 case ResourceID.RADIUSServer:
                     this.RADIUSServer = reader.TlvRecord.ValueAsString();
                     result = true;
                     break;
                 case ResourceID.RADIUSServerPort:
                     this.RADIUSServerPort = reader.TlvRecord.ValueAsInt64();
                     result = true;
                     break;
                 case ResourceID.RADIUSSecret:
                     this.RADIUSSecret = reader.TlvRecord.ValueAsString();
                     result = true;
                     break;
                 case ResourceID.WMMSupported:
                     this.WMMSupported = reader.TlvRecord.ValueAsBoolean();
                     result = true;
                     break;
                 case ResourceID.WMMEnabled:
                     this.WMMEnabled = reader.TlvRecord.ValueAsBoolean();
                     result = true;
                     break;
                 case ResourceID.MACControlEnabled:
                     this.MACControlEnabled = reader.TlvRecord.ValueAsBoolean();
                     result = true;
                     break;
                 case ResourceID.MACAddressList:
                     this.MACAddressList = StringResources.Deserialise(reader);
                     result = true;
                     break;
                 case ResourceID.TotalBytesSent:
                     this.TotalBytesSent = reader.TlvRecord.ValueAsInt64();
                     result = true;
                     break;
                 case ResourceID.TotalBytesReceived:
                     this.TotalBytesReceived = reader.TlvRecord.ValueAsInt64();
                     result = true;
                     break;
                 case ResourceID.TotalPacketsSent:
                     this.TotalPacketsSent = reader.TlvRecord.ValueAsInt64();
                     result = true;
                     break;
                 case ResourceID.TotalPacketsReceived:
                     this.TotalPacketsReceived = reader.TlvRecord.ValueAsInt64();
                     result = true;
                     break;
                 case ResourceID.TransmitErrors:
                     this.TransmitErrors = reader.TlvRecord.ValueAsInt64();
                     result = true;
                     break;
                 case ResourceID.ReceiveErrors:
                     this.ReceiveErrors = reader.TlvRecord.ValueAsInt64();
                     result = true;
                     break;
                 case ResourceID.UnicastPacketsSent:
                     this.UnicastPacketsSent = reader.TlvRecord.ValueAsInt64();
                     result = true;
                     break;
                 case ResourceID.UnicastPacketsReceived:
                     this.UnicastPacketsReceived = reader.TlvRecord.ValueAsInt64();
                     result = true;
                     break;
                 case ResourceID.MulticastPacketsSent:
                     this.MulticastPacketsSent = reader.TlvRecord.ValueAsInt64();
                     result = true;
                     break;
                 case ResourceID.MulticastPacketsReceived:
                     this.MulticastPacketsReceived = reader.TlvRecord.ValueAsInt64();
                     result = true;
                     break;
                 case ResourceID.BroadcastPacketsSent:
                     this.BroadcastPacketsSent = reader.TlvRecord.ValueAsInt64();
                     result = true;
                     break;
                 case ResourceID.BroadcastPacketsReceived:
                     this.BroadcastPacketsReceived = reader.TlvRecord.ValueAsInt64();
                     result = true;
                     break;
                 case ResourceID.DiscardPacketsSent:
                     this.DiscardPacketsSent = reader.TlvRecord.ValueAsInt64();
                     result = true;
                     break;
                 case ResourceID.DiscardPacketsReceived:
                     this.DiscardPacketsReceived = reader.TlvRecord.ValueAsInt64();
                     result = true;
                     break;
                 case ResourceID.UnknownPacketsReceived:
                     this.UnknownPacketsReceived = reader.TlvRecord.ValueAsInt64();
                     result = true;
                     break;
                 case ResourceID.VendorSpecificExtensions:
                     //this.VendorSpecificExtensions = reader.TlvRecord.Value;
                     result = true;
                     break;
                 default:
                     break;
             }
         }
     }
     return result;
 }
 public override bool Deserialise(TlvReader reader)
 {
     bool result = false;
     while (reader.Read())
     {
         if (reader.TlvRecord.TypeIdentifier == TTlvTypeIdentifier.ObjectInstance)
         {
             if (string.Compare(this.Name, reader.TlvRecord.Identifier.ToString()) != 0)
             {
                 this.Name = reader.TlvRecord.Identifier.ToString();
             }
             reader = new TlvReader(reader.TlvRecord.Value);
         }
         else if ((reader.TlvRecord.TypeIdentifier != TTlvTypeIdentifier.ObjectInstance) && (reader.TlvRecord.TypeIdentifier != TTlvTypeIdentifier.NotSet))
         {
             switch ((ResourceID)reader.TlvRecord.Identifier)
             {
                 case ResourceID.SMSTxCounter:
                     this.SMSTxCounter = reader.TlvRecord.ValueAsInt64();
                     result = true;
                     break;
                 case ResourceID.SMSRxCounter:
                     this.SMSRxCounter = reader.TlvRecord.ValueAsInt64();
                     result = true;
                     break;
                 case ResourceID.TxData:
                     this.TxData = reader.TlvRecord.ValueAsInt64();
                     result = true;
                     break;
                 case ResourceID.RxData:
                     this.RxData = reader.TlvRecord.ValueAsInt64();
                     result = true;
                     break;
                 case ResourceID.MaxMessageSize:
                     this.MaxMessageSize = reader.TlvRecord.ValueAsInt64();
                     result = true;
                     break;
                 case ResourceID.AverageMessageSize:
                     this.AverageMessageSize = reader.TlvRecord.ValueAsInt64();
                     result = true;
                     break;
                 default:
                     break;
             }
         }
     }
     return result;
 }
Пример #6
0
 public override bool Deserialise(TlvReader reader)
 {
     bool result = false;
     while (reader.Read())
     {
         if (reader.TlvRecord.TypeIdentifier == TTlvTypeIdentifier.ObjectInstance)
         {
             if (string.Compare(this.Name, reader.TlvRecord.Identifier.ToString()) != 0)
             {
                 this.Name = reader.TlvRecord.Identifier.ToString();
             }
             reader = new TlvReader(reader.TlvRecord.Value);
         }
         else if ((reader.TlvRecord.TypeIdentifier != TTlvTypeIdentifier.ObjectInstance) && (reader.TlvRecord.TypeIdentifier != TTlvTypeIdentifier.NotSet))
         {
             switch ((ResourceID)reader.TlvRecord.Identifier)
             {
                 case ResourceID.Latitude:
                     this.Latitude = reader.TlvRecord.ValueAsString();
                     result = true;
                     break;
                 case ResourceID.Longitude:
                     this.Longitude = reader.TlvRecord.ValueAsString();
                     result = true;
                     break;
                 case ResourceID.Altitude:
                     this.Altitude = reader.TlvRecord.ValueAsString();
                     result = true;
                     break;
                 case ResourceID.Uncertainty:
                     this.Uncertainty = reader.TlvRecord.ValueAsString();
                     result = true;
                     break;
                 case ResourceID.Velocity:
                     this.Velocity = reader.TlvRecord.Value;
                     result = true;
                     break;
                 case ResourceID.Timestamp:
                     this.Timestamp = reader.TlvRecord.ValueAsDateTime();
                     result = true;
                     break;
                 default:
                     break;
             }
         }
     }
     return result;
 }
 public override bool Deserialise(TlvReader reader)
 {
     bool result = false;
     while (reader.Read())
     {
         if ((reader.TlvRecord.TypeIdentifier != TTlvTypeIdentifier.ObjectInstance) && (reader.TlvRecord.TypeIdentifier != TTlvTypeIdentifier.NotSet))
         {
             switch ((ResourceID)reader.TlvRecord.Identifier)
             {
                 case ResourceID.LWM2MServerURI:
                     this.LWM2MServerURI = reader.TlvRecord.ValueAsString();
                     result = true;
                     break;
                 case ResourceID.BootstrapServer:
                     this.BootstrapServer = reader.TlvRecord.ValueAsBoolean();
                     result = true;
                     break;
                 case ResourceID.SecurityMode:
                     this.SecurityMode = reader.TlvRecord.ValueAsInt64();
                     result = true;
                     break;
                 case ResourceID.PublicKeyorIdentity:
                     this.PublicKeyorIdentity = reader.TlvRecord.Value;
                     result = true;
                     break;
                 case ResourceID.ServerPublicKeyorIdentity:
                     this.ServerPublicKeyorIdentity = reader.TlvRecord.Value;
                     result = true;
                     break;
                 case ResourceID.SecretKey:
                     this.SecretKey = reader.TlvRecord.Value;
                     result = true;
                     break;
                 case ResourceID.SMSSecurityMode:
                     this.SMSSecurityMode = reader.TlvRecord.ValueAsInt64();
                     result = true;
                     break;
                 case ResourceID.SMSBindingKeyParameters:
                     this.SMSBindingKeyParameters = reader.TlvRecord.Value;
                     result = true;
                     break;
                 case ResourceID.SMSBindingSecretKeys:
                     this.SMSBindingSecretKeys = reader.TlvRecord.Value;
                     result = true;
                     break;
                 case ResourceID.LWM2MServerSMSNumber:
                     this.LWM2MServerSMSNumber = reader.TlvRecord.ValueAsInt64();
                     result = true;
                     break;
                 case ResourceID.ShortServerID:
                     this.ShortServerID = reader.TlvRecord.ValueAsInt64();
                     result = true;
                     break;
                 case ResourceID.ClientHoldOffTime:
                     this.ClientHoldOffTime = reader.TlvRecord.ValueAsInt64();
                     result = true;
                     break;
                 default:
                     break;
             }
         }
     }
     return result;
 }
 public override bool Deserialise(TlvReader reader)
 {
     bool result = false;
     while (reader.Read())
     {
         if (reader.TlvRecord.TypeIdentifier == TTlvTypeIdentifier.ObjectInstance)
         {
             if (string.Compare(this.Name, reader.TlvRecord.Identifier.ToString()) != 0)
             {
                 this.Name = reader.TlvRecord.Identifier.ToString();
             }
             reader = new TlvReader(reader.TlvRecord.Value);
         }
         else if ((reader.TlvRecord.TypeIdentifier != TTlvTypeIdentifier.ObjectInstance) && (reader.TlvRecord.TypeIdentifier != TTlvTypeIdentifier.NotSet))
         {
             switch ((ResourceID)reader.TlvRecord.Identifier)
             {
                 case ResourceID.Property:
                     this.Property = reader.TlvRecord.ValueAsString();
                     result = true;
                     break;
                 case ResourceID.Group:
                     this.Group = reader.TlvRecord.ValueAsInt64();
                     result = true;
                     break;
                 case ResourceID.Description:
                     this.Description = reader.TlvRecord.ValueAsString();
                     result = true;
                     break;
                 case ResourceID.Attached:
                     this.Attached = reader.TlvRecord.ValueAsBoolean();
                     result = true;
                     break;
                 case ResourceID.Enabled:
                     this.Enabled = reader.TlvRecord.ValueAsBoolean();
                     result = true;
                     break;
                 case ResourceID.NotifyEn:
                     this.NotifyEn = reader.TlvRecord.ValueAsBoolean();
                     result = true;
                     break;
                 default:
                     break;
             }
         }
     }
     return result;
 }
Пример #9
0
 public override bool Deserialise(TlvReader reader)
 {
     bool result = false;
     while (reader.Read())
     {
         if (reader.TlvRecord.TypeIdentifier == TTlvTypeIdentifier.ObjectInstance)
         {
             if (string.Compare(this.Name, reader.TlvRecord.Identifier.ToString()) != 0)
             {
                 this.Name = reader.TlvRecord.Identifier.ToString();
             }
             reader = new TlvReader(reader.TlvRecord.Value);
         }
         else if ((reader.TlvRecord.TypeIdentifier != TTlvTypeIdentifier.ObjectInstance) && (reader.TlvRecord.TypeIdentifier != TTlvTypeIdentifier.NotSet))
         {
             switch ((ResourceID)reader.TlvRecord.Identifier)
             {
                 case ResourceID.Manufacturer:
                     this.Manufacturer = reader.TlvRecord.ValueAsString();
                     result = true;
                     break;
                 case ResourceID.ModelNumber:
                     this.ModelNumber = reader.TlvRecord.ValueAsString();
                     result = true;
                     break;
                 case ResourceID.SerialNumber:
                     this.SerialNumber = reader.TlvRecord.ValueAsString();
                     result = true;
                     break;
                 case ResourceID.FirmwareVersion:
                     this.FirmwareVersion = reader.TlvRecord.ValueAsString();
                     result = true;
                     break;
                 case ResourceID.AvailablePowerSources:
                     this.AvailablePowerSources = IntegerResources.Deserialise(reader);
                     result = true;
                     break;
                 case ResourceID.PowerSourceVoltages:
                     this.PowerSourceVoltages = IntegerResources.Deserialise(reader);
                     result = true;
                     break;
                 case ResourceID.PowerSourceCurrents:
                     this.PowerSourceCurrents = IntegerResources.Deserialise(reader);
                     result = true;
                     break;
                 case ResourceID.BatteryLevel:
                     this.BatteryLevel = reader.TlvRecord.ValueAsInt64();
                     result = true;
                     break;
                 case ResourceID.MemoryFree:
                     this.MemoryFree = reader.TlvRecord.ValueAsInt64();
                     result = true;
                     break;
                 case ResourceID.ErrorCodes:
                     this.ErrorCodes = IntegerResources.Deserialise(reader);
                     result = true;
                     break;
                 case ResourceID.CurrentTime:
                     this.CurrentTime = reader.TlvRecord.ValueAsDateTime();
                     result = true;
                     break;
                 case ResourceID.UTCOffset:
                     this.UTCOffset = reader.TlvRecord.ValueAsString();
                     result = true;
                     break;
                 case ResourceID.Timezone:
                     this.Timezone = reader.TlvRecord.ValueAsString();
                     result = true;
                     break;
                 case ResourceID.SupportedBindingandModes:
                     this.SupportedBindingandModes = reader.TlvRecord.ValueAsString();
                     result = true;
                     break;
                 case ResourceID.DeviceType:
                     this.DeviceType = reader.TlvRecord.ValueAsString();
                     result = true;
                     break;
                 case ResourceID.HardwareVersion:
                     this.HardwareVersion = reader.TlvRecord.ValueAsString();
                     result = true;
                     break;
                 case ResourceID.SoftwareVersion:
                     this.SoftwareVersion = reader.TlvRecord.ValueAsString();
                     result = true;
                     break;
                 case ResourceID.BatteryStatus:
                     this.BatteryStatus = reader.TlvRecord.ValueAsInt64();
                     result = true;
                     break;
                 case ResourceID.MemoryTotal:
                     this.MemoryTotal = reader.TlvRecord.ValueAsInt64();
                     result = true;
                     break;
                 default:
                     break;
             }
         }
     }
     return result;
 }
 public override bool Deserialise(TlvReader reader)
 {
     bool result = false;
     while (reader.Read())
     {
         if (reader.TlvRecord.TypeIdentifier == TTlvTypeIdentifier.ObjectInstance)
         {
             if (string.Compare(this.Name, reader.TlvRecord.Identifier.ToString()) != 0)
             {
                 this.Name = reader.TlvRecord.Identifier.ToString();
             }
             reader = new TlvReader(reader.TlvRecord.Value);
         }
         else if ((reader.TlvRecord.TypeIdentifier != TTlvTypeIdentifier.ObjectInstance) && (reader.TlvRecord.TypeIdentifier != TTlvTypeIdentifier.NotSet))
         {
             switch ((ResourceID)reader.TlvRecord.Identifier)
             {
                 case ResourceID.NetworkBearer:
                     this.NetworkBearer = reader.TlvRecord.ValueAsInt64();
                     result = true;
                     break;
                 case ResourceID.AvailableNetworkBearers:
                     this.AvailableNetworkBearers = IntegerResources.Deserialise(reader);
                     result = true;
                     break;
                 case ResourceID.RadioSignalStrength:
                     this.RadioSignalStrength = reader.TlvRecord.ValueAsInt64();
                     result = true;
                     break;
                 case ResourceID.LinkQuality:
                     this.LinkQuality = reader.TlvRecord.ValueAsInt64();
                     result = true;
                     break;
                 case ResourceID.IPAddresses:
                     this.IPAddresses = StringResources.Deserialise(reader);
                     result = true;
                     break;
                 case ResourceID.RouterIPAddresses:
                     this.RouterIPAddresses = StringResources.Deserialise(reader);
                     result = true;
                     break;
                 case ResourceID.LinkUtilization:
                     this.LinkUtilization = reader.TlvRecord.ValueAsInt64();
                     result = true;
                     break;
                 case ResourceID.APNs:
                     this.APNs = StringResources.Deserialise(reader);
                     result = true;
                     break;
                 case ResourceID.CellID:
                     this.CellID = reader.TlvRecord.ValueAsInt64();
                     result = true;
                     break;
                 case ResourceID.SMNC:
                     this.SMNC = reader.TlvRecord.ValueAsInt64();
                     result = true;
                     break;
                 case ResourceID.SMCC:
                     this.SMCC = reader.TlvRecord.ValueAsInt64();
                     result = true;
                     break;
                 default:
                     break;
             }
         }
     }
     return result;
 }
Пример #11
0
 public override bool Deserialise(TlvReader reader)
 {
     bool result = false;
     while (reader.Read())
     {
         if (reader.TlvRecord.TypeIdentifier == TTlvTypeIdentifier.ObjectInstance)
         {
             if (string.Compare(this.Name, reader.TlvRecord.Identifier.ToString()) != 0)
             {
                 this.Name = reader.TlvRecord.Identifier.ToString();
             }
             reader = new TlvReader(reader.TlvRecord.Value);
         }
         else if ((reader.TlvRecord.TypeIdentifier != TTlvTypeIdentifier.ObjectInstance) && (reader.TlvRecord.TypeIdentifier != TTlvTypeIdentifier.NotSet))
         {
             switch ((ResourceID)reader.TlvRecord.Identifier)
             {
                 case ResourceID.ShortServerID:
                     this.ShortServerID = reader.TlvRecord.ValueAsInt32();
                     result = true;
                     break;
                 case ResourceID.Lifetime:
                     this.Lifetime = reader.TlvRecord.ValueAsInt32();
                     result = true;
                     break;
                 case ResourceID.DefaultMinimumPeriod:
                     this.DefaultMinimumPeriod = reader.TlvRecord.ValueAsInt32();
                     result = true;
                     break;
                 case ResourceID.DefaultMaximumPeriod:
                     this.DefaultMaximumPeriod = reader.TlvRecord.ValueAsInt32();
                     result = true;
                     break;
                 case ResourceID.DisableTimeout:
                     this.DisableTimeout = reader.TlvRecord.ValueAsInt32();
                     result = true;
                     break;
                 case ResourceID.NotificationStoringWhenOffline:
                     this.NotificationStoringWhenOffline = reader.TlvRecord.ValueAsBoolean();
                     result = true;
                     break;
                 case ResourceID.Binding:
                     TBindingMode binding = TBindingMode.NotSet;
                     string bindingText = reader.TlvRecord.ValueAsString();
                     switch (bindingText)
                     {
                         case "U":
                             binding = TBindingMode.UDP;
                             break;
                         case "UQ":
                             binding = TBindingMode.QueuedUDP;
                             break;
                         case "S":
                             binding = TBindingMode.SMS;
                             break;
                         case "SQ":
                             binding = TBindingMode.QueuedSMS;
                             break;
                         case "US":
                             binding = TBindingMode.UDPSMS;
                             break;
                         case "UQS":
                             binding = TBindingMode.QueuedUDPSMS;
                             break;
                         default:
                             break;
                     }
                     this.Binding = binding;
                     result = true;
                     break;
                 default:
                     break;
             }
         }
     }
     return result;
 }
Пример #12
0
 public override bool Deserialise(TlvReader reader)
 {
     bool result = false;
     while (reader.Read())
     {
         if ((reader.TlvRecord.TypeIdentifier != TTlvTypeIdentifier.ObjectInstance) && (reader.TlvRecord.TypeIdentifier != TTlvTypeIdentifier.NotSet))
         {
             switch ((ResourceID)reader.TlvRecord.Identifier)
             {
                 case ResourceID.ShortServerID:
                     this.ShortServerID = reader.TlvRecord.ValueAsInt64();
                     result = true;
                     break;
                 case ResourceID.Lifetime:
                     this.Lifetime = reader.TlvRecord.ValueAsInt64();
                     result = true;
                     break;
                 case ResourceID.DefaultMinimumPeriod:
                     this.DefaultMinimumPeriod = reader.TlvRecord.ValueAsInt64();
                     result = true;
                     break;
                 case ResourceID.DefaultMaximumPeriod:
                     this.DefaultMaximumPeriod = reader.TlvRecord.ValueAsInt64();
                     result = true;
                     break;
                 case ResourceID.DisableTimeout:
                     this.DisableTimeout = reader.TlvRecord.ValueAsInt64();
                     result = true;
                     break;
                 case ResourceID.NotificationStoringWhenDisabledorOffline:
                     this.NotificationStoringWhenDisabledorOffline = reader.TlvRecord.ValueAsBoolean();
                     result = true;
                     break;
                 case ResourceID.Binding:
                     this.Binding = reader.TlvRecord.ValueAsString();
                     result = true;
                     break;
                 default:
                     break;
             }
         }
     }
     return result;
 }
 public override bool Deserialise(TlvReader reader)
 {
     bool result = false;
     while (reader.Read())
     {
         if (reader.TlvRecord.TypeIdentifier == TTlvTypeIdentifier.ObjectInstance)
         {
             if (string.Compare(this.Name, reader.TlvRecord.Identifier.ToString()) != 0)
             {
                 this.Name = reader.TlvRecord.Identifier.ToString();
             }
             reader = new TlvReader(reader.TlvRecord.Value);
         }
         else if ((reader.TlvRecord.TypeIdentifier != TTlvTypeIdentifier.ObjectInstance) && (reader.TlvRecord.TypeIdentifier != TTlvTypeIdentifier.NotSet))
         {
             switch ((ResourceID)reader.TlvRecord.Identifier)
             {
                 case ResourceID.Package:
                     this.Package = reader.TlvRecord.Value;
                     result = true;
                     break;
                 case ResourceID.PackageURI:
                     this.PackageURI = reader.TlvRecord.ValueAsString();
                     result = true;
                     break;
                 case ResourceID.State:
                     this.State = reader.TlvRecord.ValueAsInt64();
                     result = true;
                     break;
                 case ResourceID.UpdateSupportedObjects:
                     this.UpdateSupportedObjects = reader.TlvRecord.ValueAsBoolean();
                     result = true;
                     break;
                 case ResourceID.UpdateResult:
                     this.UpdateResult = reader.TlvRecord.ValueAsInt64();
                     result = true;
                     break;
                 case ResourceID.PackageName:
                     this.PackageName = reader.TlvRecord.ValueAsString();
                     result = true;
                     break;
                 case ResourceID.PackageVersion:
                     this.PackageVersion = reader.TlvRecord.ValueAsString();
                     result = true;
                     break;
                 default:
                     break;
             }
         }
     }
     return result;
 }
Пример #14
0
 public static Model.Object ParseObject(ObjectDefinition objectDefinition, TlvReader reader)
 {
     Model.Object result = null;
     while (reader.Read())
     {
         if (reader.TlvRecord.TypeIdentifier == TTlvTypeIdentifier.ObjectInstance)
         {
             TlvReader objectReader = new TlvReader(reader.TlvRecord.Value);
             result = ParseObject(objectDefinition, objectReader);
             if (result != null)
             {
                 result.InstanceID = reader.TlvRecord.Identifier.ToString();
             }
             break;
         }
         if ((reader.TlvRecord.TypeIdentifier != TTlvTypeIdentifier.ObjectInstance) && (reader.TlvRecord.TypeIdentifier != TTlvTypeIdentifier.NotSet))
         {
             if (result == null)
             {
                 result = new Model.Object();
                 result.ObjectID = objectDefinition.ObjectID;
                 result.ObjectDefinitionID = objectDefinition.ObjectDefinitionID;
             }
             if (reader.TlvRecord.TypeIdentifier == TTlvTypeIdentifier.ResourceWithValue)
             {
                 string propertyID = reader.TlvRecord.Identifier.ToString();
                 PropertyDefinition property = objectDefinition.GetProperty(propertyID);
                 if (property != null)
                 {
                     Property lwm2mProperty = new Property();
                     lwm2mProperty.PropertyDefinitionID = property.PropertyDefinitionID;
                     lwm2mProperty.PropertyID = property.PropertyID;
                     lwm2mProperty.Value = new PropertyValue(GetValue(reader, property));
                     result.Properties.Add(lwm2mProperty);
                 }
             }
             else if (reader.TlvRecord.TypeIdentifier == TTlvTypeIdentifier.MultipleResources)
             {
                 string propertyID = reader.TlvRecord.Identifier.ToString();
                 PropertyDefinition property = objectDefinition.GetProperty(propertyID);
                 if (property != null)
                 {
                     Property lwm2mProperty = new Property();
                     lwm2mProperty.PropertyDefinitionID = property.PropertyDefinitionID;
                     lwm2mProperty.PropertyID = property.PropertyID;
                     result.Properties.Add(lwm2mProperty);
                     TlvReader arrayReader = new TlvReader(reader.TlvRecord.Value);
                     while (arrayReader.Read())
                     {
                         if (arrayReader.TlvRecord.TypeIdentifier == TTlvTypeIdentifier.ResourceInstance)
                         {
                             string value = GetValue(arrayReader, property);
                             if (value != null)
                             {
                                 if (lwm2mProperty.Values == null)
                                     lwm2mProperty.Values = new List<PropertyValue>();
                                 PropertyValue propertyValue = new PropertyValue();
                                 propertyValue.PropertyValueID = arrayReader.TlvRecord.Identifier.ToString();
                                 propertyValue.Value = value;
                                 lwm2mProperty.Values.Add(propertyValue);
                             }
                         }
                     }
                 }
             }
         }
     }
     return result;
 }
Пример #15
0
 public static Model.Object ParseObject(ObjectDefinition objectDefinition, TlvReader reader)
 {
     Model.Object result = null;
     while (reader.Read())
     {
         if (reader.TlvRecord.TypeIdentifier == TTlvTypeIdentifier.ObjectInstance)
         {
             TlvReader objectReader = new TlvReader(reader.TlvRecord.Value);
             result = ParseObject(objectDefinition, objectReader);
             if (result != null)
             {
                 result.InstanceID = reader.TlvRecord.Identifier.ToString();
             }
             break;
         }
         if ((reader.TlvRecord.TypeIdentifier != TTlvTypeIdentifier.ObjectInstance) && (reader.TlvRecord.TypeIdentifier != TTlvTypeIdentifier.NotSet))
         {
             if (result == null)
             {
                 result                    = new Model.Object();
                 result.ObjectID           = objectDefinition.ObjectID;
                 result.ObjectDefinitionID = objectDefinition.ObjectDefinitionID;
             }
             if (reader.TlvRecord.TypeIdentifier == TTlvTypeIdentifier.ResourceWithValue)
             {
                 string             propertyID = reader.TlvRecord.Identifier.ToString();
                 PropertyDefinition property   = objectDefinition.GetProperty(propertyID);
                 if (property != null)
                 {
                     Property lwm2mProperty = new Property();
                     lwm2mProperty.PropertyDefinitionID = property.PropertyDefinitionID;
                     lwm2mProperty.PropertyID           = property.PropertyID;
                     lwm2mProperty.Value = new PropertyValue(GetValue(reader, property));
                     result.Properties.Add(lwm2mProperty);
                 }
             }
             else if (reader.TlvRecord.TypeIdentifier == TTlvTypeIdentifier.MultipleResources)
             {
                 string             propertyID = reader.TlvRecord.Identifier.ToString();
                 PropertyDefinition property   = objectDefinition.GetProperty(propertyID);
                 if (property != null)
                 {
                     Property lwm2mProperty = new Property();
                     lwm2mProperty.PropertyDefinitionID = property.PropertyDefinitionID;
                     lwm2mProperty.PropertyID           = property.PropertyID;
                     result.Properties.Add(lwm2mProperty);
                     TlvReader arrayReader = new TlvReader(reader.TlvRecord.Value);
                     while (arrayReader.Read())
                     {
                         if (arrayReader.TlvRecord.TypeIdentifier == TTlvTypeIdentifier.ResourceInstance)
                         {
                             string value = GetValue(arrayReader, property);
                             if (value != null)
                             {
                                 if (lwm2mProperty.Values == null)
                                 {
                                     lwm2mProperty.Values = new List <PropertyValue>();
                                 }
                                 PropertyValue propertyValue = new PropertyValue();
                                 propertyValue.PropertyValueID = arrayReader.TlvRecord.Identifier.ToString();
                                 propertyValue.Value           = value;
                                 lwm2mProperty.Values.Add(propertyValue);
                             }
                         }
                     }
                 }
             }
         }
     }
     return(result);
 }
Пример #16
0
 private List<Model.Object> ParseObjects(ObjectDefinition objectDefinition, int requestContentType, Response response)
 {
     List<Model.Object> result = new List<Model.Object>();
     int contentType;
     if (response.ContentType == -1)
     {
         contentType = requestContentType;
     }
     else
     {
         contentType = response.ContentType;
     }
     if (contentType == TlvConstant.CONTENT_TYPE_TLV)
     {
         TlvReader reader = new TlvReader(response.Payload);
         while (reader.Read())
         {
             if (reader.TlvRecord.TypeIdentifier == TTlvTypeIdentifier.ObjectInstance)
             {
                 TlvReader objectReader = new TlvReader(reader.TlvRecord.Value);
                 Model.Object item = ObjectUtils.ParseObject(objectDefinition, objectReader);
                 if (item != null)
                 {
                     item.InstanceID = reader.TlvRecord.Identifier.ToString();
                     result.Add(item);
                 }
             }
         }
     }
     return result;
 }
 public override bool Deserialise(TlvReader reader)
 {
     bool result = false;
     while (reader.Read())
     {
         if ((reader.TlvRecord.TypeIdentifier != TTlvTypeIdentifier.ObjectInstance) && (reader.TlvRecord.TypeIdentifier != TTlvTypeIdentifier.NotSet))
         {
             switch ((ResourceID)reader.TlvRecord.Identifier)
             {
                 case ResourceID.ObjectID:
                     this.ObjectID = reader.TlvRecord.ValueAsInt64();
                     result = true;
                     break;
                 case ResourceID.ObjectInstanceID:
                     this.ObjectInstanceID = reader.TlvRecord.ValueAsInt64();
                     result = true;
                     break;
                 case ResourceID.ACLs:
                     this.ACLs = IntegerResources.Deserialise(reader);
                     result = true;
                     break;
                 case ResourceID.AccessControlOwner:
                     this.AccessControlOwner = reader.TlvRecord.ValueAsInt64();
                     result = true;
                     break;
                 default:
                     break;
             }
         }
     }
     return result;
 }
Пример #18
0
 public override bool Deserialise(TlvReader reader)
 {
     bool result = false;
     while (reader.Read())
     {
         if (reader.TlvRecord.TypeIdentifier == TTlvTypeIdentifier.ObjectInstance)
         {
             if (string.Compare(this.Name, reader.TlvRecord.Identifier.ToString()) != 0)
             {
                 this.Name = reader.TlvRecord.Identifier.ToString();
             }
             reader = new TlvReader(reader.TlvRecord.Value);
         }
         else if ((reader.TlvRecord.TypeIdentifier != TTlvTypeIdentifier.ObjectInstance) && (reader.TlvRecord.TypeIdentifier != TTlvTypeIdentifier.NotSet))
         {
             switch ((ResourceID)reader.TlvRecord.Identifier)
             {
                 case ResourceID.CommandID:
                     this.CommandID = reader.TlvRecord.Value;
                     result = true;
                     break;
                 case ResourceID.CommandTypeID:
                     this.CommandTypeID = reader.TlvRecord.ValueAsString();
                     result = true;
                     break;
                 case ResourceID.Status:
                     this.Status = reader.TlvRecord.ValueAsInt64();
                     result = true;
                     break;
                 case ResourceID.StatusCode:
                     this.StatusCode = reader.TlvRecord.ValueAsString();
                     result = true;
                     break;
                 case ResourceID.ParameterName:
                     this.ParameterName = StringResources.Deserialise(reader);
                     result = true;
                     break;
                 case ResourceID.ParameterValue:
                     this.ParameterValue = StringResources.Deserialise(reader);
                     result = true;
                     break;
                 case ResourceID.ResultContentType:
                     this.ResultContentType = reader.TlvRecord.ValueAsString();
                     result = true;
                     break;
                 case ResourceID.ResultContent:
                     this.ResultContent = reader.TlvRecord.ValueAsString();
                     result = true;
                     break;
                 case ResourceID.ErrorContentType:
                     this.ErrorContentType = reader.TlvRecord.ValueAsString();
                     result = true;
                     break;
                 case ResourceID.ErrorContent:
                     this.ErrorContent = reader.TlvRecord.ValueAsString();
                     result = true;
                     break;
                 default:
                     break;
             }
         }
     }
     return result;
 }
Пример #19
0
 public override bool Deserialise(TlvReader reader)
 {
     bool result = false;
     while (reader.Read())
     {
         if (reader.TlvRecord.TypeIdentifier == TTlvTypeIdentifier.ObjectInstance)
         {
             if (string.Compare(this.Name, reader.TlvRecord.Identifier.ToString()) != 0)
             {
                 this.Name = reader.TlvRecord.Identifier.ToString();
             }
             reader = new TlvReader(reader.TlvRecord.Value);
         }
         else if ((reader.TlvRecord.TypeIdentifier != TTlvTypeIdentifier.ObjectInstance) && (reader.TlvRecord.TypeIdentifier != TTlvTypeIdentifier.NotSet))
         {
             switch ((ResourceID)reader.TlvRecord.Identifier)
             {
                 case ResourceID.URL:
                     this.URL = reader.TlvRecord.ValueAsString();
                     result = true;
                     break;
                 case ResourceID.CustomerKey:
                     this.CustomerKey = reader.TlvRecord.ValueAsString();
                     result = true;
                     break;
                 case ResourceID.CustomerSecret:
                     this.CustomerSecret = reader.TlvRecord.ValueAsString();
                     result = true;
                     break;
                 case ResourceID.RememberMeToken:
                     this.RememberMeToken = reader.TlvRecord.ValueAsString();
                     result = true;
                     break;
                 case ResourceID.RememberMeTokenExpiry:
                     this.RememberMeTokenExpiry = reader.TlvRecord.ValueAsDateTime();
                     result = true;
                     break;
                 default:
                     break;
             }
         }
     }
     return result;
 }
Пример #20
0
 public override bool Deserialise(TlvReader reader)
 {
     bool result = false;
     while (reader.Read())
     {
         if (reader.TlvRecord.TypeIdentifier == TTlvTypeIdentifier.ObjectInstance)
         {
             if (string.Compare(this.Name, reader.TlvRecord.Identifier.ToString()) != 0)
             {
                 this.Name = reader.TlvRecord.Identifier.ToString();
             }
             reader = new TlvReader(reader.TlvRecord.Value);
         }
         else if ((reader.TlvRecord.TypeIdentifier != TTlvTypeIdentifier.ObjectInstance) && (reader.TlvRecord.TypeIdentifier != TTlvTypeIdentifier.NotSet))
         {
             switch ((ResourceID)reader.TlvRecord.Identifier)
             {
                 case ResourceID.DeviceID:
                     this.DeviceID = reader.TlvRecord.Value;
                     result = true;
                     break;
                 case ResourceID.ParentID:
                     this.ParentID = reader.TlvRecord.Value;
                     result = true;
                     break;
                 case ResourceID.DeviceType:
                     this.DeviceType = reader.TlvRecord.ValueAsString();
                     result = true;
                     break;
                 case ResourceID.Name:
                     this.Name = reader.TlvRecord.ValueAsString();
                     result = true;
                     break;
                 case ResourceID.Description:
                     this.Description = reader.TlvRecord.ValueAsString();
                     result = true;
                     break;
                 case ResourceID.FCAP:
                     this.FCAP = reader.TlvRecord.ValueAsString();
                     result = true;
                     break;
                 case ResourceID.TenantID:
                     this.TenantID = reader.TlvRecord.ValueAsInt64();
                     result = true;
                     break;
                 case ResourceID.TenantChallenge:
                     this.TenantChallenge = reader.TlvRecord.Value;
                     result = true;
                     break;
                 case ResourceID.HashIterations:
                     this.HashIterations = reader.TlvRecord.ValueAsInt64();
                     result = true;
                     break;
                 case ResourceID.TenantHash:
                     this.TenantHash = reader.TlvRecord.Value;
                     result = true;
                     break;
                 case ResourceID.Status:
                     this.Status = reader.TlvRecord.ValueAsInt64();
                     result = true;
                     break;
                 default:
                     break;
             }
         }
     }
     return result;
 }