@@ -77,6 +77,11 @@ public void run() {
77
77
while ((c = reader .read ()) != -1 )
78
78
System .out .print ((char ) c );
79
79
reader .close ();
80
+
81
+ reader = new InputStreamReader (p .getErrorStream ());
82
+ while ((c = reader .read ()) != -1 )
83
+ System .err .print ((char ) c );
84
+ reader .close ();
80
85
} catch (Exception e ){}
81
86
}
82
87
};
@@ -145,7 +150,7 @@ private long getIntPref(String name){
145
150
}
146
151
147
152
private void createAndUpload (){
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" ) ){
149
154
System .err .println ();
150
155
editor .statusError ("SPIFFS Not Supported on " +PreferencesData .get ("target_platform" ));
151
156
return ;
@@ -170,21 +175,8 @@ private void createAndUpload(){
170
175
}
171
176
172
177
TargetPlatform platform = BaseNoGui .getTargetPlatform ();
173
-
174
- String esptoolCmd = platform .getTool ("esptool" ).get ("cmd" );
175
- File esptool ;
176
- esptool = new File (platform .getFolder ()+"/tools" , esptoolCmd );
177
- if (!esptool .exists () || !esptool .isFile ()){
178
- esptool = new File (platform .getFolder ()+"/tools/esptool" , esptoolCmd );
179
- if (!esptool .exists ()){
180
- esptool = new File (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
188
180
String mkspiffsCmd ;
189
181
if (PreferencesData .get ("runtime.os" ).contentEquals ("windows" ))
190
182
mkspiffsCmd = "mkspiffs.exe" ;
@@ -203,7 +195,46 @@ private void createAndUpload(){
203
195
}
204
196
}
205
197
}
198
+
199
+ Boolean isNetwork = false ;
200
+ File espota = new File (platform .getFolder ()+"/tools" );
201
+ File esptool = new File (platform .getFolder ()+"/tools" );
202
+ String serialPort = 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
+ }
206
210
211
+ //find espota if IP else find esptool
212
+ if (serialPort .split ("\\ ." ).length == 4 ){
213
+ isNetwork = true ;
214
+ String espotaCmd = "espota.py" ;
215
+ espota = new File (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
+ String esptoolCmd = platform .getTool ("esptool" ).get ("cmd" );
223
+ esptool = new File (platform .getFolder ()+"/tools" , esptoolCmd );
224
+ if (!esptool .exists () || !esptool .isFile ()){
225
+ esptool = new File (platform .getFolder ()+"/tools/esptool" , esptoolCmd );
226
+ if (!esptool .exists ()){
227
+ esptool = new File (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
207
238
int fileCount = 0 ;
208
239
File dataFolder = new File (editor .getSketch ().getFolder (), "data" );
209
240
if (!dataFolder .exists ()) {
@@ -213,21 +244,21 @@ private void createAndUpload(){
213
244
File [] files = dataFolder .listFiles ();
214
245
if (files .length > 0 ){
215
246
for (File file : files ){
216
- if (! file .isDirectory () && file .isFile () && !file .getName ().startsWith ("." )) fileCount ++;
247
+ if (( file .isDirectory () || file .isFile () ) && !file .getName ().startsWith ("." )) fileCount ++;
217
248
}
218
249
}
219
250
}
220
251
221
252
String dataPath = dataFolder .getAbsolutePath ();
222
253
String toolPath = tool .getAbsolutePath ();
223
- String esptoolPath = esptool .getAbsolutePath ();
224
254
String sketchName = editor .getSketch ().getName ();
225
255
String imagePath = getBuildFolderPath (editor .getSketch ()) + "/" + sketchName + ".spiffs.bin" ;
226
- String serialPort = PreferencesData .get ("serial.port" );
227
256
String resetMethod = BaseNoGui .getBoardPreferences ().get ("upload.resetmethod" );
228
257
String uploadSpeed = BaseNoGui .getBoardPreferences ().get ("upload.speed" );
229
258
String uploadAddress = BaseNoGui .getBoardPreferences ().get ("build.spiffs_start" );
230
259
260
+
261
+
231
262
Object [] options = { "Yes" , "No" };
232
263
String title = "SPIFFS Create" ;
233
264
String message = "No files have been found in your data folder!\n Are you sure you want to create an empty SPIFFS image?" ;
@@ -258,13 +289,25 @@ private void createAndUpload(){
258
289
259
290
editor .statusNotice ("SPIFFS Uploading Image..." );
260
291
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 (new String []{esptoolPath , "-cd" , resetMethod , "-cb" , uploadSpeed , "-cp" , serialPort , "-ca" , uploadAddress , "-cf" , imagePath });
292
+
293
+ if (isNetwork ){
294
+ String pythonCmd ;
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 (new String []{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 (new String []{esptool .getAbsolutePath (), "-cd" , resetMethod , "-cb" , uploadSpeed , "-cp" , serialPort , "-ca" , uploadAddress , "-cf" , imagePath });
310
+ }
268
311
}
269
312
270
313
public void run () {
0 commit comments