i try to send UDP packages with my old spark core. When i’m in auto mode, everything works fine. If i set the core to semi_auto the core crashes after trying todo some UDP stuff ( begin() works but it failed when i try to send a package, doesnt matter if it is send to 192.168.2.255 or to 192.168.2.2).
i read several threads about the issue while sending broadcast messages. the mentioned solution “insert a WiFi.ping()” does not solve my problem. core still stucks.
do i have to go to manual mode to get it working?
i thought i updated my core via “particle flash --factory tinker / particle flash --usb cc3000 / particle flash --usb tinker” but i will try it again this afternoon. is there a way to get the version of the cc3000 fw?
yep, connect to WiFi works fine and also ready etc works (getting correct localIp, gatewayIp, etc). i’m also waiting 1sec after i got a successful WiFi.ready() but still got the issue. Currently i’m not at home, will paste some code in around 1h
edit:
Updated my core, still same failure
Tried manual mode, some failure. only working in auto mode
If i add this code directly after the Wifi.ready() and i’m connected to the internet it works in manual mode! But without internet connection no way grrr
Serial.println("Connect to cloud");
Particle.connect();
while(!Particle.connected()) {
Serial.println("Waiting for cloud connection..");
delay(1000);
}
Particle.disconnect();
Serial.println("Disconnect from cloud");
delay(1000);
I was about to post some of the code that I use to broadcast but it’s basically the same, so no point, but I observe that @ScruffR’s code, and mine, has a time delay before attempting to send another packet. I explicitly coded delay(300) after udp.endpacket(), though cannot remember why I did that.
@timx, @ScruffR, it would seem to me that without a delay, you pretty well guarantee a flood of the send buffer. Since there is no error code return on Udp.endPacket(), there is nothing to indicate a buffer overrun. With the Core, a buffer overrun on the CC3000 is guaranteed to cause problems.
And exactly this might be the reason why AUTOMATIC works and SEMI_AUTOMATIC not.
AUTOMATIC (or cloud connection in SEMI_AUTOMATIC) add an aprox. 1ms delay between two iterations of loop() and hence you’ll not overflow the TX buffer.
At least when you are sending small packets, with bigger packets (1K+) you might even find that AUTOMATIC also crashes.
Edit:
Transfer works with version 1 (dont know why v2 crashes the core), but the reception delivers the correct message length but buffer is filled up with zeros when in semi_auto or manual mode:
/**
* Return 1 if package was available, otherwise 0
*/
int readUpdPackage() {
int rcvd = Udp.parsePacket();
if (rcvd > 0) {
// Read data
Udp.read(buffer, rcvd);
decodeIncomingUdpPackage((unsigned char*)buffer, rcvd);
//more bytes received
if (rcvd > MAX_SIZE) {
Serial.println("Too large packet");
while (Udp.available())
Udp.read();
}
return 1;
}
return 0;
}