예제 #1
0
        internal bool Register(Lwm2mClient Client)
        {
            if (!this.shortServerId.IntegerValue.HasValue)
            {
                return(false);
            }

            Lwm2mSecurityObjectInstance SecurityInfo = Client.GetSecurityInfo(
                (ushort)this.shortServerId.IntegerValue.Value);

            if (SecurityInfo is null)
            {
                return(false);
            }

            Lwm2mServerReference Ref = SecurityInfo.GetServerReference(false);

            if (Ref is null)
            {
                return(false);
            }

            Client.Register(this.lifetimeSeconds.IntegerValue.HasValue ?
                            (int)this.lifetimeSeconds.IntegerValue.Value : 86400, Ref);

            return(true);
        }
예제 #2
0
        /// <summary>
        /// Called after the resource has been registered on a CoAP Endpoint.
        /// </summary>
        /// <param name="Client">LWM2M Client</param>
        public virtual void AfterRegister(Lwm2mClient Client)
        {
            foreach (Lwm2mResource Resource in this.Resources)
            {
                Client.CoapEndpoint.Register(Resource);
                Resource.AfterRegister();
            }

            try
            {
                this.OnAfterRegister?.Invoke(this, new EventArgs());
            }
            catch (Exception ex)
            {
                Log.Critical(ex);
            }
        }
예제 #3
0
 /// <summary>
 /// Called after the resource has been registered on a CoAP Endpoint.
 /// </summary>
 /// <param name="Client">LWM2M Client</param>
 public override void AfterRegister(Lwm2mClient Client)
 {
     base.AfterRegister(Client);
     this.TriggerAll(new TimeSpan(0, 0, 1));
 }
예제 #4
0
 public BootstreapResource(Lwm2mClient Client)
     : base("/bs")
 {
     this.client = Client;
 }