So I have been experimenting with Spark Core and its realtime capabilities. I must say it SUCKS!
I ended by sending 10x8 pixels in one UDP packet (80 bytes). My PC is streaming a 10x8 area of predefined pixels unique for each packet. Spark Core will render about 30 screens, then it will hang with cyan light flashing, which means it could not ping the cloud or whatever.
Ok, so I added some delay between each UDP packet on my PC server.
- Thread.Sleep(10) = HANG
- Thread.Sleep(50) = HANG
- Thread.Sleep(100) = SEEMS TO NOT HANG
Updating the core with few more packets looks like DDOS attack
I was trying both TCP and UDP. TCP send like one packet in an hour o_0. Also documentation for TCPclient says client.read() returns -1 when no data, but I never got -1 when saving to int value. For UDP the read() method says it returns the next byte. But does not say what does it return when there’s no next byte.
/* Uncomment the #define below for the desired interface: SPI, SoftSPI, I2C, UART. */
#define _Digole_Serial_SPI_
//#define _Digole_Serial_SoftSPI_
//#define _Digole_Serial_I2C_
//#define _Digole_Serial_UART_
/* Be sure to #include "DigoleSerialDisp.h" *after* the #define above or your compile will fail. */
#include "DigoleSerialDisp.h"
/* Below are sane defaults for the various interfaces. Uncomment one and customize as needed! */
DigoleSerialDisp digole(A2); //SPI
//DigoleSerialDisp digole(D4, D3, D2); //SoftSPI
//DigoleSerialDisp digole(0x27); //I2C
//DigoleSerialDisp digole(115200); //UART
const uint8_t w = 160;
const uint8_t h = 128;
const uint8_t wChunk = 10;
const uint8_t hChunk = 8;
const uint16_t bufferSize = wChunk*hChunk;
const uint16_t localPort = 9000;
uint16_t bytesRead = 0;
uint16_t bytesPos = 0;
uint8_t bitmapData[bufferSize];
UDP client;
byte server[] = { 192, 168, 1, 65 };
void setup() {
Serial.begin(9600);
client.begin(localPort);
digole.begin();
digole.clearScreen();
//digole.print("LOADING...");
for (uint16_t x = 0; x < bufferSize; x++) {
bitmapData[x] = 60;
}
digole.drawBitmap256(0, 0, wChunk, hChunk, bitmapData);
}
void loop() {
uint16_t bytesRead = client.parsePacket();
if (bytesRead > 0) {
//for (uint16_t x = bytesPos; x < bytesRead; x++) {
int byteRead = 0;
byteRead = client.read();
if (byteRead == -1) {
Serial.println("BYTE END");
} else if (bytesPos < bufferSize) {
bitmapData[bytesPos] = byteRead;
//Serial.print("b=");
//Serial.println(bitmapData[bytesPos]);
bytesPos++;
}
//}
}
if (bytesPos >= bufferSize) {
Serial.print("bytesPos=");
Serial.println(bytesPos);
bytesPos = 0;
digole.drawBitmap256(0, 0, wChunk, hChunk, bitmapData);
}
}
I’ve lost two weeks of daily work, because I trusted the core that it can do more than just silly read/write one value per minute. I have to put a specific Spark delay on my PC UDP server, then SPI has some delay when writing data. Loop function has some other delays behind the scenes and then there’s that silly cloud I didn’t even request when ordering or reading about Spark. SRSLY I don’t care about money, I want next-gen tech devices. Looks like classic Arduino+Zigbee, Arduino Yun or dual-core ARM Cortex+dual-core GPU will be better.
BTW: This was possible in 2011 on Arduino with ATMEL: http://q61.org/en/chibimo/build/ …now it’s 2014 and I’m slowed down by some additional software bloat I didn’t even want.