/// <summary>
        /// LWM2M Access Control object instance.
        /// </summary>
        /// <param name="InstanceId">ID of object instance.</param>
        public Lwm2mAccessControlObjectInstance(ushort InstanceId)
            : base(2, InstanceId)
        {
            // E.1 LwM2M Object: LwM2M Security
            // http://www.openmobilealliance.org/release/LightweightM2M/V1_0-20170208-A/OMA-TS-LightweightM2M-V1_0-20170208-A.pdf

            this.aclObjectId         = new Lwm2mResourceInteger("Object", 2, InstanceId, 0, false, false, null, false);
            this.aclObjectInstanceId = new Lwm2mResourceInteger("Object Instance", 2, InstanceId, 1, false, false, null, false);
            this.aclPrivileges       = new Lwm2mResourceInteger("Privileges", 2, InstanceId, 2, true, false, null, false);
            this.accessControlOwner  = new Lwm2mResourceInteger("Owner", 2, InstanceId, 3, true, false, null, false);
        }
        /// <summary>
        /// LWM2M Security object instance.
        /// </summary>
        /// <param name="InstanceId">ID of object instance.</param>
        public Lwm2mSecurityObjectInstance(ushort InstanceId)
            : base(0, InstanceId)
        {
            // E.1 LwM2M Object: LwM2M Security
            // http://www.openmobilealliance.org/release/LightweightM2M/V1_0-20170208-A/OMA-TS-LightweightM2M-V1_0-20170208-A.pdf

            this.serverUri                = new Lwm2mResourceString("Server", 0, InstanceId, 0, false, false, null);
            this.bootstrapServer          = new Lwm2mResourceBoolean("BootstrapServer", 0, InstanceId, 1, false, false, null);
            this.securityMode             = new Lwm2mResourceInteger("SecurityMode", 0, InstanceId, 2, false, false, null, false);
            this.publicKeyOrIdentity      = new Lwm2mResourceOpaque(null, 0, InstanceId, 3, false, false, null);
            this.serverPublicKey          = new Lwm2mResourceOpaque(null, 0, InstanceId, 4, false, false, null);
            this.secretKey                = new Lwm2mResourceOpaque(null, 0, InstanceId, 5, false, false, null);
            this.shortServerId            = new Lwm2mResourceInteger("ShortServerId", 0, InstanceId, 10, false, false, null, false);
            this.clientHoldOffTimeSeconds = new Lwm2mResourceInteger("ClientHoldOffTimeSeconds", 0, InstanceId, 11, false, false, null, false);

            this.serverUri.OnBeforeGet                += CheckFromBootstrapServer;
            this.bootstrapServer.OnBeforeGet          += CheckFromBootstrapServer;
            this.securityMode.OnBeforeGet             += CheckFromBootstrapServer;
            this.publicKeyOrIdentity.OnBeforeGet      += CheckFromBootstrapServer;
            this.serverPublicKey.OnBeforeGet          += CheckFromBootstrapServer;
            this.secretKey.OnBeforeGet                += CheckFromBootstrapServer;
            this.shortServerId.OnBeforeGet            += CheckFromBootstrapServer;
            this.clientHoldOffTimeSeconds.OnBeforeGet += CheckFromBootstrapServer;

            this.Add(this.serverUri);
            this.Add(this.bootstrapServer);
            this.Add(this.securityMode);
            this.Add(this.publicKeyOrIdentity);
            this.Add(this.serverPublicKey);
            this.Add(this.secretKey);
            this.Add(new Lwm2mResourceNotSupported(0, InstanceId, 6));              // SMS Security Mode
            this.Add(new Lwm2mResourceNotSupported(0, InstanceId, 7));              // SMS Binding Key Parameters
            this.Add(new Lwm2mResourceNotSupported(0, InstanceId, 8));              // SMS Binding Secret Key(s)
            this.Add(new Lwm2mResourceNotSupported(0, InstanceId, 9));              // LwM2M Server SMS Number
            this.Add(this.shortServerId);
            this.Add(this.clientHoldOffTimeSeconds);
            this.Add(new Lwm2mResourceNotSupported(0, InstanceId, 12));             //  BootstrapServer Account Timeout
        }
