kamill
kamill:
Remarque: appeler partout la fonction par le tableau avec un index c'est très lourd. Tu aurais mieux fait de définir une fonction void do_debugging(char *)
Avant tout merci
Préalablement je utilise des .h (credentials.h, ...)
#define mySSID "WiFi SSID"; // WiFi SSID
#define myPASSWORD "WiFi PASSWORD"; // WiFi PASSWORD
#define myHostname "do_debug"; // hostname
// 0 > None_debugging
// 1 > Serial_debugging
// 2 > Telnet_debugging
#define myDebugging_set "1";
Si je use .cpp pour les déclararer les #define les variables sont pas là.
Quel bon usage conseilles tu?
Pour un int comme
const myDebugging_set= myDebugging_set;
#define myDebugging_set "1"; c'est bon??
je suis bloqué avec trop problèmes de compilation !!!
#include "credentials.h" // credentials.h include
#include "do_debugging.cpp"
#include "papy_wifi_proc.cpp"
void setup() {
//------------------------------------------------Serial
Serial.begin(115200);
while (!Serial) {} // phase développement
Serial.println("");
Serial.println("Booting + Serial");
delay(500);
do_debugging("");
do_debugging("Booting + Serial");
//-----------------------------------------------GPIO
//----------------------------------------------LittleFS
//-----------------------------------------------WIFI
papy_wifi_proc();
//-----------------------------------------------OTA
//-----------------------------------------------SERVER
delay(500);
do_debugging("");
do_debugging("Booting + Serial");
}
void loop() {
do_debugging("hello");
delay(5000);
}
#include <TelnetStream2.h>
const int debugging_set = myDebugging_set;
void do_debugging(char *text) {
swich (debugging_set) {
case 0:
break;
case 1:
Serial.println(debugging_set);
break;
case 2:
TelnetStream2.println(debugging_set);
break;
}
}
#include <WiFi.h>
#include <WiFiClient.h>
#include <DNSServer.h>
DNSServer dnsServer;
const char* ssid = mySSID;
const char* password = myPASSWORD;
const char* WiFi_hostname = myHostname;
//Static IP address configuration
IPAddress staticIP(192, 168, 1, 81); //ESP8266 static ip
IPAddress gateway(192, 168, 1, 1); //IP Address of your WiFi Router (Gateway)
IPAddress subnet(255, 255, 255, 0); //Subnet mask
IPAddress dns(192, 168, 1, 1); //DNS
void papy_wifi_proc() {
WiFi.setAutoConnect(false);
WiFi.disconnect(); //Prevent connecting to wifi based on previous configuration
delay(500);
do_debugging("Disconnect");
WiFi.mode(WIFI_STA); //WiFi mode station (connect to wifi router only)
// This part of code will try create static IP address
if (!WiFi.config(staticIP, gateway, subnet, dns, dns))
{
do_debugging("STA Failed to configure");
}
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
do_debugging("!");
}
do_debugging("");
do_debugging("Hostname to ");
do_debugging(WiFi_hostname);
do_debugging("");
do_debugging("Connected to ");
do_debugging(ssid);
do_debugging("IP address: ");
do_debugging(WiFi.localIP());
if (WiFi.setHostname(WiFi_hostname)) {
do_debugging("\nHostname set!\n");
} else {
do_debugging("\nHostname NOT set!\n");
}
}
do_debugging.cpp:5:27: error: 'myDebugging_set' was not declared in this scope
const int debugging_set = myDebugging_set;
^
sketch\do_debugging.cpp: In function 'void do_debugging(char*)':
do_debugging.cpp:8:23: error: 'swich' was not declared in this scope
swich (debugging_set) {
^
papy_wifi_proc.cpp:8:20: error: 'mySSID' was not declared in this scope
const char* ssid = mySSID;
^
papy_wifi_proc.cpp:9:24: error: 'myPASSWORD' was not declared in this scope
const char* password = myPASSWORD;
^
papy_wifi_proc.cpp:10:29: error: 'myHostname' was not declared in this scope
const char* WiFi_hostname = myHostname;
^
sketch\papy_wifi_proc.cpp: In function 'void papy_wifi_proc()':
papy_wifi_proc.cpp:22:28: error: 'do_debugging' was not declared in this scope
do_debugging("Disconnect");
^
..........
boom aïe aïe aïe
Merci