![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Own fork of MbedSmartRestMain
Dependencies: C027_Support C12832 LM75B MMA7660 MbedSmartRest mbed-rtos mbed
Fork of MbedSmartRestMain by
main.cpp
- Committer:
- Cumulocity
- Date:
- 2014-07-15
- Revision:
- 41:804f6a0bda26
- Parent:
- 34:8a0556f39161
- Child:
- 42:104746744af8
File content as of revision 41:804f6a0bda26:
#include "mbed.h" #include "rtos.h" #include "MDM.h" #include "DeviceInfo.h" #include "MbedAgent.h" #include "apndb.h" int main() { MDMParser::DevStatus devStatus; MDMSerial mdm; //mdm.setDebug(4); if (!mdm.init(NULL, &devStatus)) { puts("Modem initialization failed. Check your PIN number."); return 1; } puts("Searching for login..."); apndb_t *apn = apndb_get(devStatus.imsi); if (apn == NULL) { puts("No APN found. Stop."); return 1; } // print out basic device data printf("IMEI: %s\n", devStatus.imei); printf("IMSI: %s\n", devStatus.imsi); if (!mdm.registerNet()) { puts("Network registration failed."); return 1; } printf("Carrier: %s\n", apn->carrier); puts("Joining Network."); if (mdm.join(apn->apn) == NOIP) { puts("Could not join network. Make sure chosen carrier is correct and no credentials are required."); return 1; } DeviceInfo deviceInfo(mdm, devStatus); MbedAgent agent(mdm, deviceInfo); puts("Starting agent ..."); if (!agent.init()) { puts("Initialization failure."); mdm.disconnect(); return 1; } size_t tries = 3; do { puts("Running agent ..."); if (!agent.run()) { puts("Agent failure."); continue; } else { break; } } while (--tries > 0); mdm.disconnect(); return 0; }