8 years, 1 month ago.  This question has been closed. Reason: Off Topic

Xbee Wifi to Mbed (putc) doesn't work?!

Hi everyone, I am trying to receive a signal from my android to the xbee wifi and from the xbee to my mbed. Then, if the signal is 1 I want to write the data from my mass storage to the xbee and back to the android phone. However, I can receive data on my mbed, but I cannot send the data back to the phone. It seems that putc does not work at all. But I am able to see the data on the terminal of my computer! Can someone please help me to see why I am not able to transmit any data through the rx port of mbed? I am about to give up after several days of debugging!!! :(

Here is my code for data transmission:

include the mbed library with this snippet

#include "mbed.h"
Serial xbee1(p13, p14); 
DigitalOut rst1(p11); 

if(xbee1.readable()) { //See if XBee is readable
            wait(1);
            myled2 = 1;
            RChar = xbee1.getc();
        }
            if (RChar=='1') { //If phone sent a signal, read the csv file

                csv_parser csv;
                csv.reset_record_count();
                csv_row row;
                csv.set_field_term_char(',');
                csv.init("/" FSNAME "/OPC.CSV");
                //printf("\nCSV Initiated\n");
                myled2 = 0; //Turn Led 2 Off

                double TimeStamp;
                myled3 = 1;
                /*while(csv.has_more_rows()&&i<16) {
                    myled3 = 0;
                    row = csv.get_row();
                    i++;
                }*/
                while((csv.has_more_rows()== true) &&i<16) {
                    myled3 = 0;
                    row = csv.get_row();
                    i++;
                }
                if(xbee1.writeable()) {

                    while(csv.has_more_rows()== true) {
                        row = csv.get_row();
                        for (i=0; i<25; i++) {
                            if (i<16 || i>21) {
                                myled3 = 1;
                                //row[i].c_str();
                                //printf("\n %s\n", row[i]);
                                char *cstr = new char[row[i].length() + 1];
                                strcpy(cstr, row[i].c_str());
                                for(j = 0; j < row[i].size(); j++) {
                                    //xbee1.putc('1');
                                    xbee1.putc(cstr[j]); //XBee write whatever the Alphasense OPC-N2 is sending
                                    //printf(" %c", cstr[j]);
                                    wait(0.01);
                                }
                                xbee1.putc(',');
                                //printf(",");
                                myled3 = 0;
                            } else if (i==21) {
                                myled2 = 1;
                                /*char *cstr = new char[row[i].length() + 1];
                                strcpy(cstr, row[i].c_str());
                                TimeStamp = atof(cstr);
                                S= S + TimeStamp + 62.000;
                                time = ctime(&S);
                                strftime(buffer, 32, "%I:%M %p\n", localtime(&seconds));*/
                                //wait(1);
                                //for(j = 0; j < 33; j++) {
                                char *cstr = new char[row[i].length() + 1];
                                strcpy(cstr, row[i].c_str());
                                for(j = 0; j < row[i].size(); j++) {
                                    xbee1.putc(cstr[j]); //XBee write whatever the Alphasense OPC-N2 is sending
                                    //printf(" %c", cstr[j]);
                                    wait(0.01);
                                }
                                //}
                                xbee1.putc(',');
                                //printf(",");
                                myled2 = 0;
                            }
                        }
                        //printf("\n");
                        //xbee1.putc('\n');
                    }

                }

            }