Skip to content

Commit

Permalink
More USER_PRINTF
Browse files Browse the repository at this point in the history
  • Loading branch information
ewowi committed Sep 27, 2023
1 parent 5f350cb commit 9158699
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 31 deletions.
2 changes: 1 addition & 1 deletion src/App/AppEffects.h
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ class GEQEffect:public Effect {
if (remaining < 1) {band++; remaining+= bandwidth;} //increase remaining but keep the current remaining
remaining--; //consume remaining

// Serial.printf("x %d b %d n %d w %f %f\n", x, band, NUM_BANDS, bandwidth, remaining);
// USER_PRINTF("x %d b %d n %d w %f %f\n", x, band, NUM_BANDS, bandwidth, remaining);
uint8_t frBand = ((NUM_BANDS < 16) && (NUM_BANDS > 1)) ? map(band, 0, NUM_BANDS - 1, 0, 15):band; // always use full range. comment out this line to get the previous behaviour.
// frBand = constrain(frBand, 0, 15); //WLEDMM can never be out of bounds (I think...)
uint16_t colorIndex = frBand * 17; //WLEDMM 0.255
Expand Down
8 changes: 4 additions & 4 deletions src/Sys/SysModFiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ void SysModFiles::dirToJson(JsonArray array, bool nameOnly, const char * filter)
strncat(urlString, file.name(), sizeof(urlString)-1);
row.add((char *)urlString); //create a copy!
}
// Serial.printf("FILE: %s %d\n", file.name(), file.size());
// USER_PRINTF("FILE: %s %d\n", file.name(), file.size());
}

