A libery to connect to telegesis zigbee module. Bassed on implemtation of XBEE
Fork of xbee_lib by
Diff: telegesis.cpp
- Revision:
- 30:f9cdb6f62586
- Parent:
- 29:6711180763b6
- Child:
- 31:c59bc92a047e
--- a/telegesis.cpp Thu Jun 05 17:10:37 2014 +0000 +++ b/telegesis.cpp Fri Nov 28 09:28:26 2014 +0000 @@ -14,6 +14,34 @@ #endif } +size_t zigbee::comma_parse ( char *line, char *list[], size_t size ) +{ + char *p; + size_t n; + + p = line; + n = 0; + for ( ; ; ) { + /* Ditch leading commas */ + while ( *p == ',' ) + p++; + /* Nothing of use */ + if ( *p == '\0' ) + return n; + /* Save the string */ + list[n++] = p; + /* Find the next field */ + while ( *p != ',' && *p != '\0' ) + p++; + /* Nothing else of use or too many fields */ + if ( *p == '\0' || n >= size ) + return n; + /* Split the field */ + *p++ = '\0'; + } +} + + zigbee::~zigbee() { } @@ -164,7 +192,7 @@ // PacketAck=0; _zbee.printf("AT+PANSCAN\r"); - Ok=0; + wait4OK(); return 1; } @@ -330,6 +358,9 @@ In.Ready=1; } } + if (strstr(_responseFrameString,"+PANSCAN:")) { //info om nærliggende pan + + } if (strstr(_responseFrameString,"LeftPAN:")) PanOnline=0; //Local node has left the Pan if (strstr(_responseFrameString,"LostPAN:")) PanOnline=0; //Local node has left the Pan if (strstr(_responseFrameString,"ERROR:")) { @@ -360,10 +391,14 @@ } if (strstr(_responseFrameString,"N=")) { // sscanf (_responseFrameString,"+N=%s,%d,%d,%4X,",Devicetype,&channel,&NodeID,&EPID); + size_t n; p=strstr(_responseFrameString,"="); p++; - strncpy(Devicetype,p,3); - Devicetype[3]=0; //null termination + n=comma_parse(p,list,ZdataSize); + strcpy(Devicetype,list[0]); +// Devicetype[3]=0; //nulterminate + PanChan=atoi(list[1]); + strcpy(PanNumber,list[3]); } if (strstr(_responseFrameString,"ACK")) { // PacketAck=1;