I’m using my Particle Photon to connect to WLAN for some time.
I am using the Particle CLI to watch the Serial Monitor. I always got the [hal.wlan] messages to control what’s happening with the WLAN connection. Since some days they randomly disappeared and i can’t get them back.
Some days before i randomly got new [system] log massages, which never appeared before.
I didnt change the code or something else so im curious how this happened. Maybe the Software changed…
Meanwhile i also noticed that the setup function gets executed before WLAN/Cloud connection is ready, i think thats also new behaviour. Since i should be in SYSTEM_MODE(AUTOMATIC), i think this is a wrong behaviour of the software.
Searched for solutions for some time, couldn’t find anything. Enabling the SerialLogHandler logHandler(LOG_LEVEL_ALL) got me some more Logs, but still not the WLAN logs i want.
Can someone help me to get the [hal.wlan] logs back?
Here’s my code:
/* Includes ------------------------------------------------------------------*/
#include <NCD_Ethernet_Overlay.h> //Kommunikation per Ethernet-Shield
#include <Ethernet.h> //Kommunikation per Ethernet-Shield
#include <EthernetClient.h> //Kommunikation per Ethernet-Shield
#include <EthernetServer.h> //Kommunikation per Ethernet-Shield
#include <L3D.h> //Nutzung der LEDs
//SYSTEM_MODE(AUTOMATIC);
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
int serverPort = 5000;
EthernetServer server(serverPort);
SerialLogHandler logHandler;
//SerialLogHandler logHandler(LOG_LEVEL_ALL);
unsigned char buf2[256];
unsigned char buf[256];
int bytesRead = 0;
Cube cube = Cube();
/* This function is called once at start up ----------------------------------*/
void setup()
{
// Wait for a USB serial connection for up to 30 seconds
waitFor(Serial.isConnected, 30000);
delay(1000);
Log.info("Serial connection recognized");
// start the Ethernet connection and obtain an IP from the network DHCP server:
Log.info("Trying to configure Ethernet using DHCP");
for(;;){
if (Ethernet.begin(mac) == 0) {
Log.info("Failed to configure Ethernet using DHCP");
}
else {Log.info("Success to configure Ethernet using DHCP");break;}
}
server.begin(); //Start the server
String localIP = Ethernet.localIP(); // print your local IP address:
Log.info("Server now listening on port %i at IP: %s", serverPort, localIP.c_str());
cube.begin();
}
void loop()
{
EthernetClient client = server.available();
if(client){
Log.info("Client connected");
while(client.connected()){
//Check for data from client
if(client.available() > 0){
bytesRead = client.read(buf, 256);
TCP_function(buf, bytesRead);
std::copy(std::begin(buf2), std::end(buf2), std::begin(buf));
Particle.process();
}
delay(20);
}
Log.info("Client disconnected");
}
delay(20);
}
int TCP_function(unsigned char* buf, int bytesRead){
Log.info("Anzahl gelesene Bytes=%d", bytesRead);
Log.info("Bytes=\"%s\"",buf);
server.write(buf, bytesRead); // echo all available bytes back to the client
return 1;
}