file.close();
Expand All @@ -147,7 +147,7 @@ bool SysModFiles::seqNrToName(char * fileName, size_t seqNr) {
size_t counter = 0;
while (file) {
if (counter == seqNr) {
Serial.printf("seqNrToName: %s %d\n", file.name(), file.size());
USER_PRINTF("seqNrToName: %s %d\n", file.name(), file.size());
root.close();
strncat(fileName, "/", 31); //add root prefix, fileName is 32 bytes but sizeof doesn't know so cheating
strncat(fileName, file.name(), 31);
Expand Down Expand Up @@ -189,13 +189,13 @@ bool SysModFiles::readObjectFromFile(const char* path, JsonDocument* dest) {
// bool SysModFiles::writeObjectToFile(const char* path, JsonDocument* dest) {
// File f = open(path, "w");
// if (f) {
// print->println(F(" success"));
// print->println(" success");
// serializeJson(*dest, f);
// f.close();
// filesChange();
// return true;
// } else {
// print->println(F(" fail"));
// print->println(" fail");
// return false;
// }
// }
Expand Down
2 changes: 1 addition & 1 deletion src/Sys/SysModModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ SysModModel::SysModModel() :Module("Model") {

USER_PRINTF("%s %s\n", __PRETTY_FUNCTION__, name);

print->println(F("Reading model from /model.json... (deserializeConfigFromFS)"));
USER_PRINTF("Reading model from /model.json... (deserializeConfigFromFS)\n");
if (files->readObjectFromFile("/model.json", model)) {//not part of success...
print->printJson("Read model", *model);
web->sendDataWs(nullptr, false); //send new data: all clients, no def, no ws here yet!!!
Expand Down
2 changes: 1 addition & 1 deletion src/Sys/SysModNetwork.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ void SysModNetwork::handleConnection() {
dnsServer.stop();
WiFi.softAPdisconnect(true);
apActive = false;
print->println(F("Access point disabled (handle)."));
USER_PRINTF("Access point disabled (handle).\n");
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/Sys/SysModPins.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ void SysModPins::setup() {
// send leds preview to clients
for (size_t i = 0; i < buffer[0] * 256 + buffer[1]; i++)
{
buffer[i*3+4] = (digitalRead(i)+1) * 50;
buffer[i*3+4+1] = 255;
buffer[i*3+4+2] = 192;
buffer[i*3+4] = random(256);// (digitalRead(i)+1) * 50;
buffer[i*3+4+1] = random(256);;
buffer[i*3+4+2] = random(256);;
}
//new values
buffer[0] = 0; //0 * 256
Expand Down
42 changes: 21 additions & 21 deletions src/Sys/SysModWeb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,11 +203,11 @@ void SysModWeb::wsEvent(AsyncWebSocket * server, AsyncWebSocketClient * client,
//message is comprised of multiple frames or the frame is split into multiple packets
if(info->index == 0){
if(info->num == 0)
Serial.printf("ws[%s][%u] %s-message start\n", server->url(), client->id(), (info->message_opcode == WS_TEXT)?"text":"binary");
Serial.printf("ws[%s][%u] frame[%u] start[%llu]\n", server->url(), client->id(), info->num, info->len);
USER_PRINTF("ws[%s][%u] %s-message start\n", server->url(), client->id(), (info->message_opcode == WS_TEXT)?"text":"binary");
USER_PRINTF("ws[%s][%u] frame[%u] start[%llu]\n", server->url(), client->id(), info->num, info->len);
}

Serial.printf("ws[%s][%u] frame[%u] %s[%llu - %llu]: ", server->url(), client->id(), info->num, (info->message_opcode == WS_TEXT)?"text":"binary", info->index, info->index + len);
USER_PRINTF("ws[%s][%u] frame[%u] %s[%llu - %llu]: ", server->url(), client->id(), info->num, (info->message_opcode == WS_TEXT)?"text":"binary", info->index, info->index + len);

if(info->opcode == WS_TEXT){
for(size_t i=0; i < len; i++) {
Expand All @@ -221,12 +221,12 @@ void SysModWeb::wsEvent(AsyncWebSocket * server, AsyncWebSocketClient * client,
// msg += buff ;
// }
// }
Serial.printf("%s\n",msg.c_str());
USER_PRINTF("%s\n",msg.c_str());

if((info->index + len) == info->len){
Serial.printf("ws[%s][%u] frame[%u] end[%llu]\n", server->url(), client->id(), info->num, info->len);
USER_PRINTF("ws[%s][%u] frame[%u] end[%llu]\n", server->url(), client->id(), info->num, info->len);
if(info->final){
Serial.printf("ws[%s][%u] %s-message end\n", server->url(), client->id(), (info->message_opcode == WS_TEXT)?"text":"binary");
USER_PRINTF("ws[%s][%u] %s-message end\n", server->url(), client->id(), (info->message_opcode == WS_TEXT)?"text":"binary");
if(info->message_opcode == WS_TEXT)
client->text("I got your text message");
else
Expand Down Expand Up @@ -258,34 +258,34 @@ void SysModWeb::wsEvent(AsyncWebSocket * server, AsyncWebSocketClient * client,
//error was received from the other end
// printClient("WS error", client); //crashes
// USER_PRINTF("WS error\n");
Serial.printf("ws[%s][%u] error(): \n", server->url(), client->id());//, *((uint16_t*)arg));//, (char*)data);
USER_PRINTF("ws[%s][%u] error(): \n", server->url(), client->id());//, *((uint16_t*)arg));//, (char*)data);

} else if (type == WS_EVT_PONG){
//pong message was received (in response to a ping request maybe)
// printClient("WS pong", client); //crashes!
// USER_PRINTF("WS pong\n");
// Serial.printf("ws[%s][%u] pong[%u]: %s\n", server->url(), client->id(), len, (len)?(char*)data:"");
Serial.printf("ws[%s][%u] pong[%u]: \n", server->url(), client->id(), len);//, (len)?(char*)data:"");
// USER_PRINTF("ws[%s][%u] pong[%u]: %s\n", server->url(), client->id(), len, (len)?(char*)data:"");
USER_PRINTF("ws[%s][%u] pong[%u]: \n", server->url(), client->id(), len);//, (len)?(char*)data:"");
}
}

void SysModWeb::wsEvent2(AsyncWebSocket * server, AsyncWebSocketClient * client, AwsEventType type, void * arg, uint8_t *data, size_t len){
if(type == WS_EVT_CONNECT){
Serial.printf("ws[%s][%u] connect\n", server->url(), client->id());
USER_PRINTF("ws[%s][%u] connect\n", server->url(), client->id());
// client->printf("Hello Client %u :)", client->id());
client->ping();
} else if(type == WS_EVT_DISCONNECT){
Serial.printf("ws[%s][%u] disconnect\n", server->url(), client->id());
USER_PRINTF("ws[%s][%u] disconnect\n", server->url(), client->id());
} else if(type == WS_EVT_ERROR){
Serial.printf("ws[%s][%u] error(%u): %s\n", server->url(), client->id(), *((uint16_t*)arg), (char*)data);
USER_PRINTF("ws[%s][%u] error(%u): %s\n", server->url(), client->id(), *((uint16_t*)arg), (char*)data);
} else if(type == WS_EVT_PONG){
Serial.printf("ws[%s][%u] pong[%u]: %s\n", server->url(), client->id(), len, (len)?(char*)data:"");
USER_PRINTF("ws[%s][%u] pong[%u]: %s\n", server->url(), client->id(), len, (len)?(char*)data:"");
} else if(type == WS_EVT_DATA){
AwsFrameInfo * info = (AwsFrameInfo*)arg;
String msg = "";
if(info->final && info->index == 0 && info->len == len){
//the whole message is in a single frame and we got all of it's data
Serial.printf("ws[%s][%u] %s-message[%llu]: ", server->url(), client->id(), (info->opcode == WS_TEXT)?"text":"binary", info->len);
USER_PRINTF("ws[%s][%u] %s-message[%llu]: ", server->url(), client->id(), (info->opcode == WS_TEXT)?"text":"binary", info->len);

if(info->opcode == WS_TEXT){
for(size_t i=0; i < info->len; i++) {
Expand All @@ -299,7 +299,7 @@ void SysModWeb::wsEvent2(AsyncWebSocket * server, AsyncWebSocketClient * client,
// msg += buff ;
// }
// }
Serial.printf("%s\n",msg.c_str());
USER_PRINTF("%s\n",msg.c_str());

if(info->opcode == WS_TEXT)
client->text("I got your text message");
Expand All @@ -309,11 +309,11 @@ void SysModWeb::wsEvent2(AsyncWebSocket * server, AsyncWebSocketClient * client,
//message is comprised of multiple frames or the frame is split into multiple packets
if(info->index == 0){
if(info->num == 0)
Serial.printf("ws[%s][%u] %s-message start\n", server->url(), client->id(), (info->message_opcode == WS_TEXT)?"text":"binary");
Serial.printf("ws[%s][%u] frame[%u] start[%llu]\n", server->url(), client->id(), info->num, info->len);
USER_PRINTF("ws[%s][%u] %s-message start\n", server->url(), client->id(), (info->message_opcode == WS_TEXT)?"text":"binary");
USER_PRINTF("ws[%s][%u] frame[%u] start[%llu]\n", server->url(), client->id(), info->num, info->len);
}

Serial.printf("ws[%s][%u] frame[%u] %s[%llu - %llu]: ", server->url(), client->id(), info->num, (info->message_opcode == WS_TEXT)?"text":"binary", info->index, info->index + len);
USER_PRINTF("ws[%s][%u] frame[%u] %s[%llu - %llu]: ", server->url(), client->id(), info->num, (info->message_opcode == WS_TEXT)?"text":"binary", info->index, info->index + len);

if(info->opcode == WS_TEXT){
for(size_t i=0; i < len; i++) {
Expand All @@ -327,12 +327,12 @@ void SysModWeb::wsEvent2(AsyncWebSocket * server, AsyncWebSocketClient * client,
// msg += buff ;
// }
// }
Serial.printf("%s\n",msg.c_str());
USER_PRINTF("%s\n",msg.c_str());

if((info->index + len) == info->len){
Serial.printf("ws[%s][%u] frame[%u] end[%llu]\n", server->url(), client->id(), info->num, info->len);
USER_PRINTF("ws[%s][%u] frame[%u] end[%llu]\n", server->url(), client->id(), info->num, info->len);
if(info->final){
Serial.printf("ws[%s][%u] %s-message end\n", server->url(), client->id(), (info->message_opcode == WS_TEXT)?"text":"binary");
USER_PRINTF("ws[%s][%u] %s-message end\n", server->url(), client->id(), (info->message_opcode == WS_TEXT)?"text":"binary");
if(info->message_opcode == WS_TEXT)
client->text("I got your text message");
else
Expand Down

0 comments on commit 9158699

Please sign in to comment.