A libery to connect to telegesis zigbee module. Bassed on implemtation of XBEE
Fork of xbee_lib by
Diff: xbee.cpp
- Revision:
- 0:2656fb225c5d
- Child:
- 1:c3d9bdcb0b03
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/xbee.cpp Tue Aug 28 14:00:33 2012 +0000 @@ -0,0 +1,92 @@ +#include "xbee.h" + + +xbee::xbee(PinName tx, PinName rx) +{ + _tx = tx; + _rx = rx; +} + +xbee::~xbee() +{ +} + +int xbee::ConfigMode() +{ + int a; + Serial DATA(_tx,_rx); + wait(2); + DATA.printf("+++"); + while (a != 75) { + if (DATA.readable()) { + a = DATA.getc(); + } + } + wait(1); + printf("config mode\n"); + return 1; +} + +int xbee::GetSerial() +{ + int sh1,sh2,sh3,sl1,sl2,sl3,sl4; + Serial DATA(_tx,_rx); + wait_ms(50); + DATA.printf("ATSL \r"); + DATA.scanf ("%2x%2x%2x%2x",&sl1,&sl2,&sl3,&sl4); + wait_ms(500); + DATA.printf("ATSH \r"); + DATA.scanf ("%2x%2x%2x",&sh1,&sh2,&sh3); + + serial_no[0] = sh1; + serial_no[1] = sh2; + serial_no[2] = sh3; + serial_no[3] = sl1; + serial_no[4] = sl2; + serial_no[5] = sl3; + serial_no[6] = sl4; + + return 1; +} + +int xbee::SetKey() +{ + Serial DATA(_tx,_rx); + DATA.printf("ATEE 1 \r"); + + DATA.scanf ("%*s"); + wait_ms(1); + DATA.printf("ATKY %02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x \r", + security_key[0],security_key[1],security_key[2],security_key[3], + security_key[4],security_key[5],security_key[6],security_key[7], + security_key[8],security_key[9],security_key[10],security_key[11], + security_key[12],security_key[13],security_key[14],security_key[15]); + DATA.scanf ("%*s"); + return 1; +} + +int xbee::WriteSettings() +{ + Serial DATA(_tx,_rx); + wait_ms(5); + DATA.printf("ATWR \r"); + DATA.scanf ("%*s"); + return 1; +} + +int xbee::ExitConfigMode() +{ + Serial DATA(_tx,_rx); + wait_ms(5); + DATA.printf("ATCN \r"); + DATA.scanf ("%*s"); + return 1; +} + +int xbee::SendData() +{ + Serial DATA(_tx,_rx); + DATA.printf("%s",sendData); + return 1; +} +