Hello Everyone !
I'm on a project I've started on Arduino Uno Wifi I'm moving on Arduino YÙN Mini and It's almost done except one thing: The wifi.
I figured out that it was working around the same way on the two board except on Yùn, you need to include YunServer.H and YunClient.h so my code on Uno Wifi and Yun Mini is the same on my file wifi.ino.
but there's a DEEEEeeeeeeEEEEP mystery…
get prepared…
It doesn't work on YÙN ! ! ! Whooooosh
Well according to me, even on Arduino Uno Wifi, the wifi is just magic, I think they've put some magic powder in a chip.
I just don't Understand why you must have a path like…
[u]http://arduino.local/arduino/mode[/u]
…or…
[u]http://arduino.local/arduino/digital[/u]
…if you want it to work. Anyway, if someone knows the magic formula, please teach me and… where is Hogwarts ?
Here is my code:
main.ino
#include "headers/preprocessor.h"
// [...]
void setup() { // SETUP
delay(5000);
Serial.begin(115200);
while(!Serial); // waits for Serial Monitor to open
Serial.println(F("\rInitialisation"));
WifiSetup();
Serial.println(F("done"));
// [...]
}// SETUP
void loop(){
PdateUpdate();
wf_process(); // HERE IS THE FUNCTION FOR THE WIFI
tem_led_y(); // témoignage interdiction commutation
if(modeChange){
modeChange = false;
ChangeMode();
}
}
/****************
*MAIN FUNCTIONS*/
void ChangeMode(){
if(delayYunTime(stimeDef(ONOFF_DELAY), yunTime, &timeTrigger)){
Mode = !Mode;// Mode = !Mode
deplServo();// déploie ou retracte le servo f(boo.bit0)
temoignage(); // témoigne du mode de charge
}
else{}
}
/*MAIN FUNCTIONS*
****************/
wifi.ino
void WifiSetup(){
pinMode(13, OUTPUT); // sets PIN 13 as an output
digitalWrite(13, HIGH); // Sets PIN 13 to HIGH
Bridge.begin();
digitalWrite(13, LOW); // Sets PIN 13 to LOW
Wifi.listenOnLocalhost();
Wifi.begin();
Wifi.println("REST Server is up");
Serial.println(F("\rWifi available"));
}
void wf_commutation(){
inter(); // simule une interruption
Serial.println(F("commutation"));
Client.println("HTTP/1.1 200 OK\n");
}
void wf_state(){ // affiche le mode de charge du systeme
Client.println("HTTP/1.1 200 OK\n");
Client.print(F("Mode: "));
if(modeChange) Client.println(F("acc"));
else Client.println(F("eco"));
}
void wf_current(){
Client.println("HTTP/1.1 200 OK\n");
Client.print(F("current: "));
Client.println(current);
}
void wf_contact(){
contact();
}
void wf_error(){
Client.println("HTTP/1.1 404");
Serial.println(F("command not found"));
}
void wf_getd(){
String d = Client.readStringUntil('/');
if(d == "state") wf_state();
else if(d == "voltage") wf_voltage();
else if(d == "current") wf_current();
else wf_error();
}
void wf_process(){
Client = Wifi.accept();
while(Client.available()){
if (Client.readStringUntil('/') == "mode")
wf_switch();
else
Serial.println(F("command not found (process)"));//wf_error();
}
Client.stop();
}
void wf_switch(){
String command = Client.readStringUntil('/');
if (command == "commutation") wf_commutation();
else if (command == "get") wf_getd();
else wf_error();
}
headers/preprocessor.h
#ifndef PREPRO_H
#define PREPRO_H
/****************
* LIBRARIES */
#include <Wire.h>
#include <I2C.h>
#include <time.h>
#include <Servo.h>
#include <Bridge.h>
#include <YunServer.h>
// password for browser configuration panel is : "doghunter"
YunServer Wifi;
#include <YunClient.h>
YunClient Client;
#include <Process.h>
/** LIBRARIES *
****************/
/****************
* HEADERS */
#include "structure.h"
#include "prototype.h"
/** HEADERS *
****************/
/****************
* CONSTANTS */
// [...]
/** CONSTANTS *
****************/
#endif
thank you very much for your help !
lov ya♥