eried 2 лет назад
Родитель
Сommit
eee92270f6

+ 25 - 18
esp32cam_marauder/CommandLine.ino

@@ -187,20 +187,23 @@ void CommandLine::main(uint32_t currentTime) {
 
 LinkedList<String> CommandLine::parseCommand(String input, char* delim) {
   LinkedList<String> cmd_args;
-  
-  if (input != "") {
-    
-    char fancy[input.length() + 1] = {};
-    input.toCharArray(fancy, input.length() + 1);
-        
-    char* ptr = strtok(fancy, delim);
-  
-    while (ptr != NULL) {
-      cmd_args.add(String(ptr));
-  
-      ptr = strtok(NULL, delim);
+
+  bool inQuote = false;
+  String buffer = "";
+
+  for (int i = 0; i < input.length(); i++) {
+    char c = input.charAt(i);
+    // Do not break parameters that are enclosed in quotes
+    if (c == '"') {
+      inQuote = !inQuote;
+    } else if (!inQuote && strchr(delim, c) != NULL) {
+      cmd_args.add(buffer);
+      buffer = "";
+    } else {
+      buffer += c;
     }
   }
+  cmd_args.add(buffer);
 
   return cmd_args;
 }
@@ -697,12 +700,16 @@ void CommandLine::runCommand(String input) {
       }
       // Update via SD
       else if (sd_sw != -1) {
-        if (!sd_obj.supported) {
-          Serial.println("SD card is not connected. Cannot perform SD Update");
-          return;
-        }
-        wifi_scan_obj.currentScanMode = OTA_UPDATE;
-        sd_obj.runUpdate();
+        #ifndef WRITE_PACKETS_SERIAL
+          if (!sd_obj.supported) {
+            Serial.println("SD card is not connected. Cannot perform SD Update");
+            return;
+          }
+          wifi_scan_obj.currentScanMode = OTA_UPDATE;
+          sd_obj.runUpdate();
+        #else
+          Serial.println("SD card not initialized. Cannot perform SD Update");
+        #endif
       }
     }
   }

+ 11 - 10
esp32cam_marauder/SDInterface.cpp

@@ -43,32 +43,33 @@ bool SDInterface::initSD() {
     //    Serial.println(F("SD: UNKNOWN Card Mounted"));
 
     this->cardSizeMB = SD_MMC.cardSize() / (1024 * 1024);
-
+    
     //Serial.printf("SD Card Size: %lluMB\n", this->cardSizeMB);
 
     if (this->supported) {
       const int NUM_DIGITS = log10(this->cardSizeMB) + 1;
-
+    
       char sz[NUM_DIGITS + 1];
-
-      sz[NUM_DIGITS] = 0;
-      for (size_t i = NUM_DIGITS; i--; this->cardSizeMB /= 10) {
-        sz[i] = '0' + (this->cardSizeMB % 10);
-        display_string.concat((String)sz[i]);
+     
+      sz[NUM_DIGITS] =  0;
+      for ( size_t i = NUM_DIGITS; i--; this->cardSizeMB /= 10)
+      {
+          sz[i] = '0' + (this->cardSizeMB % 10);
+          display_string.concat((String)sz[i]);
       }
-
+  
       this->card_sz = sz;
     }
 
     buffer_obj = Buffer();
-
+    
     if (!SD_MMC.exists("/SCRIPTS")) {
       Serial.println("/SCRIPTS does not exist. Creating...");
 
       SD_MMC.mkdir("/SCRIPTS");
       Serial.println("/SCRIPTS created");
     }
-
+    
     return true;
   }
 }

+ 9 - 9
esp32cam_marauder/WiFiScan.cpp

@@ -176,7 +176,7 @@ int WiFiScan::clearSSIDs() {
 }
 
 bool WiFiScan::addSSID(String essid) {
-  ssid s = {essid, {random(256), random(256), random(256), random(256), random(256), random(256)}, false};
+  ssid s = {essid, random(1, 12), {random(256), random(256), random(256), random(256), random(256), random(256)}, false};
   ssids->add(s);
   Serial.println(ssids->get(ssids->size() - 1).essid);
 
@@ -191,7 +191,7 @@ int WiFiScan::generateSSIDs(int count) {
     for (uint8_t i = 0; i < 6; i++)
       essid.concat(alfa[random(65)]);
 
-    ssid s = {essid, {random(256), random(256), random(256), random(256), random(256), random(256)}, false};
+    ssid s = {essid, random(1, 12), {random(256), random(256), random(256), random(256), random(256), random(256)}, false};
     ssids->add(s);
     Serial.println(ssids->get(ssids->size() - 1).essid);
   }
@@ -2437,7 +2437,7 @@ void WiFiScan::broadcastCustomBeacon(uint32_t current_time, AccessPoint custom_s
 }
 
 void WiFiScan::broadcastCustomBeacon(uint32_t current_time, ssid custom_ssid) {
-  set_channel = random(1,12); 
+  set_channel = custom_ssid.channel;
   esp_wifi_set_channel(set_channel, WIFI_SECOND_CHAN_NONE);
   delay(1);  
 
@@ -3623,12 +3623,12 @@ void WiFiScan::main(uint32_t currentTime)
     // which makes beacon spam less effective
     for (int i = 0; i < access_points->size(); i++) {
       if (access_points->get(i).selected)
-        this->broadcastCustomBeacon(currentTime, ssid{access_points->get(i).essid, {random(256), 
-                                                                                    random(256), 
-                                                                                    random(256), 
-                                                                                    random(256), 
-                                                                                    random(256), 
-                                                                                    random(256)}});
+        this->broadcastCustomBeacon(currentTime, ssid{access_points->get(i).essid, random(1, 12), {random(256), 
+                                                                                                   random(256),
+                                                                                                   random(256),
+                                                                                                   random(256),
+                                                                                                   random(256),
+                                                                                                   random(256)}});
     }
       
 

+ 1 - 0
esp32cam_marauder/WiFiScan.h

@@ -88,6 +88,7 @@ esp_err_t esp_wifi_80211_tx(wifi_interface_t ifx, const void *buffer, int len, b
 
 struct ssid {
   String essid;
+  int channel;
   int bssid[6];
   bool selected;
 };

+ 1 - 1
esp32cam_marauder/configs.h

@@ -19,7 +19,7 @@
   //#define ESP32_LDDB
   //#define MARAUDER_DEV_BOARD_PRO
 
-  #define MARAUDER_VERSION "v0.10.2"
+  #define MARAUDER_VERSION "v0.10.3"
 
   //// BUTTON DEFINITIONS
   #ifdef MARAUDER_MINI