A libery to connect to telegesis zigbee module. Bassed on implemtation of XBEE
Fork of xbee_lib by
Diff: telegesis.cpp
- Revision:
- 28:c724a8921f01
- Parent:
- 27:a38b67f5be8f
- Child:
- 29:6711180763b6
--- a/telegesis.cpp Fri Jan 10 16:30:36 2014 +0000 +++ b/telegesis.cpp Fri May 09 10:40:27 2014 +0000 @@ -8,6 +8,7 @@ _tx = tx; _rx = rx; _zbee.baud(19200); + Ok=1; PacketAck=1; #ifdef IRQCtrl _zbee.attach(this, &zigbee::SeePacket, Serial::RxIrq); #endif @@ -21,18 +22,12 @@ { //read and waits for the packet bool datain=false; - Timer t; - t.reset(); - t.start(); b=0; -// while((b!=CR) && (t.read_ms() < 200)) - if (_zbee.readable()) { + if (_zbee.readable()) { datain=true; SeePacket(); - } - t.stop(); + } return datain; - //if (_zbee.readable()) readPacket(); } bool zigbee::wait4str(char *p) //joinpan @@ -139,13 +134,16 @@ int zigbee::Reset() { + PacketAck=0; _zbee.printf("ATZ\r"); wait4OK(); + return 1; } int zigbee::ATI() { + PacketAck=0; GetSerial(); return 1; } @@ -154,6 +152,7 @@ int zigbee::PingOut() { //just return a OK (sends it ID out out the pan) + PacketAck=0; _zbee.printf("AT+ANNCE\r"); wait4OK(); return 1; @@ -163,7 +162,9 @@ int zigbee::PanScan() { // + PacketAck=0; _zbee.printf("AT+PANSCAN\r"); + Ok=0; return 1; } @@ -171,6 +172,7 @@ int zigbee::Establish_Network() { // + PacketAck=0; _zbee.printf("AT+EN\r"); wait4JPAN(); wait4OK(); @@ -180,6 +182,7 @@ int zigbee::LeaveNetwork() { + PacketAck=0; _zbee.printf("AT+DASSL\r"); wait4OK(); wait4Offline(); @@ -188,34 +191,42 @@ int zigbee::JoinNetwork() { + PacketAck=0; _zbee.printf("AT+JN\r"); + Ok=0; return 1; } int zigbee::ScanNetwork() { + PacketAck=0; _zbee.printf("AT+SN\r"); - return 1; + Ok=0; + return 1; } int zigbee::NetworkInfo() { //Return something like this "+N=COO,12,-11,29F0,55C0E0DCE605C522" + PacketAck=0; _zbee.printf("AT+N\r"); - wait4OK(); + Ok=wait4OK(); return 1; } int zigbee::UniCast(char *adr,char *payload) //Ascii mode with null terminated string { + PacketAck=0; _zbee.printf("AT+UCAST:%s=%s\r",adr,payload); // printf("AT+UCAST:%s=%s\r",adr,payload); // _zbee.scanf ("UCAST:%X,%X=%s ",&EUI64,&framesize,Zdata); + Ok=0; return 1; } int zigbee::UniCastb(char *adr,char *payload, char payloadSize) //sends data in binary format { + PacketAck=0; _zbee.printf("AT+UCASTB:%X,%s\r",adr,payloadSize); //_zbee.scanf ("%*s"); return 1; @@ -337,7 +348,8 @@ if ((strstr(_responseFrameString,"OK")>0) && (strstr(_responseFrameString,"TOKDUMP")==0) ) { //if (ScriptState) ConnectScript(); - //Ok=1; Cmd=0; LineNo=0; + Ok=1; + //Cmd=0; LineNo=0; } if (strstr(_responseFrameString,"FFD:")) { //FFD:000D6F00026C5BEA,0000