A libery to connect to telegesis zigbee module. Bassed on implemtation of XBEE

Fork of xbee_lib by Tristan Hughes

Revision:
34:1b57f1110d59
Parent:
33:101f953225a6
Child:
35:4dec73b3e5a0
diff -r 101f953225a6 -r 1b57f1110d59 telegesis.cpp
--- a/telegesis.cpp	Sun Feb 22 10:08:09 2015 +0000
+++ b/telegesis.cpp	Thu Mar 05 20:46:05 2015 +0000
@@ -125,6 +125,14 @@
     //   wait_ms(5);
     return 1;
 }
+bool zigbee::ReadReg(char *Reg){  
+   _zbee.printf("ATS%s?\r",Reg);
+   readPacket();  
+   readPacket();  
+   readPacket();  
+   strcpy(RegData,_responseFrameString);  
+   return wait4OK();
+}    
 
 int zigbee::SetKey(char* key)
 {
@@ -136,10 +144,11 @@
     for them, so it is easiest to just set bits 8, 4, and 2 in all devices which gives S0A=0114.
     */
     char psw[50];
-    sprintf(psw,"ATS09=%s;password\r",key);
+    sprintf(psw,"ATS09=%s:password\r",key);
     _zbee.printf(psw);
     wait4OK();
-    _zbee.printf("ATS0A=0114;password\r");
+    _zbee.printf("ATS0A=0114:password\r"); //(For simplicity, you can set bits 8, 4 and 2 of S0A on every device
+    wait4OK();    
     return 1;
 }
 
@@ -209,6 +218,12 @@
     return 1;
 }
 
+int zigbee::SetOutputLevel()
+{
+    PacketAck=0;
+    _zbee.printf("ATS01=-7\r");
+    return wait4OK();
+}
 
 int zigbee::LeaveNetwork()
 {
@@ -313,11 +328,10 @@
         _pos=(_pos+1) % MAX_FRAME_DATA_SIZE;
     }
     if (b==CR) {
-        //  memcpy(&_responseFrameString,&_responseFrameData,_pos);
         GotFrame=1;
         _responseFrameString[_pos]=0; //Nul terminate
         _pos=0;
-      //  printf("%s \r\n",_responseFrameString);
+
         if (strstr(_responseFrameString,"+UCAST:")) { //returns on that we have sendt something
             //Do something
         } else if (strstr(_responseFrameString,"UCAST:")) { //checke for incoming UCAST data
@@ -369,7 +383,7 @@
             NetInfo=1;
             strncpy(NetNodeID,p,16);            
         }
-        if (strstr(_responseFrameString,"N=")) {
+        if (strstr(_responseFrameString,"+N=")) {
             //        sscanf (_responseFrameString,"+N=%s,%d,%d,%4X,",Devicetype,&channel,&NodeID,&EPID);
             size_t n;
             p=strstr(_responseFrameString,"=");
@@ -377,7 +391,7 @@
             n=comma_parse(p,list,ZdataSize);
             strcpy(Devicetype,list[0]);
             AktuelPan.channel=atoi(list[1]);
-            strcpy(AktuelPan.PID,list[3]);  
+            strncpy(AktuelPan.PID,list[3],4);  
         }
         if (strstr(_responseFrameString,"ACK")) { //
             PacketAck=1;