Shows how to send and receive SMS messages using a Vodafone USB dongle.
Dependencies: VodafoneUSBModem mbed-rtos mbed
Revision 1:38c9e35517ea, committed 2012-11-08
- Comitter:
- ashleymills
- Date:
- Thu Nov 08 17:31:46 2012 +0000
- Parent:
- 0:675760d79fa5
- Child:
- 2:60fd177f8a6a
- Commit message:
- Basic SMS tester;
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Thu Nov 08 17:19:31 2012 +0000 +++ b/main.cpp Thu Nov 08 17:31:46 2012 +0000 @@ -1,3 +1,10 @@ +// stuff to use DBG debug output +#define __DEBUG__ 4 //Maximum verbosity +#ifndef __MODULE__ +#define __MODULE__ "main.cpp" +#endif + +// relevant headers #include "mbed.h" #include "VodafoneUSBModem.h" @@ -5,9 +12,10 @@ #define MAX_SMS_LEN 256 int main() { - // construct serial object for console monitor - Serial pc(USBTX, USBRX); - pc.baud(115200); + // setup debug macro + DBG_INIT(); + DBG_SET_SPEED(115200); + DBG_SET_NEWLINE("\r\n"); // construct modem object VodafoneUSBModem modem; @@ -17,9 +25,9 @@ char numBuffer[32], msgBuffer[256]; // send a wake-up SMS - pc.printf("Sending test SMS to %s\r\n",TEST_NUMBER); + DBG("Sending test SMS to %s",TEST_NUMBER); if(modem.sendSM(TEST_NUMBER,"Hello!")!=0) { - pc.printf("Error sending test SMS!\r\n"); + DBG("Error sending test SMS!"); } // loop forever printing received SMSs @@ -27,7 +35,7 @@ // get SM count if(modem.getSMCount(&smCount)!=0) { - pc.printf("Error receiving SMS count!\r\n"); + DBG("Error receiving SMS count!"); continue; } @@ -36,12 +44,12 @@ // get SMS and sender if(modem.getSM(numBuffer,msgBuffer,MAX_SMS_LEN)!=0) { - pc.printf("Error retrieving SMS from mailbox!\r\n"); + DBG("Error retrieving SMS from mailbox!"); continue; } // print SMS and sender - pc.printf("SMS: \"%s\", From: \"%s\"\r\n",msgBuffer,numBuffer); + DBG("SMS: \"%s\", From: \"%s\"",msgBuffer,numBuffer); }