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:
- 3:03108e424931
- Parent:
- 0:df2aa79c64f2
- Child:
- 4:46459ed734f3
--- a/main.cpp Sat Aug 23 21:14:53 2014 +0000
+++ b/main.cpp Wed Aug 27 05:40:16 2014 +0000
@@ -20,8 +20,8 @@
#include "Definitions.h"
// RFID Reader - on P14 pin
- #include "ID12RFID.h"
- ID12RFID rfid_reader(p14);
+ //#include "ID12RFID.h"
+ //ID12RFID rfid_reader(p14);
// Salesforce Case Generator
#include "SalesForceCaseGenerator.h"
@@ -40,6 +40,10 @@
#include "Serial.h"
Serial pc(USBTX, USBRX);
+ // Ethernet
+ #include "EthernetInterface.h"
+ EthernetInterface ethernet;
+
// Main Entry...
int main() {
// create our object instances
@@ -48,44 +52,73 @@
// announce
logger.log("DF 2014 RFID Reader\r\nVersion: %s",APP_VERSION);
- // create the WidgetDB
- WidgetDB db;
-
- // create the Salesforce Case Generator
- SalesForceCaseGenerator case_generator(&logger);
+ // initialize Ethernet
+ logger.log("Initializing Ethernet...");
+ ethernet.init();
- // Enter the main loop
- while(true) {
- // look for a readable RFID tag
- if(rfid_reader.readable()) {
- // capture the RFID id...
- int rfid = rfid_reader.read();
- logger.log("RFID: %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,"Widget %s detected",name);
+ // get a DHCP address and bring the network interface up
+ logger.log("Getting IP Address...");
+ if (ethernet.connect() == 0) {
+ // 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);
+
+ /*
+ // Enter the main loop
+ while(true) {
+ // look for a readable RFID tag
+ if(rfid_reader.readable()) {
+ // capture the RFID id...
+ int rfid = rfid_reader.read();
+ logger.log("RFID: %d found...\r\nProcessing...",rfid);
- // create and dispatch a case
- bool success = case_generator.createCase(subject,db.lookupWidgetDescription(rfid));
- if (success == true) {
- logger.log("Case Generated!");
+ // 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,"Widget %s detected",name);
+
+ // create and dispatch a case
+ bool success = case_generator.createCase(subject,db.lookupWidgetDescription(rfid));
+ if (success == true) {
+ logger.log("Case Generated!");
+ }
+ else {
+ logger.log("Case Generation FAILED");
+ }
}
else {
- logger.log("Case Generation FAILED");
+ // unrecognized RFID
+ logger.log("RFID unknown. Ignoring...");
}
- }
- else {
- // unrecognized RFID
- logger.log("RFID unknown. Ignoring...");
- }
- }
-
- // wait a bit and look again
- wait_ms(WAIT_TIME_MS);
- }
+ }
+
+ // wait a bit and look again
+ wait_ms(WAIT_TIME_MS);
+ }
+
+ */
+
+ logger.log("Generating Sample Case...");
+ bool success = case_generator.createCase("hello doug","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...");
+ }
+
+ // disconnect
+ ethernet.disconnect();
}
\ No newline at end of file