Ejemplo n.º 3
0
        /// <summary>
        /// LWM2M Server object instance.
        /// </summary>
        /// <param name="InstanceId">ID of object instance.</param>
        public Lwm2mServerObjectInstance(ushort InstanceId)
            : base(1, InstanceId)
        {
            // E.2 LwM2M Object: LwM2M Server
            // http://www.openmobilealliance.org/release/LightweightM2M/V1_0-20170208-A/OMA-TS-LightweightM2M-V1_0-20170208-A.pdf

            this.shortServerId             = new Lwm2mResourceInteger("ShortServerId", 1, InstanceId, 0, false, false, null, false);
            this.lifetimeSeconds           = new Lwm2mResourceInteger("LifetimeSeconds", 1, InstanceId, 1, true, false, null, false);
            this.notificationStoring       = new Lwm2mResourceBoolean("NotificationStoring", 1, InstanceId, 6, true, false, null);
            this.binding                   = new Lwm2mResourceString("Binding", 1, InstanceId, 7, true, false, null);
            this.registrationUpdateTrigger = new Lwm2mResourceCommand("RegistrationUpdateTrigger", 1, InstanceId, 8);

            this.registrationUpdateTrigger.OnExecute += RegistrationUpdateTrigger_OnExecute;

            this.Add(this.shortServerId);
            this.Add(this.lifetimeSeconds);
            this.Add(new Lwm2mResourceNotSupported(1, InstanceId, 2));              // Default Minimum Period
            this.Add(new Lwm2mResourceNotSupported(1, InstanceId, 3));              // Default Maximum Period
            this.Add(new Lwm2mResourceNotSupported(1, InstanceId, 4));              // Disable
            this.Add(new Lwm2mResourceNotSupported(1, InstanceId, 5));              // Disable Timeout
            this.Add(this.notificationStoring);
            this.Add(this.binding);
            this.Add(this.registrationUpdateTrigger);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// LWM2M Device object instance.
        /// </summary>
        public Lwm2mDeviceObjectInstance(string Manufacturer, string ModelNr, string SerialNr,
                                         string FirmwareVersion, string DeviceType, string HardwareVersion,
                                         string SoftwareVersion)
            : base(3, 0)
        {
            DateTime      Now      = DateTime.Now;
            TimeSpan      TimeZone = Now - Now.ToUniversalTime();
            StringBuilder sb       = new StringBuilder();

            if (TimeZone < TimeSpan.Zero)
            {
                sb.Append('-');
                TimeZone = -TimeZone;
            }

            sb.Append(TimeZone.Hours.ToString("D2"));
            sb.Append(':');
            sb.Append(TimeZone.Minutes.ToString("D2"));

            this.manufacturer      = new Lwm2mResourceString("Manufacturer", 3, 0, 0, false, false, Manufacturer);
            this.modelNr           = new Lwm2mResourceString("Model Number", 3, 0, 1, false, false, ModelNr);
            this.serialNr          = new Lwm2mResourceString("Serial Number", 3, 0, 2, false, false, SerialNr);
            this.firmwareVersion   = new Lwm2mResourceString("Firmware Version", 3, 0, 3, false, false, FirmwareVersion);
            this.reboot            = new Lwm2mResourceCommand("Reboot", 3, 0, 4);
            this.errorCodes        = new Lwm2mResourceInteger("Error Code", 3, 0, 11, false, false, 0, true);
            this.currentTime       = new Lwm2mResourceTime("Current Time", 3, 0, 13, true, false, Now);
            this.timeZone          = new Lwm2mResourceString("Time Zone", 3, 0, 14, true, true, sb.ToString());
            this.supportedBindings = new Lwm2mResourceString("Supported Bindings", 3, 0, 16, false, false, "U");
            this.deviceType        = new Lwm2mResourceString("Device Type", 3, 0, 17, false, false, DeviceType);
            this.hardwareVersion   = new Lwm2mResourceString("Hardware Version", 3, 0, 18, false, false, HardwareVersion);
            this.softwareVersion   = new Lwm2mResourceString("Software Version", 3, 0, 19, false, false, SoftwareVersion);

            this.currentTime.OnAfterRegister += CurrentTime_OnAfterRegister;
            this.currentTime.OnBeforeGet     += CurrentTime_OnBeforeGet;

            this.reboot.OnExecute += Reboot_OnExecute;

            this.Add(this.manufacturer);
            this.Add(this.modelNr);
            this.Add(this.serialNr);
            this.Add(this.firmwareVersion);
            this.Add(this.reboot);
            this.Add(new Lwm2mResourceNotSupported(3, InstanceId, 5));              // Factory Reset
            this.Add(new Lwm2mResourceNotSupported(3, InstanceId, 6));              // Available Power Sources
            this.Add(new Lwm2mResourceNotSupported(3, InstanceId, 7));              // Power Source Voltage
            this.Add(new Lwm2mResourceNotSupported(3, InstanceId, 8));              // Power Source Current
            this.Add(new Lwm2mResourceNotSupported(3, InstanceId, 9));              // Battery Level
            this.Add(new Lwm2mResourceNotSupported(3, InstanceId, 10));             // Battery Level
            this.Add(this.errorCodes);
            this.Add(new Lwm2mResourceNotSupported(3, InstanceId, 12));             // Reset Error Code
            this.Add(this.currentTime);
            this.Add(this.timeZone);
            this.Add(new Lwm2mResourceNotSupported(3, InstanceId, 15));              // Timezone
            this.Add(this.supportedBindings);
            this.Add(this.deviceType);
            this.Add(this.hardwareVersion);
            this.Add(this.softwareVersion);
            this.Add(new Lwm2mResourceNotSupported(3, InstanceId, 20));              // Battery Status
            this.Add(new Lwm2mResourceNotSupported(3, InstanceId, 21));              // Memory Total
            this.Add(new Lwm2mResourceNotSupported(3, InstanceId, 22));              // ExtDevInfo
        }