XBee C# library API reference

Show / Hide Table of Contents

Class XBeePacket

This abstract class represents the basic structure of an XBee packet.

Inheritance
System.Object
XBeePacket
XBeeAPIPacket
Inherited Members
System.Object.Equals(System.Object, System.Object)
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
Namespace: XBeeLibrary.Core.Packet
Assembly: XBeeLibrary.Core.dll
Syntax
public abstract class XBeePacket
Remarks

Derived classes should implement their own payload generation depending on their type.

Generic actions like checksum compute or packet Length calculation is performed here.

Constructors

XBeePacket()

Class constructor. Instantiates a new XBeePacket object.

Declaration
protected XBeePacket()

Properties

Checksum

The packet checksum.

Declaration
public int Checksum { get; }
Property Value
Type Description
System.Int32
Remarks

To calculate: Not including frame delimiters and Length, add all bytes keeping only the lowest 8 bits of the result and subtract the result from 0xFF.

PacketLength

The packet Length.

Declaration
public int PacketLength { get; }
Property Value
Type Description
System.Int32

PacketParameters

A sorted dictionary with the XBee packet parameters and their values.

Declaration
protected abstract LinkedDictionary<string, string> PacketParameters { get; }
Property Value
Type Description
LinkedDictionary<System.String, System.String>

Parameters

The dictionary with the XBee packet parameters and their values.

Declaration
public LinkedDictionary<string, string> Parameters { get; }
Property Value
Type Description
LinkedDictionary<System.String, System.String>

Methods

Equals(Object)

Returns whether this object is equal to the given one.

Declaration
public override bool Equals(object obj)
Parameters
Type Name Description
System.Object obj

The object to compare if it is equal to this one.

Returns
Type Description
System.Boolean

true if this object is equal to the given one, false otherwise.

Overrides
System.Object.Equals(System.Object)

GenerateByteArray()

Generates the XBee packet byte array.

Declaration
public byte[] GenerateByteArray()
Returns
Type Description
System.Byte[]

The XBee packet byte array.

Remarks

Use only while working in API mode. If working in API_ESCAPE mode, useGenerateByteArrayEscaped().

See Also
GenerateByteArrayEscaped()

GenerateByteArrayEscaped()

Generates the XBee packet byte array escaping the special bytes.

Declaration
public byte[] GenerateByteArrayEscaped()
Returns
Type Description
System.Byte[]

he XBee packet byte array with escaped characters.

Remarks

Use only while working in API_ESCAPE mode. If working in API mode, use GenerateByteArray().

See Also
GenerateByteArray()

GetHashCode()

Returns the Hash code of this object.

Declaration
public override int GetHashCode()
Returns
Type Description
System.Int32

The Hash code of this object.

Overrides
System.Object.GetHashCode()

GetPacketData()

Returns the packet data.

Declaration
public abstract byte[] GetPacketData()
Returns
Type Description
System.Byte[]

The packet data.

ParsePacket(Byte[], OperatingMode)

Parses the given byte array and returns an XBee packet.

Declaration
public static XBeePacket ParsePacket(byte[] packet, OperatingMode mode)
Parameters
Type Name Description
System.Byte[] packet

The byte array to parse.

OperatingMode mode

The operating mode to parse the packet (API or API_ESCAPE).

Returns
Type Description
XBeePacket

The generated XBee Packet.

Remarks

The string can contain white spaces.

Exceptions
Type Condition
System.ArgumentException

If mode != API and if mode != API_ESCAPE or if the length of packet is 0 or if the packet does not have the correct start delimiter.

System.ArgumentNullException

If packet == null.

See Also
API
API_ESCAPE

ParsePacket(String, OperatingMode)

Parses the given hexadecimal string and returns an XBee packet.

Declaration
public static XBeePacket ParsePacket(string packet, OperatingMode mode)
Parameters
Type Name Description
System.String packet

The hexadecimal string to parse.

OperatingMode mode

The operating mode to parse the packet (API or API_ESCAPE).

Returns
Type Description
XBeePacket

The generated XBee Packet.

Remarks

The string can contain white spaces.

Exceptions
Type Condition
System.ArgumentNullException

If packet == null.

See Also
API
API_ESCAPE

ToPrettyString()

Gets a pretty string representation of the packet.

Declaration
public string ToPrettyString()
Returns
Type Description
System.String

Pretty String representation of the packet.

ToString()

Returns the string representation of this packet.

Declaration
public override string ToString()
Returns
Type Description
System.String

The string representation of this packet.

Overrides
System.Object.ToString()
Product page More documentation Official site About Digi Contact us Support
©2019 Digi International Inc. All rights reserved.
Digi International Inc.