Changes done in ECG and BT

Dependencies:   SDFileSystem ds3231 eeprom_Nikita mbed testUniGraphic_150217

Fork of merged_code2_20sept_2017_4th_oct_2017 by nikita teggi

Revision:
36:00d96aa14658
Parent:
27:907f8ce0025e
Child:
41:1141a75eacc4
--- a/sdcard.cpp	Sat Jul 29 10:38:05 2017 +0000
+++ b/sdcard.cpp	Sat Jul 29 11:23:19 2017 +0000
@@ -25,14 +25,6 @@
   
   FILE *fp;    // FILE pointer for random use
   
-  
-  
-  int ecgloc = 0;  // PPG and eCG maximum locations
-  int ppgloc = 0;  
-  
-  int ebp = 0;      // variable for LOOP operation to read value from File i == ECG , j == PPG
-  int pbp = 0;
-  
   //Function Added on 16/5/2017 by Nidhin
  void sd_open_mainfile(int32_t pid)
  {
@@ -207,9 +199,9 @@
  //------------------------------------------------------
   
 //FILE *sd_BP_ecgwrite (int value)      // writing data into the file NIDHIN
-FILE *sd_BP_ecgwrite (int32_t *fpdrum11)      // writing data into the file NIDHIN  
+FILE *sd_BP_ecgwrite (uint32_t *fpdrum11)      // writing data into the file NIDHIN  
   {
-        fwrite(fpdrum11,sizeof(int32_t),1, fpecg); //Change by Nidhin 30/5/2017 Direct writing to SD card. Org Val 64
+        fwrite(fpdrum11,sizeof(uint32_t),1, fpecg); //Change by Nidhin 30/5/2017 Direct writing to SD card. Org Val 64
         return fpecg;
   }
     
@@ -306,88 +298,6 @@
  
  
  
- //------------------------------------------  
- //REOPEN FUNCTIONs for reading data Nidhin
- 
- int sd_BP_ECGMAX(int32_t pid)         
- {
-     
-  char buffer1[32];
-   
-  sprintf(buffer1,"/sd/%d_BP_ECG.csv",pid);
-  fpecg = fopen(buffer1,"r"); 
-  if(fpecg == NULL)
-  {
-            exit(1);
-  }
-  
-  else
-  {
-    int ecgmax = 0;
-    int a[1] = {0};
-    int samplesecg =0;
-for(ebp=0; ebp<1024; ebp++)
-    {
-
-    
-    fread(a,sizeof(uint32_t), 1,fpecg);
-    // snd.printf("\n%d", a[0]); Commented May3_2017 (Nidhin)
-        if(a[0] > ecgmax)
-            {
-                ecgmax=a[0];
-                ecgloc= ebp +1;
-            }
-        else
-        samplesecg =ebp+1;
-    
-    }
-    }
-    fclose (fpecg);
-   return ecgloc; 
- } 
- 
- // Function to calculate PPG MAx and location
- 
-   int sd_BP_PPGMAX(int32_t pid)         
- {
-     
-  char buffer1[32];
-   
-  sprintf(buffer1,"/sd/%d_BP_PPG.csv",pid);
-  fpppg = fopen(buffer1,"r"); 
-  if(fpppg == NULL)
-  {
-            exit(1);
-  }
-  
-  else
-  {
-    uint32_t ppgmax = 0;
-    uint32_t b[1] ={0};
-    int samplesppg = 0;
-       for(pbp=0; pbp<1664; pbp++)
-            {
-                fread(b, sizeof(uint32_t),1, fpppg);
-                // snd.printf("\n%d", b[0]);   Commented May3_2017 (Nidhin)
-                
-                if((pbp>ecgloc) && (pbp< (ecgloc+350)))
-                    {
-                        if(b[0] > ppgmax)
-                            {
-                                ppgmax=b[0];
-                                ppgloc= pbp+1;
-                            }
-                        else
-                            samplesppg =pbp+1;
-                    }
-                else 
-                    samplesppg = pbp+1;
-            }
-    }        
-    fclose (fpppg);
-    return ppgloc;
- } 
- 
 //fread(buffer, 1, size, fp)
 //fwrite(&buffer, ,   
  //----------------------------------------------------28/4/2017---------------------------------
@@ -456,6 +366,8 @@
        
 }
 
+
+
 //Creating strcuture file Common to All Functions
 void structure_file(BLEMsg_info *ptr, int32_t pid)
 {
@@ -605,3 +517,27 @@
 }
 
 
+void del_ppg_ecg_BPfile(int32_t pid)
+{
+    int status = 1 ;
+    char buffer3[32];
+    sprintf(buffer3, "/sd/%d_BP_ECG.csv", pid);
+    status = remove(buffer3);                         //Removes ECG file of BP and updates status with 0 if successful
+        
+    if( status == 0 )
+        snd.printf("\n temp ECG file delete for error condition: Successful");   // Checks for SUCCESS
+    else 
+        snd.printf("\n temp ECG file delete for error condition: UnSuccessful");
+   
+    
+    //char buffer1[32] = "";
+    status = 1 ;
+    sprintf(buffer3, "/sd/%d_BP_PPG.csv", pid);
+    status = remove(buffer3);                           //Removes PPG file of BP and updates status with 0 if successful
+    
+    if( status == 0 )
+        snd.printf("\n temp PPG file delete for error condition: Successful");   // Checks for SUCCESS
+    else 
+        snd.printf("\n temp PPG file delete for error condition: UnSuccessful");
+       
+}
\ No newline at end of file