123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385 |
- static void mPrint(String txt)
- {
-
- # if DUSB>=1
- Serial.println(F(txt));
- if (debug>=2) Serial.flush();
- # endif
- # if _MONITOR>=1
- time_t tt = now();
-
- for (int i=_MONITOR; i>0; i--) {
- monitor[i]= monitor[i-1];
- }
-
- monitor[0].txt = String(day(tt)) + "-";
- monitor[0].txt += String(month(tt)) + "-";
- monitor[0].txt += String(year(tt)) + " ";
-
- byte _hour = hour(tt);
- byte _minute = minute(tt);
- byte _second = second(tt);
- if (_hour < 10) monitor[0].txt += "0"; monitor[0].txt += String( _hour )+ ":";
- if (_minute < 10) monitor[0].txt += "0"; monitor[0].txt += String(_minute) + ":";
- if (_second < 10) monitor[0].txt += "0"; monitor[0].txt += String(_second) + "- ";
-
- monitor[0].txt += String(txt);
-
- # endif
- return;
- }
- int mStat(uint8_t intr, String & response)
- {
- #if _MONITOR>=1
- if (debug>=0) {
-
- response += "I=";
- if (intr & IRQ_LORA_RXTOUT_MASK) response += String("RXTOUT ");
- if (intr & IRQ_LORA_RXDONE_MASK) response += String("RXDONE ");
- if (intr & IRQ_LORA_CRCERR_MASK) response += "CRCERR ";
- if (intr & IRQ_LORA_HEADER_MASK) response += "HEADER ";
- if (intr & IRQ_LORA_TXDONE_MASK) response += "TXDONE ";
- if (intr & IRQ_LORA_CDDONE_MASK) response += String("CDDONE ");
- if (intr & IRQ_LORA_FHSSCH_MASK) response += "FHSSCH ";
- if (intr & IRQ_LORA_CDDETD_MASK) response += "CDDETD ";
- if (intr == 0x00) response += " -- ";
-
- response += ", F=" + String(ifreq);
- response += ", SF=" + String(sf);
- response += ", E=" + String(_event);
-
- response += ", S=";
- switch (_state) {
- case S_INIT:
- response += "INIT ";
- break;
- case S_SCAN:
- response += "SCAN ";
- break;
- case S_CAD:
- response += "CAD ";
- break;
- case S_RX:
- response += String("RX ");
- break;
- case S_TX:
- response += "TX ";
- break;
- case S_TXDONE:
- response += "TXDONE";
- break;
- default:
- response += " -- ";
- }
- response += ", eT=";
- response += String( micros() - eventTime );
- response += ", dT=";
- response += String( micros() - doneTime );
-
- }
- #endif
- return(1);
- }
- static void printHEX(char * hexa, const char sep, String& response)
- {
- char m;
- m = hexa[0]; if (m<016) response+='0'; response += String(m, HEX); response+=sep;
- m = hexa[1]; if (m<016) response+='0'; response += String(m, HEX); response+=sep;
- m = hexa[2]; if (m<016) response+='0'; response += String(m, HEX); response+=sep;
- m = hexa[3]; if (m<016) response+='0'; response += String(m, HEX); response+=sep;
- }
- static void stringTime(time_t t, String& response) {
- if (t==0) { response += "--"; return; }
-
-
-
-
- time_t eTime = t;
-
-
- byte _hour = hour(eTime);
- byte _minute = minute(eTime);
- byte _second = second(eTime);
-
- switch(weekday(eTime)) {
- case 1: response += "Sunday "; break;
- case 2: response += "Monday "; break;
- case 3: response += "Tuesday "; break;
- case 4: response += "Wednesday "; break;
- case 5: response += "Thursday "; break;
- case 6: response += "Friday "; break;
- case 7: response += "Saturday "; break;
- }
- response += String(day(eTime)) + "-";
- response += String(month(eTime)) + "-";
- response += String(year(eTime)) + " ";
- if (_hour < 10) response += "0"; response += String(_hour) + ":";
- if (_minute < 10) response += "0"; response += String(_minute) + ":";
- if (_second < 10) response += "0"; response += String(_second);
- }
- void printHexDigit(uint8_t digit)
- {
-
- if(digit < 0x10)
- Serial.print('0');
- Serial.print(digit,HEX);
- }
- void printDigits(unsigned long digits)
- {
-
- if(digits < 10)
- Serial.print(F("0"));
- Serial.print(digits);
- }
- static void printTime() {
- switch (weekday())
- {
- case 1: Serial.print(F("Sunday")); break;
- case 2: Serial.print(F("Monday")); break;
- case 3: Serial.print(F("Tuesday")); break;
- case 4: Serial.print(F("Wednesday")); break;
- case 5: Serial.print(F("Thursday")); break;
- case 6: Serial.print(F("Friday")); break;
- case 7: Serial.print(F("Saturday")); break;
- default: Serial.print(F("ERROR")); break;
- }
- Serial.print(F(" "));
- printDigits(hour());
- Serial.print(F(":"));
- printDigits(minute());
- Serial.print(F(":"));
- printDigits(second());
- return;
- }
- void SerialTime()
- {
- uint32_t thrs = hour();
- uint32_t tmin = minute();
- uint32_t tsec = second();
-
- if (thrs<10) Serial.print('0'); Serial.print(thrs);
- Serial.print(':');
- if (tmin<10) Serial.print('0'); Serial.print(tmin);
- Serial.print(':');
- if (tsec<10) Serial.print('0'); Serial.print(tsec);
-
- if (debug>=2) Serial.flush();
-
- return;
- }
- void SerialStat(uint8_t intr)
- {
- #if _DUSB>=1
- if (debug>=0) {
- Serial.print(F("I="));
- if (intr & IRQ_LORA_RXTOUT_MASK) Serial.print(F("RXTOUT "));
- if (intr & IRQ_LORA_RXDONE_MASK) Serial.print(F("RXDONE "));
- if (intr & IRQ_LORA_CRCERR_MASK) Serial.print(F("CRCERR "));
- if (intr & IRQ_LORA_HEADER_MASK) Serial.print(F("HEADER "));
- if (intr & IRQ_LORA_TXDONE_MASK) Serial.print(F("TXDONE "));
- if (intr & IRQ_LORA_CDDONE_MASK) Serial.print(F("CDDONE "));
- if (intr & IRQ_LORA_FHSSCH_MASK) Serial.print(F("FHSSCH "));
- if (intr & IRQ_LORA_CDDETD_MASK) Serial.print(F("CDDETD "));
- if (intr == 0x00) Serial.print(F(" -- "));
-
- Serial.print(F(", F="));
- Serial.print(ifreq);
- Serial.print(F(", SF="));
- Serial.print(sf);
- Serial.print(F(", E="));
- Serial.print(_event);
-
- Serial.print(F(", S="));
-
- switch (_state) {
- case S_INIT:
- Serial.print(F("INIT "));
- break;
- case S_SCAN:
- Serial.print(F("SCAN "));
- break;
- case S_CAD:
- Serial.print(F("CAD "));
- break;
- case S_RX:
- Serial.print(F("RX "));
- break;
- case S_TX:
- Serial.print(F("TX "));
- break;
- case S_TXDONE:
- Serial.print(F("TXDONE"));
- break;
- default:
- Serial.print(F(" -- "));
- }
- Serial.print(F(", eT="));
- Serial.print( micros() - eventTime );
- Serial.print(F(", dT="));
- Serial.print( micros() - doneTime );
- Serial.println();
- }
- #endif
- }
-
- int SerialName(char * a, String& response)
- {
- #if _TRUSTED_NODES>=1
- uint32_t id = ((a[0]<<24) | (a[1]<<16) | (a[2]<<8) | a[3]);
- int i;
- for ( i=0; i< (sizeof(nodes)/sizeof(nodex)); i++) {
- if (id == nodes[i].id) {
- #if _DUSB >=1
- if (( debug>=3 ) && ( pdebug & P_GUI )) {
- Serial.print(F("G Name="));
- Serial.print(nodes[i].nm);
- Serial.print(F(" for node=0x"));
- Serial.print(nodes[i].id,HEX);
- Serial.println();
- }
- #endif
- response += nodes[i].nm;
- return(i);
- }
- }
- #endif
- return(-1);
- }
- #if _LOCALSERVER==1
- int inDecodes(char * id) {
- uint32_t ident = ((id[3]<<24) | (id[2]<<16) | (id[1]<<8) | id[0]);
- int i;
- for ( i=0; i< (sizeof(decodes)/sizeof(codex)); i++) {
- if (ident == decodes[i].id) {
- return(i);
- }
- }
- return(-1);
- }
- #endif
|