Skip to content

Commit

Permalink
🚧 #67 perform write flash on FreeBSD 14.1
Browse files Browse the repository at this point in the history
  • Loading branch information
rucko24 committed Oct 20, 2024
1 parent 7ad5d58 commit 4a34442
Show file tree
Hide file tree
Showing 26 changed files with 107 additions and 181 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,7 @@
import java.util.Objects;
import java.util.Set;

import static com.esp.espflow.data.util.EspFlowConstants.ESPTOOL_BUNDLE_DIR;
import static com.esp.espflow.data.util.EspFlowConstants.JAVA_IO_TEMPORAL_DIR_OS;
import static com.esp.espflow.data.util.EspFlowConstants.META_INF_RESOURCES_ESPTOOL_BUNDLE;
import static com.esp.espflow.data.util.EspFlowConstants.SET_CHMOD_X;
import static com.esp.espflow.data.util.EspFlowConstants.SLASH;
import static com.esp.espflow.data.util.EspFlowConstants.*;

/**
* <p>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
package com.esp.espflow.data.entity;

import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.MappedSuperclass;
import jakarta.persistence.SequenceGenerator;
import jakarta.persistence.Version;
import jakarta.persistence.*;

@MappedSuperclass
public abstract class AbstractEntity {
Expand Down
8 changes: 1 addition & 7 deletions src/main/java/com/esp/espflow/data/entity/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,7 @@

import com.esp.espflow.data.enums.Role;
import com.fasterxml.jackson.annotation.JsonIgnore;
import jakarta.persistence.ElementCollection;
import jakarta.persistence.Entity;
import jakarta.persistence.EnumType;
import jakarta.persistence.Enumerated;
import jakarta.persistence.FetchType;
import jakarta.persistence.Lob;
import jakarta.persistence.Table;
import jakarta.persistence.*;

import java.util.Set;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,7 @@
import java.util.Map;
import java.util.Objects;

import static com.esp.espflow.data.util.EspFlowConstants.CHIP_IS;
import static com.esp.espflow.data.util.EspFlowConstants.CHIP_TYPE;
import static com.esp.espflow.data.util.EspFlowConstants.CRYSTAL_IS;
import static com.esp.espflow.data.util.EspFlowConstants.DETECTED_FLASH_SIZE;
import static com.esp.espflow.data.util.EspFlowConstants.MAC;
import static com.esp.espflow.data.util.EspFlowConstants.SERIAL_PORT;
import static com.esp.espflow.data.util.EspFlowConstants.*;

/**
* The EspDeviceInfoMapper
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,7 @@
import lombok.extern.log4j.Log4j2;
import org.springframework.stereotype.Service;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;

Expand Down
14 changes: 1 addition & 13 deletions src/main/java/com/esp/espflow/data/service/EsptoolService.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,7 @@
import java.nio.file.Path;
import java.util.function.Predicate;

import static com.esp.espflow.data.util.EspFlowConstants.BAUD_RATE;
import static com.esp.espflow.data.util.EspFlowConstants.CHIP_IS;
import static com.esp.espflow.data.util.EspFlowConstants.CHIP_TYPE;
import static com.esp.espflow.data.util.EspFlowConstants.CRYSTAL_IS;
import static com.esp.espflow.data.util.EspFlowConstants.DETECTED_FLASH_SIZE;
import static com.esp.espflow.data.util.EspFlowConstants.ESPTOOL_PY_NOT_FOUND;
import static com.esp.espflow.data.util.EspFlowConstants.FIRST_LINE_TO_CHECK_IF_IT_EXISTS;
import static com.esp.espflow.data.util.EspFlowConstants.FLASH_ID;
import static com.esp.espflow.data.util.EspFlowConstants.JAVA_IO_TEMPORAL_DIR_OS;
import static com.esp.espflow.data.util.EspFlowConstants.MAC;
import static com.esp.espflow.data.util.EspFlowConstants.PORT;
import static com.esp.espflow.data.util.EspFlowConstants.SERIAL_PORT;
import static com.esp.espflow.data.util.EspFlowConstants.VERSION;
import static com.esp.espflow.data.util.EspFlowConstants.*;

/**
* @author rubn
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.esp.espflow.data.service.strategy.filterespslide;

import com.esp.espflow.data.entity.EspDeviceInfo;
import com.esp.espflow.data.util.GetOsName;

/**
* The FilterEsp01s
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,19 @@ public boolean filter(EspDeviceInfo espDeviceInfo) {
String chipIs = "";
if(GetOsName.getOsName() == GetOsName.LINUX) {
descriptivePortName = "CP2102N USB to UART";
chipIs = "ESP32-S3 (QFN56) (revision v0.0)";
chipIs = "ESP32-S3";
} else if(GetOsName.getOsName() == GetOsName.WINDOWS) {

} else if(GetOsName.getOsName() == GetOsName.MAC){
//Do nothing
} else if(GetOsName.getOsName() == GetOsName.FREEBSD){
//Do nothing
descriptivePortName = "Serial Port";
chipIs = "ESP32-S3";
}

return espDeviceInfo.chipType().endsWith("-S3")
&& espDeviceInfo.descriptivePortName().contains(descriptivePortName)
&& espDeviceInfo.chipIs().equals(chipIs);
&& espDeviceInfo.chipIs().contains(chipIs);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

import com.esp.espflow.data.entity.EspDeviceInfo;
import com.esp.espflow.data.util.GetOsName;
import org.apache.commons.lang3.StringUtils;

/**
* The FilterEsp8266Cp210x
*/
public class FilterEsp8266Cp210x implements FilterEspDeviceStrategy {
public class FilterEsp8266Cp210xAmica implements FilterEspDeviceStrategy {

/**
* <ul>
Expand All @@ -20,7 +21,7 @@ public class FilterEsp8266Cp210x implements FilterEspDeviceStrategy {
* <strong>MAC:</strong>
* </li>
* <li>
* <strong>FreeBSD:</strong>
* <strong>FreeBSD:</strong> the descriptivePortName is, Serial Port (Dial-In)
* </li>
* </ul>
*
Expand All @@ -29,8 +30,25 @@ public class FilterEsp8266Cp210x implements FilterEspDeviceStrategy {
*/
@Override
public boolean filter(EspDeviceInfo espDeviceInfo) {

String usbSerial = StringUtils.EMPTY;
String chipIs = StringUtils.EMPTY;
if (GetOsName.getOsName() == GetOsName.WINDOWS) {
usbSerial = "USB-SERIAL";
} else if (GetOsName.getOsName() == GetOsName.LINUX) {
usbSerial = "CP21";
chipIs = "ESP8266EX";
} else if (GetOsName.getOsName() == GetOsName.MAC) {
usbSerial = "USB Serial";
} else if(GetOsName.getOsName() == GetOsName.FREEBSD){
usbSerial = "Serial Port (Dial-In)";
chipIs = "ESP8266EX";
} else {
//Do nothing
}

return espDeviceInfo.chipType().endsWith("8266")
&& espDeviceInfo.detectedFlashSize().equals("4MB")
&& espDeviceInfo.descriptivePortName().contains("CP21");
&& espDeviceInfo.descriptivePortName().contains(usbSerial);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.esp.espflow.data.entity.EspDeviceInfo;
import com.esp.espflow.data.util.GetOsName;
import org.apache.commons.lang3.StringUtils;

/**
* The FilterEsp828852MB
Expand All @@ -20,7 +21,7 @@ public class FilterEsp828852MB implements FilterEspDeviceStrategy {
* <strong>MAC:</strong>
* </li>
* <li>
* <strong>FreeBSD:</strong>
* <strong>FreeBSD:</strong> the descriptivePortName is, Serial Port (Dial-In)
* </li>
* </ul>
*
Expand All @@ -29,16 +30,18 @@ public class FilterEsp828852MB implements FilterEspDeviceStrategy {
*/
@Override
public boolean filter(EspDeviceInfo espDeviceInfo) {
String usbSerial = "";
String usbSerial = StringUtils.EMPTY;

if (GetOsName.getOsName() == GetOsName.WINDOWS) {
usbSerial = "USB-SERIAL";
} else if (GetOsName.getOsName() == GetOsName.LINUX) {
usbSerial = "USB2.0-Serial";
} else if (GetOsName.getOsName() == GetOsName.MAC) {
usbSerial = "USB Serial";
} else if (GetOsName.getOsName() == GetOsName.FREEBSD) {
//FAILED to read CH340G driver
} else {
//FreeBSD or other
//Do nothing
}

return espDeviceInfo.chipType().contains("ESP8266")
Expand Down
7 changes: 3 additions & 4 deletions src/main/java/com/esp/espflow/data/util/GetOsName.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
import java.util.EnumSet;
import java.util.Locale;

import static com.esp.espflow.data.util.EspFlowConstants.BIN_BASH_C;
import static com.esp.espflow.data.util.EspFlowConstants.CMD_C;
import static com.esp.espflow.data.util.EspFlowConstants.*;

/**
* Get operating system in runtime
Expand Down Expand Up @@ -35,9 +34,9 @@ public static String[] shellOsName() {
if (oS == GetOsName.WINDOWS) {
return CMD_C;
} else if (oS == GetOsName.LINUX) {
return new String[]{};
return BIN_BASH_C;
} else if (oS == GetOsName.FREEBSD) {
return new String[]{};
return BIN_SH_C;
} else if (oS == GetOsName.MAC) {
return BIN_BASH_C;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@
import java.util.stream.Collectors;
import java.util.stream.Stream;

import static com.esp.espflow.data.util.EspFlowConstants.CHARSET_CP850;
import static com.esp.espflow.data.util.EspFlowConstants.COMMAND_NOT_FOUND;
import static com.esp.espflow.data.util.EspFlowConstants.DMESG_TTY;
import static com.esp.espflow.data.util.EspFlowConstants.NOT_FOUND;
import static com.esp.espflow.data.util.EspFlowConstants.*;

/**
* @author rubn
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,7 @@
import lombok.Getter;
import lombok.extern.log4j.Log4j2;

import static com.esp.espflow.data.util.EspFlowConstants.AUTO;
import static com.esp.espflow.data.util.EspFlowConstants.BOX_SHADOW_PROPERTY;
import static com.esp.espflow.data.util.EspFlowConstants.BOX_SHADOW_VALUE;
import static com.esp.espflow.data.util.EspFlowConstants.HIDDEN;
import static com.esp.espflow.data.util.EspFlowConstants.OVERFLOW_Y;
import static com.esp.espflow.data.util.EspFlowConstants.*;

/**
* @author rubn
Expand Down
13 changes: 2 additions & 11 deletions src/main/java/com/esp/espflow/views/MainLayout.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,7 @@
import com.vaadin.flow.component.applayout.DrawerToggle;
import com.vaadin.flow.component.avatar.Avatar;
import com.vaadin.flow.component.contextmenu.MenuItem;
import com.vaadin.flow.component.html.Anchor;
import com.vaadin.flow.component.html.Div;
import com.vaadin.flow.component.html.Footer;
import com.vaadin.flow.component.html.H1;
import com.vaadin.flow.component.html.Header;
import com.vaadin.flow.component.html.Image;
import com.vaadin.flow.component.html.Span;
import com.vaadin.flow.component.html.*;
import com.vaadin.flow.component.icon.Icon;
import com.vaadin.flow.component.icon.VaadinIcon;
import com.vaadin.flow.component.menubar.MenuBar;
Expand All @@ -34,10 +28,7 @@

import java.util.Optional;

import static com.esp.espflow.data.util.EspFlowConstants.FLASH_ON_SVG;
import static com.esp.espflow.data.util.EspFlowConstants.FRONTEND_IMAGES_ESPDEVICES;
import static com.esp.espflow.data.util.EspFlowConstants.FRONTEND_IMAGES_LOGO;
import static com.esp.espflow.data.util.EspFlowConstants.SIZE_25_PX;
import static com.esp.espflow.data.util.EspFlowConstants.*;

/**
* The main view is a top-level placeholder for other views.
Expand Down
10 changes: 2 additions & 8 deletions src/main/java/com/esp/espflow/views/about/AboutView.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,14 @@

import com.esp.espflow.views.MainLayout;
import com.infraleap.animatecss.Animated;
import com.vaadin.flow.component.html.Anchor;
import com.vaadin.flow.component.html.Div;
import com.vaadin.flow.component.html.H2;
import com.vaadin.flow.component.html.Image;
import com.vaadin.flow.component.html.Span;
import com.vaadin.flow.component.html.*;
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
import com.vaadin.flow.component.shared.Tooltip;
import com.vaadin.flow.router.PageTitle;
import com.vaadin.flow.router.Route;
import jakarta.annotation.security.RolesAllowed;

import static com.esp.espflow.data.util.EspFlowConstants.BOX_SHADOW_PROPERTY;
import static com.esp.espflow.data.util.EspFlowConstants.BOX_SHADOW_VALUE;
import static com.esp.espflow.data.util.EspFlowConstants.FRONTEND_IMAGES_ABOUT;
import static com.esp.espflow.data.util.EspFlowConstants.*;

@PageTitle("About")
@Route(value = "about", layout = MainLayout.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,7 @@
import java.nio.file.Path;
import java.util.Arrays;

import static com.esp.espflow.data.util.EspFlowConstants.AUTO;
import static com.esp.espflow.data.util.EspFlowConstants.BOX_SHADOW_VAADIN_BUTTON;
import static com.esp.espflow.data.util.EspFlowConstants.DISPLAY;
import static com.esp.espflow.data.util.EspFlowConstants.JAVA_IO_TEMPORAL_DIR_OS;
import static com.esp.espflow.data.util.EspFlowConstants.MARGIN_10_PX;
import static com.esp.espflow.data.util.EspFlowConstants.MARGIN_LEFT;
import static com.esp.espflow.data.util.EspFlowConstants.MARGIN_TOP;
import static com.esp.espflow.data.util.EspFlowConstants.*;

/**
* @author rubn
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,7 @@
import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;

import static com.esp.espflow.data.util.EspFlowConstants.AUTO;
import static com.esp.espflow.data.util.EspFlowConstants.BOX_SHADOW_PROPERTY;
import static com.esp.espflow.data.util.EspFlowConstants.BOX_SHADOW_VAADIN_BUTTON;
import static com.esp.espflow.data.util.EspFlowConstants.BOX_SHADOW_VALUE;
import static com.esp.espflow.data.util.EspFlowConstants.DISPLAY;
import static com.esp.espflow.data.util.EspFlowConstants.ESPTOOL_PY_NOT_FOUND;
import static com.esp.espflow.data.util.EspFlowConstants.MARGIN;
import static com.esp.espflow.data.util.EspFlowConstants.MARGIN_10_PX;
import static com.esp.espflow.data.util.EspFlowConstants.MARGIN_TOP;
import static com.esp.espflow.data.util.EspFlowConstants.*;

@Log4j2
@Getter
Expand Down
16 changes: 1 addition & 15 deletions src/main/java/com/esp/espflow/views/flashesp/FlashEspView.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,21 +40,7 @@

import java.util.Objects;

import static com.esp.espflow.data.util.EspFlowConstants.AUTO;
import static com.esp.espflow.data.util.EspFlowConstants.BAUD_RATE;
import static com.esp.espflow.data.util.EspFlowConstants.BOX_SHADOW_VAADIN_BUTTON;
import static com.esp.espflow.data.util.EspFlowConstants.DEFAULT_INIT_ADDRESS_SIZE_TO_WRITE_0x_00000;
import static com.esp.espflow.data.util.EspFlowConstants.FLASH_ID;
import static com.esp.espflow.data.util.EspFlowConstants.FLASH_OFF_SVG;
import static com.esp.espflow.data.util.EspFlowConstants.HIDDEN;
import static com.esp.espflow.data.util.EspFlowConstants.MARGIN_10_PX;
import static com.esp.espflow.data.util.EspFlowConstants.MARGIN_LEFT;
import static com.esp.espflow.data.util.EspFlowConstants.MARGIN_TOP;
import static com.esp.espflow.data.util.EspFlowConstants.OVERFLOW_X;
import static com.esp.espflow.data.util.EspFlowConstants.OVERFLOW_Y;
import static com.esp.espflow.data.util.EspFlowConstants.PORT;
import static com.esp.espflow.data.util.EspFlowConstants.SIZE_25_PX;
import static com.esp.espflow.data.util.EspFlowConstants.THIS_FEATURE_HAS_NOT_BEEN_IMPLEMENTED_YET;
import static com.esp.espflow.data.util.EspFlowConstants.*;

/**
* @author rubn
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,7 @@
import java.util.Objects;
import java.util.stream.Stream;

import static com.esp.espflow.data.util.EspFlowConstants.BAUD_RATE;
import static com.esp.espflow.data.util.EspFlowConstants.FLASH_MODE;
import static com.esp.espflow.data.util.EspFlowConstants.FLASH_SIZE;
import static com.esp.espflow.data.util.EspFlowConstants.JAVA_IO_TEMPORAL_DIR_OS;
import static com.esp.espflow.data.util.EspFlowConstants.PORT;
import static com.esp.espflow.data.util.EspFlowConstants.WRITE_FLASH;
import static com.esp.espflow.data.util.EspFlowConstants.*;

/**
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,7 @@
import java.util.Objects;
import java.util.stream.Stream;

import static com.esp.espflow.data.util.EspFlowConstants.BOX_SHADOW_VAADIN_BUTTON;
import static com.esp.espflow.data.util.EspFlowConstants.CHIP_IS;
import static com.esp.espflow.data.util.EspFlowConstants.CHIP_TYPE;
import static com.esp.espflow.data.util.EspFlowConstants.CRYSTAL_IS;
import static com.esp.espflow.data.util.EspFlowConstants.DETECTED_FLASH_SIZE;
import static com.esp.espflow.data.util.EspFlowConstants.MAC;
import static com.esp.espflow.data.util.EspFlowConstants.*;

/**
* The DeviceCardLayout
Expand Down
Loading

0 comments on commit 4a34442

Please sign in to comment.