         type = "SPIFFS";
         break;
       default: {
-          const char buff[] = "Unknown type of reprogramming attempt. Rejecting.";
+          char buff[255];
+          snprintf(buff, sizeof(buff), "[%s] Unknown type of reprogramming attempt. Rejecting.", pname);
           Serial.println(buff);
           client.publish(log_topic, buff);
           client.loop();


  if (!strcmp(buff, "report")) {
    reportStats();
    return;
  }


void reportStats() {
  char buff[255];
  snprintf(buff, sizeof(buff),
           "[%s] alive-uptime %02ld:%02ld, "
           "mqtt %s (state %d) "
           "swipes %ld, opens %ld, closes %ld, fails %ld, mis-swipes %ld, mqtt reconnects %ld, mqtt fails %ld, "
           "door %s, state %s(%d), caching %s",
           pname, cnt_minutes / 60, (cnt_minutes % 60),
           client.connected() ? "connected" : "not-connected", client.state(),
           cnt_cards,
           cnt_opens, cnt_closes, cnt_fails, cnt_misreads, cnt_reconnects, cnt_mqttfails,
           isOpen() ? "open" : "closed",
           doorstates_names[doorstate], doorstate,
           caching ? "on" : "off"
          );
  client.publish(log_topic, buff);
  Serial.println(buff);
