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.
Dependencies: mbed PowerControl SDFileSystem
Fork of HeptaBattery by
HeptaXbee.cpp
00001 #include "HeptaXbee.h" 00002 #include "mbed.h" 00003 #include <stdarg.h> 00004 00005 HeptaXbee::HeptaXbee(PinName tx, PinName rx) : xbee(tx,rx) 00006 { 00007 rcmd = 0; 00008 cmdflag = 0; 00009 } 00010 void HeptaXbee::baud(int rate) 00011 { 00012 xbee.baud(rate); 00013 } 00014 void HeptaXbee::xbee_recieve(int *xrcmd, int *xcmdflag) { 00015 xbee.attach(this,&HeptaXbee::commandget,Serial::RxIrq); 00016 //xbee.printf("ssXbeedata= %d,%d",HeptaXbee::rcmd,HeptaXbee::cmdflag); 00017 *xrcmd = HeptaXbee::rcmd; 00018 *xcmdflag = HeptaXbee::cmdflag; 00019 } 00020 00021 void HeptaXbee::initialize(){ 00022 HeptaXbee::rcmd = 0; 00023 HeptaXbee::cmdflag = 0; 00024 } 00025 00026 void HeptaXbee::commandget(){ 00027 HeptaXbee::rcmd=xbee.getc(); 00028 HeptaXbee::cmdflag = 1; 00029 //xbee.printf("Xbeedata= %d,%d",rcmd,cmdflag); 00030 } 00031 void HeptaXbee::putc(char data) 00032 { 00033 xbee.putc(data); 00034 } 00035 void HeptaXbee::xbee_transmit(char* output_data,size_t output_n, 00036 char data1[],char data2[],char data3[],char data4[],char data5[],char data6[],char data7[],char data8[],char data9[], 00037 int n1,int n2,int n3,int n4,int n5,int n6,int n7,int n8,int n9) 00038 { 00039 int N=0,i=0,ii,jj=0; 00040 for(i = 0; i <= n1-1; i++){ 00041 output_data[N+i] = data1[i]; 00042 } 00043 N=i; 00044 for(i = 0; i <= n2-1; i++){ 00045 output_data[N+i] = data2[i]; 00046 } 00047 N=N+i; 00048 for(i = 0; i <= n3-1; i++){ 00049 output_data[N+i] = data3[i]; 00050 } 00051 N=N+i; 00052 for(i = 0; i <= n4-1; i++){ 00053 output_data[N+i] = data4[i]; 00054 } 00055 N=N+i; 00056 for(i = 0; i <= n5-1; i++){ 00057 output_data[N+i] = data5[i]; 00058 } 00059 N=N+i; 00060 for(i = 0; i <= n6-1; i++){ 00061 output_data[N+i] = data6[i]; 00062 } 00063 N=N+i; 00064 for(i = 0; i <= n7-1; i++){ 00065 output_data[N+i] = data7[i]; 00066 } 00067 N=N+i; 00068 for(i = 0; i <= n8-1; i++){ 00069 output_data[N+i] = data8[i]; 00070 } 00071 N=N+i; 00072 for(i = 0; i <= n9-1; i++){ 00073 output_data[N+i] = data9[i]; 00074 } 00075 for(ii=0;ii<output_n;ii++){ 00076 xbee.putc(output_data[ii]); 00077 jj++; 00078 if(jj==2) 00079 { 00080 xbee.putc(0x20); 00081 jj=0; 00082 } 00083 } 00084 xbee.putc(0x0a); 00085 } 00086 void HeptaXbee::puts( char *s ) { 00087 while ( char c = *s++ ) 00088 xbee.putc( c ); 00089 } 00090 void HeptaXbee::printf( char *format, ... ) { 00091 char s[ 32 ]; 00092 va_list args; 00093 00094 va_start( args, format ); 00095 vsnprintf( s, 32, format, args ); 00096 va_end( args ); 00097 00098 xbee.puts( s ); 00099 }
Generated on Fri Jul 15 2022 01:55:16 by
1.7.2
