Raghav Ganesh
/
AvnetATT_shape_hackathon
This program simply connects to a HTS221 I2C device to read Temperature
Revision 29:83d9bf7b52a4, committed 2016-07-16
- Comitter:
- jet2mars
- Date:
- Sat Jul 16 17:24:50 2016 +0000
- Parent:
- 28:886833917643
- Commit message:
- source-code
Changed in this revision
--- a/config_me.h Fri Jul 15 13:17:26 2016 +0000 +++ b/config_me.h Sat Jul 16 17:24:50 2016 +0000 @@ -6,10 +6,10 @@ // This is the server's base URL name. Example "www.google.com" // Note that when you Fork a FLOW, it will typically assign either // "run-east.att.io" or "run-west.att.io", so be sure to check this. -static const char * MY_SERVER_URL = "run-west.att.io"; +static const char * MY_SERVER_URL = "run-east.att.io"; // These are FLOW fields from the Endpoints tab: -#define FLOW_BASE_URL "/1e464b19cdcde/774c88d68202/86694923d5bf28a/in/flow" +#define FLOW_BASE_URL "/0861956ba198c/4eb0452f2f49/dcdc5484efb8a86/in/flow" #define FLOW_INPUT_NAME "/climate" // Unless you want to use a different protocol, this field should be left as is: @@ -32,7 +32,7 @@ #define TEMP_HUMIDITY_ONLY 1 #define TEMP_HUMIDITY_ACCELEROMETER 2 #define TEMP_HUMIDITY_ACCELEROMETER_PMODSENSORS 3 -static int iSensorsToReport = TEMP_HUMIDITY_ONLY; //modify this to change your selection +static int iSensorsToReport = TEMP_HUMIDITY_ACCELEROMETER; //modify this to change your selection // This is the APN name for the cellular network, you will need to change this, check the instructions included with your SIM card kit: static const char * MY_APN_STR = "m2m.com.attz";
--- a/main.cpp Fri Jul 15 13:17:26 2016 +0000 +++ b/main.cpp Sat Jul 16 17:24:50 2016 +0000 @@ -183,6 +183,7 @@ } int mdm_sendAtCmdRsp(const char *cmd, const char **rsp_list, int timeout_ms, string * rsp, int * len) { + printf("\n\nENTERING SEND AT CMD REP \n\n"); static char cmd_buf[3200]; // Need enough room for the WNC sockreads (over 3000 chars) size_t n = strlen(cmd); if (cmd && n > 0) { @@ -197,6 +198,7 @@ wait_ms(1); mdm.putc('\n'); wait_ms(1); + printf("\n\nAAAA\n\n"); } if (rsp_list) { @@ -232,6 +234,7 @@ return MDM_ERR_TIMEOUT; } pc.printf("D %s",rsp); + printf("\n\nBBBB\n\n"); return MDM_OK; } @@ -276,7 +279,8 @@ }; void GenerateModemString(char * modem_string) -{ +{ + // iSensorsToReport = TEMP_HUMIDITY_ONLY; switch(iSensorsToReport) { case TEMP_HUMIDITY_ONLY: @@ -286,7 +290,8 @@ } 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); + //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); + sprintf(modem_string, "GET %s%s?serial=%s&temp=%s&humidity=%s&proximity=%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: @@ -493,7 +498,9 @@ char modem_string[512]; GenerateModemString(&modem_string[0]); printf(BLU "Sending to modem : %s" DEF "\n", modem_string); + printf("\n\nStarting SOCKWRITE\n\n"); sockwrite_mdm(modem_string); + printf("\n\nENDING SOCKWRITE\n\n"); sockread_mdm(&MySocketData, 1024, 20); // If any non-zero response from server, make it GREEN one-time @@ -509,13 +516,15 @@ if (extract_JSON(&MySocketData[0], &myJsonResponse[0])) { printf(GRN "JSON : %s" DEF "\n", &myJsonResponse[0]); - parse_JSON(&myJsonResponse[0]); + //parse_JSON(&myJsonResponse[0]); } else { printf(RED "JSON : %s" DEF "\n", &myJsonResponse[0]); //most likely an incomplete JSON string - parse_JSON(&myJsonResponse[0]); //This is risky, as the string may be corrupted + //parse_JSON(&myJsonResponse[0]); //This is risky, as the string may be corrupted } + printf("\n\nEND OF LOOP\n\n"); } //bTimerExpiredFlag + //NVIC_SystemReset(); } //forever loop }
--- a/wnc_control.cpp Fri Jul 15 13:17:26 2016 +0000 +++ b/wnc_control.cpp Sat Jul 16 17:24:50 2016 +0000 @@ -86,6 +86,7 @@ { WNC_MDM_ERR = WNC_OK; at_sockwrite_wnc(s); + printf("\n\nINSIDE SOCKWRITE\n\n"); if (WNC_MDM_ERR == WNC_NO_RESPONSE) { reinitialize_mdm(); @@ -194,6 +195,8 @@ int res = mdm_sendAtCmdRsp(s, rsp_lst, ms_timeout, &wncStr, &len); *r = &wncStr; // Return a pointer to the static string + printf("\n\nIN SEND WNC COMMAND\n\n"); + if (res >= 0) { pc.puts("["); @@ -294,8 +297,11 @@ size_t sLen = strlen(s); if (sLen <= 99999) { - string cmd_str("AT@SOCKWRITE=1,"); + printf("\n\nCreating String\n\n"); + static string cmd_str("AT@SOCKWRITE=1,"); + printf("\n\nSTARTING ITOA FUNCTION\n\n"); itoa(sLen, num2str, 10); + printf("\n\n ENDING ITOA FUNCTION\n\n"); cmd_str += num2str; cmd_str += ",\""; while(*s != '\0') @@ -311,9 +317,12 @@ cmd_str += num2str; } cmd_str += "\""; + printf("\n\nAT SOCKWRTIE FUNCTION\n\n"); send_wnc_cmd(cmd_str.data(), &pRespStr, WNC_TIMEOUT_MS); + cmd_str = ""; } else + printf("\n\nSTRING TO LOMG\n\n"); pc.puts("sockwrite Err, string to long\r\n"); }