jefffhaynes/XBee

New to XBee and Added Supply Voltage measurement.

Closed this issue · 6 comments

I'm just getting into your API, and I like it. I've got a need to ask the modules for Supply Voltage (%V command) so I added it. Perhaps you'd like to roll it into the main API.

to XBeeNode.cs:

        /// <summary>
        ///     Gets the Supply Voltage in mV
        /// </summary>
        /// <returns></returns>
        public async Task<ushort> GetSupplyVoltageAsync()
        {
            var response = await ExecuteAtQueryAsync<PrimitiveResponseData<ushort>>(new SupplyVoltageCommand()).ConfigureAwait(false);
            return response.Value;
        }

to AtCommandResponseFrameContent.cs:

        [Subtype(nameof(AtCommand), SupplyVoltageCommand.Name, typeof(PrimitiveResponseData<ushort>), BindingMode = BindingMode.OneWay)]

New file SupplyVoltageCommand.cs

namespace XBee.Frames.AtCommands
{
    internal class SupplyVoltageCommand : AtCommand
    {
        public const string Name = "%V";

        public SupplyVoltageCommand() : base(Name)
        {
        }
    }
}

Upon further review, I think adding that command at the XBeeNode level may be incorrect. I don't know if all modules support that command.

Pushed in XBee.Core.1.5.8. Take a look and let me know if it works for you.

Oh and it looks like it's supported in series 2 but not series 1.