I am using a photon to control a motor. This is connected to a raspberry pi via WiFi and telnet connection.
Everything works beautifully when the photon is cloud connected. But I have a situation where this needs to be used in a non internet connected network. When not able to connect to the cloud, the photon code is not running. Reading the docs I think I need to do the following:
SYSTEM_MODE(MANUAL);
TCPServer server = TCPServer(23);
TCPClient client;
void setup() {
WiFi.onO;
WiFi.connect();
//code to connect the TCPServer and client etc....
}
void loop() {
if (client.connected()) {
// echo all available bytes back to the client
while (client.available()) {
buffer[bytecount] = client.read();
bytecount++;
}
... code to process client message
}
}
When I do this, the telnet connection connects but no message is processed. I have to put the photon in safe mode to recover. I also tried this:
SYSTEM_MODE(MANUAL);
TCPServer server = TCPServer(23);
TCPClient client;
void setup() {
WiFi.onO;
WiFi.connect();
}
void loop() {
Particle.process();
if (client.connected()) {
// echo all available bytes back to the client
while (client.available()) {
buffer[bytecount] = client.read();
bytecount++;
}
... code to process client message
}
}
same results Telnet connects but no message processing.
If I comment out the SYSTEM_MODE statement. Everything works as expected. What am I missing?
Thanks for you help.