A library for talking to Multi-Tech's Cellular SocketModem Devices.
Dependents: M2X_dev axeda_wrapper_dev MTS_M2x_Example1 MTS_Cellular_Connect_Example ... more
test_SMS.h@17:2d7c4ea7491b, 2013-12-16 (annotated)
- Committer:
- sgodinez
- Date:
- Mon Dec 16 20:00:20 2013 +0000
- Revision:
- 17:2d7c4ea7491b
TCP send / receive working. close() still requires some finesse when other end disconnects.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
sgodinez | 17:2d7c4ea7491b | 1 | |
sgodinez | 17:2d7c4ea7491b | 2 | #ifndef _TEST_SMS_H_ |
sgodinez | 17:2d7c4ea7491b | 3 | #define _TEST_SMS_H_ |
sgodinez | 17:2d7c4ea7491b | 4 | |
sgodinez | 17:2d7c4ea7491b | 5 | void sendSms(Cellular& cellular) { |
sgodinez | 17:2d7c4ea7491b | 6 | Cellular::Code code; |
sgodinez | 17:2d7c4ea7491b | 7 | std::string sMsg("Hello from Multi-Tech MBED!"); |
sgodinez | 17:2d7c4ea7491b | 8 | std::string sPhoneNum("16514085259"); |
sgodinez | 17:2d7c4ea7491b | 9 | |
sgodinez | 17:2d7c4ea7491b | 10 | printf("Sending message [%s] to [%s]\r\n", sMsg.c_str(), sPhoneNum.c_str()); |
sgodinez | 17:2d7c4ea7491b | 11 | code = cellular.sendSMS(sPhoneNum, sMsg); |
sgodinez | 17:2d7c4ea7491b | 12 | |
sgodinez | 17:2d7c4ea7491b | 13 | if(code != Cellular::OK) { |
sgodinez | 17:2d7c4ea7491b | 14 | printf("Error during SMS send [%d]\r\n", (int)code); |
sgodinez | 17:2d7c4ea7491b | 15 | } else { |
sgodinez | 17:2d7c4ea7491b | 16 | printf("Success!\r\n"); |
sgodinez | 17:2d7c4ea7491b | 17 | } |
sgodinez | 17:2d7c4ea7491b | 18 | } |
sgodinez | 17:2d7c4ea7491b | 19 | |
sgodinez | 17:2d7c4ea7491b | 20 | void receiveSms(Cellular& cellular) { |
sgodinez | 17:2d7c4ea7491b | 21 | printf("Checking Received Messages\r\n"); |
sgodinez | 17:2d7c4ea7491b | 22 | std::vector<Cellular::Sms> vSms = cellular.getReceivedSms(); |
sgodinez | 17:2d7c4ea7491b | 23 | printf("\r\n"); |
sgodinez | 17:2d7c4ea7491b | 24 | for(unsigned int i = 0; i < vSms.size(); i++) { |
sgodinez | 17:2d7c4ea7491b | 25 | printf("[%d][%s][%s][%s]\r\n", i, vSms[i].timestamp.c_str(), |
sgodinez | 17:2d7c4ea7491b | 26 | vSms[i].phoneNumber.c_str(), vSms[i].message.c_str()); |
sgodinez | 17:2d7c4ea7491b | 27 | } |
sgodinez | 17:2d7c4ea7491b | 28 | } |
sgodinez | 17:2d7c4ea7491b | 29 | |
sgodinez | 17:2d7c4ea7491b | 30 | #endif |