Dreamforce 2014 Demo of RFID-based Salesforce Case generation for status reporting.

Dependencies:   ID12RFID ReportDB SalesforceCaseGenerator SalesforceInterface

Dependents:   mbed_mqtt_endpoint_ublox_ethernet mbed_mqtt_endpoint_ublox_cellular mbed_nsp_endpoint_ublox_cellular mbed_nsp_endpoint_ublox_ethernet ... more

Committer:
ansond
Date:
Thu Aug 28 21:06:27 2014 +0000
Revision:
4:cfa87685c859
Parent:
0:ba3327ba3a04
Child:
7:763c7a27e77a
renamed definitions

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ansond 0:ba3327ba3a04 1 /* Copyright C2014 ARM, MIT License
ansond 0:ba3327ba3a04 2 *
ansond 0:ba3327ba3a04 3 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
ansond 0:ba3327ba3a04 4 * and associated documentation files the "Software", to deal in the Software without restriction,
ansond 0:ba3327ba3a04 5 * including without limitation the rights to use, copy, modify, merge, publish, distribute,
ansond 0:ba3327ba3a04 6 * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
ansond 0:ba3327ba3a04 7 * furnished to do so, subject to the following conditions:
ansond 0:ba3327ba3a04 8 *
ansond 0:ba3327ba3a04 9 * The above copyright notice and this permission notice shall be included in all copies or
ansond 0:ba3327ba3a04 10 * substantial portions of the Software.
ansond 0:ba3327ba3a04 11 *
ansond 0:ba3327ba3a04 12 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
ansond 0:ba3327ba3a04 13 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
ansond 0:ba3327ba3a04 14 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
ansond 0:ba3327ba3a04 15 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
ansond 0:ba3327ba3a04 16 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
ansond 0:ba3327ba3a04 17 */
ansond 0:ba3327ba3a04 18
ansond 0:ba3327ba3a04 19 #include "StatusReporter.h"
ansond 0:ba3327ba3a04 20
ansond 0:ba3327ba3a04 21 StatusReporter::StatusReporter(ErrorHandler *logger) : m_case_generator(logger), m_db(), m_rfid_reader(p13,p14) {
ansond 0:ba3327ba3a04 22 this->m_logger = logger;
ansond 0:ba3327ba3a04 23 }
ansond 0:ba3327ba3a04 24
ansond 0:ba3327ba3a04 25 StatusReporter::~StatusReporter() {
ansond 0:ba3327ba3a04 26 }
ansond 0:ba3327ba3a04 27
ansond 0:ba3327ba3a04 28 void StatusReporter::checkAndReportOnStatus() {
ansond 0:ba3327ba3a04 29 // look for a readable RFID tag
ansond 0:ba3327ba3a04 30 if(this->m_rfid_reader.readable()) {
ansond 0:ba3327ba3a04 31 // capture the RFID id...
ansond 0:ba3327ba3a04 32 this->m_logger->log("RFID: Found RFID.\r\nReading...");
ansond 0:ba3327ba3a04 33 int rfid = this->m_rfid_reader.read();
ansond 0:ba3327ba3a04 34 this->m_logger->log("RFID: ID %d found...\r\nProcessing...",rfid);
ansond 0:ba3327ba3a04 35
ansond 0:ba3327ba3a04 36 // look it up in our WidgetDB... proceed only if we find something we know about...
ansond 0:ba3327ba3a04 37 char *name = this->m_db.lookupWidgetName(rfid);
ansond 0:ba3327ba3a04 38 if (name != NULL) {
ansond 0:ba3327ba3a04 39 // build out a simple subject for the case
ansond 4:cfa87685c859 40 char subject[DB_MAX_NAME_LENGTH+1];
ansond 4:cfa87685c859 41 memset(subject,0,DB_MAX_NAME_LENGTH+1);
ansond 0:ba3327ba3a04 42 sprintf(subject,"%s case update",name);
ansond 0:ba3327ba3a04 43
ansond 0:ba3327ba3a04 44 // create and dispatch a case
ansond 0:ba3327ba3a04 45 bool success = this->m_case_generator.createCase(subject,this->m_db.lookupWidgetDescription(rfid));
ansond 0:ba3327ba3a04 46 if (success == true) {
ansond 0:ba3327ba3a04 47 this->m_logger->log("Case Generated!\r\nScanning...");
ansond 0:ba3327ba3a04 48 }
ansond 0:ba3327ba3a04 49 else {
ansond 0:ba3327ba3a04 50 this->m_logger->log("Case Generation FAILED\r\nScanning...");
ansond 0:ba3327ba3a04 51 }
ansond 0:ba3327ba3a04 52 }
ansond 0:ba3327ba3a04 53 else {
ansond 0:ba3327ba3a04 54 // unrecognized RFID
ansond 0:ba3327ba3a04 55 this->m_logger->log("RFID %d unknown.\r\nScanning...",rfid);
ansond 0:ba3327ba3a04 56 }
ansond 0:ba3327ba3a04 57 }
ansond 0:ba3327ba3a04 58 }