From 6ac3785e09006da972a151e1724301293c541d4f Mon Sep 17 00:00:00 2001
From: Malaurie Bernard <mbernard@kinouby>
Date: Tue, 11 Jul 2023 12:31:24 +0200
Subject: [PATCH] /bin/bash: line 1: q: command not found

---
 pousseseringue-arduino.cpp |  8 ++++++++
 syringe.cpp                | 27 +++++++++++++--------------
 syringe.h                  |  6 ++++--
 syringefilled.cpp          |  2 +-
 4 files changed, 26 insertions(+), 17 deletions(-)

diff --git a/pousseseringue-arduino.cpp b/pousseseringue-arduino.cpp
index 44d8397..6190aa5 100644
--- a/pousseseringue-arduino.cpp
+++ b/pousseseringue-arduino.cpp
@@ -344,6 +344,14 @@ void setup()
     {
         Serial.printf("FS: could not be started\n");
     }
+
+    //Json 
+
+    syringe_filled.read_Json();
+    syringe.read_Json();
+
+
+
 }
 
 
diff --git a/syringe.cpp b/syringe.cpp
index e9fedc6..928e107 100644
--- a/syringe.cpp
+++ b/syringe.cpp
@@ -102,33 +102,32 @@ bool Syringe :: check_configuration(String name)
 
 
 
-//Example : File f = ({ InterruptLock lock; filesystem->open(filename, "w"); }); and the f becomes the argument output_stream
+//Example : File f = ({ InterruptLock lock; filesystem->open(filename, "w"); }); and the f becomes the argument input_stream
 //useful in web.cpp via a button to save data
-void Syringe :: write_Json (Stream& output_stream)
-{ 
+void Syringe :: write_Json ()
 /***
--Argument : output_stream (= serial or a file)
+-Argument : input_stream (= serial or a file)
 -Return   : /
 -Action   : Save the Json structure in a file (convert it to text)
 ***/
-
+{
 InterruptLock lock; //useful thanks to its constructor (so a is not visible in the code)
-serializeJson(syringe_json, output_stream);
-
+File f = filesystem->open("syringe_json", "w"); //Creation du fichier
+serializeJson(syringe_json, f);
+  
 }
 
-
 //useful in setup of pousse-seringue.cpp(to check at the begining what has already been saved) and web.cpp via a button to recover data
-void Syringe :: read_Json (Stream& input_stream)
-{
+void Syringe :: read_Json ()
 /***
--Argument : input_stream (= serial or a file)
+-Argument : output_stream (= serial or a file)
 -Return   : /
--Action   : Check if a Json Document alredy exist or not
+-Action   : Check if a Json Document alredy exist or not, if it does it is load
 ***/
-
+{
 InterruptLock lock; //useful thanks to its constructor (so a is not visible in the code)
-deserializeJson(syringe_json, input_stream);
+File f = filesystem->open("syringe_json", "r"); //Creation du fichier
+deserializeJson(syringe_json, f);
 
 }
 
diff --git a/syringe.h b/syringe.h
index cda73c5..64b476f 100644
--- a/syringe.h
+++ b/syringe.h
@@ -11,6 +11,8 @@ using InterruptLock = esp8266::InterruptLock;
 using namespace std;
 
 
+#include "fs.h"
+
 class Syringe
 {
   private :
@@ -50,8 +52,8 @@ class Syringe
   bool check_configuration(String name);
 
   //JSON METHODS
-  void write_Json (Stream& output_stream);
-  void read_Json (Stream& input_stream);
+  void write_Json ();
+  void read_Json ();
 
 };
 
diff --git a/syringefilled.cpp b/syringefilled.cpp
index 146093d..e3d912c 100644
--- a/syringefilled.cpp
+++ b/syringefilled.cpp
@@ -343,7 +343,7 @@ void SyringeFilled :: read_Json ()
 /***
 -Argument : output_stream (= serial or a file)
 -Return   : /
--Action   : Check if a Json Document alredy exist or not
+-Action   : Check if a Json Document alredy exist or not, if it does it is load
 ***/
 {
 InterruptLock lock; //useful thanks to its constructor (so a is not visible in the code)
-- 
GitLab