created separate function for hex to char

Dependencies:   SDFileSystem ds3231 eeprom_Nikita mbed testUniGraphic_150217

Fork of SS_SensePOC2P0_11Dec2017_USERPID by rashmi v

Committer:
rashmivenkataramaiah
Date:
Thu Nov 23 12:11:46 2017 +0000
Revision:
69:128e3b467820
Parent:
68:41da0a3ba038
Child:
70:f2e544a5645b
Modification in ASCII to hex conversion in main.cpp

Who changed what in which revision?

UserRevisionLine numberNew contents of line
nidhinvarghese 15:208b146151ba 1 // Code Modified with Bluetooth Structure Nidhin 2/6/17
nidhinvarghese 15:208b146151ba 2 ///
nidhinvarghese 15:208b146151ba 3 #include "mbed.h"
nidhinvarghese 15:208b146151ba 4 #include "glc.h"
nidhinvarghese 15:208b146151ba 5 #include "i2c_dec.h"
nidhinvarghese 15:208b146151ba 6 //#include "ili9325.h"
nidhinvarghese 15:208b146151ba 7 //#include "lcd_base.h"
nidhinvarghese 15:208b146151ba 8 #include "display_modules.h"
nidhinvarghese 15:208b146151ba 9 //#include "touch_modules.h"
nidhinvarghese 15:208b146151ba 10 #include "rtc.h"
nidhinvarghese 15:208b146151ba 11 #include "sdcard.h"
nikitateggi 20:7c64e6ecad76 12 #include "eeprom_pgm.h" // Nidhin 12/6/17
rashmivenkataramaiah 43:85a7f399cb9d 13 #include "main.h"
nidhinvarghese 15:208b146151ba 14 #include "struct.h" //Nidhin 31/5/2017
nikitateggi 19:1650bbc923cc 15 //#include "test_type.h" //Nidhin 31/5/2017
nidhinvarghese 15:208b146151ba 16
avp2417 40:f7f351699288 17 #define MAX_GLC_THRESHOLD 600
avp2417 40:f7f351699288 18 #define MIN_GLC_THRESHOLD 10
nidhinvarghese 15:208b146151ba 19
nidhinvarghese 15:208b146151ba 20 void sample();
nidhinvarghese 15:208b146151ba 21 void Compute();
nidhinvarghese 15:208b146151ba 22 void i2c_spec();
nidhinvarghese 15:208b146151ba 23 Ticker flipper;
nidhinvarghese 15:208b146151ba 24 Ticker flipper1;
nikitateggi 16:8fa1d7fd7953 25 unsigned char GLC_START = 0;
nidhinvarghese 15:208b146151ba 26 //osTimerDef (sample_data, sample); // define timers
nidhinvarghese 15:208b146151ba 27 //osTimerDef (Compute_GLC, Compute);
nidhinvarghese 15:208b146151ba 28 DigitalIn test_strip(PTA12);
nidhinvarghese 15:208b146151ba 29
nidhinvarghese 15:208b146151ba 30 AnalogIn Ain(PTC1);//Electrode one
nidhinvarghese 15:208b146151ba 31 AnalogIn Ain2(PTE29); // Electrode two
nidhinvarghese 15:208b146151ba 32 AnalogOut DAC_signal(PTE30);
nidhinvarghese 15:208b146151ba 33 Serial gtc(USBTX, USBRX);
nidhinvarghese 15:208b146151ba 34 //unsigned char c;
nidhinvarghese 15:208b146151ba 35 //unsigned char HOME = 0;
nidhinvarghese 15:208b146151ba 36
nidhinvarghese 15:208b146151ba 37 //signed char test_strip = 0;
nidhinvarghese 15:208b146151ba 38 static uint16_t mgdl = 0;
nikitateggi 16:8fa1d7fd7953 39 static uint16_t mgdll = 0;
nikitateggi 16:8fa1d7fd7953 40 uint16_t daata1= 0;
nikitateggi 16:8fa1d7fd7953 41 uint16_t data2 = 0;
nidhinvarghese 15:208b146151ba 42
nikitateggi 16:8fa1d7fd7953 43 static uint16_t data1n= 0;
nikitateggi 16:8fa1d7fd7953 44 static uint16_t data2n = 0;
nikitateggi 16:8fa1d7fd7953 45 uint16_t datafinal1 = 0;
nikitateggi 16:8fa1d7fd7953 46 uint16_t datafinal2 = 0;
nidhinvarghese 15:208b146151ba 47 //unsigned int data_diff = 0;
nidhinvarghese 15:208b146151ba 48 unsigned char err = 0;
nidhinvarghese 15:208b146151ba 49
nidhinvarghese 17:22a87e12fb3a 50 uint32_t glcraw[2]; // Nidhin 31/5/2017
nidhinvarghese 15:208b146151ba 51 uint8_t chk_glc_data = 0;
nikitateggi 20:7c64e6ecad76 52 uint16_t glc_testtype; // Nidhin 12/6/2017
nidhinvarghese 15:208b146151ba 53
nidhinvarghese 15:208b146151ba 54 Serial ble(PTC4,PTC3);
nidhinvarghese 15:208b146151ba 55
nidhinvarghese 15:208b146151ba 56
nidhinvarghese 15:208b146151ba 57
nidhinvarghese 15:208b146151ba 58 void sample()
nidhinvarghese 15:208b146151ba 59
nidhinvarghese 15:208b146151ba 60 {
nidhinvarghese 15:208b146151ba 61 data1n = Ain.read_u16();
nidhinvarghese 15:208b146151ba 62 data2n = Ain2.read_u16();
nidhinvarghese 15:208b146151ba 63 daata1 = beta*daata1+alpha*data1n;
nidhinvarghese 15:208b146151ba 64 data2 = beta*data2+alpha*data2n;
nidhinvarghese 15:208b146151ba 65
nidhinvarghese 15:208b146151ba 66 if( ((daata1-data2) >=(data2/10) && (daata1 > data2)) || ((data2-daata1) >=(data2/10) && (data2 > daata1)) )
nidhinvarghese 15:208b146151ba 67 {
nidhinvarghese 15:208b146151ba 68
nidhinvarghese 15:208b146151ba 69 err = 1;
nidhinvarghese 15:208b146151ba 70
nidhinvarghese 15:208b146151ba 71 }
nidhinvarghese 15:208b146151ba 72 else
nidhinvarghese 15:208b146151ba 73 {
nidhinvarghese 15:208b146151ba 74 err = 0;
nidhinvarghese 15:208b146151ba 75 //gtc.printf("\n", data1n, data2n); only for testing added nidhin 5Jun17
nidhinvarghese 15:208b146151ba 76 }
nidhinvarghese 15:208b146151ba 77
nidhinvarghese 15:208b146151ba 78 }
nidhinvarghese 15:208b146151ba 79
nidhinvarghese 15:208b146151ba 80
nidhinvarghese 15:208b146151ba 81
nidhinvarghese 15:208b146151ba 82 void Compute()
nidhinvarghese 15:208b146151ba 83 {
nidhinvarghese 15:208b146151ba 84
nikitateggi 22:ffa88619551d 85 flipper.detach(); // ticker for sampling is disabled
nikitateggi 16:8fa1d7fd7953 86 datafinal1 = (uint16_t ) NUMB1*(data2*VREF/(TOTAL))-NUMB2;
nikitateggi 16:8fa1d7fd7953 87 datafinal2 = (uint16_t ) NUMB1*(daata1*VREF/(TOTAL))-NUMB2;
nikitateggi 16:8fa1d7fd7953 88 mgdl = (uint16_t) NUMB1*(((daata1+data2)/2)*VREF/(TOTAL))-NUMB2; // Nidhin 5/6/17 mgdl = (uint16_t) NUMB1*(((daata1+data2)/2)*VREF/(TOTAL))-NUMB2;
nikitateggi 16:8fa1d7fd7953 89 GLC_START = 0;
nikitateggi 22:ffa88619551d 90 flipper1.detach();// ticker for computation is disabled
nidhinvarghese 15:208b146151ba 91 }
nidhinvarghese 15:208b146151ba 92
nidhinvarghese 15:208b146151ba 93
rashmivenkataramaiah 43:85a7f399cb9d 94 void glc(uint32_t pid){
nikitateggi 16:8fa1d7fd7953 95
nidhinvarghese 15:208b146151ba 96 char t_s_d = 0;
nikitateggi 54:f2a413d5dffd 97 i2c_spec(); // programming the i2c expander
nikitateggi 54:f2a413d5dffd 98 uint8_t err_no_teststip = 0;
nidhinvarghese 15:208b146151ba 99
nikitateggi 22:ffa88619551d 100 sd_open_GLCfilee(pid); // Opens GLC file in APPEND mode
nidhinvarghese 15:208b146151ba 101
nidhinvarghese 15:208b146151ba 102 // Bluetooth Structure created globally
nidhinvarghese 15:208b146151ba 103 BLEMsg_info *ptr_BLEMsg_info_glc, BLEMsg_info_glc; // A copy of master strcuture [ "BLEMsg_info" ] by name "BLEMsg_info_bp" is created
nidhinvarghese 15:208b146151ba 104 ptr_BLEMsg_info_glc = &BLEMsg_info_glc; // *ptr_BLEMsg_info_bp is the pointer to local copy;
nidhinvarghese 15:208b146151ba 105 // Cant declare this statement outside main. Causing conflicts
nidhinvarghese 15:208b146151ba 106
nidhinvarghese 15:208b146151ba 107 // Declaration of Date Structure
nidhinvarghese 15:208b146151ba 108 DateTime_info *ptr_DateTime_info_glc, DateTime_info_glc; // A copy of Master Structure "DateTime_info" created,
nidhinvarghese 15:208b146151ba 109 ptr_DateTime_info_glc = &DateTime_info_glc; // Structure pointer points to that copy.
nidhinvarghese 15:208b146151ba 110
nidhinvarghese 15:208b146151ba 111
nidhinvarghese 15:208b146151ba 112
nidhinvarghese 15:208b146151ba 113 // RTC operations
nidhinvarghese 15:208b146151ba 114 time_t epoch_time_glc; //A copy of time_t by name epoch_time_bp is created
nidhinvarghese 15:208b146151ba 115 epoch_time_glc = rtc_read(); // time is got from get epoch function.
nidhinvarghese 15:208b146151ba 116
nidhinvarghese 15:208b146151ba 117 struct tm * ptr_time_info_glc, time_info_glc; // Sturucture copy of tm is created
nidhinvarghese 15:208b146151ba 118 ptr_time_info_glc = localtime(&epoch_time_glc); // Structure accepts the time in local format from "time_t" type.
nidhinvarghese 15:208b146151ba 119 /*
nidhinvarghese 15:208b146151ba 120 //BELOW LINE IS TO CHECK Date and TIME
nidhinvarghese 15:208b146151ba 121 gtc.printf("Time is - %d:%d:%d\n", (*ptr_time_info_glc).tm_hour, (*ptr_time_info_glc).tm_min, (*ptr_time_info_glc).tm_sec);
nidhinvarghese 15:208b146151ba 122 gtc.printf("Date is - %d:%d:%d\n", (*ptr_time_info_glc).tm_mday, (*ptr_time_info_glc).tm_mon+1, (*ptr_time_info_glc).tm_year-100);
nidhinvarghese 15:208b146151ba 123 */
nidhinvarghese 15:208b146151ba 124 //Copying from one structure to the other using variables
nidhinvarghese 15:208b146151ba 125 DateTime_info_glc.hour = (uint8_t)(*ptr_time_info_glc).tm_hour;
nidhinvarghese 15:208b146151ba 126 DateTime_info_glc.mins = (uint8_t)(*ptr_time_info_glc).tm_min;
nidhinvarghese 15:208b146151ba 127 DateTime_info_glc.sec = (uint8_t)(*ptr_time_info_glc).tm_sec;
nidhinvarghese 15:208b146151ba 128
nidhinvarghese 15:208b146151ba 129 DateTime_info_glc.date = (uint8_t) (*ptr_time_info_glc).tm_mday;
nidhinvarghese 15:208b146151ba 130 DateTime_info_glc.month =(uint8_t)(*ptr_time_info_glc).tm_mon+1;
nidhinvarghese 15:208b146151ba 131 DateTime_info_glc.year = (uint8_t)(*ptr_time_info_glc).tm_year-100;
nidhinvarghese 15:208b146151ba 132
nidhinvarghese 15:208b146151ba 133 // Copying Time to Main structure
nidhinvarghese 15:208b146151ba 134 BLEMsg_info_glc.date_time.hour = DateTime_info_glc.hour;
nidhinvarghese 15:208b146151ba 135 BLEMsg_info_glc.date_time.mins = DateTime_info_glc.mins;
nidhinvarghese 15:208b146151ba 136 BLEMsg_info_glc.date_time.sec = DateTime_info_glc.sec;
nidhinvarghese 15:208b146151ba 137
nidhinvarghese 15:208b146151ba 138 BLEMsg_info_glc.date_time.date = DateTime_info_glc.date ;
nidhinvarghese 15:208b146151ba 139 BLEMsg_info_glc.date_time.month = DateTime_info_glc.month ;
nidhinvarghese 15:208b146151ba 140 BLEMsg_info_glc.date_time.year = DateTime_info_glc.year ;
nidhinvarghese 15:208b146151ba 141
nidhinvarghese 15:208b146151ba 142 /*
nidhinvarghese 15:208b146151ba 143 //Checking if the structure has these values
nidhinvarghese 15:208b146151ba 144 gtc.printf("\nTime 2 is - %d:%d:%d\n", DateTime_info_glc.hour, DateTime_info_glc.mins, DateTime_info_glc.sec);
nidhinvarghese 15:208b146151ba 145 gtc.printf("\nDate 2 is - %d:%d:%d\n",DateTime_info_glc.date, DateTime_info_glc.month, DateTime_info_glc.year);
nidhinvarghese 15:208b146151ba 146 */
nidhinvarghese 15:208b146151ba 147
nidhinvarghese 15:208b146151ba 148 //Loading values to of Test type
nidhinvarghese 15:208b146151ba 149 test_type_info test_type_info_glc; // copy of " test_type_info" created
nidhinvarghese 15:208b146151ba 150 test_type_info_glc = BG_Test; // Loaded value 00 to the test type
nidhinvarghese 15:208b146151ba 151
nidhinvarghese 15:208b146151ba 152 BLEMsg_info_glc.test_type = test_type_info_glc;
nidhinvarghese 15:208b146151ba 153 //Check if 01 is getting printed
nidhinvarghese 15:208b146151ba 154 //gtc.printf("\nTest Type for BG is 01 = %d\n", test_type_info_glc);
nidhinvarghese 15:208b146151ba 155
nidhinvarghese 15:208b146151ba 156
nidhinvarghese 15:208b146151ba 157 // Loading values of Length , PID, DID, sampling frequency, number of samples, calculated data.
nikitateggi 39:69b09bd87502 158 BLEMsg_info_glc.device_id = eprom_read_8(12); // Device ID fixed // change on 11/8/17 nikita
rashmivenkataramaiah 68:41da0a3ba038 159 //BLEMsg_info_glc.patient_id = (uint16_t)pid; // Patient ID
rashmivenkataramaiah 68:41da0a3ba038 160
rashmivenkataramaiah 69:128e3b467820 161 memcpy(BLEMsg_info_glc.patient_id,get_userpid(),sizeof(BLEMsg_info_glc.patient_id));
rashmivenkataramaiah 69:128e3b467820 162 gtc.printf("GLC pid = %s\n",BLEMsg_info_glc.patient_id);
rashmivenkataramaiah 69:128e3b467820 163
rashmivenkataramaiah 68:41da0a3ba038 164
rashmivenkataramaiah 68:41da0a3ba038 165
nidhinvarghese 15:208b146151ba 166 BLEMsg_info_glc.sampling_freq = 0; // sampling frrquency
nidhinvarghese 15:208b146151ba 167 BLEMsg_info_glc.length = 30; //Total length of data in bytes 22 B+10752 B
nidhinvarghese 15:208b146151ba 168
nidhinvarghese 15:208b146151ba 169 BLEMsg_info_glc.num_samples.num_sample_ecg_OTtyp = 2;
nidhinvarghese 15:208b146151ba 170 BLEMsg_info_glc.num_samples.num_sample_ppg_dummy = 0;
nidhinvarghese 15:208b146151ba 171
nidhinvarghese 15:208b146151ba 172
nidhinvarghese 15:208b146151ba 173
nidhinvarghese 15:208b146151ba 174 GLC_START = 1;
nidhinvarghese 15:208b146151ba 175 // ble.baud(115200);
nidhinvarghese 15:208b146151ba 176 if(GLC_START == 1)
nidhinvarghese 15:208b146151ba 177 {
rashmivenkataramaiah 57:e82d4bd6b2c0 178 // send BG Insert Strip messages to mobile application
rashmivenkataramaiah 57:e82d4bd6b2c0 179 poc2p0_send_device_msg_res(BG_INSERT_STRIP_RES);
rashmivenkataramaiah 57:e82d4bd6b2c0 180
nidhinvarghese 15:208b146151ba 181 glc_1(); // displaying messages to insert the test strip
nidhinvarghese 15:208b146151ba 182 err = 0;
nidhinvarghese 15:208b146151ba 183 data1n = 0;
nidhinvarghese 15:208b146151ba 184 data2n = 0;
nidhinvarghese 15:208b146151ba 185 daata1 = 0;
nidhinvarghese 15:208b146151ba 186 data2 = 0;
nidhinvarghese 15:208b146151ba 187 //sd_open_GLCfile(pid); // opening the glc file Commented
nidhinvarghese 15:208b146151ba 188
nidhinvarghese 15:208b146151ba 189 while((test_strip));
nidhinvarghese 15:208b146151ba 190
nidhinvarghese 15:208b146151ba 191 if (!test_strip) // checks for the presence of test strip
nidhinvarghese 15:208b146151ba 192 {
nidhinvarghese 15:208b146151ba 193 flipper.attach(&sample, 0.8);
nidhinvarghese 15:208b146151ba 194 t_s_d = 0;
rashmivenkataramaiah 57:e82d4bd6b2c0 195
rashmivenkataramaiah 57:e82d4bd6b2c0 196 // send BG Drop Blood messages to mobile application
rashmivenkataramaiah 57:e82d4bd6b2c0 197 poc2p0_send_device_msg_res(BG_DROP_BLOOD_RES);
rashmivenkataramaiah 57:e82d4bd6b2c0 198
nidhinvarghese 15:208b146151ba 199 glc_2(); // displaying message to insert blood
nidhinvarghese 15:208b146151ba 200
nidhinvarghese 15:208b146151ba 201 while((!t_s_d) && (!test_strip))
nidhinvarghese 15:208b146151ba 202 {
nidhinvarghese 15:208b146151ba 203 //if(chk_glc_data == 0) //Nidhin 31/5/2017
nidhinvarghese 15:208b146151ba 204 //{
nidhinvarghese 15:208b146151ba 205 /*
nikitateggi 16:8fa1d7fd7953 206 glcraw[0] = (uint16_t) data1n; //Nidhin 31/5/2017
nikitateggi 16:8fa1d7fd7953 207 glcraw[1] = (uint16_t) data2n; // Nidhin 31/5/2017
nidhinvarghese 15:208b146151ba 208
nidhinvarghese 15:208b146151ba 209 gtc.printf("datain is =%d\n", data1n);
nidhinvarghese 15:208b146151ba 210 gtc.printf("data2n is = %d\n", data2n);
nidhinvarghese 15:208b146151ba 211
nidhinvarghese 15:208b146151ba 212 gtc.printf("datain is =%d\n", data1n);
nidhinvarghese 15:208b146151ba 213 gtc.printf("data2n is = %d\n", data2n);
nidhinvarghese 15:208b146151ba 214 */
nidhinvarghese 15:208b146151ba 215 //chk_glc_data = 1;
nidhinvarghese 15:208b146151ba 216 //}
nidhinvarghese 15:208b146151ba 217 //gtc.printf("Checking\n");
nidhinvarghese 15:208b146151ba 218
nidhinvarghese 15:208b146151ba 219 if ((daata1 >= THRESHOLD) || (data2 >= THRESHOLD))
nidhinvarghese 15:208b146151ba 220 {
nikitateggi 16:8fa1d7fd7953 221 //glcraw[0] = (uint16_t) data1n; //Nidhin 5/6/2017
nikitateggi 16:8fa1d7fd7953 222 //glcraw[1] = (uint16_t) data2n; // Nidhin 5/6/2017
nidhinvarghese 15:208b146151ba 223
nidhinvarghese 15:208b146151ba 224 //gtc.printf("data1n is =%d\n", data1n);
nidhinvarghese 15:208b146151ba 225 //gtc.printf("data2n is = %d\n", data2n);
nidhinvarghese 15:208b146151ba 226
nidhinvarghese 15:208b146151ba 227 // gtc.printf("glcraw[0] is =%d\n", glcraw[0]);
nidhinvarghese 15:208b146151ba 228 //gtc.printf("glcraw[1] is = %d\n", glcraw[1]);
nidhinvarghese 15:208b146151ba 229
nidhinvarghese 15:208b146151ba 230 t_s_d = 1;
nidhinvarghese 15:208b146151ba 231 flipper1.attach(&Compute, 2.25); //computing the glucose level
rashmivenkataramaiah 57:e82d4bd6b2c0 232
rashmivenkataramaiah 57:e82d4bd6b2c0 233 // send BG Test in progress messages to mobile application
rashmivenkataramaiah 57:e82d4bd6b2c0 234 poc2p0_send_device_msg_res(BG_TEST_IN_PROGRESS_RES);
rashmivenkataramaiah 57:e82d4bd6b2c0 235
nidhinvarghese 15:208b146151ba 236 glc_3();
nidhinvarghese 15:208b146151ba 237 }
nidhinvarghese 15:208b146151ba 238 else
nidhinvarghese 15:208b146151ba 239 {
nidhinvarghese 15:208b146151ba 240 //wait for insertion of blood;
nidhinvarghese 15:208b146151ba 241 }
nidhinvarghese 15:208b146151ba 242 }
nikitateggi 39:69b09bd87502 243 if(test_strip) // added on 11/8/17 nikita
nikitateggi 54:f2a413d5dffd 244 {
nikitateggi 54:f2a413d5dffd 245 err_no_teststip = 1;
nikitateggi 54:f2a413d5dffd 246
nikitateggi 54:f2a413d5dffd 247
nikitateggi 54:f2a413d5dffd 248 }
nidhinvarghese 15:208b146151ba 249 wait_ms(800);
nidhinvarghese 15:208b146151ba 250 }
nikitateggi 16:8fa1d7fd7953 251
nidhinvarghese 17:22a87e12fb3a 252 //gtc.printf("mgdl is - %d\n", mgdll);
nidhinvarghese 15:208b146151ba 253 }
nikitateggi 16:8fa1d7fd7953 254 wait(2.25);
nikitateggi 54:f2a413d5dffd 255 gtc.printf("error = %d\n", err);
nikitateggi 54:f2a413d5dffd 256 if ((err==0) && (err_no_teststip == 0) && ( mgdl < MAX_GLC_THRESHOLD) && ( mgdl > MIN_GLC_THRESHOLD))
nikitateggi 22:ffa88619551d 257 {
rashmivenkataramaiah 57:e82d4bd6b2c0 258 // send Final BG result messages to mobile application
rashmivenkataramaiah 57:e82d4bd6b2c0 259 poc2p0_send_device_test_result_res(BG_TEST_SUCCSS_RES, (uint32_t)mgdl);
rashmivenkataramaiah 57:e82d4bd6b2c0 260
nikitateggi 54:f2a413d5dffd 261 glc_4(mgdl);
nidhinvarghese 15:208b146151ba 262 gtc.printf("DATA1 is - %d\n", data1n);
nidhinvarghese 15:208b146151ba 263 gtc.printf("DATA2 is - %d\n", data2n);
nikitateggi 24:d992ee8369f4 264 gtc.printf("mgdl is - %d\n", mgdl);
nidhinvarghese 15:208b146151ba 265
nidhinvarghese 17:22a87e12fb3a 266 glcraw[0] = (uint32_t)data1n;
nidhinvarghese 17:22a87e12fb3a 267 glcraw[1] = (uint32_t)data2n;
nidhinvarghese 17:22a87e12fb3a 268
nidhinvarghese 17:22a87e12fb3a 269 sd_glcwrite(glcraw, pid); //Writes the raw data into GLC file
nidhinvarghese 15:208b146151ba 270
nikitateggi 20:7c64e6ecad76 271 //Results Stored to Bluetooth structure
nikitateggi 24:d992ee8369f4 272 glc_testtype = eprom_read_16(20); // Reads the test type (before meal = 0 / after meal = 1 OR Random = 2 from location 2 of the EEPROM) Nidhin 12/6/17
nikitateggi 20:7c64e6ecad76 273 BLEMsg_info_glc.cal_data.cal_sbp_dummy = (uint16_t) glc_testtype; // Data stored into structure
nikitateggi 24:d992ee8369f4 274 BLEMsg_info_glc.cal_data.cal_dbp_OTtyp = (uint16_t) mgdl; //To be checked for reliable results
nidhinvarghese 15:208b146151ba 275
nikitateggi 54:f2a413d5dffd 276 structure_file(ptr_BLEMsg_info_glc, pid); // Copy the structure into the GLC file
rashmivenkataramaiah 41:1141a75eacc4 277 glcfile_mainfile(pid);
nikitateggi 54:f2a413d5dffd 278 if(get_filecreated_status() == false) //if file is in write mode
rashmivenkataramaiah 43:85a7f399cb9d 279 {
rashmivenkataramaiah 43:85a7f399cb9d 280 set_filecreated_status();
rashmivenkataramaiah 43:85a7f399cb9d 281 increment_filepid ();
rashmivenkataramaiah 43:85a7f399cb9d 282 }
rashmivenkataramaiah 43:85a7f399cb9d 283 }
nikitateggi 54:f2a413d5dffd 284 else // added threshold to check value out of range
nikitateggi 22:ffa88619551d 285 {
nikitateggi 54:f2a413d5dffd 286 if(err_no_teststip == 1) // added on 22/09/2017 nikita // to separately detect what is the parameter failed while testing
nikitateggi 54:f2a413d5dffd 287 {
rashmivenkataramaiah 57:e82d4bd6b2c0 288 // send BG remove test strip messages to mobile application
rashmivenkataramaiah 57:e82d4bd6b2c0 289 poc2p0_send_device_msg_res(BG_TEST_STRIP_REMOVE_RES);
rashmivenkataramaiah 57:e82d4bd6b2c0 290
rashmivenkataramaiah 57:e82d4bd6b2c0 291 glc_error_test_strip_removed();
nikitateggi 54:f2a413d5dffd 292 }
nikitateggi 54:f2a413d5dffd 293
nikitateggi 54:f2a413d5dffd 294 else if(err == 1 || mgdl > MAX_GLC_THRESHOLD || mgdl < MIN_GLC_THRESHOLD)
nikitateggi 54:f2a413d5dffd 295 {
rashmivenkataramaiah 57:e82d4bd6b2c0 296 // send BG Replace test strip messages to mobile application
rashmivenkataramaiah 57:e82d4bd6b2c0 297 poc2p0_send_device_msg_res(BG_REPLACE_TEST_STRIP_RES);
rashmivenkataramaiah 57:e82d4bd6b2c0 298
rashmivenkataramaiah 57:e82d4bd6b2c0 299 gtc.printf("replace teststip");
nikitateggi 54:f2a413d5dffd 300 glc_error(); //disaply for showing error//10/7/17//nikita
nikitateggi 54:f2a413d5dffd 301 }
nikitateggi 54:f2a413d5dffd 302
nikitateggi 39:69b09bd87502 303 delete_subfiles(pid); // added on 11/8/17 nikita
nidhinvarghese 15:208b146151ba 304 }
nidhinvarghese 15:208b146151ba 305
nikitateggi 1:8316c23ec6b9 306
avp2417 34:8f6b0dc124e8 307 }