Example program demonstrating sending and reading SMS messages from the cellular modem using the MTSAS library.
Diff: main.cpp
- Revision:
- 3:7fac2f012338
- Parent:
- 2:d0d6e939ba70
- Child:
- 4:ad889da9578c
--- a/main.cpp Tue Aug 05 14:27:36 2014 +0000 +++ b/main.cpp Thu Aug 07 21:40:17 2014 +0000 @@ -2,9 +2,9 @@ #include "mtsas.h" int main(){ - /* set logging for INFO, which is a good middle ground - * available levels are TRACE, DEBUG, INFO, WARNING, ERROR, and NONE - */ + + //Sets the log level to INFO, higher log levels produce more log output. + //Possible levels: NONE, FATAL, ERROR, WARNING, INFO, DEBUG, TRACE MTSLog::setLogLevel(MTSLog::INFO_LEVEL); //Modify to match your apn if you are using an HSPA radio with a SIM card @@ -29,17 +29,13 @@ /** Freescale KL46Z * To configure the pins for the Freescale KL46Z board, use configuration B - * for the SocketModem. The TX pin should be jumped to pin D2 (JP8), and the - * RX pin should be jumped to pin D9 (JP9). - * Uncomment te following line to use the Freescale KL46Z board + * Uncomment the following line to use the Freescale KL46Z board */ //MTSSerialFlowControl* io = new MTSSerialFlowControl(D2, D9, D3, D6); - /** Freescale KL64F + /** Freescale K64F * To configure the pins for the Freescale KL46Z board, use configuration A - * for the SocketModem. The TX pin should be jumped to pin D1 (JP8), and the - * RX pin should be jumped to pin D0 (JP9). - * Uncomment te following line to use the Freescale KL46F board + * Uncomment the following line to use the Freescale KL46F board */ //MTSSerialFlowControl* io = new MTSSerialFlowControl(D1, D0, D3, D6); @@ -51,6 +47,11 @@ radio->configureSignals(D4,D7,RESET); Transport::setTransport(radio); + if (! radio) { + logFatal("Failed to initialize radio"); + return 1; + } + //Set radio APN for (int i = 0; i < 10; i++) { if (i >= 10) { @@ -87,8 +88,8 @@ } } - //Checking for received SMS message - for (int i = 0; i < 4; i++) { + //Checking for received SMS messages + while (true) { logInfo("Checking for received messages"); vector<Cellular::Sms> recv = radio->getReceivedSms(); if(recv.size() > 0) { @@ -97,7 +98,10 @@ logInfo("Message %d: [%s] [%s] [%s]", i, recv[i].phoneNumber.c_str(), recv[i].timestamp.c_str(), recv[i].message.c_str()); } } - radio->deleteOnlyReceivedReadSms(); + + if(radio->deleteOnlyReceivedReadSms() != MTS_SUCCESS) { + logError("Failed to delete received and read SMS messages"); + } wait(10); }