-
Notifications
You must be signed in to change notification settings - Fork 209
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 90ab707
Showing
13 changed files
with
2,789 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# WiFiEsp | ||
|
||
WiFiEsp library allows Arduino board to connect to the internet. | ||
|
||
|
||
##Features | ||
|
||
- Very similar to standard WiFi library. | ||
|
||
|
||
##Contributing | ||
|
||
If you discover a bug or would like to propose a new feature, please open a new [issue](https://github.com/bportaluri/WiFiEsp/issues). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
####################################### | ||
# Syntax Coloring Map For WiFiEsp | ||
####################################### | ||
|
||
####################################### | ||
# Library (KEYWORD3) | ||
####################################### | ||
|
||
WiFiEsp KEYWORD3 | ||
|
||
|
||
####################################### | ||
# Datatypes (KEYWORD1) | ||
####################################### | ||
|
||
WiFiClient KEYWORD1 | ||
WiFiServer KEYWORD1 | ||
|
||
####################################### | ||
# Methods and Functions (KEYWORD2) | ||
####################################### | ||
|
||
firmwareVersion KEYWORD2 | ||
status KEYWORD2 | ||
connect KEYWORD2 | ||
write KEYWORD2 | ||
available KEYWORD2 | ||
config KEYWORD2 | ||
setDNS KEYWORD2 | ||
read KEYWORD2 | ||
flush KEYWORD2 | ||
stop KEYWORD2 | ||
connected KEYWORD2 | ||
begin KEYWORD2 | ||
disconnect KEYWORD2 | ||
macAddress KEYWORD2 | ||
localIP KEYWORD2 | ||
subnetMask KEYWORD2 | ||
gatewayIP KEYWORD2 | ||
SSID KEYWORD2 | ||
BSSID KEYWORD2 | ||
RSSI KEYWORD2 | ||
encryptionType KEYWORD2 | ||
getResult KEYWORD2 | ||
getSocket KEYWORD2 | ||
WiFiClient KEYWORD2 | ||
WiFiServer KEYWORD2 | ||
WiFiUDP KEYWORD2 | ||
beginPacket KEYWORD2 | ||
endPacket KEYWORD2 | ||
parsePacket KEYWORD2 | ||
remoteIP KEYWORD2 | ||
remotePort KEYWORD2 | ||
|
||
|
||
####################################### | ||
# Constants (LITERAL1) | ||
####################################### | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
name=WiFiEsp | ||
version=0.1 | ||
author=bportaluri | ||
maintainer=Bruno Portaluri <bportaluri@gmail.com> | ||
sentence=Arduino WiFi library for ESP8266 | ||
paragraph=Arduino WiFi library for ESP8266 | ||
category=Other | ||
url=https://github.com/bportaluri/WiFiEsp | ||
architectures=* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,226 @@ | ||
|
||
#include "utility/esp_drv.h" | ||
#include "WiFiEsp.h" | ||
|
||
|
||
|
||
WiFiEsp::WiFiEsp(Stream *espSerial, Stream *debugSerial, int resetPin) | ||
{ | ||
espDrv = new EspDrv(espSerial, debugSerial, resetPin); | ||
} | ||
|
||
void WiFiEsp::init() | ||
{ | ||
espDrv->wifiDriverInit(); | ||
} | ||
|
||
uint8_t WiFiEsp::getSocket() | ||
{ | ||
for (uint8_t i = 0; i < MAX_SOCK_NUM; ++i) | ||
{ | ||
if (_server_port[i] == 0) | ||
{ | ||
return i; | ||
} | ||
} | ||
return NO_SOCKET_AVAIL; | ||
} | ||
|
||
|
||
char* WiFiEsp::firmwareVersion() | ||
{ | ||
return espDrv->getFwVersion(); | ||
} | ||
|
||
|
||
|
||
|
||
int WiFiEsp::begin(char* ssid) | ||
{ | ||
/* | ||
uint8_t status = WL_IDLE_STATUS; | ||
uint8_t attempts = WL_MAX_ATTEMPT_CONNECTION; | ||
if (espDrv->wifiSetNetwork(ssid, strlen(ssid)) != WL_FAILURE) | ||
{ | ||
do | ||
{ | ||
delay(WL_DELAY_START_CONNECTION); | ||
status = espDrv->getConnectionStatus(); | ||
} | ||
while ((( status == WL_IDLE_STATUS)||(status == WL_SCAN_COMPLETED))&&(--attempts>0)); | ||
}else | ||
{ | ||
status = WL_CONNECT_FAILED; | ||
} | ||
return status; | ||
*/ | ||
return WL_CONNECT_FAILED; | ||
} | ||
|
||
int WiFiEsp::begin(char* ssid, uint8_t key_idx, const char *key) | ||
{ | ||
/* | ||
uint8_t status = WL_IDLE_STATUS; | ||
uint8_t attempts = WL_MAX_ATTEMPT_CONNECTION; | ||
// set encryption key | ||
if (espDrv->wifiSetKey(ssid, strlen(ssid), key_idx, key, strlen(key)) != WL_FAILURE) | ||
{ | ||
do | ||
{ | ||
status = espDrv->getConnectionStatus(); | ||
} while ((( status == WL_IDLE_STATUS)||(status == WL_SCAN_COMPLETED))&&(--attempts>0)); | ||
}else{ | ||
status = WL_CONNECT_FAILED; | ||
} | ||
return status; | ||
*/ | ||
return WL_CONNECT_FAILED; | ||
} | ||
|
||
int WiFiEsp::begin(char* ssid, const char *passphrase) | ||
{ | ||
if (espDrv->wifiConnect(ssid, passphrase)) | ||
return WL_CONNECTED; | ||
//{ | ||
// uint8_t status = espDrv->getConnectionStatus(); | ||
// return status; | ||
//} | ||
|
||
return WL_CONNECT_FAILED; | ||
} | ||
|
||
void WiFiEsp::config(IPAddress local_ip) | ||
{ | ||
//espDrv->config(1, (uint32_t)local_ip, 0, 0); | ||
} | ||
|
||
void WiFiEsp::config(IPAddress local_ip, IPAddress dns_server) | ||
{ | ||
//espDrv->config(1, (uint32_t)local_ip, 0, 0); | ||
//espDrv->setDNS(1, (uint32_t)dns_server, 0); | ||
} | ||
|
||
void WiFiEsp::config(IPAddress local_ip, IPAddress dns_server, IPAddress gateway) | ||
{ | ||
//espDrv->config(2, (uint32_t)local_ip, (uint32_t)gateway, 0); | ||
//espDrv->setDNS(1, (uint32_t)dns_server, 0); | ||
} | ||
|
||
void WiFiEsp::config(IPAddress local_ip, IPAddress dns_server, IPAddress gateway, IPAddress subnet) | ||
{ | ||
//espDrv->config(3, (uint32_t)local_ip, (uint32_t)gateway, (uint32_t)subnet); | ||
//espDrv->setDNS(1, (uint32_t)dns_server, 0); | ||
} | ||
|
||
void WiFiEsp::setDNS(IPAddress dns_server1) | ||
{ | ||
//espDrv->setDNS(1, (uint32_t)dns_server1, 0); | ||
} | ||
|
||
void WiFiEsp::setDNS(IPAddress dns_server1, IPAddress dns_server2) | ||
{ | ||
//espDrv->setDNS(2, (uint32_t)dns_server1, (uint32_t)dns_server2); | ||
} | ||
|
||
int WiFiEsp::disconnect() | ||
{ | ||
return espDrv->disconnect(); | ||
} | ||
|
||
uint8_t* WiFiEsp::macAddress(uint8_t* mac) | ||
{ | ||
uint8_t* _mac = espDrv->getMacAddress(); | ||
memcpy(mac, _mac, WL_MAC_ADDR_LENGTH); | ||
return mac; | ||
} | ||
|
||
IPAddress WiFiEsp::localIP() | ||
{ | ||
IPAddress ret; | ||
espDrv->getIpAddress(ret); | ||
return ret; | ||
} | ||
|
||
IPAddress WiFiEsp::subnetMask() | ||
{ | ||
IPAddress ret; | ||
espDrv->getSubnetMask(ret); | ||
return ret; | ||
} | ||
|
||
IPAddress WiFiEsp::gatewayIP() | ||
{ | ||
IPAddress ret; | ||
espDrv->getGatewayIP(ret); | ||
return ret; | ||
} | ||
|
||
char* WiFiEsp::SSID() | ||
{ | ||
return espDrv->getCurrentSSID(); | ||
} | ||
|
||
uint8_t* WiFiEsp::BSSID(uint8_t* bssid) | ||
{ | ||
uint8_t* _bssid = espDrv->getCurrentBSSID(); | ||
memcpy(bssid, _bssid, WL_MAC_ADDR_LENGTH); | ||
return bssid; | ||
} | ||
|
||
int32_t WiFiEsp::RSSI() | ||
{ | ||
return espDrv->getCurrentRSSI(); | ||
} | ||
|
||
uint8_t WiFiEsp::encryptionType() | ||
{ | ||
return espDrv->getCurrentEncryptionType(); | ||
} | ||
|
||
|
||
int8_t WiFiEsp::scanNetworks() | ||
{ | ||
uint8_t attempts = 10; | ||
uint8_t numOfNetworks = 0; | ||
|
||
if (espDrv->startScanNetworks() == WL_FAILURE) | ||
return WL_FAILURE; | ||
do | ||
{ | ||
delay(2000); | ||
numOfNetworks = espDrv->getScanNetworks(); | ||
} | ||
while (( numOfNetworks == 0)&&(--attempts>0)); | ||
return numOfNetworks; | ||
} | ||
|
||
char* WiFiEsp::SSID(uint8_t networkItem) | ||
{ | ||
return espDrv->getSSIDNetoworks(networkItem); | ||
} | ||
|
||
int32_t WiFiEsp::RSSI(uint8_t networkItem) | ||
{ | ||
return espDrv->getRSSINetoworks(networkItem); | ||
} | ||
|
||
uint8_t WiFiEsp::encryptionType(uint8_t networkItem) | ||
{ | ||
return espDrv->getEncTypeNetowrks(networkItem); | ||
} | ||
|
||
uint8_t WiFiEsp::status() | ||
{ | ||
return espDrv->getConnectionStatus(); | ||
} | ||
|
||
int WiFiEsp::hostByName(const char* aHostname, IPAddress& aResult) | ||
{ | ||
return espDrv->getHostByName(aHostname, aResult); | ||
} | ||
|
||
|
||
|
||
//WiFiEspClass WiFi; |
Oops, something went wrong.