Scroll Yuv-Arduino
Scroll Yuv-Arduino
The circuit:
Arduino YunShield
(or any Yun model with firmware > 1.6.1)
http://www.arduino.cc/en/Tutorial/YunFirstConfig
*/
#include <Process.h>
#define MAX_WIFI_LIST 10
String networks[MAX_WIFI_LIST];
String yunName;
String yunPassword;
void setup() {
SERIAL_PORT_USBVIRTUAL.begin(9600) ; // inicializa la comunicación serial
uint8_t num_networks = 0;
uint8_t i = 0;
char c;
bool dropNet = false;
networks[0].reserve(32);
num_networks = i;
String encryption;
String password;
int chose = 0;
if (encryption.indexOf("none") >= 0) {
openNet = true;
encryption = "none";
}
if (encryption.indexOf("WPA2") >= 0) {
encryption = "psk2";
}
if (encryption.indexOf("WPA") >= 0) {
encryption = "psk";
}
if (encryption.indexOf("WEP") >= 0) {
encryption = "wep";
}
yunName.trim();
yunPassword.trim();
networks[chose].trim();
password.trim();
countryCode.trim();
void loop() {
if (!serialTerminalMode) {
String resultStr = "";
if (!Connected) {
SERIAL_PORT_USBVIRTUAL.print(".");
runs++;
}
delay(1000);
if (resultStr != "") {
// Obtuvimos una IP, congelamos el ciclo, mostramos el valor y "generamos" un terminal en serie
Connected = true;
resultStr.trim();
SERIAL_PORT_USBVIRTUAL.println("");
SERIAL_PORT_USBVIRTUAL.print(F("\nGenial! Ahora puedes contactar a tu Yun desde un
navegador tipeando http: //" ) ) ;
SERIAL_PORT_USBVIRTUAL.println(resultStr);
SERIAL_PORT_USBVIRTUAL.print(F("Presionar la tecla 'Enter' dos veces para iniciar un
terminal en serie "));
resultStr = getUserInput(resultStr, false);
serialTerminalMode = true;
//startSerialTerminal();
SERIAL_PORT_HARDWARE.write((uint8_t *)"\xff\0\0\x05XXXXX\x7f\xf9", 11);
// envíar comando puente de apagado
delay(100);
SERIAL_PORT_HARDWARE.println("\nreset\n\n");
SERIAL_PORT_HARDWARE.flush();
SERIAL_PORT_HARDWARE.println("\nreset\n\n");
SERIAL_PORT_HARDWARE.write((uint8_t *)"\n", 1);
}
} else {
loopSerialTerminal();
}
}
void wifiConfig(String yunName, String yunPsw, String wifissid, String wifipsw, String
wifiAPname, String countryCode, String encryption) {
Process p;
p.runShellCommand("wifi ");
}
void startSerialTerminal() {
SERIAL_PORT_USBVIRTUAL.begin(115200); // abre una conexión serie a través de USB-Serial