@@ -77,6 +77,11 @@ public void run() {
7777while ((c =reader .read ()) != -1 )
7878System .out .print ((char )c );
7979reader .close ();
80+
81+ reader =new InputStreamReader (p .getErrorStream ());
82+ while ((c =reader .read ()) != -1 )
83+ System .err .print ((char )c );
84+ reader .close ();
8085 }catch (Exception e ){}
8186 }
8287 };
@@ -145,7 +150,7 @@ private long getIntPref(String name){
145150 }
146151
147152private 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" ) ){
149154System .err .println ();
150155editor .statusError ("SPIFFS Not Supported on " +PreferencesData .get ("target_platform" ));
151156return ;
@@ -170,21 +175,8 @@ private void createAndUpload(){
170175 }
171176
172177TargetPlatform 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
188180String mkspiffsCmd ;
189181if (PreferencesData .get ("runtime.os" ).contentEquals ("windows" ))
190182mkspiffsCmd ="mkspiffs.exe" ;
@@ -203,7 +195,46 @@ private void createAndUpload(){
203195 }
204196 }
205197 }
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+ }
206210
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
207238int fileCount =0 ;
208239File dataFolder =new File (editor .getSketch ().getFolder (),"data" );
209240if (!dataFolder .exists ()) {
@@ -213,21 +244,21 @@ private void createAndUpload(){
213244File []files =dataFolder .listFiles ();
214245if (files .length >0 ){
215246for (File file :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
221252String dataPath =dataFolder .getAbsolutePath ();
222253String toolPath =tool .getAbsolutePath ();
223- String esptoolPath =esptool .getAbsolutePath ();
224254String sketchName =editor .getSketch ().getName ();
225255String imagePath =getBuildFolderPath (editor .getSketch ()) +"/" +sketchName +".spiffs.bin" ;
226- String serialPort =PreferencesData .get ("serial.port" );
227256String resetMethod =BaseNoGui .getBoardPreferences ().get ("upload.resetmethod" );
228257String uploadSpeed =BaseNoGui .getBoardPreferences ().get ("upload.speed" );
229258String uploadAddress =BaseNoGui .getBoardPreferences ().get ("build.spiffs_start" );
230259
260+
261+
231262Object []options = {"Yes" ,"No" };
232263String title ="SPIFFS Create" ;
233264String 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(){
258289
259290editor .statusNotice ("SPIFFS Uploading Image..." );
260291System .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+ }
268311 }
269312
270313public void run () {