mirror of
https://github.com/alexhopeoconnor/WiFiManager.git
synced 2026-10-04 02:48:13 +10:00
Merge remote-tracking branch 'refs/remotes/tzapu/master'
This commit is contained in:
+33
@@ -0,0 +1,33 @@
|
||||
language: c
|
||||
before_install:
|
||||
- "/sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_1.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :1 -ac -screen 0 1280x1024x16"
|
||||
- sleep 3
|
||||
- export DISPLAY=:1.0
|
||||
- wget http://downloads.arduino.cc/arduino-1.6.5-linux64.tar.xz
|
||||
- tar xf arduino-1.6.5-linux64.tar.xz
|
||||
- sudo mv arduino-1.6.5 /usr/local/share/arduino
|
||||
- sudo ln -s /usr/local/share/arduino/arduino /usr/local/bin/arduino
|
||||
install:
|
||||
- ln -s $PWD /usr/local/share/arduino/libraries/WiFiManager
|
||||
# boards manager not working on 1.6.7 - 1.6.8
|
||||
- arduino --pref "boardsmanager.additional.urls=http://arduino.esp8266.com/stable/package_esp8266com_index.json" --save-prefs
|
||||
# install lib arduino json not working in 1.6.5
|
||||
# - arduino --install-library "ArduinoJson"
|
||||
- git clone https://github.com/bblanchon/ArduinoJson /usr/local/share/arduino/libraries/ArduinoJson
|
||||
- arduino --install-boards esp8266:esp8266
|
||||
- arduino --board esp8266:esp8266:generic --save-prefs
|
||||
- arduino --pref "compiler.warning_level=all" --save-prefs
|
||||
script:
|
||||
- "echo $PWD"
|
||||
- "echo $HOME"
|
||||
- "ls $PWD"
|
||||
- source $TRAVIS_BUILD_DIR/travis/common.sh
|
||||
- build_examples
|
||||
# - "cat $PWD/examples/AutoConnect/AutoConnect.ino"
|
||||
# - arduino -v --verbose-build --verify $PWD/examples/AutoConnect/AutoConnect.ino
|
||||
# - arduino --verify --board arduino:avr:uno $PWD/examples/IncomingCall/IncomingCall.ino
|
||||
# - arduino --verify --board arduino:avr:uno $PWD/examples/AdafruitIO_GPS/AdafruitIO_GPS.ino
|
||||
notifications:
|
||||
email:
|
||||
on_success: change
|
||||
on_failure: change
|
||||
@@ -1,6 +1,8 @@
|
||||
# WiFiManager
|
||||
ESP8266 WiFi Connection manager with fallback web configuration portal
|
||||
|
||||
[](https://travis-ci.org/tzapu/WiFiManager)
|
||||
|
||||
The configuration portal is of the captive variety, so on various devices it will present the configuration dialogue as soon as you connect to the created access point.
|
||||
|
||||
First attempt at a library. Lots more changes and fixes to do. Contributions are welcome.
|
||||
@@ -74,9 +76,11 @@ __Github version works with release 2.0.0 or newer of the [ESP8266 core for Ardu
|
||||
### Using
|
||||
- Include in your sketch
|
||||
```cpp
|
||||
#include <DNSServer.h>
|
||||
#include <ESP8266WebServer.h>
|
||||
#include <WiFiManager.h>
|
||||
#include <ESP8266WiFi.h> //ESP8266 Core WiFi Library (you most likely already have this in your sketch)
|
||||
|
||||
#include <DNSServer.h> //Local DNS Server used for redirecting all requests to the configuration portal
|
||||
#include <ESP8266WebServer.h> //Local WebServer used to serve the configuration portal
|
||||
#include <WiFiManager.h> //https://github.com/tzapu/WiFiManager WiFi Configuration Magic
|
||||
```
|
||||
|
||||
- Initialize library, in your setup function add
|
||||
|
||||
+35
-18
@@ -235,7 +235,7 @@ int WiFiManager::connectWifi(String ssid, String pass) {
|
||||
ETS_UART_INTR_DISABLE();
|
||||
wifi_station_disconnect();
|
||||
ETS_UART_INTR_ENABLE();
|
||||
|
||||
|
||||
WiFi.begin();
|
||||
} else {
|
||||
DEBUG_WM("No saved credentials");
|
||||
@@ -390,37 +390,50 @@ void WiFiManager::handleWifi(boolean scan) {
|
||||
DEBUG_WM(F("No networks found"));
|
||||
page += F("No networks found. Refresh to scan again.");
|
||||
} else {
|
||||
|
||||
//sort networks
|
||||
/*int indices[n];
|
||||
|
||||
for (int i = 0; i < n; i++) {
|
||||
indices[i] = i;
|
||||
}
|
||||
|
||||
for (int i = 0; i < n; i++) {
|
||||
for (int j = i + 1; j < n; j++) {
|
||||
if (WiFi.RSSI(indices[j]) > WiFi.RSSI(indices[i])) {
|
||||
//int temp = indices[j];
|
||||
//indices[j] = indices[i];
|
||||
//indices[i] = temp;
|
||||
std::swap(indices[i], indices[j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
int indices[n];
|
||||
for (int i = 0; i < n; i++) {
|
||||
indices[i] = i;
|
||||
}
|
||||
|
||||
// RSSI SORT
|
||||
|
||||
// old sort
|
||||
// for (int i = 0; i < n; i++) {
|
||||
// for (int j = i + 1; j < n; j++) {
|
||||
// if (WiFi.RSSI(indices[j]) > WiFi.RSSI(indices[i])) {
|
||||
// //int temp = indices[j];
|
||||
// //indices[j] = indices[i];
|
||||
// //indices[i] = temp;
|
||||
// std::swap(indices[i], indices[j]);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
std::sort(indices, indices + n, [](const int & a, const int & b) -> bool
|
||||
{
|
||||
return WiFi.RSSI(a) > WiFi.RSSI(b);
|
||||
});
|
||||
|
||||
// remove duplicates ( must be RSSI sorted )
|
||||
if(_removeDuplicateAPs){
|
||||
String cssid;
|
||||
for (int i = 0; i < n; i++) {
|
||||
if(indices[i] == -1) continue;
|
||||
cssid = WiFi.SSID(indices[i]);
|
||||
for (int j = i + 1; j < n; j++) {
|
||||
if(cssid == WiFi.SSID(indices[j])){
|
||||
DEBUG_WM("DUP AP: " + WiFi.SSID(indices[j]));
|
||||
indices[j] = -1; // set dup aps to index -1
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//display networks in page
|
||||
for (int i = 0; i < n; i++) {
|
||||
if(indices[i] == -1) continue; // skip dups
|
||||
DEBUG_WM(WiFi.SSID(indices[i]));
|
||||
DEBUG_WM(WiFi.RSSI(indices[i]));
|
||||
int quality = getRSSIasQuality(WiFi.RSSI(indices[i]));
|
||||
@@ -697,6 +710,10 @@ void WiFiManager::setCustomHeadElement(const char* element) {
|
||||
_customHeadElement = element;
|
||||
}
|
||||
|
||||
//if this is true, remove duplicated Access Points - defaut true
|
||||
void WiFiManager::setRemoveDuplicateAPs(boolean removeDuplicates) {
|
||||
_removeDuplicateAPs = removeDuplicates;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
+3
-1
@@ -110,7 +110,8 @@ class WiFiManager
|
||||
//TODO
|
||||
//if this is set, customise style
|
||||
void setCustomHeadElement(const char* element);
|
||||
|
||||
//if this is true, remove duplicated Access Points - defaut true
|
||||
void setRemoveDuplicateAPs(boolean removeDuplicates);
|
||||
|
||||
private:
|
||||
std::unique_ptr<DNSServer> dnsServer;
|
||||
@@ -141,6 +142,7 @@ class WiFiManager
|
||||
|
||||
int _paramsCount = 0;
|
||||
int _minimumQuality = -1;
|
||||
boolean _removeDuplicateAPs = true;
|
||||
boolean _shouldBreakAfterConfig = false;
|
||||
boolean _tryWPS = false;
|
||||
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
#!/bin/bash
|
||||
|
||||
function build_examples()
|
||||
{
|
||||
# track the exit code for this platform
|
||||
local exit_code=0
|
||||
# loop through results and add them to the array
|
||||
examples=($(find $PWD/examples/ -name "*.pde" -o -name "*.ino"))
|
||||
|
||||
# get the last example in the array
|
||||
local last="${examples[@]:(-1)}"
|
||||
|
||||
# loop through example sketches
|
||||
for example in "${examples[@]}"; do
|
||||
|
||||
# store the full path to the example's sketch directory
|
||||
local example_dir=$(dirname $example)
|
||||
|
||||
# store the filename for the example without the path
|
||||
local example_file=$(basename $example)
|
||||
|
||||
echo "$example_file: "
|
||||
local sketch="$example_dir/$example_file"
|
||||
echo "$sketch"
|
||||
#arduino -v --verbose-build --verify $sketch
|
||||
|
||||
# verify the example, and save stdout & stderr to a variable
|
||||
# we have to avoid reading the exit code of local:
|
||||
# "when declaring a local variable in a function, the local acts as a command in its own right"
|
||||
local build_stdout
|
||||
build_stdout=$(arduino --verify $sketch 2>&1)
|
||||
|
||||
# echo output if the build failed
|
||||
if [ $? -ne 0 ]; then
|
||||
# heavy X
|
||||
echo -e "\xe2\x9c\x96"
|
||||
echo -e "----------------------------- DEBUG OUTPUT -----------------------------\n"
|
||||
echo "$build_stdout"
|
||||
echo -e "\n------------------------------------------------------------------------\n"
|
||||
|
||||
# mark as fail
|
||||
exit_code=1
|
||||
|
||||
else
|
||||
# heavy checkmark
|
||||
echo -e "\xe2\x9c\x93"
|
||||
fi
|
||||
done
|
||||
|
||||
return $exit_code
|
||||
}
|
||||
Reference in New Issue
Block a user