123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272 |
- 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
|