jefffhaynes / XBee

A .NET library for XBee wireless controllers
MIT License
40 stars 17 forks source link

Add AT Command to set SN Register for sleeping end device #23

Closed PaulNoto closed 7 years ago

PaulNoto commented 7 years ago

Hi Jeff, I've been using your XBee Library for about a year now. It is Rock Solid! Thank You.

I have been using the source code with a few modifications. I just switched over to using the compiled library so that NuGet will keep up with the latest releases for me.

The only thing missing from the library that I need is the ability to set the SN register on a sleeping end device. I added the following code to my copy of your source and I was hoping you could roll something like it into your released version.

In the AtCommands folder I added this:

namespace XBee.Frames.AtCommands { public class SleepNumberCyclicCommand : AtCommand {

    public SleepNumberCyclicCommand() : base( "SN" ) {
    }

    public SleepNumberCyclicCommand( ushort numberOfCycles ) : this() {
        NumberOfCycles = numberOfCycles;
    }

    [Ignore]
    public ushort? NumberOfCycles {
        get {
                return Parameter as ushort?;
        }
        set { Parameter = value; }
    }
}

}


To the XBeeNode I added this:

    /// <summary>
    /// Sets the configured Cyclic Sleep Number "SN".
    /// </summary>
    /// <param name="numberOfCycles">The Number of extra "SP" Cyclic Sleep Cycles to sleep for. Total = SP * SN</param>
    public async Task SetSleepNumberCyclicAsync( ushort numberOfCylcles ) {
        await ExecuteAtCommandAsync( new SleepNumberCyclicCommand( numberOfCylcles ) );
    }

I would really appreciate if you could add something like this. Thanks, Paul

jefffhaynes commented 7 years ago

Ok I'll take a look, thanks


From: PaulNoto notifications@github.com Sent: Friday, May 12, 2017 8:27:02 AM To: jefffhaynes/XBee Cc: Subscribed Subject: [jefffhaynes/XBee] Add AT Command to set SN Register for sleeping end device (#23)

Hi Jeff, I've been using your XBee Library for about a year now. It is Rock Solid! Thank You.

I have been using the source code with a few modifications. I just switched over to using the compiled library so that NuGet will keep up with the latest releases for me.

The only thing missing from the library that I need is the ability to set the SN register on a sleeping end device. I added the following code to my copy of your source and I was hoping you could roll something like it into your released version.

In the AtCommands folder I added this:

namespace XBee.Frames.AtCommands { public class SleepNumberCyclicCommand : AtCommand {

    public SleepNumberCyclicCommand() : base( "SN" ) {
    }

    public SleepNumberCyclicCommand( ushort numberOfCycles ) : this() {
            NumberOfCycles = numberOfCycles;
    }

    [Ignore]
    public ushort? NumberOfCycles {
            get {
                            return Parameter as ushort?;
            }
            set { Parameter = value; }
    }

}

}


To the XBeeNode I added this:

    /// <summary>
    /// Sets the configured Cyclic Sleep Number "SN".
    /// </summary>
    /// <param name="numberOfCycles">The Number of extra "SP" Cyclic Sleep Cycles to sleep for. Total = SP * SN</param>
    public async Task SetSleepNumberCyclicAsync( ushort numberOfCylcles ) {
            await ExecuteAtCommandAsync( new SleepNumberCyclicCommand( numberOfCylcles ) );
    }

I would really appreciate if you could add something like this. Thanks, Paul

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/jefffhaynes/XBee/issues/23, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AJSKR-0-q-vH6HdDgv_1P4H0nK1Y7EhDks5r5HpGgaJpZM4NZb7d.

jefffhaynes commented 7 years ago

I'm traveling right now so I have no way to test it but try 4.2-beta if you want. I also added a bunch of async/await config stuff so make sure that didn't break anything for you.

I hope you don't mind but I did SetSleepPeriod and SetSleepPeriodCount. Tell me if you think that isn't an accurate characterization of the commands.

PaulNoto commented 7 years ago

Thanks Jeff, I'll have a go at it today.

PaulNoto commented 7 years ago

I finally had a chance to test writing to the SN Register. It works! Thank You.

FYI, I have my Solar Powered Sleeping XBees setup to send a sample every 10 seconds when they power up ( SP=10 Seconds/ SN=1)

When they phone home for the first time, I do whatever application configuration is necessary, I set DIO14 to High as a flag to know I have done config for this XBee, then I set SN=6 so that the XBee will send a sample every 1 minute. If I don't get a sample in three minutes I know I have a problem. Which actually happened when one of my remote sensors was stolen.

My Routers use the same scheme, except, I can just change the sample rate.

Anyway, Thank you for creating a Rock Solid Library.

jefffhaynes commented 7 years ago

That's awesome! Sucks about the sensor. People are the worst.

Cheers


From: PaulNoto notifications@github.com Sent: Monday, May 15, 2017 10:52:25 AM To: jefffhaynes/XBee Cc: Jeff Haynes; Comment Subject: Re: [jefffhaynes/XBee] Add AT Command to set SN Register for sleeping end device (#23)

I finally had a chance to test writing to the SN Register. It works! Thank You.

FYI, I have my Solar Powered Sleeping XBees setup to send a sample every 10 seconds when they power up ( SP=10 Seconds/ SN=1)

When they phone home for the first time, I do whatever application configuration is necessary, I set DIO14 to High as a flag to know I have done config for this XBee, then I set SN=6 so that the XBee will send a sample every 1 minute. If I don't get a sample in three minutes I know I have a problem. Which actually happened when one of my remote sensors was stolen.

My Routers use the same scheme, except, I can just change the sample rate.

Anyway, Thank you for creating a Rock Solid Library.

— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/jefffhaynes/XBee/issues/23#issuecomment-301499551, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AJSKR9EJzq3xcYvG37MOiNV66b-M-WTqks5r6GapgaJpZM4NZb7d.