SparkFun Forums 

Where electronics enthusiasts find answers.

All things pertaining to wireless and RF links
By Markos13
#184192
Hello i am using an rn-xv 171 and i am trying to upload data on an ftp server..
when i am using the module on gateway mode it works properly and does what i want...when i am trying to upload the commands as a code i am getting an err-?cmd and even if it connects to the wifi after a little bit it never sends the data...http://imgur.com/c1zrnRq this is the error and the code is this

Code: Select all
int cont;
char recv[512];

void setup()
{

Serial.begin(9600);
}

void loop()
{
while (Serial.available()>0) {}
// Enters in command mode
Serial.print("$$$"); check();


// Sets DHCP and TCP protocol
Serial.print("set ip dhcp 1\r"); check();
Serial.print("set ip protocol 2\r"); check();

// Configures the way to join the network AP, sets the encryption of the
// network and joins it
Serial.print("set wlan join 0\r"); check();
Serial.print("set wlan phrase 089F2DC06A\r"); check();
Serial.print("join Thomson81C748\r"); check();
Serial.print("set ftp address 185.4.135.79"); check();
Serial.print("set ftp user username"); check();
Serial.print("set ftp pass password"); check();
Serial.print("set ftp dir ./httpdocs/tasos/"); check();
Serial.print("ftp put anarxia.txt "); check();
Serial.print("hello"); 
Serial.print("set ftp timer 40"); check();

}

void check(){
cont=0; delay(1000);
// Receive the answer from the WIFI module.
while (Serial.available()>0)
{
recv[cont]=Serial.read(); delay(100);
cont++;
}
recv[cont]='\0';
// Print the answer.
Serial.println(recv);
// Clean the buffer to be able to send a command.
Serial.flush(); delay(1000);
}
is there someone that knows why this happends ? i read similar posts in the forum but i couldnt find an answer thats why i am doing this post.Thanks
Last edited by Markos13 on Sat Aug 22, 2015 3:12 am, edited 3 times in total.
By Valen
#184199
Did you send the command sequence $$$ yourself in that serial monitor image? Or are all occurrences of this somehow generated by the program? The 6 dollar signs at the beginning don't make sense.

In the check function, I would add some code to make the very first character of the recv string to be always a known unique symbol. (which isn't used in the command protocol) So then you can identify what is the configuration command sent to the RN-XV, and what is the response from it send by the check function.

p.s. PLease make use of the
Code: Select all
 [/ code] tags or use the button in the full message editor. It shortens the post and shows the code neater.
By Markos13
#184200
Valen wrote:Did you send the command sequence $$$ yourself in that serial monitor image? Or are all occurrences of this somehow generated by the program? The 6 dollar signs at the beginning don't make sense.

In the check function, I would add some code to make the very first character of the recv string to be always a known unique symbol. (which isn't used in the command protocol) So then you can identify what is the configuration command sent to the RN-XV, and what is the response from it send by the check function.

p.s. PLease make use of the
Code: Select all
 [/ code] tags or use the button in the full message editor. It shortens the post and shows the code neater.[/quote]

sry for the code tags.No thats the thing...all these are generated by the program.When i put all this commands by myself on gateway mode it works perfectly but when i use this code i am getting these erros (err-?cmd) and i dont understand why. :/ also because i am kind of newbie could you explain me what you mean about putting a unique symbol ? i am building the code piece by piece from what i find on internet and from the help that i get.Thanks for your reply
By Valen
#184203
Something like this:
Code: Select all
void check(){
cont=0;
recv[cont]='@'; // Start with 'answer' symbol in recv string.
cont++;
delay(1000);

...
I think it is better to learn the various commands available in Arduino, and the language elements in C/C++ and play around with that. Just copying code from someone else is not going to make lightbulbs flash on in your head.

Or replace with some other character that does not exist in the command repertoire . I don't know what the available commands are for this module.
By Markos13
#184218
Unfortunately nothing changed :/ i believe that i have an idea what the problem could be.when the program is typing a command it serial prints it. When i am getting the answer with void check(),to print it to the UART i also serial print it so it sends it to the wifi module and this messes the things cause the module doesnt understand the command and gives an err-?cmd(error for false command)...does this theory sound right? Is there something that i can do to fix it?
By jremington
#184222
Code: Select all
// Print the answer.
Serial.println(recv);
The above appears to send the RN-XV response back to the RN-XV, which doesn't make much sense.
You seem to be trying to use the serial output to send data to the serial monitor as well as to the RN-XV. You can't. You can use the serial port to talk to only one device at a time.

You should delete this delay() call.
Code: Select all
recv[cont]=Serial.read(); delay(100);
By Markos13
#184227
If i delete the delay it will make any difference? Yes i understood that and thats why i probably get these erros,cause i am sending the answer back to the module. If i erase the check() function nothing is happening..i am not getting an AOK confirmation :/ so i have no idea what to do.
By jremington
#184230
Why did you put the delay there? It serves no purpose other than to miss incoming characters.

You need two serial ports to configure the module, if you want to see the responses.
By Markos13
#184232
And how can i have 2? If i delete this function that shows me the response the program just prints the commands and its like it doesnt sending them to the module :/ the weird thing is that even with the errors at some point it connects to the network but the ftp commands never work.At gateway mode when i put the commands i send the file and i print what i want in it.
By Markos13
#184236
They said me about softwareserial in another forum that i asked for help. I tried to look for a tutorial or something to explain how to do it on my situation but i didnt find something :/ i tried to do it by myself but i didnt come to any result. I have an arduino UNO and i cant use arduino mega.Please if you could provide me with some example or some hints i would really appreciate because what i am trying to do is for my university project.
By Markos13
#184239
I will take a look at this,look for examples and try to understand.I will post again when i have an update :) thanks for now.
By Markos13
#184390
So i didnt have any luck with the softwareserial or the example that you posted :/ in softwareserial to work should i change with jumpers the tx-rx from the xbee communication shield and put 2 others so the module can recieve the data? I dont seem to understand :/