Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Xbee.cpp
- Committer:
- Xiaofei
- Date:
- 2015-11-28
- Revision:
- 32:a9ba94b949fd
- Parent:
- 31:84e27d1b86a6
- Child:
- 33:70e9e5e5f9d5
File content as of revision 32:a9ba94b949fd:
#pragma once
#include "Xbee.h"
//Serial pc(USBTX, USBRX);
Xbee::Xbee(PinName tx, PinName rx , PinName rst):_xbee(tx,rx),_rst(rst)
{
_xbee.baud(9600);
}
void Xbee::Reset()
{
_rst = 0;
wait(0.01);
_rst = 1;
wait(0.01);
}
void Xbee::Send(const char& buffer)
{
while(1)
{
if(_xbee.writeable())
{
_xbee.putc('\0');
_xbee.putc(buffer);
}
if(_xbee.readable())
{
//Flush();
break;
}
}
}
void Xbee::Recv(char& buffer)
{
while(1)
{
if(!_xbee.readable())
{
_xbee.putc('\0');
}
else
{
if(_xbee.getc()=='\0');
{
buffer = _xbee.getc();
//Flush();
}
break;
}
}
}
void Xbee::Flush()
{
while(_xbee.readable())
{
_xbee.getc();
}
}