This project has moved and is read-only. For the latest updates, please go here.

Get Signal Strength of last Packet

Aug 5, 2012 at 4:20 PM

Hallo

First thanks for this get Library for Xbee.

I have to Xbee PRO Device Serie 1 one connected to my PC the other connectet to my FEZ Panda.

Now i want to get the Signal Strength of last Packet. But i allways become an Timeout exeption.

Here my Code

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NETMF.OpenSource.XBee.Api;
using NETMF.OpenSource.XBee;
using NETMF.OpenSource.XBee.Api.Wpan;

namespace Quadcopter_Test_Interface
{

    public class NodeReceivedSignalStrengthFilter : AtResponseFilter
    {
        private bool _finished;
        
        public NodeReceivedSignalStrengthFilter(int packetId = PacketIdGenerator.DefaultId)
            : base((ushort)AtCmd.ReceivedSignalStrength, packetId)
        {
        }

        public override bool Accepted(XBeeResponse packet)
        {
            if (!base.Accepted(packet))
                return false;

            var atResponse = (AtResponse)packet;

            // empty response is received in series 1 modules
            // in series 2 the timeout determines the end of discovery
            if (atResponse.Value == null || atResponse.Value.Length == 0)
            {
                _finished = true;
                return false;
            }

            return true;
        }

        public override bool Finished()
        {
            return _finished;
        }
    }


    public static class Signal
    {

        public static int? SignalStrength(XBeeApi p_Xpi)
        {
            var l_Request = GetSignalRequest(p_Xpi);
            var l_Response = l_Request.GetResponse();

            return ParseResponse(l_Response);
        }


        public static int? ParseResponse(XBeeResponse p_Response)
        {
            AtResponse l_Response = (AtResponse)p_Response;

            if (l_Response.Command != (ushort)AtCmd.ReceivedSignalStrength)
                throw new ArgumentException("This method is only applicable for the DB command");

            // empty response is received after the last disovered node
            // this happens only with Wpan nodes, not Zigbee
            if (l_Response.Value == null || l_Response.Value.Length == 0)
                return null;

            return -1 * l_Response.Value[0];
        }


        public static IRequest GetSignalRequest(XBeeApi p_Xpi)
        {
            var filter = new NodeReceivedSignalStrengthFilter();
            var request = p_Xpi.Send(AtCmd.ReceivedSignalStrength).Use(filter);
            return request;

        }
    }
}

Can someone help me??

Also I thing I found an other Problem.

First I want to use Baudrate 115200 put in the PC Version i allways get Timeout exception. I thing the is because the PC do not wait after Write to the Serialbus. After Changing rate to 9600 everything is fine. Or is there an other limitation.

 

 

 

 

 

Aug 6, 2012 at 11:05 AM

Two questions:

1) Are your modules set to operate in API mode? (you have to set AT parameter to 1)

2) When you use 115200 in your PC do you also change the baudrate in the module? 

Aug 6, 2012 at 5:19 PM

1) The modules operates with API Mode 2 witch is need by this Lib or do you mean something else?

2) I changed the baudrate in the moduls. On my FEZ Panda everything works fine but the same moduel with same COM Settings connected to my PC I will get allways Timeout exception