Hi Scruff
- Not yet, but I will now you mention it.
- I will check, at first I thought I’d be well within maximum clients, but then I started adding up and thought maybe not…
- System version SYSTEM_THREAD(ENABLED) on one of the affected devices and DEFAULT on another.
- I’ve thought about it…but at the moment (been spending quite a bit on this stuff recently!) budget doesn’t allow for the upgrade. It will eventually.
As requested, the code from my most stubborn Core, which is either dropping out, or giving hard faults (seen in Console ‘events’ view) or giving Panic, 11 code.
It’s worth mentioning here that I’ve just ordered a replacement WiFi Router. I’m not convinced that the router isn’t the cause of my woes. Using the @hirotakaster MQTT library and some Particle to Particle code ‘borrowed’ from elsewhere on this forum.
#include "MQTT.h"
constexpr char * DEVICE_NAME = "NETPEX";
constexpr char * BELL_MSSG = "BELL!";
constexpr char * KDS_MSSG = "warehousedoor shut";
constexpr char * KDO_MSSG = "warehousedoor open";
constexpr char * KDB_MSSG = "warehousedoor bolted.";
constexpr char * KDU_MSSG = "warehousedoor unbolted";
constexpr char * FDL_MSSG = "sales locked";
constexpr char * FDUL_MSSG = "sales unlocked";
constexpr char * FDO_MSSG = "sales open";
constexpr char * FDS_MSSG = "sales shut";
constexpr char * NETPEXHOME_MSSG = "NetPex Home!";
constexpr char * MGRHOME_MSSG = "Manager Home!";
void eventHandler(const char * event,
const char * data);
void callback(char * topic, byte * payload, unsigned int length);
byte server[] = {192,168,0,110};
MQTT client(server, 1883, callback);
// recieve message
void callback(char * topic, byte * payload, unsigned int length) {
char p[length + 1];
memcpy(p, payload, length);
p[length] = NULL;
if (!strcmp(p, "netpexhome"))
//Particle.publish(DEVICE_NAME, NETPEXHOME_MSSG, 60, PRIVATE);
Serial.println(F("dd"));
else if (!strcmp(p, "mgrhome"))
//Particle.publish(DEVICE_NAME, MGRHOME_MSSG, 60, PRIVATE);
Serial.println(F("woo"));
else if (!strcmp(p, "BLUE"))
Serial.println(F("woo"));
else
RGB.color(255, 255, 255);
delay(1000);
}
void setup() {
RGB.control(true);
client.connect("sparkclient");
Particle.subscribe(DEVICE_NAME, eventHandler, MY_DEVICES);
if (client.isConnected()) {
client.subscribe("home-assistant/home");
}
}
void loop() {
if (client.isConnected())
client.loop();
else {
delay(30000);
System.reset();
Particle.process();
reconnect();
Particle.process();
client.connect("sparkclient");
Particle.process();
}
}
void reconnect() {
while (Particle.connected() == false) {
RGB.color(0, 0, 0);
Particle.connect();
delay(1000);
}
RGB.color(0, 0, 0);
delay(1000);
}
void eventHandler(const char * event,
const char * data) {
if (strcmp(data, KDB_MSSG) == 0) {
client.publish("home-assistant/warehouse/lock", "ON");
}
else if (strcmp(data, KDU_MSSG) == 0) {
client.publish("home-assistant/warehouse/lock", "OFF");
}
else if (strcmp(data, KDO_MSSG) == 0) {
client.publish("home-assistant/warehouse/door", "ON");
}
else if (strcmp(data, KDS_MSSG) == 0) {
client.publish("home-assistant/warehouse/door", "OFF");
}
else if (strcmp(data, FDL_MSSG) == 0) {
client.publish("home-assistant/sales/lock", "ON");
}
else if (strcmp(data, FDUL_MSSG) == 0) {
client.publish("home-assistant/sales/lock", "OFF");
}
else if (strcmp(data, FDO_MSSG) == 0) {
client.publish("home-assistant/sales/door", "ON");
}
else if (strcmp(data, FDS_MSSG) == 0) {
client.publish("home-assistant/sales/door", "OFF");
}
else if (strcmp(data, BELL_MSSG) == 0) {
client.publish("home-assistant/bell", "ON");
}
}