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
00001 #pragma once 00002 #include "Xbee.h" 00003 00004 //Serial pc(USBTX, USBRX); 00005 00006 Xbee::Xbee(PinName tx, PinName rx , PinName rst):_xbee(tx,rx),_rst(rst) 00007 { 00008 _xbee.baud(9600); 00009 } 00010 00011 void Xbee::Reset() 00012 { 00013 _rst = 0; 00014 wait(0.01); 00015 _rst = 1; 00016 wait(0.01); 00017 00018 } 00019 00020 void Xbee::Send(const char& buffer) 00021 { 00022 while(1) 00023 { 00024 if(_xbee.writeable()) 00025 { 00026 _xbee.putc('\0'); 00027 _xbee.putc(buffer); 00028 } 00029 if(_xbee.readable()) 00030 { 00031 _xbee.getc(); 00032 break; 00033 } 00034 } 00035 } 00036 00037 void Xbee::Recv(char& buffer) 00038 { 00039 while(1) 00040 { 00041 if(!_xbee.readable()) 00042 { 00043 _xbee.putc('\0'); 00044 } 00045 else 00046 { 00047 if(_xbee.getc()=='\0'); 00048 { 00049 buffer = _xbee.getc(); 00050 } 00051 break; 00052 } 00053 } 00054 }
Generated on Wed Jul 13 2022 16:50:43 by
