Well, adding the SYSTEM_THREAD(ENABLED) has messed up my message publishing. Many of my published events simply fail to show up. I switched from PublishQueueAsync to PublishQueue, but that didn’t help. Any ideas on that? The code looks as follows:
PublishQueue publishQueue(1000, false);
void MyClass::Publish(const char *format, ...)
{
va_list arg;
static char szLine[65];
va_start (arg, format);
vsnprintf(szLine, sizeof(szLine), format, arg);
va_end (arg);
static char who[32] = "";
if (who[0] == 0)
{
char *ptr = strchr(VERSION, ',');
memset(who, sizeof(who), 0);
strncpy(who, VERSION, ptr - VERSION);
}
publishQueue.publish(who, szLine);
}
//Public Members
void PublishQueue::Publish(String eventName, String data)
{
node my_node= {.eventName=eventName, .data=data};
//Debug("Adding to queue: "+ my_node.eventName);
my_queue.push(my_node);
Process();
}
void PublishQueue::Process()
{
//if (my_queue.size()>0)
//{Debug("Queue size: "+String(my_queue.size())+" _IsReadyToProcess():"+String(_IsReadyToProcess()) + " wait="+String(_intervalMillis-(millis()-lastMillis)));}
//If queue is not empty process the next event.
if (!my_queue.empty() && _IsReadyToProcess()) {
node my_node=my_queue.front();
my_queue.pop();
if (_bSerial1)
{
Serial1.println(my_node.data);
Serial1.flush();
}
else
Particle.publish(my_node.eventName, my_node.data, 60, PRIVATE, WITH_ACK);
lastMillis=millis(); //Update the time we last published
}
}
And in loop and Delay (my delay function) I call publishQueue.Process().
If I comment out the SYSTEM_THREAD(ENABLED) line, they show up fine (both with Async and non).
Thoughts?