Shows how to send and receive SMS messages using a Vodafone USB dongle.
Dependencies: VodafoneUSBModem mbed-rtos mbed
Revision 0:675760d79fa5, committed 2012-11-08
- Comitter:
- ashleymills
- Date:
- Thu Nov 08 17:19:31 2012 +0000
- Child:
- 1:38c9e35517ea
- Commit message:
- Initial commit of SMS basics prog.
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/VodafoneUSBModem.lib Thu Nov 08 17:19:31 2012 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/VodafoneUSBModem/#bf3cf216235c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu Nov 08 17:19:31 2012 +0000 @@ -0,0 +1,51 @@ +#include "mbed.h" +#include "VodafoneUSBModem.h" + +#define TEST_NUMBER "07825608771" +#define MAX_SMS_LEN 256 + +int main() { + // construct serial object for console monitor + Serial pc(USBTX, USBRX); + pc.baud(115200); + + // construct modem object + VodafoneUSBModem modem; + + // locals + size_t smCount = 0; + char numBuffer[32], msgBuffer[256]; + + // send a wake-up SMS + pc.printf("Sending test SMS to %s\r\n",TEST_NUMBER); + if(modem.sendSM(TEST_NUMBER,"Hello!")!=0) { + pc.printf("Error sending test SMS!\r\n"); + } + + // loop forever printing received SMSs + while(1) { + + // get SM count + if(modem.getSMCount(&smCount)!=0) { + pc.printf("Error receiving SMS count!\r\n"); + continue; + } + + // if SMS in mailbox + if(smCount>0) { + + // get SMS and sender + if(modem.getSM(numBuffer,msgBuffer,MAX_SMS_LEN)!=0) { + pc.printf("Error retrieving SMS from mailbox!\r\n"); + continue; + } + + // print SMS and sender + pc.printf("SMS: \"%s\", From: \"%s\"\r\n",msgBuffer,numBuffer); + + } + + // wait 1 second + Thread::wait(1000); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed-rtos.lib Thu Nov 08 17:19:31 2012 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed-rtos/#9654a71f5a90
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Thu Nov 08 17:19:31 2012 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/e2ed12d17f06 \ No newline at end of file