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

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers test_SMS.h Source File

test_SMS.h

00001 /* Universal Socket Modem Interface Library
00002 * Copyright (c) 2013 Multi-Tech Systems
00003 *
00004 * Licensed under the Apache License, Version 2.0 (the "License");
00005 * you may not use this file except in compliance with the License.
00006 * You may obtain a copy of the License at
00007 *
00008 *     http://www.apache.org/licenses/LICENSE-2.0
00009 *
00010 * Unless required by applicable law or agreed to in writing, software
00011 * distributed under the License is distributed on an "AS IS" BASIS,
00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013 * See the License for the specific language governing permissions and
00014 * limitations under the License.
00015 */
00016 
00017 #ifndef _TEST_SMS_H_
00018 #define _TEST_SMS_H_
00019 
00020 using namespace mts;
00021 
00022 void sendSms() {
00023     Code code;
00024     std::string sMsg("Hello from Multi-Tech MBED!");
00025     std::string sPhoneNum( /* your 10-digit phone number prepended with a 1, e.g. 12228675309 */);
00026     
00027     printf("Sending message [%s] to [%s]\r\n", sMsg.c_str(), sPhoneNum.c_str());
00028     code = Cellular::getInstance()->sendSMS(sPhoneNum, sMsg);
00029     
00030     if(code != SUCCESS) {
00031         printf("Error during SMS send [%d]\r\n", (int)code);
00032     } else {
00033         printf("Success!\r\n");
00034     }
00035 }
00036 
00037 void receiveSms() {
00038     printf("Checking Received Messages\r\n");
00039     std::vector<Cellular::Sms> vSms = Cellular::getInstance()->getReceivedSms();
00040     printf("\r\n");
00041     for(unsigned int i = 0; i < vSms.size(); i++) {
00042         printf("[%d][%s][%s][%s]\r\n", i, vSms[i].timestamp.c_str(), 
00043                 vSms[i].phoneNumber.c_str(), vSms[i].message.c_str());
00044     }
00045 }
00046 
00047 #endif
00048