ROHM board with IBM BlueMix Quickstart for Avnet class
Fork of Dragonfly_Cellular_HTTPS_Example by
Revision 4:d16e07588838, committed 2016-08-12
- Comitter:
- BlueShadow
- Date:
- Fri Aug 12 19:24:41 2016 +0000
- Parent:
- 3:ff2bf7a1ece8
- Commit message:
- added a loop count of 25 before disconnecting the Cell Radio.
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r ff2bf7a1ece8 -r d16e07588838 main.cpp --- a/main.cpp Fri Aug 12 18:16:13 2016 +0000 +++ b/main.cpp Fri Aug 12 19:24:41 2016 +0000 @@ -73,9 +73,9 @@ //char BlueMix_HEADER[] = "Content-Type: application/x-www-form-urlencoded; charset=utf-8\r\n"; -char BlueMix_HEADER[] = "Content-Type: application/json"; +//char BlueMix_HEADER[] = "Content-Type: application/json"; -const char BlueMix_URL[] = "http://" ORG ".internetofthings.ibmcloud.com/api/v0002/device/types/" DEVICE_TYPE "/devices/" DEVICE_ID "/events/" EVENT; +//const char BlueMix_URL[] = "http://" ORG ".internetofthings.ibmcloud.com/api/v0002/device/types/" DEVICE_TYPE "/devices/" DEVICE_ID "/events/" EVENT; // replace typeID and deviceId with "" and delete () // replace $eventId = IBM will define in class. @@ -186,44 +186,47 @@ } } + Timer post_timer; + post_timer.start(); + int timeStamp; + int countingLoop = 0; + Timer loop_timer; + loop_timer.start(); logInfo("setting APN"); if (radio->setApn(apn) != MTS_SUCCESS) logError("failed to set APN to \"%s\"", apn); logInfo("APN set successful"); - Timer post_timer; - post_timer.start(); - int timeStamp; - int countingLoop = 0; - - logInfo("Entering loop"); - while (true) { - if (post_timer.read_ms() > post_interval_ms ) { // can this be changed to seconds? - timeStamp = post_timer.read_ms(); - logDebug("timer read %d", timeStamp); - logDebug("timer value %d", post_interval_ms ); - logDebug("loop count value %d", countingLoop ); + logInfo("bringing up the link"); //added to the program to create a connection outside of the while(1) loop. + if (! radio->connect()) { + logError("failed to bring up the link"); + //return 0; + } else { + + logInfo("Entering loop"); + while (countingLoop < 25 ) { + if (post_timer.read_ms() > post_interval_ms ) { // can this be changed to seconds? + timeStamp = post_timer.read_ms(); + logDebug("timer read %d", timeStamp); + logDebug("timer value %d", post_interval_ms ); + logDebug("loop count value %d", countingLoop ); #ifdef RPR0521 //als digital - ReadRPR0521_ALS (); - int sensor_data = RPR0521_ALS[0]; - int proximity_data = RPR0521_ALS[1]; + ReadRPR0521_ALS (); + int sensor_data = RPR0521_ALS[0]; + int proximity_data = RPR0521_ALS[1]; #else - int sensor_data = -1; - int proximity_data = -1; + int sensor_data = -1; + int proximity_data = -1; #endif - logDebug("\r\nPosting Light Reading: %d Proximity Reading: %d",sensor_data,proximity_data); - - logDebug("https://quickstart.internetofthings.ibmcloud.com"); - + logDebug("\r\nPosting Light Reading: %d Proximity Reading: %d",sensor_data,proximity_data); + + logDebug("https://quickstart.internetofthings.ibmcloud.com"); + // http_tx.clear(); - logInfo("bringing up the link"); - if (! radio->connect()) { - logError("failed to bring up the link"); - //return 0; - } else { + logInfo("bringing up the link"); // HTTPClient object used for HTTP requests. HTTPClient http; @@ -262,7 +265,7 @@ logInfo("HTTPS POST to Bluemix succeeded [%d]\r\n%s", http.getHTTPResponseCode(), http_rx_buf); //logInfo("finished - bringing down link"); - radio->disconnect(); +// radio->disconnect(); post_timer.reset(); countingLoop +=1; } @@ -270,9 +273,18 @@ //return 0; } - //radio->disconnect(); + radio->disconnect(); + timeStamp = loop_timer.read_ms(); + logInfo("loop timer = %d", timeStamp); + + logInfo("\r\n\n\nEnd Of Line\r\n"); } + +/*********************************************** + * below are the call routines +/***********************************************/ + bool init_mtsas() { io = new mts::MTSSerialFlowControl(RADIO_TX, RADIO_RX, RADIO_RTS, RADIO_CTS);