Add AT Command to set SN Register for sleeping end device
Closed this issue · 5 comments
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
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.
Thanks Jeff,
I'll have a go at it today.
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.