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:
- 6:427c387b10e7
- Parent:
- 4:46459ed734f3
- Child:
- 7:5d6e03557246
--- a/main.cpp Wed Aug 27 18:10:18 2014 +0000
+++ b/main.cpp Wed Aug 27 18:30:05 2014 +0000
@@ -19,9 +19,11 @@
// our definitions
#include "Definitions.h"
- // RFID Reader - on P14 pin
- //#include "ID12RFID.h"
- //ID12RFID rfid_reader(p14);
+ // RFID Reader - on P14 pin
+ #if ID12_ENABLE
+ #include "ID12RFID.h"
+ ID12RFID rfid_reader(p14);
+ #endif
// Salesforce Case Generator
#include "SalesForceCaseGenerator.h"
@@ -44,6 +46,9 @@
#include "EthernetInterface.h"
EthernetInterface ethernet;
+ // HARD RESET
+extern "C" void HardFault_Handler() { NVIC_SystemReset(); }
+
// Main Entry...
int main() {
// create our object instances
@@ -68,17 +73,19 @@
// create the Salesforce Case Generator
SalesForceCaseGenerator case_generator(&logger);
- /*
// 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: %d found...\r\nProcessing...",rfid);
+ 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);
+ char *name = db.lookupWidgetName(rfid);
if (name != NULL) {
// build out a simple subject for the case
char subject[MAX_NAME_LENGTH+1];
@@ -99,24 +106,29 @@
logger.log("RFID unknown. Ignoring...");
}
}
+#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
// wait a bit and look again
wait_ms(WAIT_TIME_MS);
}
-
- */
-
- logger.log("Generating Sample Case...");
- bool success = case_generator.createCase("hello mbed","this is a mbed case dispatch");
- if (success == true) {
- logger.log("Case Generated!");
- }
- else {
- logger.log("Case Generation FAILED");
- }
}
else {
logger.log("No Network... Exiting...");
+ exit(1);
}
// disconnect
@@ -124,6 +136,6 @@
ethernet.disconnect();
// Exit
- logger.log("Sleeping...");
- while(1) wait(1000);
+ logger.log("Exiting...");
+ exit(1);
}
\ No newline at end of file

