Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit68fd738

Browse files
author
Me No Dev
committed
add support for folders and esp31b
1 parenta8e541f commit68fd738

File tree

1 file changed

+69
-26
lines changed

1 file changed

+69
-26
lines changed

‎src/ESP8266FS.java‎

Lines changed: 69 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,11 @@ public void run() {
7777
while ((c =reader.read()) != -1)
7878
System.out.print((char)c);
7979
reader.close();
80+
81+
reader =newInputStreamReader(p.getErrorStream());
82+
while ((c =reader.read()) != -1)
83+
System.err.print((char)c);
84+
reader.close();
8085
}catch (Exceptione){}
8186
}
8287
};
@@ -145,7 +150,7 @@ private long getIntPref(String name){
145150
}
146151

147152
privatevoidcreateAndUpload(){
148-
if(!PreferencesData.get("target_platform").contentEquals("esp8266")){
153+
if(!PreferencesData.get("target_platform").contentEquals("esp8266") && !PreferencesData.get("target_platform").contentEquals("esp31b") && !PreferencesData.get("target_platform").contentEquals("ESP31B")){
149154
System.err.println();
150155
editor.statusError("SPIFFS Not Supported on "+PreferencesData.get("target_platform"));
151156
return;
@@ -170,21 +175,8 @@ private void createAndUpload(){
170175
}
171176

172177
TargetPlatformplatform =BaseNoGui.getTargetPlatform();
173-
174-
StringesptoolCmd =platform.getTool("esptool").get("cmd");
175-
Fileesptool;
176-
esptool =newFile(platform.getFolder()+"/tools",esptoolCmd);
177-
if(!esptool.exists() || !esptool.isFile()){
178-
esptool =newFile(platform.getFolder()+"/tools/esptool",esptoolCmd);
179-
if(!esptool.exists()){
180-
esptool =newFile(PreferencesData.get("runtime.tools.esptool.path"),esptoolCmd);
181-
if (!esptool.exists()) {
182-
System.err.println();
183-
editor.statusError("SPIFFS Error: esptool not found!");
184-
return;
185-
}
186-
}
187-
}
178+
179+
//Make sure mkspiffs binary exists
188180
StringmkspiffsCmd;
189181
if(PreferencesData.get("runtime.os").contentEquals("windows"))
190182
mkspiffsCmd ="mkspiffs.exe";
@@ -203,7 +195,46 @@ private void createAndUpload(){
203195
}
204196
}
205197
}
198+
199+
BooleanisNetwork =false;
200+
Fileespota =newFile(platform.getFolder()+"/tools");
201+
Fileesptool =newFile(platform.getFolder()+"/tools");
202+
StringserialPort =PreferencesData.get("serial.port");
203+
204+
//make sure the serial port or IP is defined
205+
if (serialPort ==null ||serialPort.isEmpty()) {
206+
System.err.println();
207+
editor.statusError("SPIFFS Error: serial port not defined!");
208+
return;
209+
}
206210

211+
//find espota if IP else find esptool
212+
if(serialPort.split("\\.").length ==4){
213+
isNetwork =true;
214+
StringespotaCmd ="espota.py";
215+
espota =newFile(platform.getFolder()+"/tools",espotaCmd);
216+
if(!espota.exists() || !espota.isFile()){
217+
System.err.println();
218+
editor.statusError("SPIFFS Error: espota not found!");
219+
return;
220+
}
221+
}else {
222+
StringesptoolCmd =platform.getTool("esptool").get("cmd");
223+
esptool =newFile(platform.getFolder()+"/tools",esptoolCmd);
224+
if(!esptool.exists() || !esptool.isFile()){
225+
esptool =newFile(platform.getFolder()+"/tools/esptool",esptoolCmd);
226+
if(!esptool.exists()){
227+
esptool =newFile(PreferencesData.get("runtime.tools.esptool.path"),esptoolCmd);
228+
if (!esptool.exists()) {
229+
System.err.println();
230+
editor.statusError("SPIFFS Error: esptool not found!");
231+
return;
232+
}
233+
}
234+
}
235+
}
236+
237+
//load a list of all files
207238
intfileCount =0;
208239
FiledataFolder =newFile(editor.getSketch().getFolder(),"data");
209240
if (!dataFolder.exists()) {
@@ -213,21 +244,21 @@ private void createAndUpload(){
213244
File[]files =dataFolder.listFiles();
214245
if(files.length >0){
215246
for(Filefile :files){
216-
if(!file.isDirectory()&&file.isFile() && !file.getName().startsWith("."))fileCount++;
247+
if((file.isDirectory()||file.isFile()) && !file.getName().startsWith("."))fileCount++;
217248
}
218249
}
219250
}
220251

221252
StringdataPath =dataFolder.getAbsolutePath();
222253
StringtoolPath =tool.getAbsolutePath();
223-
StringesptoolPath =esptool.getAbsolutePath();
224254
StringsketchName =editor.getSketch().getName();
225255
StringimagePath =getBuildFolderPath(editor.getSketch()) +"/" +sketchName +".spiffs.bin";
226-
StringserialPort =PreferencesData.get("serial.port");
227256
StringresetMethod =BaseNoGui.getBoardPreferences().get("upload.resetmethod");
228257
StringuploadSpeed =BaseNoGui.getBoardPreferences().get("upload.speed");
229258
StringuploadAddress =BaseNoGui.getBoardPreferences().get("build.spiffs_start");
230259

260+
261+
231262
Object[]options = {"Yes","No" };
232263
Stringtitle ="SPIFFS Create";
233264
Stringmessage ="No files have been found in your data folder!\nAre you sure you want to create an empty SPIFFS image?";
@@ -258,13 +289,25 @@ private void createAndUpload(){
258289

259290
editor.statusNotice("SPIFFS Uploading Image...");
260291
System.out.println("[SPIFFS] upload : "+imagePath);
261-
System.out.println("[SPIFFS] reset : "+resetMethod);
262-
System.out.println("[SPIFFS] port : "+serialPort);
263-
System.out.println("[SPIFFS] speed : "+uploadSpeed);
264-
System.out.println("[SPIFFS] address: "+uploadAddress);
265-
System.out.println();
266-
267-
sysExec(newString[]{esptoolPath,"-cd",resetMethod,"-cb",uploadSpeed,"-cp",serialPort,"-ca",uploadAddress,"-cf",imagePath});
292+
293+
if(isNetwork){
294+
StringpythonCmd;
295+
if(PreferencesData.get("runtime.os").contentEquals("windows"))
296+
pythonCmd ="python.exe";
297+
else
298+
pythonCmd ="python";
299+
300+
System.out.println("[SPIFFS] IP : "+serialPort);
301+
System.out.println();
302+
sysExec(newString[]{pythonCmd,espota.getAbsolutePath(),"-i",serialPort,"-s","-f",imagePath});
303+
}else {
304+
System.out.println("[SPIFFS] address: "+uploadAddress);
305+
System.out.println("[SPIFFS] reset : "+resetMethod);
306+
System.out.println("[SPIFFS] port : "+serialPort);
307+
System.out.println("[SPIFFS] speed : "+uploadSpeed);
308+
System.out.println();
309+
sysExec(newString[]{esptool.getAbsolutePath(),"-cd",resetMethod,"-cb",uploadSpeed,"-cp",serialPort,"-ca",uploadAddress,"-cf",imagePath});
310+
}
268311
}
269312

270313
publicvoidrun() {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp