void handelSerial(){ String serialin = Serial.readStringUntil('\n'); if(rpiStatus == rpi_on){ rpiSince = millis(); } if(rpiStatus == rpi_starting){ rpiStatus = rpi_on; rpiSince = millis(); } if(!serialin.startsWith("<"))return; String command = serialin.substring(1,serialin.indexOf(">")); String goonin = serialin.substring(serialin.indexOf(">")+1); if(command == "ping"){ Serial.println(""); return; } if(command=="setBLE"){ changeMode(mode_bluetooth); return; } if(command=="setNRF"){ changeMode(mode_radio); //goonin == "0" //idel if(goonin=="1"){ //scan } if(goonin=="2"){ //auto connect } return; } if(command=="readAnalogRaw"){ Serial.println(readAnalog(hextonum(goonin),true)); } if(command=="readAnalog"){ Serial.println(readAnalog(hextonum(goonin))); } if(command=="setDEBUG"){ changeMode(mode_debug); return; } if(command=="readMPU"){ if(NRFisConnected==1){ uint16_t buf = 1; uint16_t kind = goonin.toInt(); if(kind>2){ Serial.println("error"); return; } buf |= kind<<8; if(sendRCdata(&buf,2)){ Serial.println("send"); }else{ Serial.println("lost"); } }else{ Serial.println("noconn"); } return; } if(command=="readCOMP"){ if(NRFisConnected==1){ uint16_t buf = 2; if(sendRCdata(&buf,2)){ Serial.println("send"); }else{ Serial.println("lost"); } }else{ Serial.println("noconn"); } return; } if(command=="readGNSS"){ if(NRFisConnected==1){ uint16_t buf = 3; uint16_t kind = goonin.toInt(); if(kind>7){ Serial.println("error"); return; } buf |= kind<<8; if(sendRCdata(&buf,2)){ Serial.println("send"); }else{ Serial.println("lost"); } }else{ Serial.println("noconn"); } return; } if(command=="readAnalogDesc"){ if(NRFisConnected==1){ uint16_t buf = 50; uint16_t kind = goonin.toInt(); if(kind>11){ Serial.println("error"); return; } buf |= kind<<8; if(sendRCdata(&buf,2)){ Serial.println("send"); }else{ Serial.println("lost"); } }else{ Serial.println("noconn"); } return; } if(command=="readButtonDesc"){ if(NRFisConnected==1){ uint16_t buf = 51; uint16_t kind = goonin.toInt(); if(kind>31){ Serial.println("error"); return; } buf |= kind<<8; if(sendRCdata(&buf,2)){ Serial.println("send"); }else{ Serial.println("lost"); } }else{ Serial.println("noconn"); } return; } if(command=="getARC"){ if(NRFisConnected==1){ Serial.print(""); Serial.println(radio.getARC()); }else{ Serial.println("noconn"); } return; } if(command=="loadCalibrationData"){ loadCalibrationData(goonin); } if(command=="loadLEDProgram"){ loadLEDProgram(goonin); } if(command=="putBLEProgram0"){ BLEProgramCache[0] = goonin; preferences.putString("BLEPchache_0",goonin); } if(command=="putBLEProgram1"){ BLEProgramCache[1] = goonin; preferences.putString("BLEPchache_1",goonin); } if(command=="putBLEProgram2"){ BLEProgramCache[2] = goonin; preferences.putString("BLEPchache_2",goonin); } if(command=="putBLEProgram3"){ BLEProgramCache[3] = goonin; preferences.putString("BLEPchache_3",goonin); } if(command=="putBLEProgram4"){ BLEProgramCache[4] = goonin; preferences.putString("BLEPchache_4",goonin); } if(command=="BLEnextProgram"){ BLEnextProgram(); } if(command=="BLEgetProgramId"){ Serial.print(""); Serial.println(BLEProgramActive); } if(command=="BLEsetProgramId"){ Serial.print(""); BLEProgramActive = goonin.toInt()-1; BLEnextProgram(); } if(command=="reset"){ preferences.clear(); ESP.restart(); } }