Skip to content

Instantly share code, notes, and snippets.

@eashi
Last active December 6, 2015 11:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eashi/800bdfd866c3c64b0bbd to your computer and use it in GitHub Desktop.
Save eashi/800bdfd866c3c64b0bbd to your computer and use it in GitHub Desktop.
Put XBee to Command Mode
try
{
byte[] bytes;
using (var stream = new OutputStream())
{
stream.Write("+++");
bytes = stream.ToArray();
}
Thread.Sleep(1000);
xBeeAdapter.Port.Write(bytes);
Thread.Sleep(1000);
while (xBeeAdapter.Port.BytesToRead > 0)
{
var bytesToRead = new byte[xBeeAdapter.Port.BytesToRead];
xBeeAdapter.Port.Read(bytesToRead, 0, xBeeAdapter.Port.BytesToRead);
}
xBeeAdapter.Port.Close();
}
catch (Exception ex)
{
Debug.Print(ex.Message);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment