Code examples and extended information
In the Waspmote Development section you can find complete examples:
https://development.libelium.com/waspmote/code-examples
/*
* ------ WIFI Example --------
*
* Explanation: This example shows how to join an access point (AP)
*
* Copyright (C) 2020 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.
*
* 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: 3.0
* Implementation: Yuri Carmona
*/
#include <WaspWIFI_PRO_V3.h>
uint8_t socket = SOCKET0;
uint8_t error;
uint8_t status;
unsigned long previous;
void setup()
{
USB.println(F("Start program"));
}
void loop()
{
//////////////////////////////////////////////////
// 1. Switch ON
//////////////////////////////////////////////////
error = WIFI_PRO_V3.ON(socket);
if (error == 0)
{
USB.println(F("1. WiFi switched ON"));
}
else
{
USB.println(F("1. WiFi did not initialize correctly"));
}
//////////////////////////////////////////////////
// 2. Join AP
//////////////////////////////////////////////////
// get actual time
previous = millis();
// check connectivity
status = WIFI_PRO_V3.isConnected();
// Check if module is connected
if (status == true)
{
USB.println(F("WiFi is connected OK"));
// ping
error = WIFI_PRO_V3.ping(ip_address);
// check response
if (error == 0)
{
USB.print(F("Ping sent packets = "));
USB.println(WIFI_PRO_V3._pingSent);
USB.print(F("Ping Received packets = "));
USB.println(WIFI_PRO_V3._pingReceived);
USB.print(F("Ping Lost packets = "));
USB.println(WIFI_PRO_V3._pingLost);
USB.print(F("Ping Total Time (ms) = "));
USB.println(WIFI_PRO_V3._pingTime);
USB.print(F("Ping Minimum Time (ms) = "));
USB.println(WIFI_PRO_V3._pingMinTime);
USB.print(F("Ping Maximum Time (ms) = "));
USB.println(WIFI_PRO_V3._pingMaxTime);
}
else
{
USB.println(F("Error calling 'ping' function"));
}
}
else
{
USB.println(F("WiFi is NOT connected"));
}
//////////////////////////////////////////////////
// 3. Switch OFF
//////////////////////////////////////////////////
WIFI_PRO_V3.OFF(socket);
USB.println(F("4. WiFi switched OFF\n\n"));
delay(10000);
}
Last updated