Skip to content

Commit 30ded80

Browse files
committed
Revert "esp32-c6, devicename provisioning, Core 3 -> IDF5"
This reverts commit 0790945. reverting 0790945
1 parent 7473d67 commit 30ded80

17 files changed

+177
-263
lines changed

src/main/java/org/dpsoftware/FireflyLuciferin.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -601,8 +601,7 @@ private void clean() {
601601
}
602602
}
603603
if (MainSingleton.getInstance().serial != null) {
604-
SerialManager sm = new SerialManager();
605-
sm.closeSerial();
604+
MainSingleton.getInstance().serial.closePort();
606605
}
607606
}
608607

src/main/java/org/dpsoftware/MainSingleton.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ public class MainSingleton {
105105
public boolean cpuLatencyBenchRunning = false;
106106
public int cpuLatencyBench = 0;
107107
public boolean restartNeeded = false;
108-
public String improvActive = "";
109108

110109
}
111110

src/main/java/org/dpsoftware/NativeExecutor.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
import org.dpsoftware.config.LocalizedEnum;
3434
import org.dpsoftware.gui.bindings.appindicator.LibAppIndicator;
3535
import org.dpsoftware.managers.PipelineManager;
36-
import org.dpsoftware.managers.SerialManager;
3736
import org.dpsoftware.managers.dto.mqttdiscovery.SensorProducingDiscovery;
3837
import org.dpsoftware.network.NetworkSingleton;
3938
import org.dpsoftware.utilities.CommonUtility;
@@ -390,14 +389,13 @@ public static void exit() {
390389
if (MainSingleton.getInstance().RUNNING) {
391390
MainSingleton.getInstance().guiManager.stopCapturingThreads(true);
392391
}
393-
if (MainSingleton.getInstance().serial != null) {
394-
SerialManager sm = new SerialManager();
395-
sm.closeSerial();
396-
}
397392
MainSingleton.getInstance().exitTriggered = true;
398393
log.info(Constants.CLEAN_EXIT);
399394
NetworkSingleton.getInstance().udpBroadcastReceiverRunning = false;
400395
exitOtherInstances();
396+
if (MainSingleton.getInstance().serial != null) {
397+
MainSingleton.getInstance().serial.closePort();
398+
}
401399
AudioSingleton.getInstance().RUNNING_AUDIO = false;
402400
CommonUtility.delaySeconds(() -> {
403401
lastWill();

src/main/java/org/dpsoftware/config/Constants.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,6 @@ public class Constants {
379379

380380
@SuppressWarnings("all")
381381
public static final String HTTP = "http://";
382-
public static final String BC = "0.0.0.0";
383382
public static final int HTTP_SUCCESS = 200;
384383
public static final String SERIAL_PORT_AUTO = "AUTO";
385384
public static final String SERIAL_PORT_COM = "COM";
@@ -408,7 +407,6 @@ public class Constants {
408407
public static final String SERIAL_LDR_SBPIN = "sbPin:";
409408
public static final String SERIAL_LDR_LDRPIN = "ldrPin:";
410409
public static final String SERIAL_GPIO_CLOCK = "gpioClock:";
411-
public static final String IP_ADDRESS = "IP Address";
412410
public static final String SERIAL_IMPROV = "IMPROV";
413411
public static final byte[] IMPROV_HEADER = {'I', 'M', 'P', 'R', 'O', 'V'};
414412
public static final String NO_DEVICE_FOUND = "no.device.found";
@@ -551,7 +549,6 @@ public class Constants {
551549
public static final String TOOLTIP_IMPROV_PWD = "fxml.mqtttab.improv.pwd";
552550
public static final String TOOLTIP_IMPROV_COM = "fxml.mqtttab.improv.comport";
553551
public static final String TOOLTIP_IMPROV_BAUD = "fxml.mqtttab.improv.baudrate";
554-
public static final String TOOLTIP_DEV_NAME = "fxml.mqtttab.improv.baudrate";
555552
public static final String TOOLTIP_IMPROV_CONTEXT = "fxml.mqtttab.improv.context";
556553
// Grabber
557554
public static final String INTERNAL_SCALING_X = "INTERNAL_SCALING_X";
@@ -769,7 +766,6 @@ public class Constants {
769766
public static final int PROFILE_THREAD_DELAY = 30000;
770767
public static final int SPAWN_INSTANCE_WAIT_START_DELAY = 3000;
771768
public static String REGEXP_URL = "https?://(\\d{1,3}(?:\\.\\d{1,3}){3})";
772-
public static String REGEXP_IP = "\\b((25[0-5]|2[0-4]\\d|1?\\d?\\d)\\.){3}(25[0-5]|2[0-4]\\d|1?\\d?\\d)\\b";
773769
public static final String[] CMD_CUDA_CHECK = {"/bin/sh", "-c", "gst-inspect-1.0 nvcodec | grep cuda"};
774770
public static final String[] PING_WINDOWS = {"ping", "-n", "1"};
775771
public static final String[] PING_LINUX = {"ping", "-c", "1"};

src/main/java/org/dpsoftware/config/Enums.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ public enum SupportedDevice {
4242
ESP8266,
4343
ESP32,
4444
ESP32_C3_CDC,
45-
ESP32_C6,
4645
ESP32_S2,
4746
ESP32_S3,
4847
ESP32_S3_CDC

src/main/java/org/dpsoftware/gui/controllers/ImprovDialogController.java

Lines changed: 71 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import javafx.scene.control.Button;
2727
import javafx.scene.control.ComboBox;
2828
import javafx.scene.control.PasswordField;
29-
import javafx.scene.control.TextField;
3029
import javafx.scene.input.InputEvent;
3130
import lombok.extern.slf4j.Slf4j;
3231
import org.dpsoftware.MainSingleton;
@@ -45,7 +44,7 @@
4544
import java.util.concurrent.Executors;
4645
import java.util.concurrent.ScheduledExecutorService;
4746
import java.util.concurrent.TimeUnit;
48-
import java.util.concurrent.atomic.AtomicInteger;
47+
import java.util.concurrent.atomic.AtomicBoolean;
4948
import java.util.regex.Matcher;
5049
import java.util.regex.Pattern;
5150

@@ -69,8 +68,6 @@ public class ImprovDialogController {
6968
public Button cancelButton;
7069
@FXML
7170
private SettingsController settingsController;
72-
@FXML
73-
public TextField deviceName;
7471

7572
/**
7673
* Inject main controller containing the TabPane
@@ -99,7 +96,6 @@ protected void initialize() {
9996
if (comPort != null && !comPort.getItems().isEmpty()) {
10097
comPort.setValue(comPort.getItems().getFirst());
10198
}
102-
deviceName.setText(MainSingleton.getInstance().config.getOutputDevice());
10399
baudrate.setValue(Enums.BaudRate.BAUD_RATE_115200.getBaudRate());
104100
});
105101
}
@@ -112,7 +108,6 @@ private void setTooltips() {
112108
GuiManager.createTooltip(Constants.TOOLTIP_IMPROV_PWD, wifiPwd);
113109
GuiManager.createTooltip(Constants.TOOLTIP_IMPROV_COM, comPort);
114110
GuiManager.createTooltip(Constants.TOOLTIP_IMPROV_BAUD, baudrate);
115-
GuiManager.createTooltip(Constants.TOOLTIP_DEV_NAME, deviceName);
116111
}
117112

118113
/**
@@ -150,25 +145,15 @@ public void saveAndClose(InputEvent e) {
150145
wifiPwd.commitValue();
151146
baudrate.commitValue();
152147
comPort.commitValue();
153-
manageImprov();
154-
CommonUtility.closeCurrentStage(e);
155-
}
156-
157-
/**
158-
* Program device using the IMPROV WiFi protocol
159-
*/
160-
private void manageImprov() {
161-
SerialManager serialManager = new SerialManager();
162-
serialManager.initSerial(comPort.getValue(), baudrate.getValue());
148+
AtomicBoolean error = new AtomicBoolean(false);
149+
AtomicBoolean postponed = new AtomicBoolean(false);
163150
ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);
164-
AtomicInteger retryNumber = new AtomicInteger(0);
165-
MainSingleton.getInstance().guiManager.pipelineManager.stopCapturePipeline();
166-
final int MAX_RETRY = 5;
167151
Runnable checkAndRun = () -> {
168-
boolean improvError;
169-
retryNumber.getAndIncrement();
170-
log.debug("Trying to send an Improv WiFi command");
171-
if (MainSingleton.getInstance().config != null && MainSingleton.getInstance().serial != null && MainSingleton.getInstance().serial.isOpen()) {
152+
if (MainSingleton.getInstance().config != null) {
153+
if (postponed.get()) {
154+
CommonUtility.sleepSeconds(5);
155+
}
156+
MainSingleton.getInstance().guiManager.pipelineManager.stopCapturePipeline();
172157
MainSingleton.getInstance().config.setOutputDevice(settingsController.modeTabController.serialPort.getValue());
173158
MainSingleton.getInstance().config.setMqttEnable(settingsController.networkTabController.mqttEnable.isSelected());
174159
if (MainSingleton.getInstance().config.isMqttEnable()) {
@@ -178,71 +163,20 @@ private void manageImprov() {
178163
MainSingleton.getInstance().config.setMqttUsername(settingsController.networkTabController.mqttUser.getText());
179164
MainSingleton.getInstance().config.setMqttPwd(settingsController.networkTabController.mqttPwd.getText());
180165
}
181-
try {
182-
improvError = sendImprov();
183-
} catch (IOException ex) {
184-
log.error(ex.getMessage());
185-
improvError = true;
186-
}
187-
} else {
188-
improvError = true;
189-
}
190-
if (!improvError || retryNumber.get() >= MAX_RETRY) {
166+
error.set(improvWiFiCommand());
191167
scheduler.shutdown();
192-
if (MainSingleton.getInstance().communicationError) {
193-
MainSingleton.getInstance().guiManager.showLocalizedNotification(CommonUtility.getWord(Constants.FIRMWARE_PROVISION_NOTIFY),
194-
CommonUtility.getWord(Constants.FIRMWARE_PROVISION_NOTIFY_HEADER), Constants.FIREFLY_LUCIFERIN, TrayIcon.MessageType.ERROR);
168+
} else {
169+
postponed.set(true);
170+
if (!postponed.get()) {
171+
// logger isn't initialized yet, don't use the logger here.
172+
System.out.println("Postponing provisioning...");
195173
}
196174
}
197175
};
198-
scheduler.scheduleAtFixedRate(checkAndRun, 100, 2000, TimeUnit.MILLISECONDS);
199-
}
200-
201-
/**
202-
* Send improv wifi msg
203-
*
204-
* @return error
205-
* @throws IOException can't open port
206-
*/
207-
private boolean sendImprov() throws IOException {
208-
byte version = 0x01;
209-
byte rpcPacketType = 0x03;
210-
byte rpcCommandType = 0x01;
211-
byte[] ssidBytes = ssid.getValue().getBytes(StandardCharsets.UTF_8);
212-
byte[] passBytes = wifiPwd.getText().getBytes(StandardCharsets.UTF_8);
213-
int dataLen = 1 + ssidBytes.length + 1 + passBytes.length;
214-
int packetLen = Constants.IMPROV_HEADER.length + 1 + 1 + 1 + 1 + 1 + dataLen + 1;
215-
byte[] packet = new byte[packetLen];
216-
int idx = 0;
217-
// Header
218-
for (byte b : Constants.IMPROV_HEADER) packet[idx++] = b;
219-
packet[idx++] = version;
220-
packet[idx++] = rpcPacketType;
221-
packet[idx++] = (byte) (dataLen + 2);
222-
packet[idx++] = rpcCommandType;
223-
// Data
224-
packet[idx++] = (byte) (ssidBytes.length + passBytes.length);
225-
packet[idx++] = (byte) ssidBytes.length;
226-
System.arraycopy(ssidBytes, 0, packet, idx, ssidBytes.length);
227-
idx += ssidBytes.length;
228-
packet[idx++] = (byte) passBytes.length;
229-
System.arraycopy(passBytes, 0, packet, idx, passBytes.length);
230-
idx += passBytes.length;
231-
// Checksum
232-
int checksum = 0;
233-
for (int i = 0; i < idx; i++) {
234-
checksum += packet[i] & 0xFF;
176+
scheduler.scheduleAtFixedRate(checkAndRun, 0, 500, TimeUnit.MILLISECONDS);
177+
if (!error.get()) {
178+
CommonUtility.closeCurrentStage(e);
235179
}
236-
byte checksumByte = (byte) (checksum & 0xFF);
237-
packet[idx] = checksumByte;
238-
if (MainSingleton.getInstance().output != null) {
239-
log.debug("Improv WiFi packet sent");
240-
MainSingleton.getInstance().improvActive = deviceName.getText();
241-
MainSingleton.getInstance().output.write(packet);
242-
} else {
243-
return true;
244-
}
245-
return false;
246180
}
247181

248182
/**
@@ -332,4 +266,58 @@ class NetworkInfo {
332266
}
333267
}
334268

269+
/**
270+
* Program device using the IMPROV WiFi protocol
271+
*
272+
* @return true if there is a serial error
273+
*/
274+
public boolean improvWiFiCommand() {
275+
SerialManager serialManager = new SerialManager();
276+
serialManager.closeSerial();
277+
serialManager.initSerial(comPort.getValue(), baudrate.getValue());
278+
try {
279+
byte version = 0x01;
280+
byte rpcPacketType = 0x03;
281+
byte rpcCommandType = 0x01;
282+
byte[] ssidBytes = ssid.getValue().getBytes(StandardCharsets.UTF_8);
283+
byte[] passBytes = wifiPwd.getText().getBytes(StandardCharsets.UTF_8);
284+
int dataLen = 1 + ssidBytes.length + 1 + passBytes.length;
285+
int packetLen = Constants.IMPROV_HEADER.length + 1 + 1 + 1 + 1 + 1 + dataLen + 1;
286+
byte[] packet = new byte[packetLen];
287+
int idx = 0;
288+
// Header
289+
for (byte b : Constants.IMPROV_HEADER) packet[idx++] = b;
290+
packet[idx++] = version;
291+
packet[idx++] = rpcPacketType;
292+
packet[idx++] = (byte) (dataLen + 2);
293+
packet[idx++] = rpcCommandType;
294+
// Data
295+
packet[idx++] = (byte) (ssidBytes.length + passBytes.length);
296+
packet[idx++] = (byte) ssidBytes.length;
297+
System.arraycopy(ssidBytes, 0, packet, idx, ssidBytes.length);
298+
idx += ssidBytes.length;
299+
packet[idx++] = (byte) passBytes.length;
300+
System.arraycopy(passBytes, 0, packet, idx, passBytes.length);
301+
idx += passBytes.length;
302+
// Checksum
303+
int checksum = 0;
304+
for (int i = 0; i < idx; i++) {
305+
checksum += packet[i] & 0xFF;
306+
}
307+
byte checksumByte = (byte) (checksum & 0xFF);
308+
packet[idx] = checksumByte;
309+
if (MainSingleton.getInstance().output == null) {
310+
MainSingleton.getInstance().guiManager.showLocalizedNotification(CommonUtility.getWord(Constants.FIRMWARE_PROVISION_NOTIFY),
311+
CommonUtility.getWord(Constants.FIRMWARE_PROVISION_NOTIFY_HEADER), Constants.FIREFLY_LUCIFERIN, TrayIcon.MessageType.ERROR);
312+
return true;
313+
} else {
314+
MainSingleton.getInstance().output.write(packet);
315+
}
316+
} catch (IOException ex) {
317+
log.error(ex.getMessage());
318+
return true;
319+
}
320+
return false;
321+
}
322+
335323
}

src/main/java/org/dpsoftware/gui/controllers/SettingsController.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ private void runLater() {
238238
* Init all the settings listener
239239
*/
240240
private void initListeners() {
241-
CommonUtility.delayMilliseconds(this::setSerialPortAvailableCombo, 10);
241+
setSerialPortAvailableCombo();
242242
networkTabController.initListeners();
243243
modeTabController.initListeners();
244244
miscTabController.initListeners(currentConfig);
@@ -604,11 +604,7 @@ public void setFirmwareConfig(String macToProgram, boolean changeBaudrate) {
604604
if (device.getBaudRate().isEmpty()) {
605605
firmwareConfigDto.setBr(Enums.BaudRate.findByExtendedVal(MainSingleton.getInstance().config.getBaudRate()).getBaudRateValue());
606606
} else {
607-
try {
608-
firmwareConfigDto.setBr(Enums.BaudRate.findByExtendedVal(device.getBaudRate()).getBaudRateValue());
609-
} catch (Exception nullPointerException) {
610-
firmwareConfigDto.setBr(Enums.BaudRate.BAUD_RATE_115200.getBaudRateValue());
611-
}
607+
firmwareConfigDto.setBr(Enums.BaudRate.findByExtendedVal(device.getBaudRate()).getBaudRateValue());
612608
}
613609
}
614610
firmwareConfigDto.setLednum(device.getNumberOfLEDSconnected());

0 commit comments

Comments
 (0)