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.
Zigbee_control.cpp
00001 #include "Zigbee_control.h" 00002 00003 DigitalOut led(LED1); 00004 Serial xbee1(p13, p14); 00005 DigitalOut rst1(p11); 00006 DigitalOut test(p9); 00007 Serial pc(USBTX, USBRX); 00008 00009 void Zigbee_setup(void) 00010 { 00011 xbee1.attach(&callback); 00012 } 00013 void send_Zigbee_string(char c[]) 00014 { 00015 led =0; 00016 int i=0; 00017 while(c[i]!='\0'){ 00018 xbee1.putc(c[i]); 00019 pc.putc(c[i]); 00020 i++; 00021 led =1; 00022 } 00023 xbee1.putc('\n'); 00024 led =0; 00025 00026 } 00027 00028 char recieve_Zigbee_char(void) 00029 { 00030 return xbee1.getc(); 00031 } 00032 00033 void send_Zigbee_char(char x) 00034 { 00035 if(x=='\r') 00036 x = '\n'; 00037 xbee1.putc(x); 00038 00039 } 00040 00041 bool Zigbee_status(void) 00042 { 00043 return xbee1.readable(); 00044 } 00045 00046 void callback() 00047 { 00048 test =1; 00049 led =1; 00050 char c = xbee1.getc(); 00051 test =0; 00052 led =0; 00053 } 00054 char *read_Zigbee_string(void) 00055 { 00056 static char retstr[256]; 00057 int i=0; 00058 retstr[i] = recieve_Zigbee_char(); 00059 while(retstr[i] != '\\'){ 00060 if(Zigbee_status()){ 00061 i++; 00062 // z = read_Zigbee_string(); 00063 retstr[i]= recieve_Zigbee_char(); 00064 } 00065 } 00066 retstr[i++]='\0'; 00067 00068 return retstr; 00069 }
Generated on Sat Jul 23 2022 13:28:29 by
1.7.2