I have been having issues with my electron board. It breathes cyan for few minutes and then loose connection(start flashing green) for like a minute or two. This cycle goes on continuously. I have noticed the same pattern when I upload Electron-Server TCP communication program. Currently, In the code, I have a simple program that communicates with the server through UDP. See the code below.The program works fine ,but after almost every success cycle, it gets interrupted with connection loss…What am I doing wrong or is this common cell network issue? I am using Particle original sim card.
const size_t UDP_BUFFER_SIZE = 513;
const int REMOTE_UDP_PORT = 8081;
const IPAddress REMOTE_UDP_ADDR = IPAddress(xx, xxx, xxx, xxx);
const int LOCAL_UDP_PORT = 8888;
UDP Udp;
void setup() {
Serial.begin(4800);
delay(1000);
Udp.begin(LOCAL_UDP_PORT);
}
void loop() {
char buffer[] = "electronId";
if (Udp.sendPacket(buffer, sizeof(buffer), REMOTE_UDP_ADDR, REMOTE_UDP_PORT) < 0) {
Serial.println("error sending packet");
}
delay(1000);
char message[128];
int rxError = 0;
int count = Udp.receivePacket((byte*)message, 127);
if (count >= 0 && count < 128) {
message[count] = 0;
rxError = 0;
}
else if (count < -1) {
rxError = count;
Udp.begin(LOCAL_UDP_PORT);
}
if (!rxError) {
Serial.println(message);
char messageReceived[] = "Verified";
if (Udp.sendPacket(messageReceived, sizeof(messageReceived), REMOTE_UDP_ADDR, REMOTE_UDP_PORT) < 0) {
Serial.println("error sending Message packet");
}
delay(3000)
}
}