Rick McConney
/
stripReader
Proximity strip reader
Fork of StarterKit by
Diff: main.cpp
- Revision:
- 12:7c94ec5069dc
- Parent:
- 11:e6602513730f
- Child:
- 14:0c353e212296
- Child:
- 15:61df4a452d38
diff -r e6602513730f -r 7c94ec5069dc main.cpp --- a/main.cpp Tue Jul 12 03:11:05 2016 +0000 +++ b/main.cpp Tue Jul 12 21:56:51 2016 +0000 @@ -242,19 +242,52 @@ #define CTOF(x) ((x)*1.8+32) -#include "Flow_parameters.h" //******************************************************************************************************************************************** -//* Create string that can be sent to flow as an HTTP get +//* Create string with sensor readings that can be sent to flow as an HTTP get //******************************************************************************************************************************************** -static Flow_datapoint_t FLOW_DATAPOINT = +K64F_Sensors_t SENSOR_DATA = { - .URL_start = FLOW_CALLBACK_URL_START, - .URL_end = FLOW_CALLBACK_URL_END + .Temperature = "0", + .Humidity = "0", + .AccelX = "0", + .AccelY = "0", + .AccelZ = "0", + .MagnetometerX = "0", + .MagnetometerY = "0", + .MagnetometerZ = "0", + .AmbientLightVis = "0", + .AmbientLightIr = "0", + .UVindex = "0", + .Proximity = "0", + .Temperature_Si7020 = "0", + .Humidity_Si7020 = "0" }; + void GenerateModemString(char * modem_string) { - //sprintf(modem_string, "%s?deviceID=%s&temp=%s&humidity=%s %s", FLOW_DATAPOINT.URL_start, FLOW_DATAPOINT.Device_ID, SENSOR_DATA.Temperature, SENSOR_DATA.Humidity, FLOW_DATAPOINT.URL_end); - sprintf(modem_string, "%s?serial=vstarterkit001&temp=%s&humidity=%s %s", FLOW_DATAPOINT.URL_start, SENSOR_DATA.Temperature, SENSOR_DATA.Humidity, FLOW_DATAPOINT.URL_end); + switch(iSensorsToReport) + { + case TEMP_HUMIDITY_ONLY: + { + sprintf(modem_string, "GET %s%s?serial=%s&temp=%s&humidity=%s %s%s\r\n\r\n", FLOW_BASE_URL, FLOW_INPUT_NAME, FLOW_DEVICE_NAME, SENSOR_DATA.Temperature, SENSOR_DATA.Humidity, FLOW_URL_TYPE, MY_SERVER_URL); + break; + } + case TEMP_HUMIDITY_ACCELEROMETER: + { + sprintf(modem_string, "GET %s%s?serial=%s&temp=%s&humidity=%s&accelX=%s&accelY=%s&accelZ=%s %s%s\r\n\r\n", FLOW_BASE_URL, FLOW_INPUT_NAME, FLOW_DEVICE_NAME, SENSOR_DATA.Temperature, SENSOR_DATA.Humidity, SENSOR_DATA.AccelX,SENSOR_DATA.AccelY,SENSOR_DATA.AccelZ, FLOW_URL_TYPE, MY_SERVER_URL); + break; + } + case TEMP_HUMIDITY_ACCELEROMETER_PMODSENSORS: + { + sprintf(modem_string, "GET %s%s?serial=%s&temp=%s&humidity=%s&accelX=%s&accelY=%s&accelZ=%s&proximity=%s&light_uv=%s&light_vis=%s&light_ir=%s %s%s\r\n\r\n", FLOW_BASE_URL, FLOW_INPUT_NAME, FLOW_DEVICE_NAME, SENSOR_DATA.Temperature, SENSOR_DATA.Humidity, SENSOR_DATA.AccelX,SENSOR_DATA.AccelY,SENSOR_DATA.AccelZ, SENSOR_DATA.Proximity, SENSOR_DATA.UVindex, SENSOR_DATA.AmbientLightVis, SENSOR_DATA.AmbientLightIr, FLOW_URL_TYPE, MY_SERVER_URL); + break; + } + default: + { + sprintf(modem_string, "Invalid sensor selected\r\n\r\n"); + break; + } + } //switch(*ucCommandIndex) } //GenerateModemString @@ -295,6 +328,7 @@ printf("Humid is: %02d %%\n\r",hts221.readHumidity()); sensors_init(); + read_sensors(); // Initialize the modem printf(GRN "Modem initializing... will take up to 60 seconds" DEF "\r\n"); @@ -326,16 +360,17 @@ char modem_string[512]; GenerateModemString(&modem_string[0]); printf(DEF "Sending to modem : %s\n", modem_string); - //sockwrite_mdm("GET \r\n/f653d97537235/a31c2684a02c/d35e42196968fd6/in/flow/climate?deviceID=foo&temp=41.0&humidity=87.33\r\n HTTP/1.1\r\nHost: run-east.att.io:80\r\nAccept: */*\r\n\r\n"); sockwrite_mdm(modem_string); sockread_mdm(&MySocketData, 1024, 20); sockclose_mdm(); } //bTimerExpiredFlag } //forever loop +#if (0) string * pStr; while (1) { send_wnc_cmd("AT", &pStr, WNC_TIMEOUT_MS); } +#endif }