Hi novichkov,
Here you have got an example to use with WiFr PRO. We haven't got more example developed to use with Arduino with this module:
Code:
/*
* Wifi Module
*
* Copyright (C) Libelium Comunicaciones Distribuidas S.L.
* http://www.libelium.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* a
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see http://www.gnu.org/licenses/.
*
* Version: 1.0
* Design: David Gascón
* Implementation: Jorge Casanova
*/
//Enter here your data
const char wifi_ssid[] = "libelium_wsn2";
const char wifi_password[] = "libelium.2012_";
const char server[] = "http://test.libelium.com";
const char server_port[] = "80";
const char GET[] = "test-get-post.php?a=1&b=2";
// Global variables
int8_t answer;
char response[300];
char aux_str[90];
#define DATA_BUFFER 1024
String inputLine = ""; // a string to hold incoming line
void setup()
{
//Write here you correct baud rate
Serial.begin(115200);
wifireset();
wificonfig();
// reserve DATA_BUFFER bytes for the inputString:
inputLine.reserve(DATA_BUFFER);
}
void loop()
{
Serial.println(F("INICIO DEL LOOP"));
Serial.println(F("Sending HTTP GET"));
sendGET();
Serial.println(F("FINAL DEL LOOP"));
delay(10000);
}
//**********************************************
void wifireset() {
Serial.println(F("Setting Wifi parameters"));
sendCommand("AT+iFD\r","I/OK",2000);
delay(1000);
sendCommand("AT+iDOWN\r","I/OK",2000);
delay(6000);
}
//**********************************************
void wificonfig() {
Serial.println(F("Setting Wifi parameters"));
sendCommand("AT+iFD\r","I/OK",2000);
delay(2000);
snprintf(aux_str, sizeof(aux_str), "AT+iWLSI=%s\r", wifi_ssid);
answer = sendCommand(aux_str,"I/OK",10000);
if (answer == 1){
snprintf(aux_str, sizeof(aux_str), "Joined to \"%s\"", wifi_ssid);
Serial.println(aux_str);
delay(5000);
}
else {
snprintf(aux_str, sizeof(aux_str), "Error joining to: \"%s\"", wifi_ssid);
Serial.println(aux_str);
delay(1000);
}
snprintf(aux_str, sizeof(aux_str), "AT+iWPP0=%s\r", wifi_password);
sendCommand(aux_str,"I/OK",20000);
delay(1000);
if (answer == 1){
snprintf(aux_str, sizeof(aux_str), "Connected to \"%s\"", wifi_ssid);
Serial.println(aux_str);
delay(5000);
}
else {
snprintf(aux_str, sizeof(aux_str), "Error connecting to: \"%s\"", wifi_ssid);
Serial.println(aux_str);
delay(1000);
}
sendCommand("AT+iDOWN\r","I/OK",2000);
delay(6000);
}
//**********************************************
void sendGET() {
snprintf(aux_str, sizeof(aux_str), "AT+iRLNK:\"%s:%s/%s\"\r", server, server_port, GET);
sendCommand(aux_str,"I/OK",5000);
Serial.print("GET response:");
delay(1000);
handleSerial();
}
//**********************************************
int8_t sendCommand(const char* Command, const char* expected_answer, unsigned int timeout){
uint8_t x=0, answer=0;
unsigned long previous;
memset(response, 0, 300); // Initialize the string
delay(100);
while( Serial.available() > 0) Serial.read(); // Clean the input buffer
Serial.println(Command); // Send Command
x = 0;
previous = millis();
// this loop waits for the answer
do{
if(Serial.available() != 0){
// if there are data in the UART input buffer, reads it and checks for the asnwer
response[x] = Serial.read();
x++;
// check if the desired answer is in the response of the module
if (strstr(response, expected_answer) != NULL)
{
answer = 1;
}
}
}
// Waits for the asnwer with time out
while((answer == 0) && ((millis() - previous) < timeout));
return answer;
}
//**********************************************
void handleSerial()
{
inputLine = "";
while (Serial.available())
{
// get the new byte:
char inChar = (char)Serial.read();
// latency delay for 115200 (worst condition)
delayMicroseconds(105);
// add it to the inputString:
inputLine += inChar;
}
Serial.print(inputLine);
inputLine = "";
delay(100);
}
Regards