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: BufferedSerial C12832 EndpointMain-rfid EthernetInterface Logger StatusReporter-df2014 mbed-rtos mbed
Fork of df-2014-workshop-rfid-case-generator-k64f by
Diff: main.cpp
- Revision:
- 13:2561e3855a81
- Parent:
- 8:fefcecb66463
- Child:
- 19:341ce6a43a84
diff -r a8c9a0190d30 -r 2561e3855a81 main.cpp
--- a/main.cpp Thu Aug 28 00:07:52 2014 +0000
+++ b/main.cpp Thu Aug 28 20:19:08 2014 +0000
@@ -16,23 +16,8 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
- // our definitions
- #include "Definitions.h"
-
- // RFID Reader - on P14 pin
- #if ID12_ENABLE
- #include "ID12RFID.h"
- ID12RFID rfid_reader(p13,p14);
- #endif
-
- // Salesforce Case Generator
- #include "SalesForceCaseGenerator.h"
-
- // our Logger
- #include "Logger.h"
-
- // our WidgetDB
- #include "WidgetDB.h"
+ // StatusReporter
+ #include "StatusReporter.h"
// our LCD Panel
#include "C12832_lcd.h"
@@ -52,10 +37,10 @@
// Main Entry...
int main() {
// create our object instances
- Logger logger(&pc,&lcd);
+ ErrorHandler logger(&pc,&lcd);
// announce
- logger.log("DF 2014 RFID Reader\r\nVersion: %s",APP_VERSION);
+ logger.log("ARM/DreamForce 2014 mbed Status Reporter v%s",APP_VERSION);
// initialize Ethernet
logger.log("Initializing Ethernet...");
@@ -67,63 +52,16 @@
// log our IP address (DHCP)
logger.log("IP Address: %s",ethernet.getIPAddress());
- // create the WidgetDB
- WidgetDB db;
-
- // create the Salesforce Case Generator
- SalesForceCaseGenerator case_generator(&logger);
+ // create the StatusReporter
+ StatusReporter status_reporter(&logger);
// entering main loop
logger.log("Entering Main Loop...\r\nScanning...");
// Enter the main loop
while(true) {
-#if ID12_ENABLE
- // look for a readable RFID tag
- //logger.log("RFID: Scanning...");
- if(rfid_reader.readable()) {
- // capture the RFID id...
- logger.log("RFID: Found RFID.\r\nReading...");
- int rfid = rfid_reader.read();
- logger.log("RFID: ID %d found...\r\nProcessing...",rfid);
-
- // look it up in our WidgetDB... proceed only if we find something we know about...
- char *name = db.lookupWidgetName(rfid);
- if (name != NULL) {
- // build out a simple subject for the case
- char subject[MAX_NAME_LENGTH+1];
- memset(subject,0,MAX_NAME_LENGTH+1);
- sprintf(subject,"%s case update",name);
-
- // create and dispatch a case
- bool success = case_generator.createCase(subject,db.lookupWidgetDescription(rfid));
- if (success == true) {
- logger.log("Case Generated!\r\nScanning...");
- }
- else {
- logger.log("Case Generation FAILED\r\nScanning...");
- }
- }
- else {
- // unrecognized RFID
- logger.log("RFID unk-ignored.\r\nScanning...");
- }
- }
-#else
- // simply create and dispatch a single case
- logger.log("Creating Case...");
- bool success = case_generator.createCase("sample mbed case","this is a sample mbed case");
- if (success == true) {
- logger.log("Case Generated!");
- logger.log("Exiting...");
- exit(1);
- }
- else {
- logger.log("Case Generation FAILED");
- logger.log("Exiting...");
- exit(1);
- }
-#endif
+ // check and report on status updates
+ status_reporter.checkAndReportOnStatus();
// wait a bit and look again
wait_ms(WAIT_TIME_MS);

