better output

This commit is contained in:
Owen 2021-05-09 11:56:29 +02:00
parent 3a5641cc25
commit 7fcb973e30
2 changed files with 41 additions and 44 deletions

View File

@ -49,6 +49,8 @@ extern char httpURL[];
extern char streamURL[]; extern char streamURL[];
extern char default_index[]; extern char default_index[];
extern int8_t streamCount; extern int8_t streamCount;
extern unsigned long streamsServed;
extern unsigned long imagesServed;
extern int myRotation; extern int myRotation;
extern int lampVal; extern int lampVal;
extern bool autoLamp; extern bool autoLamp;
@ -61,11 +63,6 @@ extern int sketchSize;
extern int sketchSpace; extern int sketchSpace;
extern String sketchMD5; extern String sketchMD5;
// Counters for connection and client debug/info
uint8_t connectedClients = 0;
unsigned long streamsServed = 0;
unsigned long imagesServed = 0;
#include "fb_gfx.h" #include "fb_gfx.h"
#include "fd_forward.h" #include "fd_forward.h"
@ -253,15 +250,12 @@ static int run_face_recognition(dl_matrix3du_t *image_matrix, box_array_t *net_b
} }
void serialDump() { void serialDump() {
Serial.println("\nSerial Dump."); Serial.println("\nPreferences file: ");
Serial.println("Preferences file: ");
dumpPrefs(SPIFFS); dumpPrefs(SPIFFS);
if (critERR.length() > 0) { if (critERR.length() > 0) {
Serial.printf("\n\nA critical error has occurred when initialising Camera Hardware, see startup megssages\n"); Serial.printf("\n\nA critical error has occurred when initialising Camera Hardware, see startup megssages\n");
Serial.printf("%s\n\n", critERR.c_str());
} }
// Module // Module
Serial.println("Module:");
Serial.printf("Name: %s\n", myName); Serial.printf("Name: %s\n", myName);
Serial.printf("Firmware: %s (base: %s)\n", myVer, baseVersion); Serial.printf("Firmware: %s (base: %s)\n", myVer, baseVersion);
float sketchPct = 100 * sketchSize / sketchSpace; float sketchPct = 100 * sketchSize / sketchSpace;
@ -269,41 +263,38 @@ void serialDump() {
Serial.printf("MD5: %s\n", sketchMD5.c_str()); Serial.printf("MD5: %s\n", sketchMD5.c_str());
Serial.printf("ESP sdk: %s\n", ESP.getSdkVersion()); Serial.printf("ESP sdk: %s\n", ESP.getSdkVersion());
// Network // Network
Serial.println("WiFi:");
if (accesspoint) { if (accesspoint) {
if (captivePortal) { if (captivePortal) {
Serial.printf("Mode: AccessPoint with captive portal\n"); Serial.printf("WiFi Mode: AccessPoint with captive portal\n");
} else { } else {
Serial.printf("Mode: AccessPoint\n"); Serial.printf("WiFi Mode: AccessPoint\n");
} }
Serial.printf("SSID: %s\n", apName); Serial.printf("WiFi SSID: %s\n", apName);
} else { } else {
Serial.printf("Mode: Client\n"); Serial.printf("WiFi Mode: Client\n");
String ssidName = WiFi.SSID(); String ssidName = WiFi.SSID();
Serial.printf("Ssid: %s\n", ssidName.c_str()); Serial.printf("WiFi Ssid: %s\n", ssidName.c_str());
Serial.printf("Rssi: %i\n", WiFi.RSSI()); Serial.printf("WiFi Rssi: %i\n", WiFi.RSSI());
String bssid = WiFi.BSSIDstr(); String bssid = WiFi.BSSIDstr();
Serial.printf("BSSID: %s\n", bssid.c_str()); Serial.printf("WiFi BSSID: %s\n", bssid.c_str());
} }
Serial.printf("IP address: %d.%d.%d.%d\n", ip[0], ip[1], ip[2], ip[3]); Serial.printf("WiFi IP address: %d.%d.%d.%d\n", ip[0], ip[1], ip[2], ip[3]);
if (!accesspoint) { if (!accesspoint) {
Serial.printf("Netmask: %d.%d.%d.%d\n", net[0], net[1], net[2], net[3]); Serial.printf("WiFi Netmask: %d.%d.%d.%d\n", net[0], net[1], net[2], net[3]);
Serial.printf("Gateway: %d.%d.%d.%d\n", gw[0], gw[1], gw[2], gw[3]); Serial.printf("WiFi Gateway: %d.%d.%d.%d\n", gw[0], gw[1], gw[2], gw[3]);
} }
Serial.printf("Http port: %i, Stream port: %i\n", httpPort, streamPort); Serial.printf("WiFi Http port: %i, Stream port: %i\n", httpPort, streamPort);
byte mac[6]; byte mac[6];
WiFi.macAddress(mac); WiFi.macAddress(mac);
Serial.printf("MAC: %02X:%02X:%02X:%02X:%02X:%02X\n", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); Serial.printf("WiFi MAC: %02X:%02X:%02X:%02X:%02X:%02X\n", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
// System // System
Serial.println("System:");
int64_t sec = esp_timer_get_time() / 1000000; int64_t sec = esp_timer_get_time() / 1000000;
int64_t upDays = int64_t(floor(sec/86400)); int64_t upDays = int64_t(floor(sec/86400));
int upHours = int64_t(floor(sec/3600)) % 24; int upHours = int64_t(floor(sec/3600)) % 24;
int upMin = int64_t(floor(sec/60)) % 60; int upMin = int64_t(floor(sec/60)) % 60;
int upSec = sec % 60; int upSec = sec % 60;
Serial.printf("Up: %" PRId64 ":%02i:%02i:%02i (d:h:m:s)\n", upDays, upHours, upMin, upSec); Serial.printf("System up: %" PRId64 ":%02i:%02i:%02i (d:h:m:s)\n", upDays, upHours, upMin, upSec);
Serial.printf("Active connections: %i, Total streams served: %lu, Total image captures: %lu\n", connectedClients, streamsServed, imagesServed); Serial.printf("Active streams: %i, Previous streams: %lu, Images captured: %lu\n", streamCount, streamsServed, imagesServed);
Serial.printf("Freq: %i MHz\n", ESP.getCpuFreqMHz()); Serial.printf("Freq: %i MHz\n", ESP.getCpuFreqMHz());
Serial.printf("Heap: %i, free: %i, min free: %i, max block: %i\n", ESP.getHeapSize(), ESP.getFreeHeap(), ESP.getMinFreeHeap(), ESP.getMaxAllocHeap()); Serial.printf("Heap: %i, free: %i, min free: %i, max block: %i\n", ESP.getHeapSize(), ESP.getFreeHeap(), ESP.getMinFreeHeap(), ESP.getMaxAllocHeap());
Serial.printf("Psram: %i, free: %i, min free: %i, max block: %i\n", ESP.getPsramSize(), ESP.getFreePsram(), ESP.getMinFreePsram(), ESP.getMaxAllocPsram()); Serial.printf("Psram: %i, free: %i, min free: %i, max block: %i\n", ESP.getPsramSize(), ESP.getFreePsram(), ESP.getMinFreePsram(), ESP.getMaxAllocPsram());
@ -311,7 +302,7 @@ void serialDump() {
Serial.printf("Spiffs: %i, used: %i\n", SPIFFS.totalBytes(), SPIFFS.usedBytes()); Serial.printf("Spiffs: %i, used: %i\n", SPIFFS.totalBytes(), SPIFFS.usedBytes());
} }
Serial.printf("Enrolled faces: %i (max %i)\n", id_list.count, id_list.size); Serial.printf("Enrolled faces: %i (max %i)\n", id_list.count, id_list.size);
Serial.println();
return; return;
} }
@ -370,6 +361,7 @@ static esp_err_t capture_handler(httpd_req_t *req){
if (debugData) { if (debugData) {
Serial.printf("JPG: %uB %ums\n", (uint32_t)(fb_len), (uint32_t)((fr_end - fr_start)/1000)); Serial.printf("JPG: %uB %ums\n", (uint32_t)(fb_len), (uint32_t)((fr_end - fr_start)/1000));
} }
imagesServed++;
if (autoLamp && (lampVal != -1)) setLamp(0); if (autoLamp && (lampVal != -1)) setLamp(0);
return res; return res;
} }
@ -448,7 +440,7 @@ static esp_err_t stream_handler(httpd_req_t *req){
Serial.println("Stream requested"); Serial.println("Stream requested");
if (autoLamp && (lampVal != -1)) setLamp(lampVal); if (autoLamp && (lampVal != -1)) setLamp(lampVal);
streamCount = 1; // at present we only have one stream handler.. streamCount = 1; // at present we only have one stream handler, so values are 0 or 1..
flashLED(75); // double flash of status LED flashLED(75); // double flash of status LED
delay(75); delay(75);
flashLED(75); flashLED(75);
@ -460,14 +452,13 @@ static esp_err_t stream_handler(httpd_req_t *req){
res = httpd_resp_set_type(req, _STREAM_CONTENT_TYPE); res = httpd_resp_set_type(req, _STREAM_CONTENT_TYPE);
if(res != ESP_OK){ if(res != ESP_OK){
streamCount = 0;
if (autoLamp && (lampVal != -1)) setLamp(0); if (autoLamp && (lampVal != -1)) setLamp(0);
return res; return res;
} }
httpd_resp_set_hdr(req, "Access-Control-Allow-Origin", "*"); httpd_resp_set_hdr(req, "Access-Control-Allow-Origin", "*");
connectedClients = 1;
while(true){ while(true){
detected = false; detected = false;
face_id = 0; face_id = 0;
@ -481,6 +472,7 @@ static esp_err_t stream_handler(httpd_req_t *req){
fr_face = fr_start; fr_face = fr_start;
fr_encode = fr_start; fr_encode = fr_start;
fr_recognize = fr_start; fr_recognize = fr_start;
if(!detection_enabled || fb->width > 400){ if(!detection_enabled || fb->width > 400){
if(fb->format != PIXFORMAT_JPEG){ if(fb->format != PIXFORMAT_JPEG){
bool jpeg_converted = frame2jpg(fb, 80, &_jpg_buf, &_jpg_buf_len); bool jpeg_converted = frame2jpg(fb, 80, &_jpg_buf, &_jpg_buf_len);
@ -585,11 +577,9 @@ static esp_err_t stream_handler(httpd_req_t *req){
} }
} }
connectedClients = 0;
streamsServed++; streamsServed++;
streamCount = 0;
if (autoLamp && (lampVal != -1)) setLamp(0); if (autoLamp && (lampVal != -1)) setLamp(0);
streamCount = 0; // at present we only have one stream handler..
Serial.println("Stream ended"); Serial.println("Stream ended");
last_frame = 0; last_frame = 0;
return res; return res;
@ -872,7 +862,7 @@ static esp_err_t dump_handler(httpd_req_t *req){
int upMin = int64_t(floor(sec/60)) % 60; int upMin = int64_t(floor(sec/60)) % 60;
int upSec = sec % 60; int upSec = sec % 60;
d+= sprintf(d,"Up: %" PRId64 ":%02i:%02i:%02i (d:h:m:s)<br>\n", upDays, upHours, upMin, upSec); d+= sprintf(d,"Up: %" PRId64 ":%02i:%02i:%02i (d:h:m:s)<br>\n", upDays, upHours, upMin, upSec);
d+= sprintf(d,"Active connections: %i, Total streams served: %lu, Total image captures: %lu<br>\n", connectedClients, streamsServed, imagesServed); d+= sprintf(d,"Active streams: %i, Previous streams: %lu, Image captured: %lu<br>\n", streamCount, streamsServed, imagesServed);
d+= sprintf(d,"Freq: %i MHz<br>\n", ESP.getCpuFreqMHz()); d+= sprintf(d,"Freq: %i MHz<br>\n", ESP.getCpuFreqMHz());
d+= sprintf(d,"Heap: %i, free: %i, min free: %i, max block: %i<br>\n", ESP.getHeapSize(), ESP.getFreeHeap(), ESP.getMinFreeHeap(), ESP.getMaxAllocHeap()); d+= sprintf(d,"Heap: %i, free: %i, min free: %i, max block: %i<br>\n", ESP.getHeapSize(), ESP.getFreeHeap(), ESP.getMinFreeHeap(), ESP.getMaxAllocHeap());
d+= sprintf(d,"Psram: %i, free: %i, min free: %i, max block: %i<br>\n", ESP.getPsramSize(), ESP.getFreePsram(), ESP.getMinFreePsram(), ESP.getMaxAllocPsram()); d+= sprintf(d,"Psram: %i, free: %i, min free: %i, max block: %i<br>\n", ESP.getPsramSize(), ESP.getFreePsram(), ESP.getMinFreePsram(), ESP.getMaxAllocPsram());

View File

@ -70,6 +70,7 @@ IPAddress gw;
// Declare external function from app_httpd.cpp // Declare external function from app_httpd.cpp
extern void startCameraServer(int hPort, int sPort); extern void startCameraServer(int hPort, int sPort);
extern void serialDump();
// A Name for the Camera. (set in myconfig.h) // A Name for the Camera. (set in myconfig.h)
#if defined(CAM_NAME) #if defined(CAM_NAME)
@ -122,8 +123,10 @@ char apName[64] = "Undefined";
char httpURL[64] = {"Undefined"}; char httpURL[64] = {"Undefined"};
char streamURL[64] = {"Undefined"}; char streamURL[64] = {"Undefined"};
// Count number of active streams // Counters for info screens and debug
int8_t streamCount = 0; int8_t streamCount = 0; // Number of currently active streams
unsigned long streamsServed = 0; // Total completed streams
unsigned long imagesServed = 0; // Total image requests
// This will be displayed to identify the firmware // This will be displayed to identify the firmware
char myVer[] PROGMEM = __DATE__ " @ " __TIME__; char myVer[] PROGMEM = __DATE__ " @ " __TIME__;
@ -598,8 +601,8 @@ void setup() {
Serial.printf("\nCamera Ready!\nUse '%s' to connect\n", httpURL); Serial.printf("\nCamera Ready!\nUse '%s' to connect\n", httpURL);
Serial.printf("Stream viewer available at '%sview'\n", streamURL); Serial.printf("Stream viewer available at '%sview'\n", streamURL);
Serial.printf("Raw stream URL is '%s'\n", streamURL); Serial.printf("Raw stream URL is '%s'\n", streamURL);
if (debugData) Serial.println("Camera debug data is enabled (send any char to disable)"); if (debugData) Serial.println("Camera debug data is enabled (send 'd' for status dump, or any other char to disable debug)");
else Serial.println("Camera debug data is disabled (send any char to enable)"); else Serial.println("Camera debug data is disabled (send 'd' for status dump, or any other char to enable debug)");
} else { } else {
Serial.printf("\nCamera unavailable due to initialisation errors.\n\n"); Serial.printf("\nCamera unavailable due to initialisation errors.\n\n");
} }
@ -638,13 +641,17 @@ void loop() {
while (millis() - start < WIFI_WATCHDOG ) { while (millis() - start < WIFI_WATCHDOG ) {
delay(100); delay(100);
if (Serial.available()) { if (Serial.available()) {
// Toggle debug output on serial input if (Serial.read() == 'd' ) {
if (debugData) { serialDump();
debugData = false;
Serial.println("Camera debug data is disabled (send any char to enable)");
} else { } else {
debugData = true; // Toggle debug output on serial input
Serial.println("Camera debug data is enabled (send any char to disable)"); if (debugData) {
debugData = false;
Serial.println("Camera debug data is disabled (send 'd' for status dump, or any other char to enable debug)");
} else {
debugData = true;
Serial.println("Camera debug data is enabled (send 'd' for status dump, or any other char to disable debug)");
}
} }
} }
while (Serial.available()) Serial.read(); // chomp the buffer while (Serial.available()) Serial.read(); // chomp the buffer