This is a basic program that provides the necessary BLE service to allow communications with the UPAS

Dependencies:   BLE_API mbed nRF51822 CronoDot EEPROM NCP5623BMUTBG ADS1115 BME280 Calibration_one MCP40D17 SDFileSystem LSM303 SI1145 STC3100

Fork of BLE_Button by Bluetooth Low Energy

Committer:
caseyquinn
Date:
Tue Dec 08 05:41:19 2015 +0000
Revision:
19:9886f667a62a
Parent:
18:c911a8928d0b
semi works. seems to be hanging at the SD card file creation and writing calls.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jelord 10:66549fa08986 1 //CODE BY JAKE LORD
jelord 10:66549fa08986 2 //ALL RIGHTS RESERVED BY VOLCKENS GROUP, FORT COLLINS CO
rgrover1 0:28f095301cb2 3 #include "mbed.h"
rgrover1 5:43a3ab27f2e4 4 #include "BLE.h"
jelord 10:66549fa08986 5 #include "UPAS_Service.h"
jelord 11:1058647c66e8 6 #include "EEPROM.h"
jelord 11:1058647c66e8 7 #include "CronoDot.h"
jelord 11:1058647c66e8 8 #include "NCP5623BMUTBG.h"
jelord 13:b43ec7e0cc1d 9
jelord 17:077712e4e5e3 10 #include "SDFileSystem.h"
jelord 17:077712e4e5e3 11 #include "Adafruit_ADS1015.h"
jelord 17:077712e4e5e3 12 #include "MCP40D17.h"
jelord 17:077712e4e5e3 13 #include "BME280.h"
caseyquinn 18:c911a8928d0b 14 #include "Calibration_one.h"
jelord 17:077712e4e5e3 15
jelord 17:077712e4e5e3 16 //List of files not currently in this Code
caseyquinn 18:c911a8928d0b 17 #include "LSM303.h"
caseyquinn 18:c911a8928d0b 18 #include "SI1145.h"
caseyquinn 18:c911a8928d0b 19 #include "STC3100.h"
jelord 17:077712e4e5e3 20 //#include "US_Menu.h"
jelord 17:077712e4e5e3 21
jelord 17:077712e4e5e3 22
rgrover1 0:28f095301cb2 23
jelord 11:1058647c66e8 24 DigitalOut blower(p29, 0);
jelord 11:1058647c66e8 25 DigitalOut pbKill(p18, 1);
jelord 11:1058647c66e8 26 DigitalOut GPS_EN(p4,0);
jelord 11:1058647c66e8 27 EEPROM E2PROM(p22, p20);
jelord 11:1058647c66e8 28 CronoDot RTC(p22, p20);
jelord 12:27273e6a50b3 29 NCP5623BMUTBG RGB_LED(p22, p20);
caseyquinn 18:c911a8928d0b 30 Serial pc(USBTX, USBRX);
caseyquinn 18:c911a8928d0b 31 LSM303 movementsensor(p22, p20);
caseyquinn 18:c911a8928d0b 32 SI1145 lightsensor(p22, p20);
caseyquinn 18:c911a8928d0b 33 STC3100 gasG(p22, p20);
jelord 17:077712e4e5e3 34 I2C i2c(p22, p20);
jelord 17:077712e4e5e3 35 Adafruit_ADS1115 ads(&i2c);
caseyquinn 18:c911a8928d0b 36 Calibration calibrations(7); //Default serial/calibration if there are no values for the selected option
caseyquinn 19:9886f667a62a 37 MCP40D17 DigPot(&i2c);
caseyquinn 19:9886f667a62a 38 BME280 bmesensor(p22, p20);
jelord 17:077712e4e5e3 39
jelord 16:e066ab7e8fb3 40 BLE ble;
jelord 11:1058647c66e8 41 /*EEPROM ADDRESSING:
jelord 11:1058647c66e8 42 0:Status bit-Unused
jelord 11:1058647c66e8 43 1-15:Device Name
jelord 11:1058647c66e8 44 16-19:Flow Rate
jelord 11:1058647c66e8 45 20: Data Log Interval
jelord 11:1058647c66e8 46 21-26: Start Time: ssmmHHddMMyy
jelord 11:1058647c66e8 47 27-32: Stop Time: ssmmHHddMMyy
jelord 11:1058647c66e8 48 33: Duty Up
jelord 11:1058647c66e8 49 34: Duty Down
jelord 11:1058647c66e8 50 35-38: Home Latitude
jelord 11:1058647c66e8 51 39-42: Home Longitude
jelord 11:1058647c66e8 52 43-46: Work Latitude
jelord 11:1058647c66e8 53 47-50: Work Longitude
jelord 11:1058647c66e8 54 51: Runready: Currently useless, should be 0
jelord 11:1058647c66e8 55 52-53: Device Calibration
jelord 11:1058647c66e8 56 54: Consider RunReady
jelord 11:1058647c66e8 57 55-56: Menu Options
jelord 11:1058647c66e8 58 57+ Nothing*/
rgrover1 0:28f095301cb2 59
jelord 17:077712e4e5e3 60 Timeout stop; //This is the stop call back object
jelord 17:077712e4e5e3 61 Timeout logg; //This is the logging call back object
jelord 17:077712e4e5e3 62
jelord 17:077712e4e5e3 63 uint16_t serial_num = 1; // Default serial/calibration number
jelord 17:077712e4e5e3 64 int RunReady =0;
jelord 17:077712e4e5e3 65
jelord 17:077712e4e5e3 66
caseyquinn 19:9886f667a62a 67 float press;
caseyquinn 19:9886f667a62a 68 float temp;
caseyquinn 19:9886f667a62a 69 float rh;
caseyquinn 19:9886f667a62a 70
caseyquinn 19:9886f667a62a 71 int uv;
caseyquinn 19:9886f667a62a 72
caseyquinn 19:9886f667a62a 73 float compass;
caseyquinn 19:9886f667a62a 74 float accel_x;
caseyquinn 19:9886f667a62a 75 float accel_y;
caseyquinn 19:9886f667a62a 76 float accel_z;
caseyquinn 19:9886f667a62a 77 float accel_comp;
caseyquinn 19:9886f667a62a 78
caseyquinn 19:9886f667a62a 79 int vInReading;
caseyquinn 19:9886f667a62a 80 int vBlowerReading;
caseyquinn 19:9886f667a62a 81 int omronDiff;
caseyquinn 19:9886f667a62a 82 float omronVolt; //V
caseyquinn 19:9886f667a62a 83 int omronReading;
caseyquinn 19:9886f667a62a 84 float atmoRho; //g/L
caseyquinn 19:9886f667a62a 85
caseyquinn 19:9886f667a62a 86 float massflow; //g/min
caseyquinn 19:9886f667a62a 87 float volflow; //L/min
caseyquinn 19:9886f667a62a 88 float volflowSet = 1.0; //L/min
caseyquinn 19:9886f667a62a 89 int logInerval = 10; //seconds
caseyquinn 19:9886f667a62a 90
caseyquinn 19:9886f667a62a 91 float massflowSet;
caseyquinn 19:9886f667a62a 92 float deltaVflow = 0.0;
caseyquinn 19:9886f667a62a 93 float deltaMflow = 0.0;
caseyquinn 19:9886f667a62a 94 float gainFlow;
caseyquinn 19:9886f667a62a 95 float sampledVol; //L, total sampled volume
caseyquinn 19:9886f667a62a 96
caseyquinn 19:9886f667a62a 97 int digital_pot_setpoint; //min = 0x7F, max = 0x00
caseyquinn 19:9886f667a62a 98 int digital_pot_set;
caseyquinn 19:9886f667a62a 99 int digital_pot_change;
caseyquinn 19:9886f667a62a 100 int digitalpotMax = 127;
caseyquinn 19:9886f667a62a 101 int digitalpotMin = 2;
caseyquinn 19:9886f667a62a 102
caseyquinn 19:9886f667a62a 103 //char filename[] = "/sd/XXXX0000LOG000000000000---------------.txt";
caseyquinn 19:9886f667a62a 104 char filename[] = "/sd/UPASLOG00.txt";
caseyquinn 19:9886f667a62a 105 SDFileSystem sd(SPIS_PSELMOSI, SPIS_PSELMISO, SPIS_PSELSCK, SPIS_PSELSS, "sd"); // I believe this matches Todd's pinout, let me know if this doesn't work. (p12, p13, p15, p14)
caseyquinn 19:9886f667a62a 106
caseyquinn 19:9886f667a62a 107
jelord 10:66549fa08986 108 const static char DEVICE_NAME[] = "UPAS"; //Will hold the actual name of the whichever UPAS is being connected to
jelord 10:66549fa08986 109 static const uint16_t uuid16_list[] = {UPAS_Service::UPAS_SERVICE_UUID}; //Currently a custom 16-bit representation of 128-bit UUID
rgrover1 0:28f095301cb2 110
jelord 10:66549fa08986 111 UPAS_Service *upasServicePtr;
rgrover1 0:28f095301cb2 112
jelord 12:27273e6a50b3 113
jelord 17:077712e4e5e3 114
jelord 10:66549fa08986 115 void disconnectionCallback(const Gap::DisconnectionCallbackParams_t *params)//Code called when mbed ble senses a disconnect
rgrover1 0:28f095301cb2 116 {
rgrover1 6:18d8750f39ee 117 ble.gap().startAdvertising();
rgrover1 0:28f095301cb2 118 }
rgrover1 0:28f095301cb2 119
rgrover1 0:28f095301cb2 120 void periodicCallback(void)
rgrover1 0:28f095301cb2 121 {
jelord 12:27273e6a50b3 122 RTC.get_time();
jelord 12:27273e6a50b3 123 const uint8_t refreshPassValues[6] = {RTC.seconds, RTC.minutes,RTC.hour,RTC.date,RTC.month,RTC.year};
jelord 12:27273e6a50b3 124 ble.updateCharacteristicValue( upasServicePtr->rtcCharacteristic.getValueHandle(),refreshPassValues,6);
jelord 17:077712e4e5e3 125
jelord 17:077712e4e5e3 126 }
jelord 17:077712e4e5e3 127 void periodicPrint(void)
jelord 17:077712e4e5e3 128 {
jelord 17:077712e4e5e3 129 // led1 = !led1; /* Do blinky on LED1 to indicate system aliveness. */
jelord 17:077712e4e5e3 130 //RGB_LED.set_led(1,1,5);
jelord 17:077712e4e5e3 131
jelord 11:1058647c66e8 132 }
jelord 13:b43ec7e0cc1d 133
jelord 17:077712e4e5e3 134 /*
jelord 17:077712e4e5e3 135 This function is called the BLE GATT Server every time a characterisitic is written to
jelord 17:077712e4e5e3 136 All logic revolving around which bits to write to EEPROM, and what to see the RTC to us done here
jelord 17:077712e4e5e3 137 */
jelord 12:27273e6a50b3 138 void writeCharacteristicCallback(const GattWriteCallbackParams *params)
jelord 10:66549fa08986 139 {
jelord 12:27273e6a50b3 140 uint8_t *writeData = const_cast<uint8_t*>(params->data);
jelord 10:66549fa08986 141 // check to see what characteristic was written, by handle
jelord 12:27273e6a50b3 142 if(params->handle == upasServicePtr->rtcCharacteristic.getValueHandle()) {
jelord 12:27273e6a50b3 143
jelord 12:27273e6a50b3 144 //ble.updateCharacteristicValue(upasServicePtr->readChar.getValueHandle(),params->data,params->len);
jelord 12:27273e6a50b3 145
jelord 17:077712e4e5e3 146 E2PROM.write(0x00015, writeData+6, 12);
jelord 11:1058647c66e8 147 RTC.set_time(writeData[0],writeData[1],writeData[2],writeData[3],writeData[3],writeData[4],writeData[5]);
jelord 12:27273e6a50b3 148
jelord 12:27273e6a50b3 149 }else if(params->handle == upasServicePtr->sampleTimeCharacteristic.getValueHandle()){
jelord 12:27273e6a50b3 150
jelord 12:27273e6a50b3 151 E2PROM.write(0x00015, writeData, 12);
jelord 13:b43ec7e0cc1d 152
jelord 13:b43ec7e0cc1d 153 }else if(params->handle == upasServicePtr->subjectLabelCharacteristic.getValueHandle()){
jelord 13:b43ec7e0cc1d 154 E2PROM.write(0x00001,writeData,15);
jelord 13:b43ec7e0cc1d 155
jelord 15:c9c93454dd56 156 }else if(params->handle == upasServicePtr->runReadyCharacteristic.getValueHandle()){
jelord 17:077712e4e5e3 157 uint8_t runData = writeData[0];
jelord 17:077712e4e5e3 158
jelord 17:077712e4e5e3 159 if(runData == 10){
jelord 17:077712e4e5e3 160 RunReady = 10;
jelord 17:077712e4e5e3 161 RGB_LED.set_led(1,2,3);
jelord 17:077712e4e5e3 162 }else{
jelord 17:077712e4e5e3 163 RunReady = 2;
jelord 17:077712e4e5e3 164 }
jelord 13:b43ec7e0cc1d 165
jelord 14:4fc1788b8ad2 166 }else if(params->handle == upasServicePtr->runModeCharacteristic.getValueHandle()){
jelord 13:b43ec7e0cc1d 167 /* Trigger demo mode*/
jelord 13:b43ec7e0cc1d 168 RGB_LED.set_led(3,1,0);
jelord 14:4fc1788b8ad2 169 E2PROM.write(0x00036,writeData,1);
jelord 10:66549fa08986 170 }
jelord 10:66549fa08986 171 }
jelord 10:66549fa08986 172
caseyquinn 19:9886f667a62a 173 void log_data()
caseyquinn 19:9886f667a62a 174 {
caseyquinn 19:9886f667a62a 175 //logg.detach();
caseyquinn 19:9886f667a62a 176 //logg.attach(&log_data, logInerval); // reading and logging data must take significintly less than 0.5s. This can be increased.
caseyquinn 19:9886f667a62a 177 RGB_LED.set_led(0,0,0);
caseyquinn 19:9886f667a62a 178 RTC.get_time();
caseyquinn 19:9886f667a62a 179 //*****************************************//
caseyquinn 19:9886f667a62a 180 //RTC.get_time(); //debug
caseyquinn 19:9886f667a62a 181 //pc.printf("%02d:%02d:%02d on %d/%d/%d before fmod \r\n",RTC.hour, RTC.minutes, RTC.seconds, RTC.month, RTC.date, RTC.year);//debug
caseyquinn 19:9886f667a62a 182 //*****************************************//
caseyquinn 19:9886f667a62a 183
caseyquinn 19:9886f667a62a 184
caseyquinn 19:9886f667a62a 185
caseyquinn 19:9886f667a62a 186 /* while(fmod(secondsD,logInerval)!=0 || floor(secondsD)==floor(lastsecondD)) {
caseyquinn 19:9886f667a62a 187 //pc.printf("%f, %f\r\n", floor(secondsD), floor(lastsecondD));
caseyquinn 19:9886f667a62a 188 RTC.get_time();
caseyquinn 19:9886f667a62a 189 secondsD = RTC.seconds;
caseyquinn 19:9886f667a62a 190 wait_ms(100);
caseyquinn 19:9886f667a62a 191 }
caseyquinn 19:9886f667a62a 192 lastsecondD = secondsD;
caseyquinn 19:9886f667a62a 193 */
caseyquinn 19:9886f667a62a 194 //*****************************************//
caseyquinn 19:9886f667a62a 195 //RTC.get_time(); //debug
caseyquinn 19:9886f667a62a 196 //pc.printf("%02d:%02d:%02d on %d/%d/%d after fmod \r\n",RTC.hour, RTC.minutes, RTC.seconds, RTC.month, RTC.date, RTC.year);//debug
caseyquinn 19:9886f667a62a 197 //*****************************************//
caseyquinn 19:9886f667a62a 198 DigPot.writeRegister(digital_pot_setpoint);
caseyquinn 19:9886f667a62a 199 omronReading = ads.readADC_SingleEnded(0, 0xC583); // read channel 0 PGA = 2 : Full Scale Range = 2.048V
caseyquinn 19:9886f667a62a 200 omronVolt = (omronReading*4.096)/(32768*2);
caseyquinn 19:9886f667a62a 201
caseyquinn 19:9886f667a62a 202 vInReading = ads.readADC_SingleEnded(1, 0xD583); // read channel 0
caseyquinn 19:9886f667a62a 203 vBlowerReading = ads.readADC_SingleEnded(2, 0xE783); // read channel 0
caseyquinn 19:9886f667a62a 204 omronDiff = ads.readADC_Differential(0x8583); // differential channel 2-3
caseyquinn 19:9886f667a62a 205 press = bmesensor.getPressure();
caseyquinn 19:9886f667a62a 206 temp = bmesensor.getTemperature()-5.0;
caseyquinn 19:9886f667a62a 207 rh = bmesensor.getHumidity();
caseyquinn 19:9886f667a62a 208 uint16_t fuel = gasG.getCounter();
caseyquinn 19:9886f667a62a 209
caseyquinn 19:9886f667a62a 210
caseyquinn 19:9886f667a62a 211
caseyquinn 19:9886f667a62a 212 FILE *fp = fopen(filename, "a");
caseyquinn 19:9886f667a62a 213 fprintf(fp, "%02d,%02d,%02d,%02d,%02d,%02d,",RTC.year, RTC.month,RTC.date,RTC.hour,RTC.minutes,RTC.seconds);
caseyquinn 19:9886f667a62a 214 fprintf(fp, "%1.3f,%1.3f,%2.2f,%4.2f,%2.1f,%1.3f,", omronVolt,massflow,temp,press,rh,atmoRho);
caseyquinn 19:9886f667a62a 215 fprintf(fp, "%1.3f,%5.1f,%1.1f,%1.1f,%1.1f,%1.1f,", volflow, sampledVol, accel_x, accel_y, accel_z, accel_comp);
caseyquinn 19:9886f667a62a 216 fprintf(fp, "%.1f,", compass);
caseyquinn 19:9886f667a62a 217 fprintf(fp, "%d," ,uv);
caseyquinn 19:9886f667a62a 218 fprintf(fp, "%d,%d,%d,%d,%d," ,omronReading, vInReading, vBlowerReading, omronDiff,gasG.getAmps());
caseyquinn 19:9886f667a62a 219 fprintf(fp, "%d,%d,%d,%1.3f,%1.3f,", gasG.getVolts(), gasG.getCharge(),digital_pot_set, deltaMflow, deltaVflow);
caseyquinn 19:9886f667a62a 220 fclose(fp);
caseyquinn 19:9886f667a62a 221 wait(5);
caseyquinn 19:9886f667a62a 222 RGB_LED.set_led(0,1,0);
caseyquinn 19:9886f667a62a 223
caseyquinn 19:9886f667a62a 224
caseyquinn 19:9886f667a62a 225 }
caseyquinn 19:9886f667a62a 226
caseyquinn 19:9886f667a62a 227
rgrover1 0:28f095301cb2 228 int main(void)
rgrover1 0:28f095301cb2 229 {
rgrover1 0:28f095301cb2 230 Ticker ticker;
jelord 17:077712e4e5e3 231 ticker.attach(periodicPrint, 600); //currently unused. But do not want to comment out
jelord 11:1058647c66e8 232 RGB_LED.set_led(1,1,1);
jelord 11:1058647c66e8 233 RTC.get_time();
jelord 12:27273e6a50b3 234 uint8_t rtcPassValues[6] = {RTC.seconds, RTC.minutes,RTC.hour,RTC.date,RTC.month,RTC.year};
jelord 12:27273e6a50b3 235 uint8_t sampleTimePassValues[12] = {0,};
jelord 12:27273e6a50b3 236 uint8_t subjectLabelOriginal[15] = {0,};
jelord 12:27273e6a50b3 237 E2PROM.read(0x00015, sampleTimePassValues, 12);
jelord 12:27273e6a50b3 238 E2PROM.read(0x00001, subjectLabelOriginal,15);
rgrover1 0:28f095301cb2 239
rgrover1 0:28f095301cb2 240 ble.init();
rgrover1 6:18d8750f39ee 241 ble.gap().onDisconnection(disconnectionCallback);
jelord 12:27273e6a50b3 242 ble.gattServer().onDataWritten(writeCharacteristicCallback); //add writeCharCallback (custom function) to whenever data is being written to device
jelord 12:27273e6a50b3 243 UPAS_Service upasService(ble, false,rtcPassValues,sampleTimePassValues,subjectLabelOriginal); //Create a GattService that is defined in UPAS_Service.h
jelord 10:66549fa08986 244 upasServicePtr = &upasService; //Create a pointer to the service (Allows advertisement without specifically adding the service
rgrover1 0:28f095301cb2 245
jelord 10:66549fa08986 246 /* setup advertising
jelord 10:66549fa08986 247 Following lines do the follow:
jelord 10:66549fa08986 248 1:Declare the device as Bluetooth Smart(Low-Energy)
jelord 10:66549fa08986 249 2.Advertise the UPAS service that will send and receive the 57-bits of settable values in the UPAS EEPROM
jelord 10:66549fa08986 250 3.Advertise the name that will be associated with the UPAS
jelord 10:66549fa08986 251 4.Allow the UPAS to advertise unrestricted (this might change) */
jelord 10:66549fa08986 252
rgrover1 6:18d8750f39ee 253 ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::BREDR_NOT_SUPPORTED | GapAdvertisingData::LE_GENERAL_DISCOVERABLE);
rgrover1 6:18d8750f39ee 254 ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LIST_16BIT_SERVICE_IDS, (uint8_t *)uuid16_list, sizeof(uuid16_list));
rgrover1 6:18d8750f39ee 255 ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LOCAL_NAME, (uint8_t *)DEVICE_NAME, sizeof(DEVICE_NAME));
rgrover1 6:18d8750f39ee 256 ble.gap().setAdvertisingType(GapAdvertisingParams::ADV_CONNECTABLE_UNDIRECTED);
jelord 17:077712e4e5e3 257 ble.gap().setAdvertisingInterval(30); /* 160ms. */
rgrover1 6:18d8750f39ee 258 ble.gap().startAdvertising();
jelord 10:66549fa08986 259
jelord 10:66549fa08986 260 //Loop keeps device in infinite loop waiting for events to occur
jelord 13:b43ec7e0cc1d 261 while (1) {
jelord 17:077712e4e5e3 262 ble.waitForEvent();
jelord 17:077712e4e5e3 263 if(RunReady==2 && blower ==0){ //Code used to see if one-click run should begin
jelord 17:077712e4e5e3 264 calibrations.initialize(serial_num);
jelord 17:077712e4e5e3 265 RGB_LED.set_led(3,0,2);
jelord 17:077712e4e5e3 266 blower=1;
jelord 17:077712e4e5e3 267 RunReady=0;
caseyquinn 19:9886f667a62a 268 break;
jelord 17:077712e4e5e3 269 }
jelord 17:077712e4e5e3 270 if(RunReady==2 && blower ==1){ //Code used to see if one-click run is done.
jelord 17:077712e4e5e3 271 blower=0;
jelord 17:077712e4e5e3 272 RunReady=0;
jelord 17:077712e4e5e3 273 }
jelord 17:077712e4e5e3 274
jelord 17:077712e4e5e3 275 if(RunReady==10){ //Check to see if app is done with configurations
jelord 17:077712e4e5e3 276 blower = 0;
jelord 17:077712e4e5e3 277 ble.gap().stopAdvertising();
caseyquinn 19:9886f667a62a 278 //break;
jelord 17:077712e4e5e3 279 }
rgrover1 0:28f095301cb2 280 }
jelord 17:077712e4e5e3 281 uint8_t startAndEndTime[12] = {0,};
jelord 17:077712e4e5e3 282 E2PROM.read(0x00015, startAndEndTime, 12); //Grab start and end times from EEPROM
jelord 17:077712e4e5e3 283 while(!RTC.compare(startAndEndTime[0], startAndEndTime[1], startAndEndTime[2], startAndEndTime[3], startAndEndTime[4], startAndEndTime[5])) { // this while waits for the start time by looping until the start time
jelord 17:077712e4e5e3 284 wait(0.5);
jelord 17:077712e4e5e3 285 RTC.get_time();
jelord 17:077712e4e5e3 286
jelord 17:077712e4e5e3 287 }
jelord 17:077712e4e5e3 288 calibrations.initialize(serial_num);
jelord 17:077712e4e5e3 289 blower=1;
jelord 17:077712e4e5e3 290
jelord 17:077712e4e5e3 291 while(!RTC.compare(startAndEndTime[6], startAndEndTime[7], startAndEndTime[8], startAndEndTime[9], startAndEndTime[10], startAndEndTime[11])) { //Waits for end time
jelord 17:077712e4e5e3 292 wait(0.5);
jelord 17:077712e4e5e3 293 RTC.get_time();
jelord 17:077712e4e5e3 294
jelord 17:077712e4e5e3 295 }
caseyquinn 19:9886f667a62a 296 //pbKill = 0; // this is were we shut everything down
caseyquinn 19:9886f667a62a 297
caseyquinn 19:9886f667a62a 298 RGB_LED.set_led(1,0,0);
caseyquinn 19:9886f667a62a 299 //The filename creation isn't working...
caseyquinn 19:9886f667a62a 300 /*
caseyquinn 19:9886f667a62a 301 for (uint8_t i = 0; i < 100; i++) {
caseyquinn 19:9886f667a62a 302 filename[11] = i/10 + '0';
caseyquinn 19:9886f667a62a 303 filename[12] = i%10 + '0';
caseyquinn 19:9886f667a62a 304 FILE *fp = fopen(filename, "r");
caseyquinn 19:9886f667a62a 305 if (fp == NULL) {
caseyquinn 19:9886f667a62a 306 // only open a new file if it doesn't exist
caseyquinn 19:9886f667a62a 307 FILE *fp = fopen(filename, "w");
caseyquinn 19:9886f667a62a 308 fclose(fp);
caseyquinn 19:9886f667a62a 309 break; // leave the loop!
caseyquinn 19:9886f667a62a 310 }
caseyquinn 19:9886f667a62a 311 }
caseyquinn 19:9886f667a62a 312 */
caseyquinn 19:9886f667a62a 313 wait(10);
caseyquinn 19:9886f667a62a 314 RGB_LED.set_led(0,0,1);
caseyquinn 19:9886f667a62a 315
caseyquinn 19:9886f667a62a 316 wait(10);
caseyquinn 19:9886f667a62a 317
caseyquinn 19:9886f667a62a 318 while(1) {
caseyquinn 19:9886f667a62a 319
caseyquinn 19:9886f667a62a 320
caseyquinn 19:9886f667a62a 321 log_data();
caseyquinn 19:9886f667a62a 322 }
jelord 17:077712e4e5e3 323
rgrover1 0:28f095301cb2 324 }