Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: GPSLibrary GSM mbed-modifed Storage_Library Temp_Library Wakeup pH_Sensor
Diff: main.cpp
- Revision:
- 11:cc22917d6634
- Parent:
- 10:01bbf4f1c250
- Child:
- 12:973566676eba
--- a/main.cpp Wed Nov 18 18:45:50 2015 +0000
+++ b/main.cpp Wed Nov 18 21:36:49 2015 +0000
@@ -24,7 +24,7 @@
AnalogIn temperature(TMP_ANALOG);
#define READINGSIZE sizeof(struct reading)
-#define URL "http://requestb.in/um8rhrum"
+#define URL "http://requestb.in/17asutd1"
// Cellular communication global variables
Adafruit_FONA fona(FONA_TX, FONA_RX, FONA_RST, FONA_RI);
@@ -197,13 +197,16 @@
wait(1);
}
fona.begin(9600);
- fona.setGPRSNetworkSettings("pwg", "", "");
+ printf("After begin\n");
+ fona.setGPRSNetworkSettings("fast.t-mobile.com", "", "");
+ printf("After set setting\n");
bool enable = false;
while(enable != true) {
fona.enableGPRS(true);
fona.enableGPRS(false);
enable = fona.enableGPRS(true);
}
+ printf("After enable\n");
}
void changeGSMPowerState()
@@ -326,11 +329,13 @@
return temperatureValue; // 22.5 mV / °C; Ratiometric measurement, conversion valid for 5 V!
}
-bool sendDataToURL(uint8_t* data, int nreadings)
+bool sendDataToURL(uint8_t* data, int size)
{
changeGSMPowerState();
setupGSM();
- bool res = sendDataOverHTTP(URL, data, nreadings * READINGSIZE);
+ printf("Setup GSM\n");
+ bool res = sendDataOverHTTP(URL, data, size);
+ printf("After sent data\n");
changeGSMPowerState();
return res;
}
@@ -378,26 +383,18 @@
if(toSend) {
struct reading* data = new struct reading[nreadings];
getEEPROM((uint8_t*) data);
+ char buffer[((8+8+10+10+5*sizeof(int)+8)*nreadings) + 1];
for(int i = 0; i < nreadings; i++)
{
- for (int j = 0; j < READINGSIZE; j++) {
- char current_character = ((char*) (data + i))[j];
- for (int k = 7; k >= 0; k--) {
- char mask = 1;
- mask = mask << k;
- if (mask & current_character) {
- printf("1");
- } else {
- printf("0");
- }
- }
- printf("%c\n", current_character);
- }
- printf("pH is %f\n", data[i].pH);
- printf("Temperature is %f\n", data[i].temperature);
+ int n = sprintf(buffer, "%8f %8f %10f %10f %d %d %d %d %d", data[i].temperature, data[i].pH, data[i].latitude, data[i].longitude, data[i].day,
+ data[i].month, data[i].year, data[i].hour, data[i].minutes);
+ printf("%s\n", buffer);
+ printf("%d\n", n);
+ printf("%d\n", (sizeof(buffer)));
+ printf("%d\n", data[i].minutes);
}
printf("HERE\n");
- bool res = sendDataToURL((uint8_t*) data, nreadings);
+ bool res = sendDataToURL((uint8_t*) buffer, sizeof(buffer));
if(res) {
toSend = false;
nreadings = 0;